Class: ActiveMerchant::Billing::AdyenGateway
- Defined in:
- lib/active_merchant/billing/gateways/adyen.rb
Constant Summary collapse
- PAYMENT_API_VERSION =
'v68'
- RECURRING_API_VERSION =
'v68'
- STANDARD_ERROR_CODE_MAPPING =
{ '0' => STANDARD_ERROR_CODE[:processing_error], '10' => STANDARD_ERROR_CODE[:config_error], '100' => STANDARD_ERROR_CODE[:invalid_amount], '101' => STANDARD_ERROR_CODE[:incorrect_number], '103' => STANDARD_ERROR_CODE[:invalid_cvc], '104' => STANDARD_ERROR_CODE[:incorrect_address], '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
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?
Methods included from CreditCardFormatting
#expdate, #format, #strftime_yyyymm
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.
37 38 39 40 41 |
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 37 def initialize( = {}) requires!(, :username, :password, :merchant_account) @username, @password, @merchant_account = .values_at(:username, :password, :merchant_account) super end |
Instance Method Details
#adjust(money, authorization, options = {}) ⇒ Object
131 132 133 134 135 136 137 138 |
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 131 def adjust(money, , = {}) post = init_post() add_invoice_for_modification(post, money, ) add_reference(post, , ) add_extra_data(post, nil, ) add_recurring_detail_reference(post, ) commit('adjustAuthorisation', post, ) end |
#authorize(money, payment, options = {}) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 54 def (money, payment, = {}) requires!(, :order_id) post = init_post() add_invoice(post, money, ) add_payment(post, payment, ) add_extra_data(post, payment, ) add_stored_credentials(post, payment, ) add_address(post, ) add_installments(post, ) if [:installments] add_3ds(post, ) add_3ds_authenticated_data(post, ) add_splits(post, ) add_recurring_contract(post, , payment) add_network_transaction_reference(post, ) add_application_info(post, ) add_level_2_data(post, ) add_level_3_data(post, ) add_data_airline(post, ) add_data_lodging(post, ) (post, ) add_recurring_detail_reference(post, ) commit('authorise', post, ) end |
#capture(money, authorization, options = {}) ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 78 def capture(money, , = {}) post = init_post() add_invoice_for_modification(post, money, ) add_reference(post, , ) add_splits(post, ) add_network_transaction_reference(post, ) add_shopper_statement(post, ) commit('capture', post, ) end |
#credit(money, payment, options = {}) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 97 def credit(money, payment, = {}) action = [:payout] ? 'payout' : 'refundWithData' post = init_post() add_invoice(post, money, ) add_payment(post, payment, , action) add_shopper_reference(post, ) add_network_transaction_reference(post, ) if action == 'payout' add_shopper_interaction(post, payment, ) add_fraud_offset(post, ) add_fund_source(post, ) add_recurring_contract(post, ) add_shopper_data(post, payment, ) if (address = [:billing_address] || [:address]) && address[:country] add_billing_address(post, , address) end post[:dateOfBirth] = [:date_of_birth] if [:date_of_birth] post[:nationality] = [:nationality] if [:nationality] end add_recurring_detail_reference(post, ) commit(action, post, ) end |
#purchase(money, payment, options = {}) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 43 def purchase(money, payment, = {}) if [:execute_threed] || [:threed_dynamic] (money, payment, ) else MultiResponse.run do |r| r.process { (money, payment, ) } r.process { capture(money, r., ()) } end end end |
#refund(money, authorization, options = {}) ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 88 def refund(money, , = {}) post = init_post() add_invoice_for_modification(post, money, ) add_reference(post, , ) add_splits(post, ) add_network_transaction_reference(post, ) commit('refund', post, ) end |
#scrub(transcript) ⇒ Object
191 192 193 194 195 196 197 198 199 200 |
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 191 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
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 140 def store(credit_card, = {}) requires!(, :order_id) post = init_post() add_invoice(post, 0, ) add_payment(post, credit_card, ) add_extra_data(post, credit_card, ) add_stored_credentials(post, credit_card, ) add_address(post, ) add_network_transaction_reference(post, ) [:recurring_contract_type] ||= 'RECURRING' add_recurring_contract(post, ) action = [:tokenize_only] ? 'storeToken' : 'authorise' initial_response = commit(action, post, ) if initial_response.success? && card_not_stored?(initial_response) unsupported_failure_response(initial_response) else initial_response end end |
#supports_network_tokenization? ⇒ Boolean
187 188 189 |
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 187 def supports_network_tokenization? true end |
#supports_scrubbing? ⇒ Boolean
183 184 185 |
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 183 def supports_scrubbing? true end |
#unstore(options = {}) ⇒ Object
163 164 165 166 167 168 169 170 171 172 |
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 163 def unstore( = {}) requires!(, :shopper_reference, :recurring_detail_reference) post = {} add_shopper_reference(post, ) add_merchant_account(post, ) post[:recurringDetailReference] = [:recurring_detail_reference] commit('disable', post, ) end |
#verify(credit_card, options = {}) ⇒ Object
174 175 176 177 178 179 180 181 |
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 174 def verify(credit_card, = {}) amount = [:verify_amount]&.to_i || 0 MultiResponse.run(:use_first_response) do |r| r.process { (amount, credit_card, ) } [:idempotency_key] = nil r.process(:ignore_result) { void(r., ) } end end |
#void(authorization, options = {}) ⇒ Object
123 124 125 126 127 128 129 |
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 123 def void(, = {}) post = init_post() endpoint = [:cancel_or_refund] ? 'cancelOrRefund' : 'cancel' add_reference(post, , ) add_network_transaction_reference(post, ) commit(endpoint, post, ) end |