Class: ActiveMerchant::Billing::ReachGateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::ReachGateway
show all
- Defined in:
- lib/active_merchant/billing/gateways/reach.rb
Constant Summary
collapse
- API_VERSION =
'v2.22'.freeze
- STANDARD_ERROR_CODE_MAPPING =
{}
- PAYMENT_METHOD_MAP =
{
american_express: 'AMEX',
cabal: 'CABAL',
check: 'ACH',
dankort: 'DANKORT',
diners_club: 'DINERS',
discover: 'DISC',
elo: 'ELO',
jcb: 'JCB',
maestro: 'MAESTRO',
master: 'MC',
naranja: 'NARANJA',
union_pay: 'UNIONPAY',
visa: 'VISA'
}
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 = {}) ⇒ ReachGateway
constructor
A new instance of ReachGateway.
-
#purchase(money, payment, options = {}) ⇒ Object
-
#refund(amount, 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, #strftime_yyyymm
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
#initialize(options = {}) ⇒ ReachGateway
Returns a new instance of ReachGateway.
40
41
42
43
|
# File 'lib/active_merchant/billing/gateways/reach.rb', line 40
def initialize(options = {})
requires!(options, :merchant_id, :secret)
super
end
|
Instance Method Details
#authorize(money, payment, options = {}) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/active_merchant/billing/gateways/reach.rb', line 45
def authorize(money, payment, options = {})
request = build_checkout_request(money, payment, options)
add_custom_fields_data(request, options)
add_customer_data(request, options, payment)
add_stored_credentials(request, options)
post = { request:, card: add_payment(payment, options) }
if options[:stored_credential]
MultiResponse.run(:use_first_response) do |r|
r.process { commit('checkout', post) }
r.process do
r2 = get_network_payment_reference(r.responses[0])
r.params[:network_transaction_id] = r2.message
r2
end
end
else
commit('checkout', post)
end
end
|
#capture(money, authorization, options = {}) ⇒ Object
70
71
72
73
|
# File 'lib/active_merchant/billing/gateways/reach.rb', line 70
def capture(money, authorization, options = {})
post = { request: { MerchantId: @options[:merchant_id], OrderId: authorization } }
commit('capture', post)
end
|
#purchase(money, payment, options = {}) ⇒ Object
65
66
67
68
|
# File 'lib/active_merchant/billing/gateways/reach.rb', line 65
def purchase(money, payment, options = {})
options[:capture] = true
authorize(money, payment, options)
end
|
#refund(amount, authorization, options = {}) ⇒ Object
87
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/active_merchant/billing/gateways/reach.rb', line 87
def refund(amount, authorization, options = {})
currency = options[:currency] || currency(options[:amount])
post = {
request: {
MerchantId: @options[:merchant_id],
OrderId: authorization,
ReferenceId: options[:order_id] || options[:reference_id],
Amount: localized_amount(amount, currency)
}
}
commit('refund', post)
end
|
#scrub(transcript) ⇒ Object
79
80
81
82
83
84
85
|
# File 'lib/active_merchant/billing/gateways/reach.rb', line 79
def scrub(transcript)
transcript.
gsub(%r(((MerchantId)[% \w]+%\d{2})[\w -]+), '\1[FILTERED]').
gsub(%r((signature=)[\w%]+), '\1[FILTERED]\2').
gsub(%r((Number%22%3A%22)\d+), '\1[FILTERED]\2').
gsub(%r((VerificationCode%22%3A)\d+), '\1[FILTERED]\2')
end
|
#supports_scrubbing? ⇒ Boolean
75
76
77
|
# File 'lib/active_merchant/billing/gateways/reach.rb', line 75
def supports_scrubbing?
true
end
|
#verify(credit_card, options = {}) ⇒ Object
111
112
113
114
115
116
|
# File 'lib/active_merchant/billing/gateways/reach.rb', line 111
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
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/active_merchant/billing/gateways/reach.rb', line 100
def void(authorization, options = {})
post = {
request: {
MerchantId: @options[:merchant_id],
OrderId: authorization
}
}
commit('cancel', post)
end
|