Class: ActiveMerchant::Billing::PaymentezGateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::PaymentezGateway
show all
- Defined in:
- lib/active_merchant/billing/gateways/paymentez.rb
Overview
Constant Summary
collapse
- STANDARD_ERROR_CODE_MAPPING =
{
1 => :processing_error,
6 => :card_declined,
9 => :card_declined,
10 => :processing_error,
11 => :card_declined,
12 => :config_error,
13 => :config_error,
19 => :invalid_cvc,
20 => :config_error,
21 => :card_declined,
22 => :card_declined,
23 => :card_declined,
24 => :card_declined,
25 => :card_declined,
26 => :card_declined,
27 => :card_declined,
28 => :card_declined
}.freeze
- SUCCESS_STATUS =
['APPROVED', 'PENDING', 'pending', 'success', 1, 0]
- CARD_MAPPING =
{
'visa' => 'vi',
'master' => 'mc',
'american_express' => 'ax',
'diners_club' => 'di',
'elo' => 'el',
'discover' => 'dc',
'maestro' => 'ms',
'sodexo' => 'sx',
'olimpica' => 'ol',
'carnet' => 'ct',
'unionpay' => 'up',
'jcb' => 'jc'
}.freeze
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
-
#authorize(money, payment, options = {}) ⇒ Object
-
#capture(money, authorization, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ PaymentezGateway
constructor
A new instance of PaymentezGateway.
-
#inquire(authorization, options = {}) ⇒ Object
-
#purchase(money, payment, options = {}) ⇒ Object
-
#refund(money, authorization, options = {}) ⇒ Object
-
#scrub(transcript) ⇒ Object
-
#store(credit_card, options = {}) ⇒ Object
-
#supports_scrubbing? ⇒ Boolean
-
#unstore(identification, options = {}) ⇒ Object
-
#verify(credit_card, options = {}) ⇒ Object
-
#void(authorization, _options = {}) ⇒ Object
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?
#expdate, #format, #strftime_yyyymm
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
Returns a new instance of PaymentezGateway.
54
55
56
57
|
# File 'lib/active_merchant/billing/gateways/paymentez.rb', line 54
def initialize(options = {})
requires!(options, :application_code, :app_key)
super
end
|
Instance Method Details
#authorize(money, payment, options = {}) ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/active_merchant/billing/gateways/paymentez.rb', line 71
def authorize(money, payment, options = {})
return purchase(money, payment, options) if options[:otp_flow]
post = {}
add_invoice(post, money, options)
add_payment(post, payment)
add_customer_data(post, options)
(post, options)
commit_transaction('authorize', post)
end
|
#capture(money, authorization, options = {}) ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/active_merchant/billing/gateways/paymentez.rb', line 84
def capture(money, authorization, options = {})
post = {
transaction: { id: authorization }
}
verify_flow = options[:type] && options[:value]
if verify_flow
add_customer_data(post, options)
add_verify_value(post, options)
elsif money
post[:order] = { amount: amount(money).to_f }
end
action = verify_flow ? 'verify' : 'capture'
commit_transaction(action, post)
end
|
#inquire(authorization, options = {}) ⇒ Object
140
141
142
|
# File 'lib/active_merchant/billing/gateways/paymentez.rb', line 140
def inquire(authorization, options = {})
commit_transaction('inquire', authorization)
end
|
#purchase(money, payment, options = {}) ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/active_merchant/billing/gateways/paymentez.rb', line 59
def purchase(money, payment, options = {})
post = {}
add_invoice(post, money, options)
add_payment(post, payment)
add_customer_data(post, options)
(post, options)
action = payment.is_a?(String) ? 'debit' : 'debit_cc'
commit_transaction(action, post)
end
|
#refund(money, authorization, options = {}) ⇒ Object
101
102
103
104
105
106
107
|
# File 'lib/active_merchant/billing/gateways/paymentez.rb', line 101
def refund(money, authorization, options = {})
post = { transaction: { id: authorization } }
post[:order] = { amount: amount(money).to_f } if money
add_more_info(post, options)
commit_transaction('refund', post)
end
|
#scrub(transcript) ⇒ Object
148
149
150
151
152
153
|
# File 'lib/active_merchant/billing/gateways/paymentez.rb', line 148
def scrub(transcript)
transcript.
gsub(%r{(\\?"number\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]').
gsub(%r{(\\?"cvc\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]').
gsub(%r{(Auth-Token: )([A-Za-z0-9=]+)}, '\1[FILTERED]')
end
|
#store(credit_card, options = {}) ⇒ Object
121
122
123
124
125
126
127
128
129
130
131
132
133
|
# File 'lib/active_merchant/billing/gateways/paymentez.rb', line 121
def store(credit_card, options = {})
post = {}
add_customer_data(post, options)
add_payment(post, credit_card)
response = commit_card('add', post)
if !response.success? && !(token = (response)).nil?
unstore(token, options)
response = commit_card('add', post)
end
response
end
|
#supports_scrubbing? ⇒ Boolean
144
145
146
|
# File 'lib/active_merchant/billing/gateways/paymentez.rb', line 144
def supports_scrubbing?
true
end
|
#unstore(identification, options = {}) ⇒ Object
135
136
137
138
|
# File 'lib/active_merchant/billing/gateways/paymentez.rb', line 135
def unstore(identification, options = {})
post = { card: { token: identification }, user: { id: options[:user_id] } }
commit_card('delete', post)
end
|
#verify(credit_card, options = {}) ⇒ Object
114
115
116
117
118
119
|
# File 'lib/active_merchant/billing/gateways/paymentez.rb', line 114
def verify(credit_card, options = {})
MultiResponse.run do |r|
r.process { authorize(100, credit_card, options) }
r.process { void(r.authorization, options) }
end
end
|
#void(authorization, _options = {}) ⇒ Object
109
110
111
112
|
# File 'lib/active_merchant/billing/gateways/paymentez.rb', line 109
def void(authorization, _options = {})
post = { transaction: { id: authorization } }
commit_transaction('refund', post)
end
|