Class: ActiveMerchant::Billing::CheckoutV2Gateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::CheckoutV2Gateway
show all
- Defined in:
- lib/active_merchant/billing/gateways/checkout_v2.rb
Constant Summary
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
-
#authorize(amount, payment_method, options = {}) ⇒ Object
-
#capture(amount, authorization, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ CheckoutV2Gateway
constructor
A new instance of CheckoutV2Gateway.
-
#purchase(amount, payment_method, options = {}) ⇒ Object
-
#refund(amount, authorization, options = {}) ⇒ Object
-
#scrub(transcript) ⇒ Object
-
#supports_scrubbing? ⇒ Boolean
-
#verify(credit_card, options = {}) ⇒ Object
-
#verify_payment(authorization, option = {}) ⇒ 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?, #supports_network_tokenization?, #test?
#expdate, #format
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
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
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 31
def authorize(amount, payment_method, options = {})
post = {}
post[:capture] = false
add_invoice(post, amount, options)
add_payment_method(post, payment_method, options)
add_customer_data(post, options)
add_transaction_data(post, options)
add_3ds(post, options)
commit(:authorize, post)
end
|
#capture(amount, authorization, options = {}) ⇒ Object
43
44
45
46
47
48
49
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 43
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
|
# 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(&:params).reduce({}, :merge)
succeeded = success_from(merged_params)
response(:purchase, succeeded, merged_params)
end
|
#refund(amount, authorization, options = {}) ⇒ Object
56
57
58
59
60
61
62
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 56
def refund(amount, authorization, options = {})
post = {}
add_invoice(post, amount, options)
add_customer_data(post, options)
commit(:refund, post, authorization)
end
|
#scrub(transcript) ⇒ Object
79
80
81
82
83
84
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 79
def scrub(transcript)
transcript.
gsub(/(Authorization: )[^\\]*/i, '\1[FILTERED]').
gsub(/("number\\":\\")\d+/, '\1[FILTERED]').
gsub(/("cvv\\":\\")\d+/, '\1[FILTERED]')
end
|
#supports_scrubbing? ⇒ Boolean
75
76
77
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 75
def supports_scrubbing?
true
end
|
#verify(credit_card, options = {}) ⇒ Object
64
65
66
67
68
69
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 64
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
|
#verify_payment(authorization, option = {}) ⇒ Object
71
72
73
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 71
def verify_payment(authorization, option={})
commit(:verify_payment, authorization)
end
|
#void(authorization, _options = {}) ⇒ Object
51
52
53
54
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 51
def void(authorization, _options = {})
post = {}
commit(:void, post, authorization)
end
|