Class: ActiveMerchant::Billing::AdyenGateway

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

Constant Summary collapse

API_VERSION =
'v40'
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

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 = {}) ⇒ AdyenGateway

Returns a new instance of AdyenGateway.



32
33
34
35
36
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 32

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



82
83
84
85
86
87
88
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 82

def adjust(money, authorization, options={})
  post = init_post(options)
  add_invoice_for_modification(post, money, options)
  add_reference(post, authorization, options)
  add_extra_data(post, nil, options)
  commit('adjustAuthorisation', post, options)
end

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



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 49

def authorize(money, payment, options={})
  requires!(options, :order_id)
  post = init_post(options)
  add_invoice(post, money, options)
  add_payment(post, payment)
  add_extra_data(post, payment, options)
  add_stored_credentials(post, payment, options)
  add_address(post, options)
  add_installments(post, options) if options[:installments]
  add_3ds(post, options)
  commit('authorise', post, options)
end

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



62
63
64
65
66
67
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 62

def capture(money, authorization, options={})
  post = init_post(options)
  add_invoice_for_modification(post, money, options)
  add_reference(post, authorization, options)
  commit('capture', post, options)
end

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



38
39
40
41
42
43
44
45
46
47
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 38

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



69
70
71
72
73
74
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 69

def refund(money, authorization, options={})
  post = init_post(options)
  add_invoice_for_modification(post, money, options)
  add_original_reference(post, authorization, options)
  commit('refund', post, options)
end

#scrub(transcript) ⇒ Object



114
115
116
117
118
119
120
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 114

def scrub(transcript)
  transcript.
    gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
    gsub(%r(("number\\?":\\?")[^"]*)i, '\1[FILTERED]').
    gsub(%r(("cvc\\?":\\?")[^"]*)i, '\1[FILTERED]').
    gsub(%r(("cavv\\?":\\?")[^"]*)i, '\1[FILTERED]')
end

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



90
91
92
93
94
95
96
97
98
99
100
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 90

def store(credit_card, options={})
  requires!(options, :order_id)
  post = init_post(options)
  add_invoice(post, 0, options)
  add_payment(post, credit_card)
  add_extra_data(post, credit_card, options)
  add_stored_credentials(post, credit_card, options)
  add_recurring_contract(post, options)
  add_address(post, options)
  commit('authorise', post, options)
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


110
111
112
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 110

def supports_scrubbing?
  true
end

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



102
103
104
105
106
107
108
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 102

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

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



76
77
78
79
80
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 76

def void(authorization, options={})
  post = init_post(options)
  add_reference(post, authorization, options)
  commit('cancel', post, options)
end