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.
-
#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, 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.
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 19
def initialize(options = {})
@options = options
@access_token = nil
if options.has_key?(:secret_key)
requires!(options, :secret_key)
else
requires!(options, :client_id, :client_secret)
@access_token = setup_access_token
end
super
end
|
Instance Method Details
#authorize(amount, payment_method, options = {}) ⇒ Object
40
41
42
43
44
45
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 40
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[:incremental_authorization]) : commit(:authorize, post)
end
|
#capture(amount, authorization, options = {}) ⇒ Object
47
48
49
50
51
52
53
54
55
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 47
def capture(amount, authorization, options = {})
post = {}
post[:capture_type] = options[:capture_type] || 'Final'
add_invoice(post, amount, options)
add_customer_data(post, options)
add_metadata(post, options)
commit(:capture, post, authorization)
end
|
#credit(amount, payment, options = {}) ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 57
def credit(amount, payment, options = {})
post = {}
post[:instruction] = {}
post[:instruction][:funds_transfer_type] = options[:funds_transfer_type] || 'FD'
add_processing_channel(post, options)
add_invoice(post, amount, options)
add_payment_method(post, payment, options, :destination)
add_source(post, options)
commit(:credit, post)
end
|
#purchase(amount, payment_method, options = {}) ⇒ Object
33
34
35
36
37
38
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 33
def purchase(amount, payment_method, options = {})
post = {}
build_auth_or_purchase(post, amount, payment_method, options)
commit(:purchase, post)
end
|
#refund(amount, authorization, options = {}) ⇒ Object
76
77
78
79
80
81
82
83
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 76
def refund(amount, authorization, options = {})
post = {}
add_invoice(post, amount, options)
add_customer_data(post, options)
add_metadata(post, options)
commit(:refund, post, authorization)
end
|
#scrub(transcript) ⇒ Object
97
98
99
100
101
102
103
104
105
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 97
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]')
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
|
# 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)
r.process { commit(:store, post) }
end
end
end
|
#supports_scrubbing? ⇒ Boolean
93
94
95
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 93
def supports_scrubbing?
true
end
|
#unstore(id, options = {}) ⇒ Object
129
130
131
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 129
def unstore(id, options = {})
commit(:unstore, nil, id, :delete)
end
|
#verify(credit_card, options = {}) ⇒ Object
85
86
87
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 85
def verify(credit_card, options = {})
authorize(0, credit_card, options)
end
|
#verify_payment(authorization, option = {}) ⇒ Object
89
90
91
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 89
def verify_payment(authorization, option = {})
commit(:verify_payment, nil, authorization, :get)
end
|
#void(authorization, _options = {}) ⇒ Object
69
70
71
72
73
74
|
# File 'lib/active_merchant/billing/gateways/checkout_v2.rb', line 69
def void(authorization, _options = {})
post = {}
add_metadata(post, options)
commit(:void, post, authorization)
end
|