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
# File 'lib/tappay/configuration.rb', line 10

def initialize
  @mode = :sandbox
end

Instance Attribute Details

#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

#ipass_money_merchant_idObject

Returns the value of attribute ipass_money_merchant_id.



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

def ipass_money_merchant_id
  @ipass_money_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



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

def mode
  @mode ||= :sandbox
end

#mode=(value) ⇒ Object



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

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)


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

def production?
  @mode == :production
end

#sandbox?Boolean

Returns:

  • (Boolean)


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

def sandbox?
  @mode == :sandbox
end

#validate!Object

Raises:



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

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