Class: Tappay::PaymentBase

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

Constant Summary collapse

VALID_INSTALMENT_VALUES =
[0, 3, 6, 12, 18, 24, 30].freeze

Instance Attribute Summary

Attributes inherited from Client

#options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Client

#post

Constructor Details

#initialize(options = {}) ⇒ PaymentBase

Returns a new instance of PaymentBase.



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

def initialize(options = {})
  super
  validate_options!
end

Class Method Details

.merchant_id_keyObject

Walks the ancestry, because a class-level ivar is not inherited and the get_merchant_id overrides this replaced were. Without this, a subclass of a payment class silently charges the default merchant.



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

def merchant_id_key
  @merchant_id_key ||
    (superclass.merchant_id_key if superclass.respond_to?(:merchant_id_key))
end

.uses_merchant_id(key) ⇒ Object

Some payment methods get their own merchant ID from TapPay. Declaring the config key here replaces a get_merchant_id override per class.



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

def uses_merchant_id(key)
  @merchant_id_key = key
end

Instance Method Details

#executeObject



28
29
30
# File 'lib/tappay/payment_base.rb', line 28

def execute
  post(endpoint_url, payment_data)
end