Class: ActiveMerchant::Billing::AdyenGateway

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

Constant Summary collapse

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::DEBIT_CARDS, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#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.



29
30
31
32
33
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 29

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

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



42
43
44
45
46
47
48
49
50
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 42

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, options)
  add_address(post, options)
  commit('authorise', post)
end

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



52
53
54
55
56
57
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 52

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

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



35
36
37
38
39
40
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 35

def purchase(money, payment, options={})
  MultiResponse.run do |r|
    r.process{authorize(money, payment, options)}
    r.process{capture(money, r.authorization, options)}
  end
end

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



59
60
61
62
63
64
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 59

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

#scrub(transcript) ⇒ Object



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

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

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 79

def supports_scrubbing?
  true
end

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



72
73
74
75
76
77
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 72

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



66
67
68
69
70
# File 'lib/active_merchant/billing/gateways/adyen.rb', line 66

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