Class: ActiveMerchant::Billing::FlexChargeGateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::FlexChargeGateway
show all
- Defined in:
- lib/active_merchant/billing/gateways/flex_charge.rb
Constant Summary
collapse
- ENDPOINTS_MAPPING =
{
authenticate: 'oauth2/token',
purchase: 'evaluate',
sync: 'outcome',
refund: 'orders/%s/refund',
store: 'tokenize',
inquire: 'orders/%s',
capture: 'capture',
void: 'orders/%s/cancel'
}
- SUCCESS_MESSAGES =
%w(APPROVED CHALLENGE SUBMITTED SUCCESS PROCESSING CAPTUREREQUIRED).freeze
- NO_ERROR_KEYS =
%w(TraceId access_token token_expires).freeze
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
-
#add_metadata(post, options) ⇒ Object
-
#authorize(money, credit_card, options = {}) ⇒ Object
-
#capture(money, authorization, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ FlexChargeGateway
constructor
A new instance of FlexChargeGateway.
-
#inquire(authorization, options = {}) ⇒ Object
-
#purchase(money, credit_card, options = {}) ⇒ Object
-
#refund(money, authorization, options = {}) ⇒ Object
-
#scrub(transcript) ⇒ Object
-
#store(credit_card, options = {}) ⇒ Object
-
#supports_scrubbing? ⇒ Boolean
-
#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 FlexChargeGateway.
29
30
31
32
|
# File 'lib/active_merchant/billing/gateways/flex_charge.rb', line 29
def initialize(options = {})
requires!(options, :app_key, :app_secret, :site_id, :mid)
super
end
|
Instance Method Details
120
121
122
123
|
# File 'lib/active_merchant/billing/gateways/flex_charge.rb', line 120
def add_metadata(post, options)
post[:Source] = 'Spreedly'
post[:ExtraData] = options[:extra_data] if options[:extra_data].present?
end
|
#authorize(money, credit_card, options = {}) ⇒ Object
51
52
53
54
|
# File 'lib/active_merchant/billing/gateways/flex_charge.rb', line 51
def authorize(money, credit_card, options = {})
options[:transactionType] = 'Authorization'
purchase(money, credit_card, options)
end
|
#capture(money, authorization, options = {}) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/active_merchant/billing/gateways/flex_charge.rb', line 56
def capture(money, authorization, options = {})
order_id, currency = authorization.split('#')
post = {
idempotencyKey: options[:idempotency_key] || SecureRandom.uuid,
orderId: order_id,
amount: money,
currency: currency
}
commit(:capture, post, authorization)
end
|
#inquire(authorization, options = {}) ⇒ Object
115
116
117
118
|
# File 'lib/active_merchant/billing/gateways/flex_charge.rb', line 115
def inquire(authorization, options = {})
order_id, _currency = authorization.split('#')
commit(:inquire, {}, order_id, :get)
end
|
#purchase(money, credit_card, options = {}) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/active_merchant/billing/gateways/flex_charge.rb', line 34
def purchase(money, credit_card, options = {})
post = { transactionType: options.fetch(:transactionType, 'Purchase') }
add_merchant_data(post, options)
add_base_data(post, options)
add_invoice(post, money, credit_card, options)
add_mit_data(post, options)
add_payment_method(post, credit_card, address(options), options)
add_address(post, credit_card, address(options), :billingInformation)
add_address(post, credit_card, options[:shipping_address], :shippingInformation)
add_customer_data(post, options)
add_three_ds(post, options)
add_metadata(post, options)
commit(:purchase, post)
end
|
#refund(money, authorization, options = {}) ⇒ Object
68
69
70
71
72
|
# File 'lib/active_merchant/billing/gateways/flex_charge.rb', line 68
def refund(money, authorization, options = {})
order_id, _currency = authorization.split('#')
self.money_format = :dollars
commit(:refund, { amountToRefund: localized_amount(money, 2).to_f }, order_id)
end
|
#scrub(transcript) ⇒ Object
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/active_merchant/billing/gateways/flex_charge.rb', line 101
def scrub(transcript)
transcript.
gsub(%r((Authorization: Bearer )[a-zA-Z0-9._-]+)i, '\1[FILTERED]').
gsub(%r(("AppKey\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
gsub(%r(("AppSecret\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
gsub(%r(("accessToken\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
gsub(%r(("mid\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
gsub(%r(("siteId\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
gsub(%r(("environment\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
gsub(%r(("number\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
gsub(%r(("cardNumber\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
gsub(%r(("verification_value\\?":\\?")\d+), '\1[FILTERED]')
end
|
#store(credit_card, options = {}) ⇒ Object
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/active_merchant/billing/gateways/flex_charge.rb', line 79
def store(credit_card, options = {})
first_name, last_name = names_from_address(address(options), credit_card)
post = {
payment_method: {
credit_card: {
first_name: first_name,
last_name: last_name,
month: credit_card.month,
year: credit_card.year,
number: credit_card.number,
verification_value: credit_card.verification_value
}.compact
}
}
commit(:store, post)
end
|
#supports_scrubbing? ⇒ Boolean
97
98
99
|
# File 'lib/active_merchant/billing/gateways/flex_charge.rb', line 97
def supports_scrubbing?
true
end
|
#void(authorization, options = {}) ⇒ Object
74
75
76
77
|
# File 'lib/active_merchant/billing/gateways/flex_charge.rb', line 74
def void(authorization, options = {})
order_id, _currency = authorization.split('#')
commit(:void, {}, order_id)
end
|