Class: ActiveMerchant::Billing::CheckoutV2

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ CheckoutV2

Returns a new instance of CheckoutV2.



22
23
24
25
# File 'lib/active_merchant/billing/checkout_v2.rb', line 22

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

Instance Method Details

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



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/active_merchant/billing/checkout_v2.rb', line 34

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

  if payment_method.is_a?(String) && payment_method.include?('card_tok_')
    post[:cardToken] = payment_method
    post[:email] = options[:email]

    commit(:authorize_token, post)
  else
    add_payment_method(post, payment_method)
    add_customer_data(post, options)

    commit(:authorize, post)
  end
end

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



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

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



27
28
29
30
31
32
# File 'lib/active_merchant/billing/checkout_v2.rb', line 27

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

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



65
66
67
68
69
70
71
# File 'lib/active_merchant/billing/checkout_v2.rb', line 65

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

  commit(:refund, post, authorization)
end

#scrub(transcript) ⇒ Object



84
85
86
87
88
89
# File 'lib/active_merchant/billing/checkout_v2.rb', line 84

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)


80
81
82
# File 'lib/active_merchant/billing/checkout_v2.rb', line 80

def supports_scrubbing?
  true
end

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



73
74
75
76
77
78
# File 'lib/active_merchant/billing/checkout_v2.rb', line 73

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



60
61
62
63
# File 'lib/active_merchant/billing/checkout_v2.rb', line 60

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