Class: OpenPayU::Configuration
- Inherits:
-
Object
- Object
- OpenPayU::Configuration
- Includes:
- Singleton
- Defined in:
- lib/openpayu/configuration.rb
Class Attribute Summary (collapse)
-
+ (Object) algorithm
Returns the value of attribute algorithm.
-
+ (Object) client_id
Returns the value of attribute client_id.
-
+ (Object) client_secret
Returns the value of attribute client_secret.
-
+ (Object) continue_url
Returns the value of attribute continue_url.
-
+ (Object) country
Returns the value of attribute country.
-
+ (Object) data_format
Returns the value of attribute data_format.
-
+ (Object) env
Returns the value of attribute env.
-
+ (Object) merchant_pos_id
Returns the value of attribute merchant_pos_id.
-
+ (Object) notify_url
Returns the value of attribute notify_url.
-
+ (Object) order_url
Returns the value of attribute order_url.
-
+ (Object) pos_auth_key
Returns the value of attribute pos_auth_key.
-
+ (Object) protocol
Returns the value of attribute protocol.
-
+ (Object) service_domain
Returns the value of attribute service_domain.
-
+ (Object) signature_key
Returns the value of attribute signature_key.
Class Method Summary (collapse)
- + (Object) configure(file_path = nil)
- + (Object) get_base_url
- + (Object) required_parameters
- + (Object) set_defaults
- + (Boolean) use_ssl?
- + (Boolean) valid?
Class Attribute Details
+ (Object) algorithm
Returns the value of attribute algorithm
11 12 13 |
# File 'lib/openpayu/configuration.rb', line 11 def algorithm @algorithm end |
+ (Object) client_id
Returns the value of attribute client_id
11 12 13 |
# File 'lib/openpayu/configuration.rb', line 11 def client_id @client_id end |
+ (Object) client_secret
Returns the value of attribute client_secret
11 12 13 |
# File 'lib/openpayu/configuration.rb', line 11 def client_secret @client_secret end |
+ (Object) continue_url
Returns the value of attribute continue_url
11 12 13 |
# File 'lib/openpayu/configuration.rb', line 11 def continue_url @continue_url end |
+ (Object) country
Returns the value of attribute country
11 12 13 |
# File 'lib/openpayu/configuration.rb', line 11 def country @country end |
+ (Object) data_format
Returns the value of attribute data_format
11 12 13 |
# File 'lib/openpayu/configuration.rb', line 11 def data_format @data_format end |
+ (Object) env
Returns the value of attribute env
11 12 13 |
# File 'lib/openpayu/configuration.rb', line 11 def env @env end |
+ (Object) merchant_pos_id
Returns the value of attribute merchant_pos_id
11 12 13 |
# File 'lib/openpayu/configuration.rb', line 11 def merchant_pos_id @merchant_pos_id end |
+ (Object) notify_url
Returns the value of attribute notify_url
11 12 13 |
# File 'lib/openpayu/configuration.rb', line 11 def notify_url @notify_url end |
+ (Object) order_url
Returns the value of attribute order_url
11 12 13 |
# File 'lib/openpayu/configuration.rb', line 11 def order_url @order_url end |
+ (Object) pos_auth_key
Returns the value of attribute pos_auth_key
11 12 13 |
# File 'lib/openpayu/configuration.rb', line 11 def pos_auth_key @pos_auth_key end |
+ (Object) protocol
Returns the value of attribute protocol
11 12 13 |
# File 'lib/openpayu/configuration.rb', line 11 def protocol @protocol end |
+ (Object) service_domain
Returns the value of attribute service_domain
11 12 13 |
# File 'lib/openpayu/configuration.rb', line 11 def service_domain @service_domain end |
+ (Object) signature_key
Returns the value of attribute signature_key
11 12 13 |
# File 'lib/openpayu/configuration.rb', line 11 def signature_key @signature_key end |
Class Method Details
+ (Object) configure(file_path = nil)
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/openpayu/configuration.rb', line 15 def configure(file_path = nil) set_defaults if block_given? yield self else file = File.open(file_path) if file_path && File.exists?(file_path) env = defined?(Rails) ? Rails.env : ENV['RACK_ENV'] config = YAML.load(file)[env] if config.present? config.each_pair do |key, value| send("#{key}=", value) end end end valid? end |
+ (Object) get_base_url
53 54 55 |
# File 'lib/openpayu/configuration.rb', line 53 def get_base_url "#{@protocol}://#{@env}.#{@service_domain}/api/v2/" end |
+ (Object) required_parameters
40 41 42 |
# File 'lib/openpayu/configuration.rb', line 40 def required_parameters [:merchant_pos_id, :signature_key] end |
+ (Object) set_defaults
32 33 34 35 36 37 38 |
# File 'lib/openpayu/configuration.rb', line 32 def set_defaults @service_domain = 'payu.com' @env = 'sandbox' @country = 'pl' @algorithm = 'MD5' @data_format = 'json' end |
+ (Boolean) use_ssl?
57 58 59 |
# File 'lib/openpayu/configuration.rb', line 57 def use_ssl? @protocol == 'https' end |
+ (Boolean) valid?
44 45 46 47 48 49 50 51 |
# File 'lib/openpayu/configuration.rb', line 44 def valid? required_parameters.each do |parameter| if send(parameter).nil? || send(parameter).blank? raise WrongConfigurationError, "Parameter #{parameter} is invalid." end end true end |