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
collapse
- LIVE_ACCESS_TOKEN_URL =
'https://access.checkout.com/connect/token'
- TEST_ACCESS_TOKEN_URL =
'https://access.sandbox.checkout.com/connect/token'
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
-
#credit(amount, payment, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ CheckoutV2Gateway
constructor
A new instance of CheckoutV2Gateway.
-
#inquire(authorization, options = {}) ⇒ Object
-
#purchase(amount, payment_method, options = {}) ⇒ Object
-
#refund(amount, authorization, options = {}) ⇒ Object
-
#scrub(transcript) ⇒ Object
-
#store(payment_method, options = {}) ⇒ Object
-
#supports_scrubbing? ⇒ Boolean
-
#unstore(id, options = {}) ⇒ Object
-
#verify(credit_card, options = {}) ⇒ Object
-
#verify_payment(authorization, options = {}) ⇒ 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, #strftime_yyyymm
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
Returns a new instance of CheckoutV2Gateway.
19
20
21
22
23
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 19
def initialize(options = {})
options.has_key?(:secret_key) ? requires!(options, :secret_key) : requires!(options, :client_id, :client_secret)
super
end
|
Instance Method Details
#authorize(amount, payment_method, options = {}) ⇒ Object
32
33
34
35
36
37
38
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 32
def authorize(amount, payment_method, options = {})
post = {}
post[:capture] = false
build_auth_or_purchase(post, amount, payment_method, options)
options[:incremental_authorization] ? commit(:incremental_authorize, post, options, options[:incremental_authorization]) : commit(:authorize, post, options)
end
|
#capture(amount, authorization, options = {}) ⇒ Object
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 40
def capture(amount, authorization, options = {})
post = {}
post[:capture_type] = options[:capture_type] || 'Final'
add_invoice(post, amount, options)
add_customer_data(post, options)
add_shipping_address(post, options)
add_metadata(post, options)
commit(:capture, post, options, authorization)
end
|
#credit(amount, payment, options = {}) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 51
def credit(amount, payment, options = {})
post = {}
add_processing_channel(post, options)
add_invoice(post, amount, options)
add_payment_method(post, payment, options, :destination)
add_source(post, options)
add_instruction_data(post, options)
add_payout_sender_data(post, options)
add_payout_destination_data(post, options)
commit(:credit, post, options)
end
|
#inquire(authorization, options = {}) ⇒ Object
84
85
86
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 84
def inquire(authorization, options = {})
verify_payment(authorization, {})
end
|
#purchase(amount, payment_method, options = {}) ⇒ Object
25
26
27
28
29
30
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 25
def purchase(amount, payment_method, options = {})
post = {}
build_auth_or_purchase(post, amount, payment_method, options)
commit(:purchase, post, options)
end
|
#refund(amount, authorization, options = {}) ⇒ Object
71
72
73
74
75
76
77
78
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 71
def refund(amount, authorization, options = {})
post = {}
add_invoice(post, amount, options)
add_customer_data(post, options)
add_metadata(post, options)
commit(:refund, post, options, authorization)
end
|
#scrub(transcript) ⇒ Object
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 96
def scrub(transcript)
transcript.
gsub(/(Authorization: )[^\\]*/i, '\1[FILTERED]').
gsub(/("number\\":\\")\d+/, '\1[FILTERED]').
gsub(/("cvv\\":\\")\d+/, '\1[FILTERED]').
gsub(/("cryptogram\\":\\")\w+/, '\1[FILTERED]').
gsub(/(source\\":\{.*\\"token\\":\\")\d+/, '\1[FILTERED]').
gsub(/("token\\":\\")\w+/, '\1[FILTERED]').
gsub(/("access_token\\?"\s*:\s*\\?")[^"]*\w+/, '\1[FILTERED]')
end
|
#store(payment_method, options = {}) ⇒ Object
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 107
def store(payment_method, options = {})
post = {}
MultiResponse.run do |r|
if payment_method.is_a?(NetworkTokenizationCreditCard)
r.process { verify(payment_method, options) }
break r unless r.success?
r.params['source']['customer'] = r.params['customer']
r.process { response(:store, true, r.params['source']) }
else
r.process { tokenize(payment_method, options) }
break r unless r.success?
token = r.params['token']
add_payment_method(post, token, options)
post.merge!(post.delete(:source))
add_customer_data(post, options)
add_shipping_address(post, options)
r.process { commit(:store, post, options) }
end
end
end
|
#supports_scrubbing? ⇒ Boolean
92
93
94
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 92
def supports_scrubbing?
true
end
|
#unstore(id, options = {}) ⇒ Object
130
131
132
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 130
def unstore(id, options = {})
commit(:unstore, nil, options, id, :delete)
end
|
#verify(credit_card, options = {}) ⇒ Object
80
81
82
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 80
def verify(credit_card, options = {})
authorize(0, credit_card, options)
end
|
#verify_payment(authorization, options = {}) ⇒ Object
88
89
90
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 88
def verify_payment(authorization, options = {})
commit(:verify_payment, nil, options, authorization, :get)
end
|
#void(authorization, _options = {}) ⇒ Object
64
65
66
67
68
69
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 64
def void(authorization, _options = {})
post = {}
add_metadata(post, options)
commit(:void, post, options, authorization)
end
|