Class: ActiveMerchant::Billing::MokaGateway

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

Constant Summary collapse

ERROR_CODE_MAPPING =
{
  '000' =>  'General error',
  '001' =>  '3D Not authenticated',
  '002' =>  'Limit is insufficient',
  '003' =>  'Credit card number format is wrong',
  '004' =>  'General decline',
  '005' =>  'This process is invalid for the card owner',
  '006' =>  'Expiration date is wrong',
  '007' =>  'Invalid transaction',
  '008' =>  'Connection with the bank not established',
  '009' =>  'Undefined error code',
  '010' =>  'Bank SSL error',
  '011' =>  'Call the bank for the manual authentication',
  '012' =>  'Card info is wrong - Kart Number or CVV2',
  '013' =>  '3D secure is not supported other than Visa MC cards',
  '014' =>  'Invalid account number',
  '015' =>  'CVV is wrong',
  '016' =>  'Authentication process is not present',
  '017' =>  'System error',
  '018' =>  'Stolen card',
  '019' =>  'Lost card',
  '020' =>  'Card with limited properties',
  '021' =>  'Timeout',
  '022' =>  'Invalid merchant',
  '023' =>  'False authentication',
  '024' =>  '3D authorization is successful but the process cannot be completed',
  '025' =>  '3D authorization failure',
  '026' =>  'Either the issuer bank or the card is not enrolled to the 3D process',
  '027' =>  'The bank did not allow the process',
  '028' =>  'Fraud suspect',
  '029' =>  'The card is closed to the e-commerce operations'
}

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#add_field_to_post_if_present, #add_fields_to_post_if_present, #card_brand, card_brand, #generate_unique_id, inherited, #supported_countries, supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #test?

Methods included from CreditCardFormatting

#expdate, #format

Methods included from PostsData

included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request

Constructor Details

#initialize(options = {}) ⇒ MokaGateway

Returns a new instance of MokaGateway.



48
49
50
51
# File 'lib/active_merchant/billing/gateways/moka.rb', line 48

def initialize(options = {})
  requires!(options, :dealer_code, :username, :password)
  super
end

Instance Method Details

#authorize(money, payment, options = {}) ⇒ Object



64
65
66
67
68
69
70
71
72
73
# File 'lib/active_merchant/billing/gateways/moka.rb', line 64

def authorize(money, payment, options = {})
  post = {}
  post[:PaymentDealerRequest] = {}
  options[:pre_auth] = 1
  add_auth_purchase(post, money, payment, options)
  add_3ds_data(post, options) if options[:execute_threed]

  action = options[:execute_threed] ? 'three_ds_authorize' : 'authorize'
  commit(action, post)
end

#capture(money, authorization, options = {}) ⇒ Object



75
76
77
78
79
80
81
82
83
# File 'lib/active_merchant/billing/gateways/moka.rb', line 75

def capture(money, authorization, options = {})
  post = {}
  post[:PaymentDealerRequest] = {}
  add_payment_dealer_authentication(post)
  add_transaction_reference(post, authorization)
  add_invoice(post, money, options)

  commit('capture', post)
end

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



53
54
55
56
57
58
59
60
61
62
# File 'lib/active_merchant/billing/gateways/moka.rb', line 53

def purchase(money, payment, options = {})
  post = {}
  post[:PaymentDealerRequest] = {}
  options[:pre_auth] = 0
  add_auth_purchase(post, money, payment, options)
  add_3ds_data(post, options) if options[:execute_threed]

  action = options[:execute_threed] ? 'three_ds_purchase' : 'purchase'
  commit(action, post)
end

#refund(money, authorization, options = {}) ⇒ Object



85
86
87
88
89
90
91
92
93
94
# File 'lib/active_merchant/billing/gateways/moka.rb', line 85

def refund(money, authorization, options = {})
  post = {}
  post[:PaymentDealerRequest] = {}
  add_payment_dealer_authentication(post)
  add_transaction_reference(post, authorization)
  add_void_refund_reason(post)
  add_amount(post, money)

  commit('refund', post)
end

#scrub(transcript) ⇒ Object



117
118
119
120
121
122
123
124
125
# File 'lib/active_merchant/billing/gateways/moka.rb', line 117

def scrub(transcript)
  transcript.
    gsub(%r(("CardNumber\\?":\\?")[^"]*)i, '\1[FILTERED]').
    gsub(%r(("CvcNumber\\?":\\?")[^"]*)i, '\1[FILTERED]').
    gsub(%r(("DealerCode\\?":\\?"?)[^"?]*)i, '\1[FILTERED]').
    gsub(%r(("Username\\?":\\?")[^"]*)i, '\1[FILTERED]').
    gsub(%r(("Password\\?":\\?")[^"]*)i, '\1[FILTERED]').
    gsub(%r(("CheckKey\\?":\\?")[^"]*)i, '\1[FILTERED]')
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


113
114
115
# File 'lib/active_merchant/billing/gateways/moka.rb', line 113

def supports_scrubbing?
  true
end

#verify(credit_card, options = {}) ⇒ Object



106
107
108
109
110
111
# File 'lib/active_merchant/billing/gateways/moka.rb', line 106

def verify(credit_card, options = {})
  MultiResponse.run(:use_first_response) do |r|
    r.process { authorize(100, credit_card, options) }
    r.process(:ignore_result) { void(r.authorization, options) }
  end
end

#void(authorization, options = {}) ⇒ Object



96
97
98
99
100
101
102
103
104
# File 'lib/active_merchant/billing/gateways/moka.rb', line 96

def void(authorization, options = {})
  post = {}
  post[:PaymentDealerRequest] = {}
  add_payment_dealer_authentication(post)
  add_transaction_reference(post, authorization)
  add_void_refund_reason(post)

  commit('void', post)
end