Class: ActiveMerchant::Billing::AirwallexGateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::AirwallexGateway
show all
- Defined in:
- lib/active_merchant/billing/gateways/airwallex.rb
Constant Summary
collapse
- ENDPOINTS =
{
login: '/authentication/login',
setup: '/pa/payment_intents/create',
sale: '/pa/payment_intents/%{id}/confirm',
capture: '/pa/payment_intents/%{id}/capture',
refund: '/pa/refunds/create',
void: '/pa/payment_intents/%{id}/cancel'
}
- TEST_NETWORK_TRANSACTION_IDS =
Provided by Airwallex for testing purposes
{
visa: '123456789012345',
master: 'MCC123ABC0101'
}
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(money, payment, options = {}) ⇒ Object
-
#capture(money, authorization, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ AirwallexGateway
constructor
A new instance of AirwallexGateway.
-
#purchase(money, card, options = {}) ⇒ Object
-
#refund(money, authorization, options = {}) ⇒ Object
-
#scrub(transcript) ⇒ Object
-
#supports_scrubbing? ⇒ Boolean
-
#verify(credit_card, 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
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
Returns a new instance of AirwallexGateway.
30
31
32
33
34
35
36
|
# File 'lib/active_merchant/billing/gateways/airwallex.rb', line 30
def initialize(options = {})
requires!(options, :client_id, :client_api_key)
@client_id = options[:client_id]
@client_api_key = options[:client_api_key]
super
@access_token = setup_access_token
end
|
Instance Method Details
#authorize(money, payment, options = {}) ⇒ Object
54
55
56
57
|
# File 'lib/active_merchant/billing/gateways/airwallex.rb', line 54
def authorize(money, payment, options = {})
purchase(money, payment, options.merge({ auto_capture: false }))
end
|
#capture(money, authorization, options = {}) ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/active_merchant/billing/gateways/airwallex.rb', line 59
def capture(money, authorization, options = {})
raise ArgumentError, 'An authorization value must be provided.' if authorization.blank?
post = {
'request_id' => request_id(options),
'merchant_order_id' => merchant_order_id(options),
'amount' => amount(money)
}
add_descriptor(post, options)
commit(:capture, post, authorization)
end
|
#purchase(money, card, options = {}) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/active_merchant/billing/gateways/airwallex.rb', line 38
def purchase(money, card, options = {})
payment_intent_id = create_payment_intent(money, options)
post = {
'request_id' => request_id(options),
'merchant_order_id' => merchant_order_id(options)
}
add_card(post, card, options)
add_descriptor(post, options)
add_stored_credential(post, options)
add_return_url(post, options)
post['payment_method_options'] = { 'card' => { 'auto_capture' => false } } if authorization_only?(options)
add_three_ds(post, options)
commit(:sale, post, payment_intent_id)
end
|
#refund(money, authorization, options = {}) ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/active_merchant/billing/gateways/airwallex.rb', line 72
def refund(money, authorization, options = {})
raise ArgumentError, 'An authorization value must be provided.' if authorization.blank?
post = {}
post[:amount] = amount(money)
post[:payment_intent_id] = authorization
post[:request_id] = request_id(options)
post[:merchant_order_id] = merchant_order_id(options)
commit(:refund, post)
end
|
#scrub(transcript) ⇒ Object
106
107
108
109
110
|
# File 'lib/active_merchant/billing/gateways/airwallex.rb', line 106
def scrub(transcript)
transcript.
gsub(/(\\\"number\\\":\\\")\d+/, '\1[REDACTED]').
gsub(/(\\\"cvc\\\":\\\")\d+/, '\1[REDACTED]')
end
|
#supports_scrubbing? ⇒ Boolean
102
103
104
|
# File 'lib/active_merchant/billing/gateways/airwallex.rb', line 102
def supports_scrubbing?
true
end
|
#verify(credit_card, options = {}) ⇒ Object
95
96
97
98
99
100
|
# File 'lib/active_merchant/billing/gateways/airwallex.rb', line 95
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
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/active_merchant/billing/gateways/airwallex.rb', line 84
def void(authorization, options = {})
raise ArgumentError, 'An authorization value must be provided.' if authorization.blank?
post = {}
post[:request_id] = request_id(options)
post[:merchant_order_id] = merchant_order_id(options)
add_descriptor(post, options)
commit(:void, post, authorization)
end
|