Class: Tappay::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/tappay/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



10
11
12
13
# File 'lib/tappay/configuration.rb', line 10

def initialize
  @mode = :sandbox
  @api_version = '3'
end

Instance Attribute Details

#api_versionObject



15
16
17
# File 'lib/tappay/configuration.rb', line 15

def api_version
  @api_version.to_s
end

#apple_pay_merchant_idObject

Returns the value of attribute apple_pay_merchant_id.



5
6
7
# File 'lib/tappay/configuration.rb', line 5

def apple_pay_merchant_id
  @apple_pay_merchant_id
end

#currencyObject

Returns the value of attribute currency.



5
6
7
# File 'lib/tappay/configuration.rb', line 5

def currency
  @currency
end

#google_pay_merchant_idObject

Returns the value of attribute google_pay_merchant_id.



5
6
7
# File 'lib/tappay/configuration.rb', line 5

def google_pay_merchant_id
  @google_pay_merchant_id
end

#instalment_merchant_idObject

Returns the value of attribute instalment_merchant_id.



5
6
7
# File 'lib/tappay/configuration.rb', line 5

def instalment_merchant_id
  @instalment_merchant_id
end

#jko_pay_merchant_idObject

Returns the value of attribute jko_pay_merchant_id.



5
6
7
# File 'lib/tappay/configuration.rb', line 5

def jko_pay_merchant_id
  @jko_pay_merchant_id
end

#line_pay_merchant_idObject

Returns the value of attribute line_pay_merchant_id.



5
6
7
# File 'lib/tappay/configuration.rb', line 5

def line_pay_merchant_id
  @line_pay_merchant_id
end

#merchant_group_idObject

Returns the value of attribute merchant_group_id.



5
6
7
# File 'lib/tappay/configuration.rb', line 5

def merchant_group_id
  @merchant_group_id
end

#merchant_idObject

Returns the value of attribute merchant_id.



5
6
7
# File 'lib/tappay/configuration.rb', line 5

def merchant_id
  @merchant_id
end

#partner_keyObject

Returns the value of attribute partner_key.



5
6
7
# File 'lib/tappay/configuration.rb', line 5

def partner_key
  @partner_key
end

Instance Method Details

#modeObject



34
35
36
# File 'lib/tappay/configuration.rb', line 34

def mode
  @mode ||= :sandbox
end

#mode=(value) ⇒ Object



27
28
29
30
31
32
# File 'lib/tappay/configuration.rb', line 27

def mode=(value)
  unless [:sandbox, :production].include?(value.to_sym)
    raise ArgumentError, "Invalid mode. Must be :sandbox or :production"
  end
  @mode = value.to_sym
end

#production?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/tappay/configuration.rb', line 23

def production?
  @mode == :production
end

#sandbox?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/tappay/configuration.rb', line 19

def sandbox?
  @mode == :sandbox
end

#validate!Object

Raises:



38
39
40
41
# File 'lib/tappay/configuration.rb', line 38

def validate!
  raise ValidationError, 'partner_key is required' if partner_key.nil?
  raise ValidationError, 'Either merchant_id or merchant_group_id is required' if merchant_id.nil? && merchant_group_id.nil?
end