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
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.
27
28
29
30
|
# File 'lib/active_merchant/billing/gateways/flex_charge.rb', line 27
def initialize(options = {})
requires!(options, :app_key, :app_secret, :site_id, :mid)
super
end
|
Instance Method Details
118
119
120
121
|
# File 'lib/active_merchant/billing/gateways/flex_charge.rb', line 118
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
49
50
51
52
|
# File 'lib/active_merchant/billing/gateways/flex_charge.rb', line 49
def authorize(money, credit_card, options = {})
options[:transactionType] = 'Authorization'
purchase(money, credit_card, options)
end
|
#capture(money, authorization, options = {}) ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/active_merchant/billing/gateways/flex_charge.rb', line 54
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
113
114
115
116
|
# File 'lib/active_merchant/billing/gateways/flex_charge.rb', line 113
def inquire(authorization, options = {})
order_id, _currency = authorization.split('#')
commit(:inquire, {}, order_id, :get)
end
|
#purchase(money, credit_card, options = {}) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/active_merchant/billing/gateways/flex_charge.rb', line 32
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
66
67
68
69
70
|
# File 'lib/active_merchant/billing/gateways/flex_charge.rb', line 66
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
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/active_merchant/billing/gateways/flex_charge.rb', line 99
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/active_merchant/billing/gateways/flex_charge.rb', line 77
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
95
96
97
|
# File 'lib/active_merchant/billing/gateways/flex_charge.rb', line 95
def supports_scrubbing?
true
end
|
#void(authorization, options = {}) ⇒ Object
72
73
74
75
|
# File 'lib/active_merchant/billing/gateways/flex_charge.rb', line 72
def void(authorization, options = {})
order_id, _currency = authorization.split('#')
commit(:void, {}, order_id)
end
|