Class: ActiveMerchant::Billing::ModernPaymentsGateway

Inherits:
Gateway
  • Object
show all
Defined in:
lib/active_merchant/billing/gateways/modern_payments.rb

Constant Summary

Constants inherited from Gateway

Gateway::DEBIT_CARDS

Constants included from PostsData

PostsData::MAX_RETRIES, PostsData::OPEN_TIMEOUT, PostsData::READ_TIMEOUT

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#card_brand, card_brand, inherited, supports?, #test?

Methods included from Utils

generate_unique_id

Methods included from CreditCardFormatting

#format

Methods included from RequiresParameters

#requires!

Methods included from PostsData

included, #retry_exceptions, #ssl_post

Constructor Details

#initialize(options = {}) ⇒ ModernPaymentsGateway

Returns a new instance of ModernPaymentsGateway.



11
12
13
14
15
# File 'lib/active_merchant/billing/gateways/modern_payments.rb', line 11

def initialize(options = {})
  requires!(options, :login, :password)
  @options = options
  super
end

Instance Method Details

#purchase(money, credit_card, options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/active_merchant/billing/gateways/modern_payments.rb', line 17

def purchase(money, credit_card, options = {})
  customer_response = cim.create_customer(options)
  return customer_response unless customer_response.success?
  
  customer_id = customer_response.params["create_customer_result"]
  
  card_response = cim.modify_customer_credit_card(customer_id, credit_card)
  return card_response unless card_response.success?
  
  cim.authorize_credit_card_payment(customer_id, money)
end