Class: ActiveMerchant::Billing::AdyenGateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::AdyenGateway
show all
- Defined in:
- lib/active_merchant/billing/gateways/adyen.rb
Constant Summary
collapse
- PAYMENT_API_VERSION =
'v64'
- RECURRING_API_VERSION =
'v49'
- STANDARD_ERROR_CODE_MAPPING =
{
'101' => STANDARD_ERROR_CODE[:incorrect_number],
'103' => STANDARD_ERROR_CODE[:invalid_cvc],
'131' => STANDARD_ERROR_CODE[:incorrect_address],
'132' => STANDARD_ERROR_CODE[:incorrect_address],
'133' => STANDARD_ERROR_CODE[:incorrect_address],
'134' => STANDARD_ERROR_CODE[:incorrect_address],
'135' => STANDARD_ERROR_CODE[:incorrect_address]
}
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
-
#adjust(money, authorization, options = {}) ⇒ Object
-
#authorize(money, payment, options = {}) ⇒ Object
-
#capture(money, authorization, options = {}) ⇒ Object
-
#credit(money, payment, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ AdyenGateway
constructor
A new instance of AdyenGateway.
-
#purchase(money, payment, options = {}) ⇒ Object
-
#refund(money, authorization, options = {}) ⇒ Object
-
#scrub(transcript) ⇒ Object
-
#store(credit_card, options = {}) ⇒ Object
-
#supports_network_tokenization? ⇒ Boolean
-
#supports_scrubbing? ⇒ Boolean
-
#unstore(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?, #test?
#expdate, #format
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
#initialize(options = {}) ⇒ AdyenGateway
Returns a new instance of AdyenGateway.
33
34
35
36
37
|
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 33
def initialize(options = {})
requires!(options, :username, :password, :merchant_account)
@username, @password, @merchant_account = options.values_at(:username, :password, :merchant_account)
super
end
|
Instance Method Details
#adjust(money, authorization, options = {}) ⇒ Object
104
105
106
107
108
109
110
|
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 104
def adjust(money, authorization, options = {})
post = init_post(options)
add_invoice_for_modification(post, money, options)
add_reference(post, authorization, options)
(post, nil, options)
commit('adjustAuthorisation', post, options)
end
|
#authorize(money, payment, options = {}) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 50
def authorize(money, payment, options = {})
requires!(options, :order_id)
post = init_post(options)
add_invoice(post, money, options)
add_payment(post, payment, options)
(post, payment, options)
add_stored_credentials(post, payment, options)
add_address(post, options)
add_installments(post, options) if options[:installments]
add_3ds(post, options)
add_3ds_authenticated_data(post, options)
add_splits(post, options)
add_recurring_contract(post, options)
add_network_transaction_reference(post, options)
add_application_info(post, options)
commit('authorise', post, options)
end
|
#capture(money, authorization, options = {}) ⇒ Object
68
69
70
71
72
73
74
75
|
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 68
def capture(money, authorization, options = {})
post = init_post(options)
add_invoice_for_modification(post, money, options)
add_reference(post, authorization, options)
add_splits(post, options)
add_network_transaction_reference(post, options)
commit('capture', post, options)
end
|
#credit(money, payment, options = {}) ⇒ Object
86
87
88
89
90
91
92
93
94
|
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 86
def credit(money, payment, options = {})
action = 'refundWithData'
post = init_post(options)
add_invoice(post, money, options)
add_payment(post, payment, options, action)
add_shopper_reference(post, options)
add_network_transaction_reference(post, options)
commit(action, post, options)
end
|
#purchase(money, payment, options = {}) ⇒ Object
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 39
def purchase(money, payment, options = {})
if options[:execute_threed] || options[:threed_dynamic]
authorize(money, payment, options)
else
MultiResponse.run do |r|
r.process { authorize(money, payment, options) }
r.process { capture(money, r.authorization, capture_options(options)) }
end
end
end
|
#refund(money, authorization, options = {}) ⇒ Object
77
78
79
80
81
82
83
84
|
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 77
def refund(money, authorization, options = {})
post = init_post(options)
add_invoice_for_modification(post, money, options)
add_reference(post, authorization, options)
add_splits(post, options)
add_network_transaction_reference(post, options)
commit('refund', post, options)
end
|
#scrub(transcript) ⇒ Object
163
164
165
166
167
168
169
170
171
172
|
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 163
def scrub(transcript)
transcript.
gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
gsub(%r(("number\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
gsub(%r(("cvc\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
gsub(%r(("cavv\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
gsub(%r(("bankLocationId\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
gsub(%r(("iban\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
gsub(%r(("bankAccountNumber\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]')
end
|
#store(credit_card, options = {}) ⇒ Object
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 112
def store(credit_card, options = {})
requires!(options, :order_id)
post = init_post(options)
add_invoice(post, 0, options)
add_payment(post, credit_card, options)
(post, credit_card, options)
add_stored_credentials(post, credit_card, options)
add_address(post, options)
options[:recurring_contract_type] ||= 'RECURRING'
add_recurring_contract(post, options)
action = options[:tokenize_only] ? 'storeToken' : 'authorise'
initial_response = commit(action, post, options)
if initial_response.success? && card_not_stored?(initial_response)
unsupported_failure_response(initial_response)
else
initial_response
end
end
|
#supports_network_tokenization? ⇒ Boolean
159
160
161
|
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 159
def supports_network_tokenization?
true
end
|
#supports_scrubbing? ⇒ Boolean
155
156
157
|
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 155
def supports_scrubbing?
true
end
|
#unstore(options = {}) ⇒ Object
135
136
137
138
139
140
141
142
143
144
|
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 135
def unstore(options = {})
requires!(options, :shopper_reference, :recurring_detail_reference)
post = {}
add_shopper_reference(post, options)
add_merchant_account(post, options)
post[:recurringDetailReference] = options[:recurring_detail_reference]
commit('disable', post, options)
end
|
#verify(credit_card, options = {}) ⇒ Object
146
147
148
149
150
151
152
153
|
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 146
def verify(credit_card, options = {})
amount = options[:verify_amount]&.to_i || 0
MultiResponse.run(:use_first_response) do |r|
r.process { authorize(amount, credit_card, options) }
options[:idempotency_key] = nil
r.process(:ignore_result) { void(r.authorization, options) }
end
end
|
#void(authorization, options = {}) ⇒ Object
96
97
98
99
100
101
102
|
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 96
def void(authorization, options = {})
post = init_post(options)
endpoint = options[:cancel_or_refund] ? 'cancelOrRefund' : 'cancel'
add_reference(post, authorization, options)
add_network_transaction_reference(post, options)
commit(endpoint, post, options)
end
|