activemerchant 1.133.0 → 1.137.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +240 -0
- data/lib/active_merchant/billing/check.rb +2 -2
- data/lib/active_merchant/billing/compatibility.rb +4 -4
- data/lib/active_merchant/billing/credit_card.rb +11 -8
- data/lib/active_merchant/billing/credit_card_formatting.rb +4 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +59 -6
- data/lib/active_merchant/billing/gateway.rb +9 -0
- data/lib/active_merchant/billing/gateways/adyen.rb +162 -43
- data/lib/active_merchant/billing/gateways/airwallex.rb +26 -12
- data/lib/active_merchant/billing/gateways/alelo.rb +23 -5
- data/lib/active_merchant/billing/gateways/authorize_net.rb +43 -35
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +10 -6
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +1 -3
- data/lib/active_merchant/billing/gateways/axcessms.rb +6 -2
- data/lib/active_merchant/billing/gateways/banwire.rb +4 -2
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +7 -3
- data/lib/active_merchant/billing/gateways/blue_pay.rb +13 -5
- data/lib/active_merchant/billing/gateways/blue_snap.rb +5 -5
- data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +65 -20
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +226 -73
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +1 -1
- data/lib/active_merchant/billing/gateways/card_connect.rb +5 -2
- data/lib/active_merchant/billing/gateways/card_stream.rb +4 -6
- data/lib/active_merchant/billing/gateways/cashnet.rb +1 -1
- data/lib/active_merchant/billing/gateways/cecabank/cecabank_common.rb +36 -0
- data/lib/active_merchant/billing/gateways/cecabank/cecabank_json.rb +316 -0
- data/lib/active_merchant/billing/gateways/cecabank/cecabank_xml.rb +220 -0
- data/lib/active_merchant/billing/gateways/cecabank.rb +7 -240
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +238 -34
- data/lib/active_merchant/billing/gateways/commerce_hub.rb +63 -6
- data/lib/active_merchant/billing/gateways/credorax.rb +3 -5
- data/lib/active_merchant/billing/gateways/cyber_source.rb +185 -47
- data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +102 -58
- data/lib/active_merchant/billing/gateways/d_local.rb +26 -15
- data/lib/active_merchant/billing/gateways/data_cash.rb +21 -17
- data/lib/active_merchant/billing/gateways/datatrans.rb +279 -0
- data/lib/active_merchant/billing/gateways/decidir.rb +53 -18
- data/lib/active_merchant/billing/gateways/decidir_plus.rb +4 -1
- data/lib/active_merchant/billing/gateways/deepstack.rb +382 -0
- data/lib/active_merchant/billing/gateways/ebanx.rb +40 -36
- data/lib/active_merchant/billing/gateways/efsnet.rb +6 -2
- data/lib/active_merchant/billing/gateways/elavon.rb +99 -33
- data/lib/active_merchant/billing/gateways/element.rb +36 -7
- data/lib/active_merchant/billing/gateways/epay.rb +6 -2
- data/lib/active_merchant/billing/gateways/evo_ca.rb +6 -2
- data/lib/active_merchant/billing/gateways/eway.rb +4 -2
- data/lib/active_merchant/billing/gateways/eway_managed.rb +6 -2
- data/lib/active_merchant/billing/gateways/exact.rb +6 -2
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +31 -3
- data/lib/active_merchant/billing/gateways/federated_canada.rb +6 -2
- data/lib/active_merchant/billing/gateways/first_pay/first_pay_common.rb +15 -0
- data/lib/active_merchant/billing/gateways/first_pay/first_pay_json.rb +190 -0
- data/lib/active_merchant/billing/gateways/first_pay/first_pay_xml.rb +183 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +6 -172
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +6 -2
- data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +7 -3
- data/lib/active_merchant/billing/gateways/flex_charge.rb +347 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +4 -2
- data/lib/active_merchant/billing/gateways/global_collect.rb +45 -37
- data/lib/active_merchant/billing/gateways/hi_pay.rb +286 -0
- data/lib/active_merchant/billing/gateways/hps.rb +1 -1
- data/lib/active_merchant/billing/gateways/iats_payments.rb +7 -2
- data/lib/active_merchant/billing/gateways/inspire.rb +6 -4
- data/lib/active_merchant/billing/gateways/instapay.rb +7 -4
- data/lib/active_merchant/billing/gateways/ipg.rb +9 -5
- data/lib/active_merchant/billing/gateways/iridium.rb +15 -5
- data/lib/active_merchant/billing/gateways/itransact.rb +6 -2
- data/lib/active_merchant/billing/gateways/iveri.rb +3 -3
- data/lib/active_merchant/billing/gateways/ixopay.rb +2 -2
- data/lib/active_merchant/billing/gateways/jetpay.rb +4 -2
- data/lib/active_merchant/billing/gateways/jetpay_v2.rb +4 -2
- data/lib/active_merchant/billing/gateways/kushki.rb +72 -12
- data/lib/active_merchant/billing/gateways/linkpoint.rb +6 -2
- data/lib/active_merchant/billing/gateways/litle.rb +33 -50
- data/lib/active_merchant/billing/gateways/mastercard.rb +4 -4
- data/lib/active_merchant/billing/gateways/maxipago.rb +2 -2
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +8 -5
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +11 -4
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +11 -4
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +19 -3
- data/lib/active_merchant/billing/gateways/mercury.rb +6 -2
- data/lib/active_merchant/billing/gateways/metrics_global.rb +8 -6
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +1 -0
- data/lib/active_merchant/billing/gateways/migs.rb +6 -2
- data/lib/active_merchant/billing/gateways/mit.rb +8 -3
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +18 -10
- data/lib/active_merchant/billing/gateways/monei.rb +1 -1
- data/lib/active_merchant/billing/gateways/moneris.rb +9 -3
- data/lib/active_merchant/billing/gateways/money_movers.rb +6 -2
- data/lib/active_merchant/billing/gateways/nab_transact.rb +12 -4
- data/lib/active_merchant/billing/gateways/net_registry.rb +6 -2
- data/lib/active_merchant/billing/gateways/netbanx.rb +1 -3
- data/lib/active_merchant/billing/gateways/netbilling.rb +6 -2
- data/lib/active_merchant/billing/gateways/network_merchants.rb +6 -2
- data/lib/active_merchant/billing/gateways/nmi.rb +18 -6
- data/lib/active_merchant/billing/gateways/ogone.rb +6 -2
- data/lib/active_merchant/billing/gateways/openpay.rb +4 -2
- data/lib/active_merchant/billing/gateways/opp.rb +1 -2
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +6 -2
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +1 -3
- data/lib/active_merchant/billing/gateways/orbital.rb +83 -24
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +7 -4
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +6 -2
- data/lib/active_merchant/billing/gateways/pay_hub.rb +4 -2
- data/lib/active_merchant/billing/gateways/pay_junction.rb +6 -2
- data/lib/active_merchant/billing/gateways/pay_secure.rb +6 -2
- data/lib/active_merchant/billing/gateways/pay_trace.rb +31 -18
- data/lib/active_merchant/billing/gateways/payeezy.rb +19 -8
- data/lib/active_merchant/billing/gateways/payex.rb +4 -2
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -1
- data/lib/active_merchant/billing/gateways/payflow.rb +1 -3
- data/lib/active_merchant/billing/gateways/payment_express.rb +8 -4
- data/lib/active_merchant/billing/gateways/paymentez.rb +23 -11
- data/lib/active_merchant/billing/gateways/paysafe.rb +12 -11
- data/lib/active_merchant/billing/gateways/payscout.rb +7 -4
- data/lib/active_merchant/billing/gateways/paystation.rb +7 -3
- data/lib/active_merchant/billing/gateways/payway.rb +6 -2
- data/lib/active_merchant/billing/gateways/payway_dot_com.rb +2 -2
- data/lib/active_merchant/billing/gateways/pin.rb +22 -4
- data/lib/active_merchant/billing/gateways/plexo.rb +49 -10
- data/lib/active_merchant/billing/gateways/plugnpay.rb +6 -2
- data/lib/active_merchant/billing/gateways/priority.rb +6 -5
- data/lib/active_merchant/billing/gateways/psigate.rb +6 -2
- data/lib/active_merchant/billing/gateways/psl_card.rb +6 -2
- data/lib/active_merchant/billing/gateways/qbms.rb +6 -2
- data/lib/active_merchant/billing/gateways/quantum.rb +6 -2
- data/lib/active_merchant/billing/gateways/quickbooks.rb +6 -5
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +7 -4
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +6 -2
- data/lib/active_merchant/billing/gateways/rapyd.rb +148 -46
- data/lib/active_merchant/billing/gateways/reach.rb +11 -4
- data/lib/active_merchant/billing/gateways/redsys.rb +2 -10
- data/lib/active_merchant/billing/gateways/redsys_rest.rb +507 -0
- data/lib/active_merchant/billing/gateways/s5.rb +3 -3
- data/lib/active_merchant/billing/gateways/safe_charge.rb +36 -16
- data/lib/active_merchant/billing/gateways/sage.rb +12 -4
- data/lib/active_merchant/billing/gateways/sage_pay.rb +79 -5
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +6 -2
- data/lib/active_merchant/billing/gateways/secure_net.rb +6 -2
- data/lib/active_merchant/billing/gateways/secure_pay.rb +8 -6
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +12 -4
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +6 -2
- data/lib/active_merchant/billing/gateways/securion_pay.rb +24 -10
- data/lib/active_merchant/billing/gateways/shift4.rb +17 -20
- data/lib/active_merchant/billing/gateways/shift4_v2.rb +117 -0
- data/lib/active_merchant/billing/gateways/simetrik.rb +17 -11
- data/lib/active_merchant/billing/gateways/skip_jack.rb +6 -2
- data/lib/active_merchant/billing/gateways/smart_ps.rb +7 -4
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +4 -2
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +2 -4
- data/lib/active_merchant/billing/gateways/stripe.rb +53 -21
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +199 -50
- data/lib/active_merchant/billing/gateways/sum_up.rb +223 -0
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +4 -2
- data/lib/active_merchant/billing/gateways/telr.rb +3 -4
- data/lib/active_merchant/billing/gateways/trans_first.rb +1 -2
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +8 -16
- data/lib/active_merchant/billing/gateways/transact_pro.rb +1 -1
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +6 -2
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +9 -8
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +6 -2
- data/lib/active_merchant/billing/gateways/vanco.rb +2 -4
- data/lib/active_merchant/billing/gateways/vantiv_express.rb +587 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +6 -2
- data/lib/active_merchant/billing/gateways/viaklix.rb +6 -2
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +2 -2
- data/lib/active_merchant/billing/gateways/vpos.rb +3 -3
- data/lib/active_merchant/billing/gateways/wirecard.rb +7 -3
- data/lib/active_merchant/billing/gateways/wompi.rb +5 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +140 -73
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +13 -10
- data/lib/active_merchant/billing/gateways/xpay.rb +242 -0
- data/lib/active_merchant/billing/network_tokenization_credit_card.rb +1 -1
- data/lib/active_merchant/billing/response.rb +2 -2
- data/lib/active_merchant/connection.rb +3 -17
- data/lib/active_merchant/country.rb +1 -0
- data/lib/active_merchant/errors.rb +10 -0
- data/lib/active_merchant/version.rb +1 -1
- data/lib/support/gateway_support.rb +2 -2
- data/lib/support/ssl_verify.rb +4 -4
- data/lib/support/ssl_version.rb +6 -6
- metadata +30 -9
@@ -0,0 +1,223 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class SumUpGateway < Gateway
|
4
|
+
self.live_url = 'https://api.sumup.com/v0.1/'
|
5
|
+
|
6
|
+
self.supported_countries = %w(AT BE BG BR CH CL CO CY CZ DE DK EE ES FI FR
|
7
|
+
GB GR HR HU IE IT LT LU LV MT NL NO PL PT RO
|
8
|
+
SE SI SK US)
|
9
|
+
self.currencies_with_three_decimal_places = %w(EUR BGN BRL CHF CZK DKK GBP
|
10
|
+
HUF NOK PLN SEK USD)
|
11
|
+
self.default_currency = 'USD'
|
12
|
+
|
13
|
+
self.homepage_url = 'https://www.sumup.com/'
|
14
|
+
self.display_name = 'SumUp'
|
15
|
+
|
16
|
+
STANDARD_ERROR_CODE_MAPPING = {
|
17
|
+
multiple_invalid_parameters: 'MULTIPLE_INVALID_PARAMETERS'
|
18
|
+
}
|
19
|
+
|
20
|
+
def initialize(options = {})
|
21
|
+
requires!(options, :access_token, :pay_to_email)
|
22
|
+
super
|
23
|
+
end
|
24
|
+
|
25
|
+
def purchase(money, payment, options = {})
|
26
|
+
MultiResponse.run do |r|
|
27
|
+
r.process { create_checkout(money, payment, options) } unless options[:checkout_id]
|
28
|
+
r.process { complete_checkout(options[:checkout_id] || r.params['id'], payment, options) }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def refund(money, authorization, options = {})
|
33
|
+
transaction_id = authorization.split('#').last
|
34
|
+
post = money ? { amount: amount(money) } : {}
|
35
|
+
add_merchant_data(post, options)
|
36
|
+
|
37
|
+
commit('me/refund/' + transaction_id, post)
|
38
|
+
end
|
39
|
+
|
40
|
+
def supports_scrubbing?
|
41
|
+
true
|
42
|
+
end
|
43
|
+
|
44
|
+
def scrub(transcript)
|
45
|
+
transcript.
|
46
|
+
gsub(%r((Authorization: Bearer )\w+), '\1[FILTERED]').
|
47
|
+
gsub(%r(("pay_to_email\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
|
48
|
+
gsub(%r(("number\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
|
49
|
+
gsub(%r(("cvv\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]')
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def create_checkout(money, payment, options)
|
55
|
+
post = {}
|
56
|
+
|
57
|
+
add_merchant_data(post, options)
|
58
|
+
add_invoice(post, money, options)
|
59
|
+
add_address(post, options)
|
60
|
+
add_customer_data(post, payment, options)
|
61
|
+
add_3ds_data(post, options)
|
62
|
+
|
63
|
+
commit('checkouts', post)
|
64
|
+
end
|
65
|
+
|
66
|
+
def complete_checkout(checkout_id, payment, options = {})
|
67
|
+
post = {}
|
68
|
+
|
69
|
+
add_payment(post, payment, options)
|
70
|
+
|
71
|
+
commit('checkouts/' + checkout_id, post, :put)
|
72
|
+
end
|
73
|
+
|
74
|
+
def add_customer_data(post, payment, options)
|
75
|
+
post[:customer_id] = options[:customer_id]
|
76
|
+
post[:personal_details] = {
|
77
|
+
email: options[:email],
|
78
|
+
first_name: payment&.first_name,
|
79
|
+
last_name: payment&.last_name,
|
80
|
+
tax_id: options[:tax_id]
|
81
|
+
}
|
82
|
+
end
|
83
|
+
|
84
|
+
def add_merchant_data(post, options)
|
85
|
+
# Required field: pay_to_email
|
86
|
+
# Description: Email address of the merchant to whom the payment is made.
|
87
|
+
post[:pay_to_email] = @options[:pay_to_email]
|
88
|
+
end
|
89
|
+
|
90
|
+
def add_address(post, options)
|
91
|
+
post[:personal_details] ||= {}
|
92
|
+
if address = (options[:billing_address] || options[:shipping_address] || options[:address])
|
93
|
+
post[:personal_details][:address] = {
|
94
|
+
city: address[:city],
|
95
|
+
state: address[:state],
|
96
|
+
country: address[:country],
|
97
|
+
line_1: address[:address1],
|
98
|
+
postal_code: address[:zip]
|
99
|
+
}
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def add_invoice(post, money, options)
|
104
|
+
post[:checkout_reference] = options[:order_id]
|
105
|
+
post[:amount] = amount(money)
|
106
|
+
post[:currency] = options[:currency] || currency(money)
|
107
|
+
post[:description] = options[:description]
|
108
|
+
end
|
109
|
+
|
110
|
+
def add_payment(post, payment, options)
|
111
|
+
post[:payment_type] = options[:payment_type] || 'card'
|
112
|
+
|
113
|
+
post[:card] = {
|
114
|
+
name: payment.name,
|
115
|
+
number: payment.number,
|
116
|
+
expiry_month: format(payment.month, :two_digits),
|
117
|
+
expiry_year: payment.year,
|
118
|
+
cvv: payment.verification_value
|
119
|
+
}
|
120
|
+
end
|
121
|
+
|
122
|
+
def add_3ds_data(post, options)
|
123
|
+
post[:redirect_url] = options[:redirect_url] if options[:redirect_url]
|
124
|
+
end
|
125
|
+
|
126
|
+
def commit(action, post, method = :post)
|
127
|
+
response = api_request(action, post.compact, method)
|
128
|
+
succeeded = success_from(response)
|
129
|
+
|
130
|
+
Response.new(
|
131
|
+
succeeded,
|
132
|
+
message_from(succeeded, response),
|
133
|
+
action.include?('refund') ? { response_code: response.to_s } : response,
|
134
|
+
authorization: authorization_from(response),
|
135
|
+
test: test?,
|
136
|
+
error_code: error_code_from(succeeded, response)
|
137
|
+
)
|
138
|
+
end
|
139
|
+
|
140
|
+
def api_request(action, post, method)
|
141
|
+
raw_response =
|
142
|
+
begin
|
143
|
+
ssl_request(method, live_url + action, post.to_json, auth_headers)
|
144
|
+
rescue ResponseError => e
|
145
|
+
e.response.body
|
146
|
+
end
|
147
|
+
response = parse(raw_response)
|
148
|
+
response = response.is_a?(Hash) ? response.symbolize_keys : response
|
149
|
+
|
150
|
+
return format_errors(response) if raw_response.include?('error_code') && response.is_a?(Array)
|
151
|
+
|
152
|
+
response
|
153
|
+
end
|
154
|
+
|
155
|
+
def parse(body)
|
156
|
+
JSON.parse(body)
|
157
|
+
end
|
158
|
+
|
159
|
+
def success_from(response)
|
160
|
+
(response.is_a?(Hash) && response[:next_step]) ||
|
161
|
+
response == 204 ||
|
162
|
+
%w(PENDING PAID).include?(response[:status]) ||
|
163
|
+
response[:transactions]&.all? { |transaction| transaction.symbolize_keys[:status] == 'SUCCESSFUL' }
|
164
|
+
end
|
165
|
+
|
166
|
+
def message_from(succeeded, response)
|
167
|
+
if succeeded
|
168
|
+
return 'Succeeded' if (response.is_a?(Hash) && response[:next_step]) || response == 204
|
169
|
+
|
170
|
+
return response[:status]
|
171
|
+
end
|
172
|
+
|
173
|
+
response[:message] || response[:error_message] || response[:status]
|
174
|
+
end
|
175
|
+
|
176
|
+
def authorization_from(response)
|
177
|
+
return nil if response.is_a?(Integer)
|
178
|
+
|
179
|
+
return response[:id] unless response[:transaction_id]
|
180
|
+
|
181
|
+
[response[:id], response[:transaction_id]].join('#')
|
182
|
+
end
|
183
|
+
|
184
|
+
def auth_headers
|
185
|
+
{
|
186
|
+
'Content-Type' => 'application/json',
|
187
|
+
'Authorization' => "Bearer #{options[:access_token]}"
|
188
|
+
}
|
189
|
+
end
|
190
|
+
|
191
|
+
def error_code_from(succeeded, response)
|
192
|
+
response[:error_code] unless succeeded
|
193
|
+
end
|
194
|
+
|
195
|
+
def format_error(error, key)
|
196
|
+
{
|
197
|
+
:error_code => error['error_code'],
|
198
|
+
key => error['param']
|
199
|
+
}
|
200
|
+
end
|
201
|
+
|
202
|
+
def format_errors(errors)
|
203
|
+
return format_error(errors.first, :message) if errors.size == 1
|
204
|
+
|
205
|
+
return {
|
206
|
+
error_code: STANDARD_ERROR_CODE_MAPPING[:multiple_invalid_parameters],
|
207
|
+
message: 'Validation error',
|
208
|
+
errors: errors.map { |error| format_error(error, :param) }
|
209
|
+
}
|
210
|
+
end
|
211
|
+
|
212
|
+
def handle_response(response)
|
213
|
+
case response.code.to_i
|
214
|
+
# to get the response code (204) when the body is nil
|
215
|
+
when 200...300
|
216
|
+
response.body || response.code
|
217
|
+
else
|
218
|
+
raise ResponseError.new(response)
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
@@ -104,12 +104,14 @@ module ActiveMerchant #:nodoc:
|
|
104
104
|
result = response['data']['result']
|
105
105
|
success = (result == 'accepted' || (test? && result == 'test-accepted'))
|
106
106
|
|
107
|
-
Response.new(
|
107
|
+
Response.new(
|
108
|
+
success,
|
108
109
|
success ?
|
109
110
|
TRANSACTION_APPROVED_MSG :
|
110
111
|
TRANSACTION_DECLINED_MSG,
|
111
112
|
response,
|
112
|
-
test: test?
|
113
|
+
test: test?
|
114
|
+
)
|
113
115
|
else
|
114
116
|
build_error_response(message, response)
|
115
117
|
end
|
@@ -162,9 +162,9 @@ module ActiveMerchant #:nodoc:
|
|
162
162
|
country.code(:alpha2)
|
163
163
|
end
|
164
164
|
|
165
|
-
def commit(action, amount = nil, currency = nil)
|
165
|
+
def commit(action, amount = nil, currency = nil, &block)
|
166
166
|
currency = default_currency if currency == nil
|
167
|
-
request = build_xml_request
|
167
|
+
request = build_xml_request(&block)
|
168
168
|
response = ssl_post(live_url, request, headers)
|
169
169
|
parsed = parse(response)
|
170
170
|
|
@@ -231,8 +231,7 @@ module ActiveMerchant #:nodoc:
|
|
231
231
|
|
232
232
|
def authorization_from(action, response, amount, currency)
|
233
233
|
auth = response[:tranref]
|
234
|
-
|
235
|
-
auth
|
234
|
+
[auth, amount, currency].join('|')
|
236
235
|
end
|
237
236
|
|
238
237
|
def split_authorization(authorization)
|
@@ -219,8 +219,7 @@ module ActiveMerchant #:nodoc:
|
|
219
219
|
params[:MerchantID] = @options[:login]
|
220
220
|
params[:RegKey] = @options[:password]
|
221
221
|
|
222
|
-
|
223
|
-
request
|
222
|
+
params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
|
224
223
|
end
|
225
224
|
|
226
225
|
def add_pair(post, key, value, options = {})
|
@@ -438,29 +438,21 @@ module ActiveMerchant #:nodoc:
|
|
438
438
|
end
|
439
439
|
|
440
440
|
# -- request methods ---------------------------------------------------
|
441
|
-
def build_xml_transaction_request
|
442
|
-
build_xml_request('SendTranRequest')
|
443
|
-
yield doc
|
444
|
-
end
|
441
|
+
def build_xml_transaction_request(&block)
|
442
|
+
build_xml_request('SendTranRequest', &block)
|
445
443
|
end
|
446
444
|
|
447
|
-
def build_xml_payment_storage_request
|
448
|
-
build_xml_request('UpdtRecurrProfRequest')
|
449
|
-
yield doc
|
450
|
-
end
|
445
|
+
def build_xml_payment_storage_request(&block)
|
446
|
+
build_xml_request('UpdtRecurrProfRequest', &block)
|
451
447
|
end
|
452
448
|
|
453
|
-
def build_xml_payment_update_request
|
449
|
+
def build_xml_payment_update_request(&block)
|
454
450
|
merchant_product_type = 5 # credit card
|
455
|
-
build_xml_request('UpdtRecurrProfRequest', merchant_product_type)
|
456
|
-
yield doc
|
457
|
-
end
|
451
|
+
build_xml_request('UpdtRecurrProfRequest', merchant_product_type, &block)
|
458
452
|
end
|
459
453
|
|
460
|
-
def build_xml_payment_search_request
|
461
|
-
build_xml_request('FndRecurrProfRequest')
|
462
|
-
yield doc
|
463
|
-
end
|
454
|
+
def build_xml_payment_search_request(&block)
|
455
|
+
build_xml_request('FndRecurrProfRequest', &block)
|
464
456
|
end
|
465
457
|
|
466
458
|
def build_xml_request(wrapper, merchant_product_type = nil)
|
@@ -450,11 +450,15 @@ module ActiveMerchant #:nodoc:
|
|
450
450
|
# to be considered successful, transaction status must be either "approved" or "accepted"
|
451
451
|
success = SUCCESS_TYPES.include?(data['status'])
|
452
452
|
message = message_from(data)
|
453
|
-
Response.new(
|
453
|
+
Response.new(
|
454
|
+
success,
|
455
|
+
message,
|
456
|
+
data,
|
454
457
|
test: test?,
|
455
458
|
authorization: authorization_from(action, data),
|
456
459
|
cvv_result: data['cvv'],
|
457
|
-
avs_result: { code: data['avs'] }
|
460
|
+
avs_result: { code: data['avs'] }
|
461
|
+
)
|
458
462
|
end
|
459
463
|
|
460
464
|
def parse(body)
|
@@ -1030,15 +1030,17 @@ module ActiveMerchant #:nodoc:
|
|
1030
1030
|
|
1031
1031
|
# Build soap header, etc.
|
1032
1032
|
def build_request(action, options = {})
|
1033
|
-
|
1034
|
-
soap.instruct!(:xml, version: '1.0', encoding: 'utf-8')
|
1035
|
-
soap.tag! 'SOAP-ENV:Envelope',
|
1033
|
+
envelope_obj = {
|
1036
1034
|
'xmlns:SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/',
|
1037
1035
|
'xmlns:ns1' => 'urn:usaepay',
|
1038
1036
|
'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
|
1039
1037
|
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
|
1040
1038
|
'xmlns:SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/',
|
1041
|
-
'SOAP-ENV:encodingStyle' => 'http://schemas.xmlsoap.org/soap/encoding/'
|
1039
|
+
'SOAP-ENV:encodingStyle' => 'http://schemas.xmlsoap.org/soap/encoding/'
|
1040
|
+
}
|
1041
|
+
soap = Builder::XmlMarkup.new
|
1042
|
+
soap.instruct!(:xml, version: '1.0', encoding: 'utf-8')
|
1043
|
+
soap.tag! 'SOAP-ENV:Envelope', envelope_obj do
|
1042
1044
|
soap.tag! 'SOAP-ENV:Body' do
|
1043
1045
|
send("build_#{action}", soap, options)
|
1044
1046
|
end
|
@@ -1335,8 +1337,7 @@ module ActiveMerchant #:nodoc:
|
|
1335
1337
|
case
|
1336
1338
|
when payment_method[:method].kind_of?(ActiveMerchant::Billing::CreditCard)
|
1337
1339
|
build_tag soap, :string, 'CardNumber', payment_method[:method].number
|
1338
|
-
build_tag soap, :string, 'CardExpiration',
|
1339
|
-
"#{'%02d' % payment_method[:method].month}#{payment_method[:method].year.to_s[-2..-1]}"
|
1340
|
+
build_tag soap, :string, 'CardExpiration', "#{'%02d' % payment_method[:method].month}#{payment_method[:method].year.to_s[-2..-1]}"
|
1340
1341
|
if options[:billing_address]
|
1341
1342
|
build_tag soap, :string, 'AvsStreet', options[:billing_address][:address1]
|
1342
1343
|
build_tag soap, :string, 'AvsZip', options[:billing_address][:zip]
|
@@ -1520,8 +1521,8 @@ module ActiveMerchant #:nodoc:
|
|
1520
1521
|
|
1521
1522
|
begin
|
1522
1523
|
soap = ssl_post(url, request, 'Content-Type' => 'text/xml')
|
1523
|
-
rescue ActiveMerchant::ResponseError =>
|
1524
|
-
soap =
|
1524
|
+
rescue ActiveMerchant::ResponseError => e
|
1525
|
+
soap = e.response.body
|
1525
1526
|
end
|
1526
1527
|
|
1527
1528
|
build_response(action, soap)
|
@@ -329,12 +329,16 @@ module ActiveMerchant #:nodoc:
|
|
329
329
|
approved = response[:status] == 'Approved'
|
330
330
|
error_code = nil
|
331
331
|
error_code = (STANDARD_ERROR_CODE_MAPPING[response[:error_code]] || STANDARD_ERROR_CODE[:processing_error]) unless approved
|
332
|
-
Response.new(
|
332
|
+
Response.new(
|
333
|
+
approved,
|
334
|
+
message_from(response),
|
335
|
+
response,
|
333
336
|
test: test?,
|
334
337
|
authorization: authorization_from(action, response),
|
335
338
|
cvv_result: response[:cvv2_result_code],
|
336
339
|
avs_result: { code: response[:avs_result_code] },
|
337
|
-
error_code: error_code
|
340
|
+
error_code: error_code
|
341
|
+
)
|
338
342
|
end
|
339
343
|
|
340
344
|
def message_from(response)
|
@@ -281,11 +281,9 @@ module ActiveMerchant
|
|
281
281
|
end
|
282
282
|
end
|
283
283
|
|
284
|
-
def build_xml_request
|
284
|
+
def build_xml_request(&block)
|
285
285
|
builder = Nokogiri::XML::Builder.new
|
286
|
-
builder.__send__('VancoWS')
|
287
|
-
yield(doc)
|
288
|
-
end
|
286
|
+
builder.__send__('VancoWS', &block)
|
289
287
|
builder.to_xml
|
290
288
|
end
|
291
289
|
|