Class: ActiveMerchant::Billing::CheckoutV2Gateway

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

Constant Summary

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

Returns a new instance of CheckoutV2Gateway.


14
15
16
17
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 14

def initialize(options={})
  requires!(options, :secret_key)
  super
end

Instance Method Details

#authorize(amount, payment_method, options = {}) ⇒ Object


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

def authorize(amount, payment_method, options={})
  post = {}
  post[:autoCapture] = "n"
  add_invoice(post, amount, options)
  add_payment_method(post, payment_method)
  add_customer_data(post, options)

  commit(:authorize, post)
end

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


50
51
52
53
54
55
56
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 50

def capture(amount, authorization, options={})
  post = {}
  add_invoice(post, amount, options)
  add_customer_data(post, options)

  commit(:capture, post, authorization)
end

#purchase(amount, payment_method, options = {}) ⇒ Object


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 19

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

  merged_params = multi.responses.map { |r| r.params }.reduce({}, :merge)
  succeeded = success_from(merged_params)

  Response.new(
    succeeded,
    message_from(succeeded, merged_params),
    merged_params,
    authorization: authorization_from(merged_params),
    avs_result: avs_result(:purchase, succeeded, merged_params),
    cvv_result: cvv_result(:purchase, succeeded, merged_params),
    error_code: error_code_from(succeeded, merged_params),
    test: test?
  )
end

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


63
64
65
66
67
68
69
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 63

def refund(amount, authorization, options={})
  post = {}
  add_invoice(post, amount, options)
  add_customer_data(post, options)

  commit(:refund, post, authorization)
end

#scrub(transcript) ⇒ Object


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

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

#supports_scrubbing?Boolean

Returns:

  • (Boolean)

78
79
80
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 78

def supports_scrubbing?
  true
end

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


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

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


58
59
60
61
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 58

def void(authorization, options={})
  post = {}
  commit(:void, post, authorization)
end