activemerchant 1.114.0 → 1.116.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +45 -0
- data/lib/active_merchant.rb +1 -1
- data/lib/active_merchant/billing/avs_result.rb +1 -1
- data/lib/active_merchant/billing/compatibility.rb +3 -3
- data/lib/active_merchant/billing/credit_card_methods.rb +5 -5
- data/lib/active_merchant/billing/gateways/adyen.rb +23 -13
- data/lib/active_merchant/billing/gateways/allied_wallet.rb +7 -7
- data/lib/active_merchant/billing/gateways/authorize_net.rb +13 -11
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +3 -4
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +1 -1
- data/lib/active_merchant/billing/gateways/axcessms.rb +8 -9
- data/lib/active_merchant/billing/gateways/balanced.rb +4 -3
- data/lib/active_merchant/billing/gateways/bambora_apac.rb +7 -7
- data/lib/active_merchant/billing/gateways/bank_frick.rb +7 -7
- data/lib/active_merchant/billing/gateways/banwire.rb +1 -1
- data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +6 -4
- data/lib/active_merchant/billing/gateways/beanstream.rb +3 -3
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +4 -5
- data/lib/active_merchant/billing/gateways/blue_pay.rb +2 -3
- data/lib/active_merchant/billing/gateways/blue_snap.rb +19 -17
- data/lib/active_merchant/billing/gateways/bogus.rb +19 -19
- data/lib/active_merchant/billing/gateways/borgun.rb +11 -11
- data/lib/active_merchant/billing/gateways/bpoint.rb +8 -8
- data/lib/active_merchant/billing/gateways/braintree.rb +1 -1
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +7 -10
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +7 -7
- data/lib/active_merchant/billing/gateways/cams.rb +8 -8
- data/lib/active_merchant/billing/gateways/card_connect.rb +1 -1
- data/lib/active_merchant/billing/gateways/card_save.rb +1 -1
- data/lib/active_merchant/billing/gateways/card_stream.rb +2 -2
- data/lib/active_merchant/billing/gateways/cardknox.rb +7 -7
- data/lib/active_merchant/billing/gateways/cardprocess.rb +1 -1
- data/lib/active_merchant/billing/gateways/cecabank.rb +5 -5
- data/lib/active_merchant/billing/gateways/cenpos.rb +10 -10
- data/lib/active_merchant/billing/gateways/checkout.rb +2 -2
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +16 -19
- data/lib/active_merchant/billing/gateways/clearhaus.rb +7 -7
- data/lib/active_merchant/billing/gateways/commercegate.rb +1 -1
- data/lib/active_merchant/billing/gateways/conekta.rb +2 -2
- data/lib/active_merchant/billing/gateways/creditcall.rb +10 -10
- data/lib/active_merchant/billing/gateways/credorax.rb +9 -9
- data/lib/active_merchant/billing/gateways/ct_payment.rb +10 -10
- data/lib/active_merchant/billing/gateways/culqi.rb +9 -9
- data/lib/active_merchant/billing/gateways/cyber_source.rb +30 -31
- data/lib/active_merchant/billing/gateways/d_local.rb +11 -11
- data/lib/active_merchant/billing/gateways/data_cash.rb +2 -3
- data/lib/active_merchant/billing/gateways/decidir.rb +9 -8
- data/lib/active_merchant/billing/gateways/dibs.rb +8 -8
- data/lib/active_merchant/billing/gateways/digitzs.rb +5 -5
- data/lib/active_merchant/billing/gateways/ebanx.rb +9 -9
- data/lib/active_merchant/billing/gateways/efsnet.rb +2 -3
- data/lib/active_merchant/billing/gateways/elavon.rb +251 -232
- data/lib/active_merchant/billing/gateways/element.rb +8 -8
- data/lib/active_merchant/billing/gateways/evo_ca.rb +5 -6
- data/lib/active_merchant/billing/gateways/eway.rb +3 -4
- data/lib/active_merchant/billing/gateways/eway_managed.rb +6 -7
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +6 -6
- data/lib/active_merchant/billing/gateways/exact.rb +8 -9
- data/lib/active_merchant/billing/gateways/ezic.rb +7 -7
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +4 -4
- data/lib/active_merchant/billing/gateways/federated_canada.rb +2 -3
- data/lib/active_merchant/billing/gateways/first_giving.rb +1 -1
- data/lib/active_merchant/billing/gateways/first_pay.rb +6 -6
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +7 -7
- data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +4 -4
- data/lib/active_merchant/billing/gateways/flo2cash.rb +8 -8
- data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +1 -1
- data/lib/active_merchant/billing/gateways/forte.rb +14 -8
- data/lib/active_merchant/billing/gateways/global_collect.rb +10 -10
- data/lib/active_merchant/billing/gateways/global_transport.rb +7 -7
- data/lib/active_merchant/billing/gateways/hdfc.rb +9 -9
- data/lib/active_merchant/billing/gateways/hps.rb +7 -7
- data/lib/active_merchant/billing/gateways/iats_payments.rb +9 -4
- data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +1 -1
- data/lib/active_merchant/billing/gateways/inspire.rb +3 -4
- data/lib/active_merchant/billing/gateways/instapay.rb +1 -2
- data/lib/active_merchant/billing/gateways/ipp.rb +5 -5
- data/lib/active_merchant/billing/gateways/iridium.rb +14 -15
- data/lib/active_merchant/billing/gateways/iveri.rb +7 -7
- data/lib/active_merchant/billing/gateways/ixopay.rb +7 -7
- data/lib/active_merchant/billing/gateways/jetpay.rb +1 -2
- data/lib/active_merchant/billing/gateways/jetpay_v2.rb +4 -5
- data/lib/active_merchant/billing/gateways/kushki.rb +6 -6
- data/lib/active_merchant/billing/gateways/latitude19.rb +14 -14
- data/lib/active_merchant/billing/gateways/linkpoint.rb +4 -5
- data/lib/active_merchant/billing/gateways/litle.rb +11 -11
- data/lib/active_merchant/billing/gateways/mastercard.rb +10 -10
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +7 -7
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +1 -2
- data/lib/active_merchant/billing/gateways/merchant_one.rb +1 -1
- data/lib/active_merchant/billing/gateways/merchant_partners.rb +10 -10
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +5 -7
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +4 -6
- data/lib/active_merchant/billing/gateways/mercury.rb +4 -4
- data/lib/active_merchant/billing/gateways/metrics_global.rb +4 -5
- data/lib/active_merchant/billing/gateways/micropayment.rb +8 -8
- data/lib/active_merchant/billing/gateways/migs.rb +3 -4
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +2 -4
- data/lib/active_merchant/billing/gateways/monei.rb +7 -7
- data/lib/active_merchant/billing/gateways/moneris.rb +4 -3
- data/lib/active_merchant/billing/gateways/money_movers.rb +2 -3
- data/lib/active_merchant/billing/gateways/mundipagg.rb +37 -10
- data/lib/active_merchant/billing/gateways/nab_transact.rb +2 -4
- data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +7 -7
- data/lib/active_merchant/billing/gateways/net_registry.rb +1 -2
- data/lib/active_merchant/billing/gateways/netaxept.rb +6 -6
- data/lib/active_merchant/billing/gateways/netbanx.rb +8 -8
- data/lib/active_merchant/billing/gateways/netbilling.rb +4 -5
- data/lib/active_merchant/billing/gateways/network_merchants.rb +2 -3
- data/lib/active_merchant/billing/gateways/nmi.rb +21 -7
- data/lib/active_merchant/billing/gateways/ogone.rb +3 -3
- data/lib/active_merchant/billing/gateways/omise.rb +13 -13
- data/lib/active_merchant/billing/gateways/openpay.rb +3 -4
- data/lib/active_merchant/billing/gateways/opp.rb +9 -9
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +2 -3
- data/lib/active_merchant/billing/gateways/orbital.rb +61 -66
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +3 -4
- data/lib/active_merchant/billing/gateways/pagarme.rb +8 -8
- data/lib/active_merchant/billing/gateways/pago_facil.rb +2 -2
- data/lib/active_merchant/billing/gateways/pay_conex.rb +8 -8
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +6 -7
- data/lib/active_merchant/billing/gateways/pay_hub.rb +7 -8
- data/lib/active_merchant/billing/gateways/pay_junction.rb +2 -3
- data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +9 -9
- data/lib/active_merchant/billing/gateways/pay_secure.rb +2 -3
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +23 -1
- data/lib/active_merchant/billing/gateways/payeezy.rb +9 -9
- data/lib/active_merchant/billing/gateways/payex.rb +6 -7
- data/lib/active_merchant/billing/gateways/payflow.rb +1 -1
- data/lib/active_merchant/billing/gateways/payment_express.rb +1 -2
- data/lib/active_merchant/billing/gateways/paymentez.rb +5 -5
- data/lib/active_merchant/billing/gateways/paymill.rb +7 -7
- data/lib/active_merchant/billing/gateways/paypal_express.rb +1 -1
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +1 -1
- data/lib/active_merchant/billing/gateways/payscout.rb +1 -2
- data/lib/active_merchant/billing/gateways/paystation.rb +3 -4
- data/lib/active_merchant/billing/gateways/payu_in.rb +3 -3
- data/lib/active_merchant/billing/gateways/payu_latam.rb +17 -10
- data/lib/active_merchant/billing/gateways/payway.rb +8 -9
- data/lib/active_merchant/billing/gateways/plugnpay.rb +1 -2
- data/lib/active_merchant/billing/gateways/pro_pay.rb +8 -8
- data/lib/active_merchant/billing/gateways/psigate.rb +2 -3
- data/lib/active_merchant/billing/gateways/psl_card.rb +1 -2
- data/lib/active_merchant/billing/gateways/qbms.rb +1 -2
- data/lib/active_merchant/billing/gateways/quantum.rb +1 -2
- data/lib/active_merchant/billing/gateways/quickbooks.rb +1 -1
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +3 -4
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +1 -2
- data/lib/active_merchant/billing/gateways/qvalent.rb +8 -8
- data/lib/active_merchant/billing/gateways/realex.rb +1 -1
- data/lib/active_merchant/billing/gateways/redsys.rb +4 -4
- data/lib/active_merchant/billing/gateways/s5.rb +7 -7
- data/lib/active_merchant/billing/gateways/safe_charge.rb +12 -12
- data/lib/active_merchant/billing/gateways/sage.rb +3 -5
- data/lib/active_merchant/billing/gateways/sage_pay.rb +2 -3
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +1 -2
- data/lib/active_merchant/billing/gateways/secure_net.rb +1 -2
- data/lib/active_merchant/billing/gateways/secure_pay.rb +3 -4
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +2 -4
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +1 -2
- data/lib/active_merchant/billing/gateways/securion_pay.rb +5 -6
- data/lib/active_merchant/billing/gateways/skip_jack.rb +2 -3
- data/lib/active_merchant/billing/gateways/smart_ps.rb +5 -6
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +7 -7
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +6 -6
- data/lib/active_merchant/billing/gateways/stripe.rb +9 -9
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +9 -0
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +3 -4
- data/lib/active_merchant/billing/gateways/telr.rb +8 -8
- data/lib/active_merchant/billing/gateways/trans_first.rb +2 -2
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +12 -12
- data/lib/active_merchant/billing/gateways/transact_pro.rb +9 -9
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +1 -2
- data/lib/active_merchant/billing/gateways/usa_epay.rb +1 -1
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +32 -32
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +3 -4
- data/lib/active_merchant/billing/gateways/vanco.rb +3 -3
- data/lib/active_merchant/billing/gateways/verifi.rb +1 -2
- data/lib/active_merchant/billing/gateways/viaklix.rb +1 -2
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +10 -10
- data/lib/active_merchant/billing/gateways/webpay.rb +2 -2
- data/lib/active_merchant/billing/gateways/wepay.rb +3 -2
- data/lib/active_merchant/billing/gateways/wirecard.rb +1 -2
- data/lib/active_merchant/billing/gateways/worldpay.rb +12 -8
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +14 -16
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +7 -7
- data/lib/active_merchant/billing/response.rb +1 -1
- data/lib/active_merchant/country.rb +1 -1
- data/lib/active_merchant/network_connection_retries.rb +2 -2
- data/lib/active_merchant/post_data.rb +1 -1
- data/lib/active_merchant/posts_data.rb +1 -1
- data/lib/active_merchant/version.rb +1 -1
- data/lib/support/ssl_verify.rb +2 -2
- data/lib/support/ssl_version.rb +2 -2
- metadata +2 -2
@@ -262,8 +262,7 @@ module ActiveMerchant
|
|
262
262
|
|
263
263
|
Response.new(response[:status] == '1', response[:reason], response,
|
264
264
|
test: test?,
|
265
|
-
authorization: "#{response[:datacash_reference]};#{response[:authcode]};#{response[:ca_reference]}"
|
266
|
-
)
|
265
|
+
authorization: "#{response[:datacash_reference]};#{response[:authcode]};#{response[:ca_reference]}")
|
267
266
|
end
|
268
267
|
|
269
268
|
def format_date(month, year)
|
@@ -296,7 +295,7 @@ module ActiveMerchant
|
|
296
295
|
|
297
296
|
def parse_authorization_string(authorization)
|
298
297
|
reference, auth_code, ca_reference = authorization.to_s.split(';')
|
299
|
-
{reference: reference, auth_code: auth_code, ca_reference: ca_reference}
|
298
|
+
{ reference: reference, auth_code: auth_code, ca_reference: ca_reference }
|
300
299
|
end
|
301
300
|
end
|
302
301
|
end
|
@@ -42,13 +42,13 @@ module ActiveMerchant #:nodoc:
|
|
42
42
|
97 => STANDARD_ERROR_CODE[:processing_error]
|
43
43
|
}
|
44
44
|
|
45
|
-
def initialize(options={})
|
45
|
+
def initialize(options = {})
|
46
46
|
requires!(options, :api_key)
|
47
47
|
super
|
48
48
|
@options[:preauth_mode] ||= false
|
49
49
|
end
|
50
50
|
|
51
|
-
def purchase(money, payment, options={})
|
51
|
+
def purchase(money, payment, options = {})
|
52
52
|
raise ArgumentError, 'Purchase is not supported on Decidir gateways configured with the preauth_mode option' if @options[:preauth_mode]
|
53
53
|
|
54
54
|
post = {}
|
@@ -56,7 +56,7 @@ module ActiveMerchant #:nodoc:
|
|
56
56
|
commit(:post, 'payments', post)
|
57
57
|
end
|
58
58
|
|
59
|
-
def authorize(money, payment, options={})
|
59
|
+
def authorize(money, payment, options = {})
|
60
60
|
raise ArgumentError, 'Authorize is not supported on Decidir gateways unless the preauth_mode option is enabled' unless @options[:preauth_mode]
|
61
61
|
|
62
62
|
post = {}
|
@@ -64,7 +64,7 @@ module ActiveMerchant #:nodoc:
|
|
64
64
|
commit(:post, 'payments', post)
|
65
65
|
end
|
66
66
|
|
67
|
-
def capture(money, authorization, options={})
|
67
|
+
def capture(money, authorization, options = {})
|
68
68
|
raise ArgumentError, 'Capture is not supported on Decidir gateways unless the preauth_mode option is enabled' unless @options[:preauth_mode]
|
69
69
|
|
70
70
|
post = {}
|
@@ -72,18 +72,18 @@ module ActiveMerchant #:nodoc:
|
|
72
72
|
commit(:put, "payments/#{authorization}", post)
|
73
73
|
end
|
74
74
|
|
75
|
-
def refund(money, authorization, options={})
|
75
|
+
def refund(money, authorization, options = {})
|
76
76
|
post = {}
|
77
77
|
add_amount(post, money, options)
|
78
78
|
commit(:post, "payments/#{authorization}/refunds", post)
|
79
79
|
end
|
80
80
|
|
81
|
-
def void(authorization, options={})
|
81
|
+
def void(authorization, options = {})
|
82
82
|
post = {}
|
83
83
|
commit(:post, "payments/#{authorization}/refunds", post)
|
84
84
|
end
|
85
85
|
|
86
|
-
def verify(credit_card, options={})
|
86
|
+
def verify(credit_card, options = {})
|
87
87
|
raise ArgumentError, 'Verify is not supported on Decidir gateways unless the preauth_mode option is enabled' unless @options[:preauth_mode]
|
88
88
|
|
89
89
|
MultiResponse.run(:use_first_response) do |r|
|
@@ -209,6 +209,7 @@ module ActiveMerchant #:nodoc:
|
|
209
209
|
hsh[:send_to_cs] = options[:send_to_cs] if valid_fraud_detection_option?(options[:send_to_cs]) # true/false
|
210
210
|
hsh[:channel] = options[:channel] if valid_fraud_detection_option?(options[:channel])
|
211
211
|
hsh[:dispatch_method] = options[:dispatch_method] if valid_fraud_detection_option?(options[:dispatch_method])
|
212
|
+
hsh[:csmdds] = options[:csmdds] if valid_fraud_detection_option?(options[:csmdds])
|
212
213
|
end
|
213
214
|
end
|
214
215
|
|
@@ -225,7 +226,7 @@ module ActiveMerchant #:nodoc:
|
|
225
226
|
}
|
226
227
|
end
|
227
228
|
|
228
|
-
def commit(method, endpoint, parameters, options={})
|
229
|
+
def commit(method, endpoint, parameters, options = {})
|
229
230
|
url = "#{(test? ? test_url : live_url)}/#{endpoint}"
|
230
231
|
|
231
232
|
begin
|
@@ -11,19 +11,19 @@ module ActiveMerchant #:nodoc:
|
|
11
11
|
self.money_format = :cents
|
12
12
|
self.supported_cardtypes = %i[visa master american_express discover]
|
13
13
|
|
14
|
-
def initialize(options={})
|
14
|
+
def initialize(options = {})
|
15
15
|
requires!(options, :merchant_id, :secret_key)
|
16
16
|
super
|
17
17
|
end
|
18
18
|
|
19
|
-
def purchase(amount, payment_method, options={})
|
19
|
+
def purchase(amount, payment_method, options = {})
|
20
20
|
MultiResponse.run(false) do |r|
|
21
21
|
r.process { authorize(amount, payment_method, options) }
|
22
22
|
r.process { capture(amount, r.authorization, options) }
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
def authorize(amount, payment_method, options={})
|
26
|
+
def authorize(amount, payment_method, options = {})
|
27
27
|
post = {}
|
28
28
|
add_amount(post, amount)
|
29
29
|
add_invoice(post, amount, options)
|
@@ -36,7 +36,7 @@ module ActiveMerchant #:nodoc:
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
def capture(amount, authorization, options={})
|
39
|
+
def capture(amount, authorization, options = {})
|
40
40
|
post = {}
|
41
41
|
add_amount(post, amount)
|
42
42
|
add_reference(post, authorization)
|
@@ -44,14 +44,14 @@ module ActiveMerchant #:nodoc:
|
|
44
44
|
commit(:capture, post)
|
45
45
|
end
|
46
46
|
|
47
|
-
def void(authorization, options={})
|
47
|
+
def void(authorization, options = {})
|
48
48
|
post = {}
|
49
49
|
add_reference(post, authorization)
|
50
50
|
|
51
51
|
commit(:void, post)
|
52
52
|
end
|
53
53
|
|
54
|
-
def refund(amount, authorization, options={})
|
54
|
+
def refund(amount, authorization, options = {})
|
55
55
|
post = {}
|
56
56
|
add_amount(post, amount)
|
57
57
|
add_reference(post, authorization)
|
@@ -59,7 +59,7 @@ module ActiveMerchant #:nodoc:
|
|
59
59
|
commit(:refund, post)
|
60
60
|
end
|
61
61
|
|
62
|
-
def verify(credit_card, options={})
|
62
|
+
def verify(credit_card, options = {})
|
63
63
|
MultiResponse.run(:use_first_response) do |r|
|
64
64
|
r.process { authorize(100, credit_card, options) }
|
65
65
|
r.process(:ignore_result) { void(r.authorization, options) }
|
@@ -87,7 +87,7 @@ module ActiveMerchant #:nodoc:
|
|
87
87
|
|
88
88
|
private
|
89
89
|
|
90
|
-
CURRENCY_CODES = Hash.new { |
|
90
|
+
CURRENCY_CODES = Hash.new { |_h, k| raise ArgumentError.new("Unsupported currency: #{k}") }
|
91
91
|
CURRENCY_CODES['USD'] = '840'
|
92
92
|
CURRENCY_CODES['DKK'] = '208'
|
93
93
|
CURRENCY_CODES['NOK'] = '578'
|
@@ -14,19 +14,19 @@ module ActiveMerchant #:nodoc:
|
|
14
14
|
self.homepage_url = 'https://digitzs.com'
|
15
15
|
self.display_name = 'Digitzs'
|
16
16
|
|
17
|
-
def initialize(options={})
|
17
|
+
def initialize(options = {})
|
18
18
|
requires!(options, :app_key, :api_key)
|
19
19
|
super
|
20
20
|
end
|
21
21
|
|
22
|
-
def purchase(money, payment, options={})
|
22
|
+
def purchase(money, payment, options = {})
|
23
23
|
MultiResponse.run do |r|
|
24
24
|
r.process { commit('auth/token', app_token_request(options)) }
|
25
25
|
r.process { commit('payments', purchase_request(money, payment, options), options.merge({ app_token: app_token_from(r) })) }
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
def refund(money, authorization, options={})
|
29
|
+
def refund(money, authorization, options = {})
|
30
30
|
MultiResponse.run do |r|
|
31
31
|
r.process { commit('auth/token', app_token_request(options)) }
|
32
32
|
r.process { commit('payments', refund_request(money, authorization, options), options.merge({ app_token: app_token_from(r) })) }
|
@@ -151,7 +151,7 @@ module ActiveMerchant #:nodoc:
|
|
151
151
|
post[:data][:type] = 'payments'
|
152
152
|
post[:data][:attributes][:merchantId] = options[:merchant_id]
|
153
153
|
post[:data][:attributes][:paymentType] = 'cardRefund'
|
154
|
-
post[:data][:attributes][:originalTransaction] = {id: authorization}
|
154
|
+
post[:data][:attributes][:originalTransaction] = { id: authorization }
|
155
155
|
add_transaction(post, money, options)
|
156
156
|
|
157
157
|
post
|
@@ -206,7 +206,7 @@ module ActiveMerchant #:nodoc:
|
|
206
206
|
JSON.parse(body)
|
207
207
|
end
|
208
208
|
|
209
|
-
def commit(action, parameters, options={})
|
209
|
+
def commit(action, parameters, options = {})
|
210
210
|
url = (test? ? test_url : live_url)
|
211
211
|
response = parse(ssl_post(url + "/#{action}", parameters.to_json, headers(options)))
|
212
212
|
|
@@ -46,12 +46,12 @@ module ActiveMerchant #:nodoc:
|
|
46
46
|
'cl' => 5000
|
47
47
|
}
|
48
48
|
|
49
|
-
def initialize(options={})
|
49
|
+
def initialize(options = {})
|
50
50
|
requires!(options, :integration_key)
|
51
51
|
super
|
52
52
|
end
|
53
53
|
|
54
|
-
def purchase(money, payment, options={})
|
54
|
+
def purchase(money, payment, options = {})
|
55
55
|
post = { payment: {} }
|
56
56
|
add_integration_key(post)
|
57
57
|
add_operation(post)
|
@@ -65,7 +65,7 @@ module ActiveMerchant #:nodoc:
|
|
65
65
|
commit(:purchase, post)
|
66
66
|
end
|
67
67
|
|
68
|
-
def authorize(money, payment, options={})
|
68
|
+
def authorize(money, payment, options = {})
|
69
69
|
post = { payment: {} }
|
70
70
|
add_integration_key(post)
|
71
71
|
add_operation(post)
|
@@ -80,7 +80,7 @@ module ActiveMerchant #:nodoc:
|
|
80
80
|
commit(:authorize, post)
|
81
81
|
end
|
82
82
|
|
83
|
-
def capture(money, authorization, options={})
|
83
|
+
def capture(money, authorization, options = {})
|
84
84
|
post = {}
|
85
85
|
add_integration_key(post)
|
86
86
|
post[:hash] = authorization
|
@@ -89,7 +89,7 @@ module ActiveMerchant #:nodoc:
|
|
89
89
|
commit(:capture, post)
|
90
90
|
end
|
91
91
|
|
92
|
-
def refund(money, authorization, options={})
|
92
|
+
def refund(money, authorization, options = {})
|
93
93
|
post = {}
|
94
94
|
add_integration_key(post)
|
95
95
|
add_operation(post)
|
@@ -100,7 +100,7 @@ module ActiveMerchant #:nodoc:
|
|
100
100
|
commit(:refund, post)
|
101
101
|
end
|
102
102
|
|
103
|
-
def void(authorization, options={})
|
103
|
+
def void(authorization, options = {})
|
104
104
|
post = {}
|
105
105
|
add_integration_key(post)
|
106
106
|
add_authorization(post, authorization)
|
@@ -108,7 +108,7 @@ module ActiveMerchant #:nodoc:
|
|
108
108
|
commit(:void, post)
|
109
109
|
end
|
110
110
|
|
111
|
-
def store(credit_card, options={})
|
111
|
+
def store(credit_card, options = {})
|
112
112
|
post = {}
|
113
113
|
add_integration_key(post)
|
114
114
|
add_payment_details(post, credit_card)
|
@@ -117,7 +117,7 @@ module ActiveMerchant #:nodoc:
|
|
117
117
|
commit(:store, post)
|
118
118
|
end
|
119
119
|
|
120
|
-
def verify(credit_card, options={})
|
120
|
+
def verify(credit_card, options = {})
|
121
121
|
MultiResponse.run(:use_first_response) do |r|
|
122
122
|
r.process { authorize(VERIFY_AMOUNT_PER_COUNTRY[customer_country(options)], credit_card, options) }
|
123
123
|
r.process(:ignore_result) { void(r.authorization, options) }
|
@@ -222,7 +222,7 @@ module ActiveMerchant #:nodoc:
|
|
222
222
|
|
223
223
|
def commit(action, parameters)
|
224
224
|
url = url_for((test? ? test_url : live_url), action, parameters)
|
225
|
-
response = parse(ssl_request(HTTP_METHOD[action], url, post_data(action, parameters), {'x-ebanx-client-user-agent': "ActiveMerchant/#{ActiveMerchant::VERSION}"}))
|
225
|
+
response = parse(ssl_request(HTTP_METHOD[action], url, post_data(action, parameters), { 'x-ebanx-client-user-agent': "ActiveMerchant/#{ActiveMerchant::VERSION}" }))
|
226
226
|
|
227
227
|
success = success_from(action, response)
|
228
228
|
|
@@ -54,7 +54,7 @@ module ActiveMerchant #:nodoc:
|
|
54
54
|
def void(identification, options = {})
|
55
55
|
requires!(options, :order_id)
|
56
56
|
original_transaction_id, = identification.split(';')
|
57
|
-
commit(:void_transaction, {reference_number: format_reference_number(options[:order_id]), transaction_id: original_transaction_id})
|
57
|
+
commit(:void_transaction, { reference_number: format_reference_number(options[:order_id]), transaction_id: original_transaction_id })
|
58
58
|
end
|
59
59
|
|
60
60
|
def voice_authorize(money, authorization_code, creditcard, options = {})
|
@@ -149,8 +149,7 @@ module ActiveMerchant #:nodoc:
|
|
149
149
|
test: test?,
|
150
150
|
authorization: authorization_from(response, parameters),
|
151
151
|
avs_result: { code: response[:avs_response_code] },
|
152
|
-
cvv_result: response[:cvv_response_code]
|
153
|
-
)
|
152
|
+
cvv_result: response[:cvv_response_code])
|
154
153
|
end
|
155
154
|
|
156
155
|
def success?(response)
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'active_merchant/billing/gateways/viaklix'
|
2
|
+
require 'nokogiri'
|
2
3
|
|
3
4
|
module ActiveMerchant #:nodoc:
|
4
5
|
module Billing #:nodoc:
|
@@ -7,13 +8,15 @@ module ActiveMerchant #:nodoc:
|
|
7
8
|
|
8
9
|
class_attribute :test_url, :live_url, :delimiter, :actions
|
9
10
|
|
10
|
-
self.test_url = 'https://api.demo.convergepay.com/VirtualMerchantDemo/
|
11
|
-
self.live_url = 'https://api.convergepay.com/VirtualMerchant/
|
11
|
+
self.test_url = 'https://api.demo.convergepay.com/VirtualMerchantDemo/processxml.do'
|
12
|
+
self.live_url = 'https://api.convergepay.com/VirtualMerchant/processxml.do'
|
12
13
|
|
13
14
|
self.display_name = 'Elavon MyVirtualMerchant'
|
14
15
|
self.supported_countries = %w(US CA PR DE IE NO PL LU BE NL MX)
|
15
16
|
self.supported_cardtypes = %i[visa master american_express discover]
|
16
17
|
self.homepage_url = 'http://www.elavon.com/'
|
18
|
+
self.money_format = :dollars
|
19
|
+
self.default_currency = 'USD'
|
17
20
|
|
18
21
|
self.delimiter = "\n"
|
19
22
|
self.actions = {
|
@@ -35,115 +38,143 @@ module ActiveMerchant #:nodoc:
|
|
35
38
|
end
|
36
39
|
|
37
40
|
def purchase(money, payment_method, options = {})
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
request = build_xml_request do |xml|
|
42
|
+
xml.ssl_transaction_type self.actions[:purchase]
|
43
|
+
xml.ssl_amount amount(money)
|
44
|
+
|
45
|
+
if payment_method.is_a?(String)
|
46
|
+
add_token(xml, payment_method)
|
47
|
+
else
|
48
|
+
add_creditcard(xml, payment_method)
|
49
|
+
end
|
50
|
+
|
51
|
+
add_invoice(xml, options)
|
52
|
+
add_salestax(xml, options)
|
53
|
+
add_currency(xml, money, options)
|
54
|
+
add_address(xml, options)
|
55
|
+
add_customer_email(xml, options)
|
56
|
+
add_test_mode(xml, options)
|
57
|
+
add_ip(xml, options)
|
58
|
+
add_auth_purchase_params(xml, options)
|
59
|
+
add_level_3_fields(xml, options) if options[:level_3_data]
|
45
60
|
end
|
46
|
-
|
47
|
-
add_address(form, options)
|
48
|
-
add_customer_data(form, options)
|
49
|
-
add_test_mode(form, options)
|
50
|
-
add_ip(form, options)
|
51
|
-
add_auth_purchase_params(form, options)
|
52
|
-
add_level_3_fields(form, options) if options[:level_3_data]
|
53
|
-
commit(:purchase, money, form, options)
|
61
|
+
commit(request)
|
54
62
|
end
|
55
63
|
|
56
64
|
def authorize(money, creditcard, options = {})
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
65
|
+
request = build_xml_request do |xml|
|
66
|
+
xml.ssl_transaction_type self.actions[:authorize]
|
67
|
+
xml.ssl_amount amount(money)
|
68
|
+
|
69
|
+
add_salestax(xml, options)
|
70
|
+
add_invoice(xml, options)
|
71
|
+
add_creditcard(xml, creditcard)
|
72
|
+
add_currency(xml, money, options)
|
73
|
+
add_address(xml, options)
|
74
|
+
add_customer_email(xml, options)
|
75
|
+
add_test_mode(xml, options)
|
76
|
+
add_ip(xml, options)
|
77
|
+
add_auth_purchase_params(xml, options)
|
78
|
+
add_level_3_fields(xml, options) if options[:level_3_data]
|
79
|
+
end
|
80
|
+
commit(request)
|
69
81
|
end
|
70
82
|
|
71
83
|
def capture(money, authorization, options = {})
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
84
|
+
request = build_xml_request do |xml|
|
85
|
+
if options[:credit_card]
|
86
|
+
xml.ssl_transaction_type self.actions[:capture]
|
87
|
+
xml.ssl_amount amount(money)
|
88
|
+
add_salestax(xml, options)
|
89
|
+
add_approval_code(xml, authorization)
|
90
|
+
add_invoice(xml, options)
|
91
|
+
add_creditcard(xml, options[:credit_card])
|
92
|
+
add_currency(xml, money, options)
|
93
|
+
add_address(xml, options)
|
94
|
+
add_customer_email(xml, options)
|
95
|
+
add_test_mode(xml, options)
|
96
|
+
else
|
97
|
+
xml.ssl_transaction_type self.actions[:capture_complete]
|
98
|
+
xml.ssl_amount amount(money)
|
99
|
+
add_currency(xml, money, options)
|
100
|
+
add_txn_id(xml, authorization)
|
101
|
+
add_partial_shipment_flag(xml, options)
|
102
|
+
add_test_mode(xml, options)
|
103
|
+
end
|
88
104
|
end
|
89
|
-
commit(
|
105
|
+
commit(request)
|
90
106
|
end
|
91
107
|
|
92
108
|
def refund(money, identification, options = {})
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
109
|
+
request = build_xml_request do |xml|
|
110
|
+
xml.ssl_transaction_type self.actions[:refund]
|
111
|
+
xml.ssl_amount amount(money)
|
112
|
+
add_txn_id(xml, identification)
|
113
|
+
add_test_mode(xml, options)
|
114
|
+
end
|
115
|
+
commit(request)
|
97
116
|
end
|
98
117
|
|
99
118
|
def void(identification, options = {})
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
119
|
+
request = build_xml_request do |xml|
|
120
|
+
xml.ssl_transaction_type self.actions[:void]
|
121
|
+
|
122
|
+
add_txn_id(xml, identification)
|
123
|
+
add_test_mode(xml, options)
|
124
|
+
end
|
125
|
+
commit(request)
|
104
126
|
end
|
105
127
|
|
106
128
|
def credit(money, creditcard, options = {})
|
107
129
|
raise ArgumentError, 'Reference credits are not supported. Please supply the original credit card or use the #refund method.' if creditcard.is_a?(String)
|
108
130
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
131
|
+
request = build_xml_request do |xml|
|
132
|
+
xml.ssl_transaction_type self.actions[:credit]
|
133
|
+
xml.ssl_amount amount(money)
|
134
|
+
add_invoice(xml, options)
|
135
|
+
add_creditcard(xml, creditcard)
|
136
|
+
add_currency(xml, money, options)
|
137
|
+
add_address(xml, options)
|
138
|
+
add_customer_email(xml, options)
|
139
|
+
add_test_mode(xml, options)
|
140
|
+
end
|
141
|
+
commit(request)
|
117
142
|
end
|
118
143
|
|
119
144
|
def verify(credit_card, options = {})
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
145
|
+
request = build_xml_request do |xml|
|
146
|
+
xml.ssl_transaction_type self.actions[:verify]
|
147
|
+
add_creditcard(xml, credit_card)
|
148
|
+
add_address(xml, options)
|
149
|
+
add_test_mode(xml, options)
|
150
|
+
add_ip(xml, options)
|
151
|
+
end
|
152
|
+
commit(request)
|
126
153
|
end
|
127
154
|
|
128
155
|
def store(creditcard, options = {})
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
156
|
+
request = build_xml_request do |xml|
|
157
|
+
xml.ssl_transaction_type self.actions[:store]
|
158
|
+
xml.ssl_add_token 'Y'
|
159
|
+
add_creditcard(xml, creditcard)
|
160
|
+
add_address(xml, options)
|
161
|
+
add_customer_email(xml, options)
|
162
|
+
add_test_mode(xml, options)
|
163
|
+
add_verification(xml, options)
|
164
|
+
end
|
165
|
+
commit(request)
|
137
166
|
end
|
138
167
|
|
139
168
|
def update(token, creditcard, options = {})
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
169
|
+
request = build_xml_request do |xml|
|
170
|
+
xml.ssl_transaction_type self.actions[:update]
|
171
|
+
add_token(xml, token)
|
172
|
+
add_creditcard(xml, creditcard)
|
173
|
+
add_address(xml, options)
|
174
|
+
add_customer_email(xml, options)
|
175
|
+
add_test_mode(xml, options)
|
176
|
+
end
|
177
|
+
commit(request)
|
147
178
|
end
|
148
179
|
|
149
180
|
def supports_scrubbing?
|
@@ -152,217 +183,205 @@ module ActiveMerchant #:nodoc:
|
|
152
183
|
|
153
184
|
def scrub(transcript)
|
154
185
|
transcript.
|
155
|
-
gsub(%r((
|
156
|
-
gsub(%r((
|
157
|
-
gsub(%r((
|
186
|
+
gsub(%r((<ssl_pin>)(.*)(</ssl_pin>)), '\1[FILTERED]\3').
|
187
|
+
gsub(%r((<ssl_card_number>)(.*)(</ssl_card_number>)), '\1[FILTERED]\3').
|
188
|
+
gsub(%r((<ssl_cvv2cvc2>)(.*)(</ssl_cvv2cvc2>)), '\1[FILTERED]\3')
|
158
189
|
end
|
159
190
|
|
160
191
|
private
|
161
192
|
|
162
|
-
def add_invoice(
|
163
|
-
|
164
|
-
|
193
|
+
def add_invoice(xml, options)
|
194
|
+
xml.ssl_invoice_number truncate((options[:order_id] || options[:invoice]), 25)
|
195
|
+
xml.ssl_description truncate(options[:description], 255)
|
165
196
|
end
|
166
197
|
|
167
|
-
def add_approval_code(
|
168
|
-
|
198
|
+
def add_approval_code(xml, authorization)
|
199
|
+
xml.ssl_approval_code authorization.split(';').first
|
169
200
|
end
|
170
201
|
|
171
|
-
def add_txn_id(
|
172
|
-
|
202
|
+
def add_txn_id(xml, authorization)
|
203
|
+
xml.ssl_txn_id authorization.split(';').last
|
173
204
|
end
|
174
205
|
|
175
|
-
def
|
176
|
-
|
177
|
-
|
206
|
+
def add_creditcard(xml, creditcard)
|
207
|
+
xml.ssl_card_number creditcard.number
|
208
|
+
xml.ssl_exp_date expdate(creditcard)
|
178
209
|
|
179
|
-
|
180
|
-
form[:card_number] = creditcard.number
|
181
|
-
form[:exp_date] = expdate(creditcard)
|
210
|
+
add_verification_value(xml, creditcard) if creditcard.verification_value?
|
182
211
|
|
183
|
-
|
184
|
-
|
185
|
-
form[:first_name] = truncate(creditcard.first_name, 20)
|
186
|
-
form[:last_name] = truncate(creditcard.last_name, 30)
|
212
|
+
xml.ssl_first_name truncate(creditcard.first_name, 20)
|
213
|
+
xml.ssl_last_name truncate(creditcard.last_name, 30)
|
187
214
|
end
|
188
215
|
|
189
|
-
def add_currency(
|
216
|
+
def add_currency(xml, money, options)
|
190
217
|
currency = options[:currency] || currency(money)
|
191
|
-
|
218
|
+
return unless currency && (@options[:multi_currency] || options[:multi_currency])
|
219
|
+
|
220
|
+
xml.ssl_transaction_currency currency
|
192
221
|
end
|
193
222
|
|
194
|
-
def add_token(
|
195
|
-
|
223
|
+
def add_token(xml, token)
|
224
|
+
xml.ssl_token token
|
196
225
|
end
|
197
226
|
|
198
|
-
def add_verification_value(
|
199
|
-
|
200
|
-
|
227
|
+
def add_verification_value(xml, creditcard)
|
228
|
+
xml.ssl_cvv2cvc2 creditcard.verification_value
|
229
|
+
xml.ssl_cvv2cvc2_indicator 1
|
201
230
|
end
|
202
231
|
|
203
|
-
def
|
204
|
-
|
205
|
-
form[:customer_code] = truncate(options[:customer], 10) unless empty?(options[:customer])
|
206
|
-
form[:customer_number] = options[:customer_number] unless empty?(options[:customer_number])
|
207
|
-
options[:custom_fields]&.each do |key, value|
|
208
|
-
form[key.to_s] = value
|
209
|
-
end
|
232
|
+
def add_customer_email(xml, options)
|
233
|
+
xml.ssl_email truncate(options[:email], 100) unless empty?(options[:email])
|
210
234
|
end
|
211
235
|
|
212
|
-
def add_salestax(
|
213
|
-
|
236
|
+
def add_salestax(xml, options)
|
237
|
+
return unless options[:tax].present?
|
238
|
+
|
239
|
+
xml.ssl_salestax options[:tax]
|
214
240
|
end
|
215
241
|
|
216
|
-
def add_address(
|
242
|
+
def add_address(xml, options)
|
217
243
|
billing_address = options[:billing_address] || options[:address]
|
218
244
|
|
219
245
|
if billing_address
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
246
|
+
xml.ssl_avs_address truncate(billing_address[:address1], 30)
|
247
|
+
xml.ssl_address2 truncate(billing_address[:address2], 30)
|
248
|
+
xml.ssl_avs_zip truncate(billing_address[:zip].to_s.gsub(/[^a-zA-Z0-9]/, ''), 9)
|
249
|
+
xml.ssl_city truncate(billing_address[:city], 30)
|
250
|
+
xml.ssl_state truncate(billing_address[:state], 10)
|
251
|
+
xml.ssl_company truncate(billing_address[:company], 50)
|
252
|
+
xml.ssl_phone truncate(billing_address[:phone], 20)
|
253
|
+
xml.ssl_country truncate(billing_address[:country], 50)
|
228
254
|
end
|
229
255
|
|
230
256
|
if shipping_address = options[:shipping_address]
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
257
|
+
xml.ssl_ship_to_address1 truncate(shipping_address[:address1], 30)
|
258
|
+
xml.ssl_ship_to_address2 truncate(shipping_address[:address2], 30)
|
259
|
+
xml.ssl_ship_to_city truncate(shipping_address[:city], 30)
|
260
|
+
xml.ssl_ship_to_company truncate(shipping_address[:company], 50)
|
261
|
+
xml.ssl_ship_to_country truncate(shipping_address[:country], 50)
|
262
|
+
xml.ssl_ship_to_first_name truncate(shipping_address[:first_name], 20)
|
263
|
+
xml.ssl_ship_to_last_name truncate(shipping_address[:last_name], 30)
|
264
|
+
xml.ssl_ship_to_phone truncate(shipping_address[:phone], 10)
|
265
|
+
xml.ssl_ship_to_state truncate(shipping_address[:state], 2)
|
266
|
+
xml.ssl_ship_to_zip truncate(shipping_address[:zip], 10)
|
241
267
|
end
|
242
268
|
end
|
243
269
|
|
244
|
-
def add_verification(
|
245
|
-
|
270
|
+
def add_verification(xml, options)
|
271
|
+
xml.ssl_verify 'Y' if options[:verify]
|
246
272
|
end
|
247
273
|
|
248
|
-
def add_test_mode(
|
249
|
-
|
274
|
+
def add_test_mode(xml, options)
|
275
|
+
xml.ssl_test_mode 'TRUE' if options[:test_mode]
|
250
276
|
end
|
251
277
|
|
252
|
-
def add_partial_shipment_flag(
|
253
|
-
|
278
|
+
def add_partial_shipment_flag(xml, options)
|
279
|
+
xml.ssl_partial_shipment_flag 'Y' if options[:partial_shipment_flag]
|
254
280
|
end
|
255
281
|
|
256
|
-
def add_ip(
|
257
|
-
|
282
|
+
def add_ip(xml, options)
|
283
|
+
xml.ssl_cardholder_ip options[:ip] if options.has_key?(:ip)
|
258
284
|
end
|
259
285
|
|
260
|
-
def add_auth_purchase_params(
|
261
|
-
|
262
|
-
|
286
|
+
def add_auth_purchase_params(xml, options)
|
287
|
+
xml.ssl_dynamic_dba options[:dba] if options.has_key?(:dba)
|
288
|
+
xml.ssl_merchant_initiated_unscheduled options[:merchant_initiated_unscheduled] if options.has_key?(:merchant_initiated_unscheduled)
|
289
|
+
xml.ssl_customer_code options[:customer] if options.has_key?(:customer)
|
290
|
+
xml.ssl_customer_number options[:customer_number] if options.has_key?(:customer_number)
|
291
|
+
add_custom_fields(xml, options) if options[:custom_fields]
|
263
292
|
end
|
264
293
|
|
265
|
-
def
|
266
|
-
|
267
|
-
|
268
|
-
form[:salestax] = level_3_data[:salestax] if level_3_data[:salestax]
|
269
|
-
form[:salestax_indicator] = level_3_data[:salestax_indicator] if level_3_data[:salestax_indicator]
|
270
|
-
form[:level3_indicator] = level_3_data[:level3_indicator] if level_3_data[:level3_indicator]
|
271
|
-
form[:ship_to_zip] = level_3_data[:ship_to_zip] if level_3_data[:ship_to_zip]
|
272
|
-
form[:ship_to_country] = level_3_data[:ship_to_country] if level_3_data[:ship_to_country]
|
273
|
-
form[:shipping_amount] = level_3_data[:shipping_amount] if level_3_data[:shipping_amount]
|
274
|
-
form[:ship_from_postal_code] = level_3_data[:ship_from_postal_code] if level_3_data[:ship_from_postal_code]
|
275
|
-
form[:discount_amount] = level_3_data[:discount_amount] if level_3_data[:discount_amount]
|
276
|
-
form[:duty_amount] = level_3_data[:duty_amount] if level_3_data[:duty_amount]
|
277
|
-
form[:national_tax_indicator] = level_3_data[:national_tax_indicator] if level_3_data[:national_tax_indicator]
|
278
|
-
form[:national_tax_amount] = level_3_data[:national_tax_amount] if level_3_data[:national_tax_amount]
|
279
|
-
form[:order_date] = level_3_data[:order_date] if level_3_data[:order_date]
|
280
|
-
form[:other_tax] = level_3_data[:other_tax] if level_3_data[:other_tax]
|
281
|
-
form[:summary_commodity_code] = level_3_data[:summary_commodity_code] if level_3_data[:summary_commodity_code]
|
282
|
-
form[:merchant_vat_number] = level_3_data[:merchant_vat_number] if level_3_data[:merchant_vat_number]
|
283
|
-
form[:customer_vat_number] = level_3_data[:customer_vat_number] if level_3_data[:customer_vat_number]
|
284
|
-
form[:freight_tax_amount] = level_3_data[:freight_tax_amount] if level_3_data[:freight_tax_amount]
|
285
|
-
form[:vat_invoice_number] = level_3_data[:vat_invoice_number] if level_3_data[:vat_invoice_number]
|
286
|
-
form[:tracking_number] = level_3_data[:tracking_number] if level_3_data[:tracking_number]
|
287
|
-
form[:shipping_company] = level_3_data[:shipping_company] if level_3_data[:shipping_company]
|
288
|
-
form[:other_fees] = level_3_data[:other_fees] if level_3_data[:other_fees]
|
289
|
-
add_line_items(form, level_3_data) if level_3_data[:line_items]
|
290
|
-
end
|
291
|
-
|
292
|
-
def add_line_items(form, level_3_data)
|
293
|
-
items = []
|
294
|
-
level_3_data[:line_items].each do |line_item|
|
295
|
-
item = {}
|
296
|
-
line_item.each do |key, value|
|
297
|
-
prefixed_key = "ssl_line_Item_#{key}"
|
298
|
-
item[prefixed_key.to_sym] = value
|
299
|
-
end
|
300
|
-
items << item
|
294
|
+
def add_custom_fields(xml, options)
|
295
|
+
options[:custom_fields]&.each do |key, value|
|
296
|
+
xml.send(key.to_sym, value)
|
301
297
|
end
|
302
|
-
form[:LineItemProducts] = { product: items }
|
303
298
|
end
|
304
299
|
|
305
|
-
def
|
306
|
-
|
300
|
+
def add_level_3_fields(xml, options)
|
301
|
+
level_3_data = options[:level_3_data]
|
302
|
+
xml.ssl_customer_code level_3_data[:customer_code] if level_3_data[:customer_code]
|
303
|
+
xml.ssl_salestax level_3_data[:salestax] if level_3_data[:salestax]
|
304
|
+
xml.ssl_salestax_indicator level_3_data[:salestax_indicator] if level_3_data[:salestax_indicator]
|
305
|
+
xml.ssl_level3_indicator level_3_data[:level3_indicator] if level_3_data[:level3_indicator]
|
306
|
+
xml.ssl_ship_to_zip level_3_data[:ship_to_zip] if level_3_data[:ship_to_zip]
|
307
|
+
xml.ssl_ship_to_country level_3_data[:ship_to_country] if level_3_data[:ship_to_country]
|
308
|
+
xml.ssl_shipping_amount level_3_data[:shipping_amount] if level_3_data[:shipping_amount]
|
309
|
+
xml.ssl_ship_from_postal_code level_3_data[:ship_from_postal_code] if level_3_data[:ship_from_postal_code]
|
310
|
+
xml.ssl_discount_amount level_3_data[:discount_amount] if level_3_data[:discount_amount]
|
311
|
+
xml.ssl_duty_amount level_3_data[:duty_amount] if level_3_data[:duty_amount]
|
312
|
+
xml.ssl_national_tax_indicator level_3_data[:national_tax_indicator] if level_3_data[:national_tax_indicator]
|
313
|
+
xml.ssl_national_tax_amount level_3_data[:national_tax_amount] if level_3_data[:national_tax_amount]
|
314
|
+
xml.ssl_order_date level_3_data[:order_date] if level_3_data[:order_date]
|
315
|
+
xml.ssl_other_tax level_3_data[:other_tax] if level_3_data[:other_tax]
|
316
|
+
xml.ssl_summary_commodity_code level_3_data[:summary_commodity_code] if level_3_data[:summary_commodity_code]
|
317
|
+
xml.ssl_merchant_vat_number level_3_data[:merchant_vat_number] if level_3_data[:merchant_vat_number]
|
318
|
+
xml.ssl_customer_vat_number level_3_data[:customer_vat_number] if level_3_data[:customer_vat_number]
|
319
|
+
xml.ssl_freight_tax_amount level_3_data[:freight_tax_amount] if level_3_data[:freight_tax_amount]
|
320
|
+
xml.ssl_vat_invoice_number level_3_data[:vat_invoice_number] if level_3_data[:vat_invoice_number]
|
321
|
+
xml.ssl_tracking_number level_3_data[:tracking_number] if level_3_data[:tracking_number]
|
322
|
+
xml.ssl_shipping_company level_3_data[:shipping_company] if level_3_data[:shipping_company]
|
323
|
+
xml.ssl_other_fees level_3_data[:other_fees] if level_3_data[:other_fees]
|
324
|
+
add_line_items(xml, level_3_data) if level_3_data[:line_items]
|
325
|
+
end
|
326
|
+
|
327
|
+
def add_line_items(xml, level_3_data)
|
328
|
+
xml.LineItemProducts {
|
329
|
+
level_3_data[:line_items].each do |line_item|
|
330
|
+
xml.product {
|
331
|
+
line_item.each do |key, value|
|
332
|
+
prefixed_key = "ssl_line_Item_#{key}"
|
333
|
+
xml.send(prefixed_key, value)
|
334
|
+
end
|
335
|
+
}
|
336
|
+
end
|
337
|
+
}
|
307
338
|
end
|
308
339
|
|
309
|
-
def
|
310
|
-
|
311
|
-
|
340
|
+
def build_xml_request
|
341
|
+
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
342
|
+
xml.txn do
|
343
|
+
xml.ssl_merchant_id @options[:login]
|
344
|
+
xml.ssl_user_id @options[:user]
|
345
|
+
xml.ssl_pin @options[:password]
|
346
|
+
yield(xml)
|
347
|
+
end
|
348
|
+
end
|
312
349
|
|
313
|
-
|
314
|
-
|
315
|
-
parameters[:transaction_type] = self.actions[action]
|
350
|
+
builder.to_xml.gsub("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", '')
|
351
|
+
end
|
316
352
|
|
317
|
-
|
353
|
+
def commit(request)
|
354
|
+
request = "xmldata=#{request}".delete('&')
|
355
|
+
response = parse(ssl_post(test? ? self.test_url : self.live_url, request, headers))
|
318
356
|
|
319
|
-
Response.new(
|
357
|
+
Response.new(
|
358
|
+
response[:result] == '0',
|
359
|
+
response[:result_message] || response[:errorMessage],
|
360
|
+
response,
|
320
361
|
test: @options[:test] || test?,
|
321
362
|
authorization: authorization_from(response),
|
322
|
-
|
323
|
-
|
363
|
+
error_code: response[:errorCode],
|
364
|
+
avs_result: { code: response[:avs_response] },
|
365
|
+
cvv_result: response[:cvv2_response]
|
324
366
|
)
|
325
367
|
end
|
326
368
|
|
327
|
-
def
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
def post_data_string(key, value, options)
|
334
|
-
if custom_field?(key, options) || key == :LineItemProducts
|
335
|
-
"#{key}=#{CGI.escape(value.to_s)}"
|
336
|
-
else
|
337
|
-
"ssl_#{key}=#{CGI.escape(value.to_s)}"
|
338
|
-
end
|
339
|
-
end
|
340
|
-
|
341
|
-
def custom_field?(field_name, options)
|
342
|
-
return true if options[:custom_fields]&.include?(field_name.to_sym)
|
343
|
-
|
344
|
-
field_name == :customer_number
|
369
|
+
def headers
|
370
|
+
{
|
371
|
+
'Accept' => 'application/xml',
|
372
|
+
'Content-type' => 'application/x-www-form-urlencoded'
|
373
|
+
}
|
345
374
|
end
|
346
375
|
|
347
|
-
def
|
348
|
-
|
349
|
-
|
350
|
-
'pin' => @options[:password],
|
351
|
-
'show_form' => 'false',
|
352
|
-
'result_format' => 'ASCII'
|
353
|
-
}
|
376
|
+
def parse(body)
|
377
|
+
xml = Nokogiri::XML(body)
|
378
|
+
response = Hash.from_xml(xml.to_s)['txn']
|
354
379
|
|
355
|
-
|
356
|
-
result
|
380
|
+
response.deep_transform_keys { |key| key.gsub('ssl_', '').to_sym }
|
357
381
|
end
|
358
382
|
|
359
|
-
def
|
360
|
-
|
361
|
-
msg.split(self.delimiter).collect { |li|
|
362
|
-
key, value = li.split('=')
|
363
|
-
resp[key.to_s.strip.gsub(/^ssl_/, '')] = value.to_s.strip
|
364
|
-
}
|
365
|
-
resp
|
383
|
+
def authorization_from(response)
|
384
|
+
[response[:approval_code], response[:txn_id]].join(';')
|
366
385
|
end
|
367
386
|
end
|
368
387
|
end
|