activemerchant 1.100.0 → 1.133.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +1057 -0
- data/README.md +11 -9
- data/lib/active_merchant/billing/avs_result.rb +9 -9
- data/lib/active_merchant/billing/base.rb +0 -13
- data/lib/active_merchant/billing/check.rb +49 -17
- data/lib/active_merchant/billing/compatibility.rb +5 -4
- data/lib/active_merchant/billing/credit_card.rb +55 -8
- data/lib/active_merchant/billing/credit_card_formatting.rb +1 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +209 -36
- data/lib/active_merchant/billing/cvv_result.rb +0 -1
- data/lib/active_merchant/billing/gateway.rb +38 -36
- data/lib/active_merchant/billing/gateways/adyen.rb +399 -78
- data/lib/active_merchant/billing/gateways/airwallex.rb +370 -0
- data/lib/active_merchant/billing/gateways/alelo.rb +256 -0
- data/lib/active_merchant/billing/gateways/allied_wallet.rb +14 -14
- data/lib/active_merchant/billing/gateways/authorize_net.rb +200 -130
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +27 -20
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +48 -51
- data/lib/active_merchant/billing/gateways/axcessms.rb +13 -15
- data/lib/active_merchant/billing/gateways/balanced.rb +43 -36
- data/lib/active_merchant/billing/gateways/bambora_apac.rb +16 -20
- data/lib/active_merchant/billing/gateways/bank_frick.rb +13 -13
- data/lib/active_merchant/billing/gateways/banwire.rb +5 -5
- data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +43 -30
- data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +1 -1
- data/lib/active_merchant/billing/gateways/be2bill.rb +5 -5
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +37 -36
- data/lib/active_merchant/billing/gateways/beanstream.rb +21 -3
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +1 -1
- data/lib/active_merchant/billing/gateways/blue_pay.rb +53 -28
- data/lib/active_merchant/billing/gateways/blue_snap.rb +176 -54
- data/lib/active_merchant/billing/gateways/bogus.rb +24 -20
- data/lib/active_merchant/billing/gateways/borgun.rb +92 -38
- data/lib/active_merchant/billing/gateways/bpoint.rb +15 -15
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +8 -2
- data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +1 -1
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +387 -175
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +13 -13
- data/lib/active_merchant/billing/gateways/cams.rb +10 -10
- data/lib/active_merchant/billing/gateways/card_connect.rb +33 -14
- data/lib/active_merchant/billing/gateways/card_save.rb +3 -4
- data/lib/active_merchant/billing/gateways/card_stream.rb +67 -40
- data/lib/active_merchant/billing/gateways/cardknox.rb +13 -13
- data/lib/active_merchant/billing/gateways/cardprocess.rb +4 -2
- data/lib/active_merchant/billing/gateways/cashnet.rb +28 -12
- data/lib/active_merchant/billing/gateways/cc5.rb +9 -9
- data/lib/active_merchant/billing/gateways/cecabank.rb +38 -38
- data/lib/active_merchant/billing/gateways/cenpos.rb +29 -28
- data/lib/active_merchant/billing/gateways/checkout.rb +7 -9
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +316 -68
- data/lib/active_merchant/billing/gateways/citrus_pay.rb +1 -2
- data/lib/active_merchant/billing/gateways/clearhaus.rb +32 -33
- data/lib/active_merchant/billing/gateways/commerce_hub.rb +370 -0
- data/lib/active_merchant/billing/gateways/commercegate.rb +4 -4
- data/lib/active_merchant/billing/gateways/conekta.rb +8 -6
- data/lib/active_merchant/billing/gateways/creditcall.rb +18 -17
- data/lib/active_merchant/billing/gateways/credorax.rb +152 -63
- data/lib/active_merchant/billing/gateways/ct_payment.rb +15 -14
- data/lib/active_merchant/billing/gateways/culqi.rb +30 -28
- data/lib/active_merchant/billing/gateways/cyber_source/cyber_source_common.rb +36 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +496 -187
- data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +454 -0
- data/lib/active_merchant/billing/gateways/d_local.rb +148 -31
- data/lib/active_merchant/billing/gateways/data_cash.rb +34 -37
- data/lib/active_merchant/billing/gateways/decidir.rb +134 -21
- data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
- data/lib/active_merchant/billing/gateways/dibs.rb +10 -10
- data/lib/active_merchant/billing/gateways/digitzs.rb +11 -8
- data/lib/active_merchant/billing/gateways/ebanx.rb +90 -40
- data/lib/active_merchant/billing/gateways/efsnet.rb +36 -36
- data/lib/active_merchant/billing/gateways/elavon.rb +349 -194
- data/lib/active_merchant/billing/gateways/element.rb +71 -21
- data/lib/active_merchant/billing/gateways/epay.rb +43 -43
- data/lib/active_merchant/billing/gateways/evo_ca.rb +12 -13
- data/lib/active_merchant/billing/gateways/eway.rb +9 -9
- data/lib/active_merchant/billing/gateways/eway_managed.rb +55 -56
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +37 -22
- data/lib/active_merchant/billing/gateways/exact.rb +19 -20
- data/lib/active_merchant/billing/gateways/ezic.rb +9 -9
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +24 -19
- data/lib/active_merchant/billing/gateways/federated_canada.rb +6 -7
- data/lib/active_merchant/billing/gateways/finansbank.rb +3 -3
- data/lib/active_merchant/billing/gateways/first_giving.rb +5 -4
- data/lib/active_merchant/billing/gateways/first_pay.rb +7 -7
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +39 -38
- data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +51 -31
- data/lib/active_merchant/billing/gateways/flo2cash.rb +24 -24
- data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +1 -1
- data/lib/active_merchant/billing/gateways/forte.rb +38 -22
- data/lib/active_merchant/billing/gateways/garanti.rb +12 -15
- data/lib/active_merchant/billing/gateways/global_collect.rb +333 -89
- data/lib/active_merchant/billing/gateways/global_transport.rb +8 -9
- data/lib/active_merchant/billing/gateways/hdfc.rb +22 -23
- data/lib/active_merchant/billing/gateways/hps.rb +171 -50
- data/lib/active_merchant/billing/gateways/iats_payments.rb +47 -25
- data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +1 -1
- data/lib/active_merchant/billing/gateways/inspire.rb +22 -27
- data/lib/active_merchant/billing/gateways/instapay.rb +5 -8
- data/lib/active_merchant/billing/gateways/ipg.rb +420 -0
- data/lib/active_merchant/billing/gateways/ipp.rb +9 -9
- data/lib/active_merchant/billing/gateways/iridium.rb +30 -31
- data/lib/active_merchant/billing/gateways/itransact.rb +11 -10
- data/lib/active_merchant/billing/gateways/iveri.rb +62 -23
- data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +10 -17
- data/lib/active_merchant/billing/gateways/jetpay_v2.rb +13 -18
- data/lib/active_merchant/billing/gateways/komoju.rb +1 -1
- data/lib/active_merchant/billing/gateways/kushki.rb +100 -22
- data/lib/active_merchant/billing/gateways/latitude19.rb +20 -19
- data/lib/active_merchant/billing/gateways/linkpoint.rb +71 -72
- data/lib/active_merchant/billing/gateways/litle.rb +181 -45
- data/lib/active_merchant/billing/gateways/mastercard.rb +16 -22
- data/lib/active_merchant/billing/gateways/maxipago.rb +2 -2
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +89 -18
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +58 -24
- data/lib/active_merchant/billing/gateways/merchant_one.rb +7 -10
- data/lib/active_merchant/billing/gateways/merchant_partners.rb +19 -19
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +18 -22
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +15 -17
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +46 -8
- data/lib/active_merchant/billing/gateways/mercury.rb +19 -23
- data/lib/active_merchant/billing/gateways/metrics_global.rb +24 -33
- data/lib/active_merchant/billing/gateways/micropayment.rb +11 -12
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +7 -7
- data/lib/active_merchant/billing/gateways/migs.rb +18 -21
- data/lib/active_merchant/billing/gateways/mit.rb +260 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +10 -12
- data/lib/active_merchant/billing/gateways/moka.rb +290 -0
- data/lib/active_merchant/billing/gateways/monei.rb +236 -150
- data/lib/active_merchant/billing/gateways/moneris.rb +122 -53
- data/lib/active_merchant/billing/gateways/money_movers.rb +6 -7
- data/lib/active_merchant/billing/gateways/mundipagg.rb +69 -23
- data/lib/active_merchant/billing/gateways/nab_transact.rb +18 -20
- data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +10 -12
- data/lib/active_merchant/billing/gateways/net_registry.rb +8 -9
- data/lib/active_merchant/billing/gateways/netaxept.rb +12 -12
- data/lib/active_merchant/billing/gateways/netbanx.rb +128 -46
- data/lib/active_merchant/billing/gateways/netbilling.rb +18 -21
- data/lib/active_merchant/billing/gateways/netpay.rb +5 -4
- data/lib/active_merchant/billing/gateways/network_merchants.rb +7 -10
- data/lib/active_merchant/billing/gateways/nmi.rb +69 -27
- data/lib/active_merchant/billing/gateways/ogone.rb +62 -31
- data/lib/active_merchant/billing/gateways/omise.rb +15 -16
- data/lib/active_merchant/billing/gateways/openpay.rb +33 -15
- data/lib/active_merchant/billing/gateways/opp.rb +39 -33
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +43 -42
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +3 -5
- data/lib/active_merchant/billing/gateways/orbital.rb +623 -362
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +20 -20
- data/lib/active_merchant/billing/gateways/pagarme.rb +16 -23
- data/lib/active_merchant/billing/gateways/pago_facil.rb +4 -6
- data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
- data/lib/active_merchant/billing/gateways/pay_conex.rb +17 -17
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +30 -33
- data/lib/active_merchant/billing/gateways/pay_hub.rb +10 -10
- data/lib/active_merchant/billing/gateways/pay_junction.rb +31 -31
- data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +36 -18
- data/lib/active_merchant/billing/gateways/pay_secure.rb +10 -11
- data/lib/active_merchant/billing/gateways/pay_trace.rb +450 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +64 -40
- data/lib/active_merchant/billing/gateways/payeezy.rb +130 -27
- data/lib/active_merchant/billing/gateways/payex.rb +24 -25
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +17 -17
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +1 -1
- data/lib/active_merchant/billing/gateways/payflow.rb +103 -25
- data/lib/active_merchant/billing/gateways/payflow_express.rb +4 -4
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +1 -1
- data/lib/active_merchant/billing/gateways/payment_express.rb +22 -18
- data/lib/active_merchant/billing/gateways/paymentez.rb +89 -24
- data/lib/active_merchant/billing/gateways/paymill.rb +14 -16
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +2 -1
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +4 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +13 -5
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +1 -1
- data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +1 -1
- data/lib/active_merchant/billing/gateways/paypal_express.rb +4 -1
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +1 -1
- data/lib/active_merchant/billing/gateways/paysafe.rb +420 -0
- data/lib/active_merchant/billing/gateways/payscout.rb +8 -9
- data/lib/active_merchant/billing/gateways/paystation.rb +6 -9
- data/lib/active_merchant/billing/gateways/payu_in.rb +20 -19
- data/lib/active_merchant/billing/gateways/payu_latam.rb +70 -37
- data/lib/active_merchant/billing/gateways/payway.rb +22 -22
- data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
- data/lib/active_merchant/billing/gateways/pin.rb +60 -21
- data/lib/active_merchant/billing/gateways/plexo.rb +308 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +20 -21
- data/lib/active_merchant/billing/gateways/priority.rb +392 -0
- data/lib/active_merchant/billing/gateways/pro_pay.rb +13 -14
- data/lib/active_merchant/billing/gateways/psigate.rb +29 -29
- data/lib/active_merchant/billing/gateways/psl_card.rb +7 -8
- data/lib/active_merchant/billing/gateways/qbms.rb +25 -26
- data/lib/active_merchant/billing/gateways/quantum.rb +9 -11
- data/lib/active_merchant/billing/gateways/quickbooks.rb +126 -39
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +98 -98
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +19 -23
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +3 -3
- data/lib/active_merchant/billing/gateways/quickpay.rb +0 -1
- data/lib/active_merchant/billing/gateways/qvalent.rb +36 -20
- data/lib/active_merchant/billing/gateways/rapyd.rb +319 -0
- data/lib/active_merchant/billing/gateways/reach.rb +277 -0
- data/lib/active_merchant/billing/gateways/realex.rb +42 -16
- data/lib/active_merchant/billing/gateways/redsys.rb +191 -86
- data/lib/active_merchant/billing/gateways/s5.rb +10 -9
- data/lib/active_merchant/billing/gateways/safe_charge.rb +70 -33
- data/lib/active_merchant/billing/gateways/sage.rb +19 -21
- data/lib/active_merchant/billing/gateways/sage_pay.rb +57 -57
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +3 -4
- data/lib/active_merchant/billing/gateways/secure_net.rb +19 -26
- data/lib/active_merchant/billing/gateways/secure_pay.rb +24 -33
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +18 -20
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +4 -5
- data/lib/active_merchant/billing/gateways/securion_pay.rb +48 -7
- data/lib/active_merchant/billing/gateways/shift4.rb +345 -0
- data/lib/active_merchant/billing/gateways/simetrik.rb +368 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +19 -19
- data/lib/active_merchant/billing/gateways/smart_ps.rb +26 -32
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +24 -25
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +27 -21
- data/lib/active_merchant/billing/gateways/stripe.rb +126 -53
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +441 -113
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +7 -8
- data/lib/active_merchant/billing/gateways/telr.rb +17 -18
- data/lib/active_merchant/billing/gateways/tns.rb +3 -7
- data/lib/active_merchant/billing/gateways/trans_first.rb +10 -9
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +28 -24
- data/lib/active_merchant/billing/gateways/transact_pro.rb +13 -15
- data/lib/active_merchant/billing/gateways/transax.rb +1 -2
- data/lib/active_merchant/billing/gateways/trexle.rb +5 -2
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +57 -47
- data/lib/active_merchant/billing/gateways/usa_epay.rb +1 -2
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +176 -184
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +60 -48
- data/lib/active_merchant/billing/gateways/vanco.rb +17 -8
- data/lib/active_merchant/billing/gateways/verifi.rb +13 -14
- data/lib/active_merchant/billing/gateways/viaklix.rb +9 -14
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +26 -21
- data/lib/active_merchant/billing/gateways/vpos.rb +223 -0
- data/lib/active_merchant/billing/gateways/webpay.rb +4 -4
- data/lib/active_merchant/billing/gateways/wepay.rb +14 -16
- data/lib/active_merchant/billing/gateways/wirecard.rb +14 -16
- data/lib/active_merchant/billing/gateways/wompi.rb +197 -0
- data/lib/active_merchant/billing/gateways/world_net.rb +36 -35
- data/lib/active_merchant/billing/gateways/worldpay.rb +556 -190
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +47 -54
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +16 -16
- data/lib/active_merchant/billing/network_tokenization_credit_card.rb +2 -2
- data/lib/active_merchant/billing/response.rb +25 -6
- data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
- data/lib/active_merchant/billing.rb +1 -0
- data/lib/active_merchant/connection.rb +14 -15
- data/lib/active_merchant/country.rb +3 -1
- data/lib/active_merchant/errors.rb +4 -1
- data/lib/active_merchant/net_http_ssl_connection.rb +1 -0
- data/lib/active_merchant/network_connection_retries.rb +15 -17
- data/lib/active_merchant/post_data.rb +3 -2
- data/lib/active_merchant/posts_data.rb +2 -2
- data/lib/active_merchant/version.rb +1 -1
- data/lib/active_merchant.rb +2 -2
- data/lib/certs/cacert.pem +1587 -2361
- data/lib/support/gateway_support.rb +1 -1
- data/lib/support/ssl_verify.rb +3 -7
- data/lib/support/ssl_version.rb +2 -3
- metadata +86 -34
- data/lib/active_merchant/billing/gateways/moneris_us.rb +0 -352
@@ -8,10 +8,10 @@ module ActiveMerchant #:nodoc:
|
|
8
8
|
# Currently Authorization and Capture is not implemented because
|
9
9
|
# capturing requires the original credit card information
|
10
10
|
TRANSACTIONS = {
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
11
|
+
purchase: 'PURCHASE',
|
12
|
+
authorization: 'AUTHORISE',
|
13
|
+
capture: 'ADVICE',
|
14
|
+
credit: 'REFUND'
|
15
15
|
}
|
16
16
|
|
17
17
|
SUCCESS = 'Accepted'
|
@@ -20,7 +20,7 @@ module ActiveMerchant #:nodoc:
|
|
20
20
|
self.supported_countries = ['AU']
|
21
21
|
self.homepage_url = 'http://www.commsecure.com.au/paysecure.shtml'
|
22
22
|
self.display_name = 'PaySecure'
|
23
|
-
self.supported_cardtypes = [
|
23
|
+
self.supported_cardtypes = %i[visa master american_express diners_club]
|
24
24
|
|
25
25
|
def initialize(options = {})
|
26
26
|
requires!(options, :login, :password)
|
@@ -43,7 +43,7 @@ module ActiveMerchant #:nodoc:
|
|
43
43
|
# Used for capturing, which is currently not supported.
|
44
44
|
def add_reference(post, identification)
|
45
45
|
auth, trans_id = identification.split(';')
|
46
|
-
post[:authnum]
|
46
|
+
post[:authnum] = auth
|
47
47
|
post[:transid] = trans_id
|
48
48
|
end
|
49
49
|
|
@@ -69,9 +69,8 @@ module ActiveMerchant #:nodoc:
|
|
69
69
|
response = parse(ssl_post(self.live_url, post_data(action, parameters)))
|
70
70
|
|
71
71
|
Response.new(successful?(response), message_from(response), response,
|
72
|
-
:
|
73
|
-
:
|
74
|
-
)
|
72
|
+
test: test_response?(response),
|
73
|
+
authorization: authorization_from(response))
|
75
74
|
end
|
76
75
|
|
77
76
|
def successful?(response)
|
@@ -79,7 +78,7 @@ module ActiveMerchant #:nodoc:
|
|
79
78
|
end
|
80
79
|
|
81
80
|
def authorization_from(response)
|
82
|
-
[
|
81
|
+
[response[:authnum], response[:transid]].compact.join(';')
|
83
82
|
end
|
84
83
|
|
85
84
|
def test_response?(response)
|
@@ -104,7 +103,7 @@ module ActiveMerchant #:nodoc:
|
|
104
103
|
parameters[:merchant_id] = @options[:login]
|
105
104
|
parameters[:password] = @options[:password]
|
106
105
|
|
107
|
-
parameters.reject { |
|
106
|
+
parameters.reject { |_k, v| v.blank? }.collect { |key, value| "#{key.to_s.upcase}=#{CGI.escape(value.to_s)}" }.join('&')
|
108
107
|
end
|
109
108
|
end
|
110
109
|
end
|
@@ -0,0 +1,450 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class PayTraceGateway < Gateway
|
4
|
+
self.test_url = 'https://api.paytrace.com'
|
5
|
+
self.live_url = 'https://api.paytrace.com'
|
6
|
+
|
7
|
+
self.supported_countries = ['US']
|
8
|
+
self.default_currency = 'USD'
|
9
|
+
self.supported_cardtypes = %i[visa master american_express discover]
|
10
|
+
|
11
|
+
self.homepage_url = 'https://paytrace.com/'
|
12
|
+
self.display_name = 'PayTrace'
|
13
|
+
|
14
|
+
# Response codes based on API Response Codes found here: https://developers.paytrace.com/support/home#14000041297
|
15
|
+
STANDARD_ERROR_CODE_MAPPING = {
|
16
|
+
'1' => STANDARD_ERROR_CODE[:error_occurred],
|
17
|
+
'102' => STANDARD_ERROR_CODE[:declined],
|
18
|
+
'103' => STANDARD_ERROR_CODE[:auto_voided],
|
19
|
+
'107' => STANDARD_ERROR_CODE[:unsuccessful_refund],
|
20
|
+
'108' => STANDARD_ERROR_CODE[:test_refund],
|
21
|
+
'110' => STANDARD_ERROR_CODE[:unsuccessful_void],
|
22
|
+
'113' => STANDARD_ERROR_CODE[:unsuccessful_capture]
|
23
|
+
}
|
24
|
+
|
25
|
+
ENDPOINTS = {
|
26
|
+
customer_id_sale: 'transactions/sale/by_customer',
|
27
|
+
keyed_sale: 'transactions/sale/keyed',
|
28
|
+
customer_id_auth: 'transactions/authorization/by_customer',
|
29
|
+
keyed_auth: 'transactions/authorization/keyed',
|
30
|
+
capture: 'transactions/authorization/capture',
|
31
|
+
transaction_refund: 'transactions/refund/for_transaction',
|
32
|
+
transaction_void: 'transactions/void',
|
33
|
+
store: 'customer/create',
|
34
|
+
redact: 'customer/delete',
|
35
|
+
level_3_visa: 'level_three/visa',
|
36
|
+
level_3_mastercard: 'level_three/mastercard',
|
37
|
+
ach_sale: 'checks/sale/by_account',
|
38
|
+
ach_customer_sale: 'checks/sale/by_customer',
|
39
|
+
ach_authorize: 'checks/hold/by_account',
|
40
|
+
ach_customer_authorize: 'checks/hold/by_customer',
|
41
|
+
ach_refund: 'checks/refund/by_transaction',
|
42
|
+
ach_capture: 'checks/manage/fund',
|
43
|
+
ach_void: 'checks/manage/void'
|
44
|
+
}
|
45
|
+
|
46
|
+
def initialize(options = {})
|
47
|
+
requires!(options, :username, :password, :integrator_id)
|
48
|
+
super
|
49
|
+
acquire_access_token
|
50
|
+
end
|
51
|
+
|
52
|
+
def purchase(money, payment_or_customer_id, options = {})
|
53
|
+
if visa_or_mastercard?(options)
|
54
|
+
MultiResponse.run(:use_first_response) do |r|
|
55
|
+
endpoint = customer_id?(payment_or_customer_id) ? ENDPOINTS[:customer_id_sale] : ENDPOINTS[:keyed_sale]
|
56
|
+
|
57
|
+
r.process { commit(endpoint, build_purchase_request(money, payment_or_customer_id, options)) }
|
58
|
+
r.process { commit(ENDPOINTS[:"level_3_#{options[:visa_or_mastercard]}"], send_level_3_data(r, options)) }
|
59
|
+
end
|
60
|
+
else
|
61
|
+
post = build_purchase_request(money, payment_or_customer_id, options)
|
62
|
+
endpoint = if payment_or_customer_id.kind_of?(Check)
|
63
|
+
ENDPOINTS[:ach_sale]
|
64
|
+
elsif options[:check_transaction]
|
65
|
+
ENDPOINTS[:ach_customer_sale]
|
66
|
+
elsif post[:customer_id]
|
67
|
+
ENDPOINTS[:customer_id_sale]
|
68
|
+
else
|
69
|
+
ENDPOINTS[:keyed_sale]
|
70
|
+
end
|
71
|
+
response = commit(endpoint, post)
|
72
|
+
check_token_response(response, endpoint, post, options)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def authorize(money, payment_or_customer_id, options = {})
|
77
|
+
post = {}
|
78
|
+
add_amount(post, money, options)
|
79
|
+
if customer_id?(payment_or_customer_id)
|
80
|
+
post[:customer_id] = payment_or_customer_id
|
81
|
+
endpoint = if options[:check_transaction]
|
82
|
+
ENDPOINTS[:ach_customer_authorize]
|
83
|
+
else
|
84
|
+
ENDPOINTS[:customer_id_auth]
|
85
|
+
end
|
86
|
+
else
|
87
|
+
add_payment(post, payment_or_customer_id)
|
88
|
+
add_address(post, payment_or_customer_id, options)
|
89
|
+
add_customer_data(post, options)
|
90
|
+
endpoint = payment_or_customer_id.kind_of?(Check) ? ENDPOINTS[:ach_authorize] : ENDPOINTS[:keyed_auth]
|
91
|
+
end
|
92
|
+
response = commit(endpoint, post)
|
93
|
+
check_token_response(response, endpoint, post, options)
|
94
|
+
end
|
95
|
+
|
96
|
+
def capture(money, authorization, options = {})
|
97
|
+
if visa_or_mastercard?(options)
|
98
|
+
MultiResponse.run do |r|
|
99
|
+
r.process { commit(ENDPOINTS[:capture], build_capture_request(money, authorization, options)) }
|
100
|
+
r.process { commit(ENDPOINTS[:"level_3_#{options[:visa_or_mastercard]}"], send_level_3_data(r, options)) }
|
101
|
+
end
|
102
|
+
else
|
103
|
+
post = build_capture_request(money, authorization, options)
|
104
|
+
endpoint = if options[:check_transaction]
|
105
|
+
ENDPOINTS[:ach_capture]
|
106
|
+
else
|
107
|
+
ENDPOINTS[:capture]
|
108
|
+
end
|
109
|
+
response = commit(endpoint, post)
|
110
|
+
check_token_response(response, endpoint, post, options)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def refund(money, authorization, options = {})
|
115
|
+
# currently only support full and partial refunds of settled transactions via a transaction ID
|
116
|
+
post = {}
|
117
|
+
add_amount(post, money, options)
|
118
|
+
if options[:check_transaction]
|
119
|
+
post[:check_transaction_id] = authorization
|
120
|
+
endpoint = ENDPOINTS[:ach_refund]
|
121
|
+
else
|
122
|
+
post[:transaction_id] = authorization
|
123
|
+
endpoint = ENDPOINTS[:transaction_refund]
|
124
|
+
end
|
125
|
+
response = commit(endpoint, post)
|
126
|
+
check_token_response(response, endpoint, post, options)
|
127
|
+
end
|
128
|
+
|
129
|
+
def void(authorization, options = {})
|
130
|
+
post = {}
|
131
|
+
if options[:check_transaction]
|
132
|
+
post[:check_transaction_id] = authorization
|
133
|
+
endpoint = ENDPOINTS[:ach_void]
|
134
|
+
else
|
135
|
+
post[:transaction_id] = authorization
|
136
|
+
endpoint = ENDPOINTS[:transaction_void]
|
137
|
+
end
|
138
|
+
|
139
|
+
response = commit(endpoint, post)
|
140
|
+
check_token_response(response, endpoint, post, options)
|
141
|
+
end
|
142
|
+
|
143
|
+
def verify(credit_card, options = {})
|
144
|
+
authorize(0, credit_card, options)
|
145
|
+
end
|
146
|
+
|
147
|
+
# The customer_IDs that come from storing cards can be used for auth and purchase transaction types
|
148
|
+
def store(credit_card, options = {})
|
149
|
+
post = {}
|
150
|
+
post[:customer_id] = options[:customer_id] || SecureRandom.hex(12)
|
151
|
+
add_payment(post, credit_card)
|
152
|
+
add_address(post, credit_card, options)
|
153
|
+
response = commit(ENDPOINTS[:store], post)
|
154
|
+
check_token_response(response, ENDPOINTS[:store], post, options)
|
155
|
+
end
|
156
|
+
|
157
|
+
def unstore(customer_id)
|
158
|
+
post = {}
|
159
|
+
post[:customer_id] = customer_id
|
160
|
+
response = commit(ENDPOINTS[:redact], post)
|
161
|
+
check_token_response(response, ENDPOINTS[:redact], post, options)
|
162
|
+
end
|
163
|
+
|
164
|
+
def supports_scrubbing?
|
165
|
+
true
|
166
|
+
end
|
167
|
+
|
168
|
+
def scrub(transcript)
|
169
|
+
transcript.
|
170
|
+
gsub(%r((Authorization: Bearer )[a-zA-Z0-9:_]+), '\1[FILTERED]').
|
171
|
+
gsub(%r(("credit_card\\?":{\\?"number\\?":\\?")\d+), '\1[FILTERED]').
|
172
|
+
gsub(%r(("cvv\\?":\\?")\d+), '\1[FILTERED]').
|
173
|
+
gsub(%r(("username\\?":\\?")\w+@+\w+.+\w+), '\1[FILTERED]').
|
174
|
+
gsub(%r(("password\\?":\\?")\w+), '\1[FILTERED]').
|
175
|
+
gsub(%r(("integrator_id\\?":\\?")\w+), '\1[FILTERED]')
|
176
|
+
end
|
177
|
+
|
178
|
+
def acquire_access_token
|
179
|
+
post = {}
|
180
|
+
post[:grant_type] = 'password'
|
181
|
+
post[:username] = @options[:username]
|
182
|
+
post[:password] = @options[:password]
|
183
|
+
data = post.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
|
184
|
+
url = live_url + '/oauth/token'
|
185
|
+
oauth_headers = {
|
186
|
+
'Accept' => '*/*',
|
187
|
+
'Content-Type' => 'application/x-www-form-urlencoded'
|
188
|
+
}
|
189
|
+
response = ssl_post(url, data, oauth_headers)
|
190
|
+
json_response = JSON.parse(response)
|
191
|
+
|
192
|
+
@options[:access_token] = json_response['access_token'] if json_response['access_token']
|
193
|
+
response
|
194
|
+
end
|
195
|
+
|
196
|
+
private
|
197
|
+
|
198
|
+
def build_purchase_request(money, payment_or_customer_id, options)
|
199
|
+
post = {}
|
200
|
+
add_amount(post, money, options)
|
201
|
+
if customer_id?(payment_or_customer_id)
|
202
|
+
post[:customer_id] = payment_or_customer_id
|
203
|
+
else
|
204
|
+
add_payment(post, payment_or_customer_id)
|
205
|
+
add_address(post, payment_or_customer_id, options)
|
206
|
+
add_customer_data(post, options)
|
207
|
+
end
|
208
|
+
|
209
|
+
post
|
210
|
+
end
|
211
|
+
|
212
|
+
def build_capture_request(money, authorization, options)
|
213
|
+
post = {}
|
214
|
+
if options[:check_transaction]
|
215
|
+
post[:check_transaction_id] = authorization
|
216
|
+
else
|
217
|
+
post[:transaction_id] = authorization
|
218
|
+
end
|
219
|
+
add_amount(post, money, options)
|
220
|
+
|
221
|
+
post
|
222
|
+
end
|
223
|
+
|
224
|
+
# method can only be used to add level 3 data to any approved and unsettled sale transaction so it is built into the standard purchase workflow above
|
225
|
+
def send_level_3_data(response, options)
|
226
|
+
post = {}
|
227
|
+
post[:transaction_id] = response.authorization
|
228
|
+
add_level_3_data(post, options)
|
229
|
+
|
230
|
+
post
|
231
|
+
end
|
232
|
+
|
233
|
+
def visa_or_mastercard?(options)
|
234
|
+
return false unless options[:visa_or_mastercard]
|
235
|
+
|
236
|
+
options[:visa_or_mastercard] == 'visa' || options[:visa_or_mastercard] == 'mastercard'
|
237
|
+
end
|
238
|
+
|
239
|
+
def customer_id?(payment_or_customer_id)
|
240
|
+
payment_or_customer_id.class == String
|
241
|
+
end
|
242
|
+
|
243
|
+
def string_literal_to_boolean(value)
|
244
|
+
return value unless value.class == String
|
245
|
+
|
246
|
+
if value.casecmp('true').zero?
|
247
|
+
true
|
248
|
+
elsif value.casecmp('false').zero?
|
249
|
+
false
|
250
|
+
else return nil
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
def add_customer_data(post, options)
|
255
|
+
return unless options[:email]
|
256
|
+
|
257
|
+
post[:email] = options[:email]
|
258
|
+
end
|
259
|
+
|
260
|
+
def add_address(post, creditcard, options)
|
261
|
+
return unless options[:billing_address] || options[:address]
|
262
|
+
|
263
|
+
address = options[:billing_address] || options[:address]
|
264
|
+
post[:billing_address] = {}
|
265
|
+
post[:billing_address][:name] = creditcard.name
|
266
|
+
post[:billing_address][:street_address] = address[:address1]
|
267
|
+
post[:billing_address][:city] = address[:city]
|
268
|
+
post[:billing_address][:state] = address[:state]
|
269
|
+
post[:billing_address][:zip] = address[:zip]
|
270
|
+
end
|
271
|
+
|
272
|
+
def add_amount(post, money, options)
|
273
|
+
post[:amount] = amount(money)
|
274
|
+
end
|
275
|
+
|
276
|
+
def add_payment(post, payment)
|
277
|
+
if payment.kind_of?(Check)
|
278
|
+
post[:check] = {}
|
279
|
+
post[:check][:account_number] = payment.account_number
|
280
|
+
post[:check][:routing_number] = payment.routing_number
|
281
|
+
else
|
282
|
+
post[:credit_card] = {}
|
283
|
+
post[:credit_card][:number] = payment.number
|
284
|
+
post[:credit_card][:expiration_month] = payment.month
|
285
|
+
post[:credit_card][:expiration_year] = payment.year
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
def add_level_3_data(post, options)
|
290
|
+
post[:invoice_id] = options[:invoice_id] if options[:invoice_id]
|
291
|
+
post[:customer_reference_id] = options[:customer_reference_id] if options[:customer_reference_id]
|
292
|
+
post[:tax_amount] = options[:tax_amount].to_i if options[:tax_amount]
|
293
|
+
post[:national_tax_amount] = options[:national_tax_amount].to_i if options[:national_tax_amount]
|
294
|
+
post[:merchant_tax_id] = options[:merchant_tax_id] if options[:merchant_tax_id]
|
295
|
+
post[:customer_tax_id] = options[:customer_tax_id] if options[:customer_tax_id]
|
296
|
+
post[:commodity_code] = options[:commodity_code] if options[:commodity_code]
|
297
|
+
post[:discount_amount] = options[:discount_amount].to_i if options[:discount_amount]
|
298
|
+
post[:freight_amount] = options[:freight_amount].to_i if options[:freight_amount]
|
299
|
+
post[:duty_amount] = options[:duty_amount].to_i if options[:duty_amount]
|
300
|
+
post[:additional_tax_amount] = options[:additional_tax_amount].to_i if options[:additional_tax_amount]
|
301
|
+
post[:additional_tax_rate] = options[:additional_tax_rate].to_i if options[:additional_tax_rate]
|
302
|
+
|
303
|
+
add_source_address(post, options)
|
304
|
+
add_shipping_address(post, options)
|
305
|
+
add_line_items(post, options)
|
306
|
+
end
|
307
|
+
|
308
|
+
def add_source_address(post, options)
|
309
|
+
return unless source_address = options[:source_address] ||
|
310
|
+
options[:billing_address] ||
|
311
|
+
options[:address]
|
312
|
+
|
313
|
+
post[:source_address] = {}
|
314
|
+
post[:source_address][:zip] = source_address[:zip] if source_address[:zip]
|
315
|
+
end
|
316
|
+
|
317
|
+
def add_shipping_address(post, options)
|
318
|
+
return unless shipping_address = options[:shipping_address]
|
319
|
+
|
320
|
+
post[:shipping_address] = {}
|
321
|
+
post[:shipping_address][:name] = shipping_address[:name] if shipping_address[:name]
|
322
|
+
post[:shipping_address][:street_address] = shipping_address[:address1] if shipping_address[:address1]
|
323
|
+
post[:shipping_address][:street_address2] = shipping_address[:address2] if shipping_address[:address2]
|
324
|
+
post[:shipping_address][:city] = shipping_address[:city] if shipping_address[:city]
|
325
|
+
post[:shipping_address][:state] = shipping_address[:state] if shipping_address[:state]
|
326
|
+
post[:shipping_address][:zip] = shipping_address[:zip] if shipping_address[:zip]
|
327
|
+
post[:shipping_address][:country] = shipping_address[:country] if shipping_address[:country]
|
328
|
+
end
|
329
|
+
|
330
|
+
def add_line_items(post, options)
|
331
|
+
return unless options[:line_items]
|
332
|
+
|
333
|
+
line_items = []
|
334
|
+
options[:line_items].each do |li|
|
335
|
+
obj = {}
|
336
|
+
|
337
|
+
obj[:additional_tax_amount] = li[:additional_tax_amount].to_i if li[:additional_tax_amount]
|
338
|
+
obj[:additional_tax_included] = string_literal_to_boolean(li[:additional_tax_included]) if li[:additional_tax_included]
|
339
|
+
obj[:additional_tax_rate] = li[:additional_tax_rate].to_i if li[:additional_tax_rate]
|
340
|
+
obj[:amount] = li[:amount].to_i if li[:amount]
|
341
|
+
obj[:commodity_code] = li[:commodity_code] if li[:commodity_code]
|
342
|
+
obj[:debit_or_credit] = li[:debit_or_credit] if li[:debit_or_credit]
|
343
|
+
obj[:description] = li[:description] if li[:description]
|
344
|
+
obj[:discount_amount] = li[:discount_amount].to_i if li[:discount_amount]
|
345
|
+
obj[:discount_rate] = li[:discount_rate].to_i if li[:discount_rate]
|
346
|
+
obj[:discount_included] = string_literal_to_boolean(li[:discount_included]) if li[:discount_included]
|
347
|
+
obj[:merchant_tax_id] = li[:merchant_tax_id] if li[:merchant_tax_id]
|
348
|
+
obj[:product_id] = li[:product_id] if li[:product_id]
|
349
|
+
obj[:quantity] = li[:quantity] if li[:quantity]
|
350
|
+
obj[:transaction_id] = li[:transaction_id] if li[:transaction_id]
|
351
|
+
obj[:tax_included] = string_literal_to_boolean(li[:tax_included]) if li[:tax_included]
|
352
|
+
obj[:unit_of_measure] = li[:unit_of_measure] if li[:unit_of_measure]
|
353
|
+
obj[:unit_cost] = li[:unit_cost].to_i if li[:unit_cost]
|
354
|
+
|
355
|
+
line_items << obj
|
356
|
+
end
|
357
|
+
post[:line_items] = line_items
|
358
|
+
end
|
359
|
+
|
360
|
+
def check_token_response(response, endpoint, body = {}, options = {})
|
361
|
+
return response unless response.params['error'] == 'invalid_token'
|
362
|
+
|
363
|
+
acquire_access_token
|
364
|
+
commit(endpoint, body)
|
365
|
+
end
|
366
|
+
|
367
|
+
def parse(body)
|
368
|
+
JSON.parse(body)
|
369
|
+
end
|
370
|
+
|
371
|
+
def commit(action, parameters)
|
372
|
+
base_url = (test? ? test_url : live_url)
|
373
|
+
url = base_url + '/v1/' + action
|
374
|
+
raw_response = ssl_post(url, post_data(parameters), headers)
|
375
|
+
response = parse(raw_response)
|
376
|
+
success = success_from(response)
|
377
|
+
|
378
|
+
Response.new(
|
379
|
+
success,
|
380
|
+
message_from(success, response),
|
381
|
+
response,
|
382
|
+
authorization: authorization_from(action, response),
|
383
|
+
avs_result: AVSResult.new(code: response['avs_response']),
|
384
|
+
cvv_result: response['csc_response'],
|
385
|
+
test: test?,
|
386
|
+
error_code: success ? nil : error_code_from(response)
|
387
|
+
)
|
388
|
+
rescue JSON::ParserError
|
389
|
+
unparsable_response(raw_response)
|
390
|
+
end
|
391
|
+
|
392
|
+
def unparsable_response(raw_response)
|
393
|
+
message = 'Unparsable response received from PayTrace. Please contact PayTrace if you continue to receive this message.'
|
394
|
+
message += " (The raw response returned by the API was #{raw_response.inspect})"
|
395
|
+
return Response.new(false, message)
|
396
|
+
end
|
397
|
+
|
398
|
+
def headers
|
399
|
+
{
|
400
|
+
'Content-type' => 'application/json',
|
401
|
+
'Authorization' => 'Bearer ' + @options[:access_token]
|
402
|
+
}
|
403
|
+
end
|
404
|
+
|
405
|
+
def success_from(response)
|
406
|
+
response['success']
|
407
|
+
end
|
408
|
+
|
409
|
+
def message_from(success, response)
|
410
|
+
return response['status_message'] if success
|
411
|
+
|
412
|
+
if error = response['errors']
|
413
|
+
message = 'Errors-'
|
414
|
+
error.each do |k, v|
|
415
|
+
message.concat(" code:#{k}, message:#{v}")
|
416
|
+
end
|
417
|
+
else
|
418
|
+
message = response['status_message'].to_s + " #{response['approval_message']}"
|
419
|
+
end
|
420
|
+
|
421
|
+
message
|
422
|
+
end
|
423
|
+
|
424
|
+
# store transactions do not return a transaction_id, but they return a customer_id that will then be used as the third_party_token for the stored payment method
|
425
|
+
def authorization_from(action, response)
|
426
|
+
if action == ENDPOINTS[:store]
|
427
|
+
response['customer_id']
|
428
|
+
else
|
429
|
+
response['transaction_id'] || response['check_transaction_id']
|
430
|
+
end
|
431
|
+
end
|
432
|
+
|
433
|
+
def post_data(parameters = {})
|
434
|
+
parameters[:password] = @options[:password]
|
435
|
+
parameters[:username] = @options[:username]
|
436
|
+
parameters[:integrator_id] = @options[:integrator_id]
|
437
|
+
|
438
|
+
parameters.to_json
|
439
|
+
end
|
440
|
+
|
441
|
+
def error_code_from(response)
|
442
|
+
STANDARD_ERROR_CODE_MAPPING[response['response_code']]
|
443
|
+
end
|
444
|
+
|
445
|
+
def handle_response(response)
|
446
|
+
response.body
|
447
|
+
end
|
448
|
+
end
|
449
|
+
end
|
450
|
+
end
|
@@ -12,34 +12,34 @@ module ActiveMerchant #:nodoc:
|
|
12
12
|
|
13
13
|
# Transactions hash
|
14
14
|
TRANSACTIONS = {
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
20
|
-
:
|
15
|
+
authorization: '00001',
|
16
|
+
capture: '00002',
|
17
|
+
purchase: '00003',
|
18
|
+
unreferenced_credit: '00004',
|
19
|
+
void: '00005',
|
20
|
+
refund: '00014'
|
21
21
|
}
|
22
22
|
|
23
23
|
CURRENCY_CODES = {
|
24
|
-
'AUD'=> '036',
|
25
|
-
'CAD'=> '124',
|
26
|
-
'CZK'=> '203',
|
27
|
-
'DKK'=> '208',
|
28
|
-
'HKD'=> '344',
|
29
|
-
'ICK'=> '352',
|
30
|
-
'JPY'=> '392',
|
31
|
-
'NOK'=> '578',
|
32
|
-
'SGD'=> '702',
|
33
|
-
'SEK'=> '752',
|
34
|
-
'CHF'=> '756',
|
35
|
-
'GBP'=> '826',
|
36
|
-
'USD'=> '840',
|
37
|
-
'EUR'=> '978',
|
38
|
-
'XPF'=> '953'
|
24
|
+
'AUD' => '036',
|
25
|
+
'CAD' => '124',
|
26
|
+
'CZK' => '203',
|
27
|
+
'DKK' => '208',
|
28
|
+
'HKD' => '344',
|
29
|
+
'ICK' => '352',
|
30
|
+
'JPY' => '392',
|
31
|
+
'NOK' => '578',
|
32
|
+
'SGD' => '702',
|
33
|
+
'SEK' => '752',
|
34
|
+
'CHF' => '756',
|
35
|
+
'GBP' => '826',
|
36
|
+
'USD' => '840',
|
37
|
+
'EUR' => '978',
|
38
|
+
'XPF' => '953'
|
39
39
|
}
|
40
40
|
|
41
41
|
SUCCESS_CODES = ['00000']
|
42
|
-
UNAVAILABILITY_CODES = [
|
42
|
+
UNAVAILABILITY_CODES = %w[00001 00097 00098]
|
43
43
|
SUCCESS_MESSAGE = 'The transaction was approved'
|
44
44
|
FAILURE_MESSAGE = 'The transaction failed'
|
45
45
|
|
@@ -51,7 +51,7 @@ module ActiveMerchant #:nodoc:
|
|
51
51
|
self.supported_countries = ['FR']
|
52
52
|
|
53
53
|
# The card types supported by the payment gateway
|
54
|
-
self.supported_cardtypes = [
|
54
|
+
self.supported_cardtypes = %i[visa master american_express diners_club jcb]
|
55
55
|
|
56
56
|
# The homepage URL of the gateway
|
57
57
|
self.homepage_url = 'http://www.paybox.com/'
|
@@ -64,10 +64,31 @@ module ActiveMerchant #:nodoc:
|
|
64
64
|
super
|
65
65
|
end
|
66
66
|
|
67
|
+
def add_3dsecure(post, options)
|
68
|
+
# ECI=02 => MasterCard success
|
69
|
+
# ECI=05 => Visa, Amex or JCB success
|
70
|
+
if options[:eci] == '02' || options[:eci] == '05'
|
71
|
+
post[:"3DSTATUS"] = 'Y'
|
72
|
+
post[:"3DENROLLED"] = 'Y'
|
73
|
+
post[:"3DSIGNVAL"] = 'Y'
|
74
|
+
post[:"3DERROR"] = '0'
|
75
|
+
else
|
76
|
+
post[:"3DSTATUS"] = 'N'
|
77
|
+
post[:"3DENROLLED"] = 'N'
|
78
|
+
post[:"3DSIGNVAL"] = 'N'
|
79
|
+
post[:"3DERROR"] = '10000'
|
80
|
+
end
|
81
|
+
post[:"3DECI"] = options[:eci]
|
82
|
+
post[:"3DXID"] = options[:xid]
|
83
|
+
post[:"3DCAVV"] = options[:cavv]
|
84
|
+
post[:"3DCAVVALGO"] = options[:cavv_algorithm]
|
85
|
+
end
|
86
|
+
|
67
87
|
def authorize(money, creditcard, options = {})
|
68
88
|
post = {}
|
69
89
|
add_invoice(post, options)
|
70
90
|
add_creditcard(post, creditcard)
|
91
|
+
add_3dsecure(post, options[:three_d_secure]) if options[:three_d_secure]
|
71
92
|
add_amount(post, money, options)
|
72
93
|
|
73
94
|
commit('authorization', money, post)
|
@@ -77,6 +98,7 @@ module ActiveMerchant #:nodoc:
|
|
77
98
|
post = {}
|
78
99
|
add_invoice(post, options)
|
79
100
|
add_creditcard(post, creditcard)
|
101
|
+
add_3dsecure(post, options[:three_d_secure]) if options[:three_d_secure]
|
80
102
|
add_amount(post, money, options)
|
81
103
|
|
82
104
|
commit('purchase', money, post)
|
@@ -95,7 +117,7 @@ module ActiveMerchant #:nodoc:
|
|
95
117
|
|
96
118
|
def void(identification, options = {})
|
97
119
|
requires!(options, :order_id, :amount)
|
98
|
-
post ={}
|
120
|
+
post = {}
|
99
121
|
add_invoice(post, options)
|
100
122
|
add_reference(post, identification)
|
101
123
|
add_amount(post, options[:amount], options)
|
@@ -153,12 +175,14 @@ module ActiveMerchant #:nodoc:
|
|
153
175
|
request_data = post_data(action, parameters)
|
154
176
|
response = parse(ssl_post(test? ? self.test_url : self.live_url, request_data))
|
155
177
|
response = parse(ssl_post(self.live_url_backup, request_data)) if service_unavailable?(response) && !test?
|
156
|
-
Response.new(
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
:
|
161
|
-
:
|
178
|
+
Response.new(
|
179
|
+
success?(response),
|
180
|
+
message_from(response),
|
181
|
+
response.merge(timestamp: parameters[:dateq]),
|
182
|
+
test: test?,
|
183
|
+
authorization: response[:numappel].to_s + response[:numtrans].to_s,
|
184
|
+
fraud_review: false,
|
185
|
+
sent_params: parameters.delete_if { |key, _value| %w[porteur dateval cvv].include?(key.to_s) }
|
162
186
|
)
|
163
187
|
end
|
164
188
|
|
@@ -171,20 +195,20 @@ module ActiveMerchant #:nodoc:
|
|
171
195
|
end
|
172
196
|
|
173
197
|
def message_from(response)
|
174
|
-
success?(response) ? SUCCESS_MESSAGE : (response[:commentaire]
|
198
|
+
success?(response) ? SUCCESS_MESSAGE : (response[:commentaire] || FAILURE_MESSAGE)
|
175
199
|
end
|
176
200
|
|
177
201
|
def post_data(action, parameters = {})
|
178
202
|
parameters.update(
|
179
|
-
:
|
180
|
-
:
|
181
|
-
:
|
182
|
-
:
|
183
|
-
:
|
184
|
-
:
|
185
|
-
:
|
186
|
-
:
|
187
|
-
:
|
203
|
+
version: API_VERSION,
|
204
|
+
type: TRANSACTIONS[action.to_sym],
|
205
|
+
dateq: Time.now.strftime('%d%m%Y%H%M%S'),
|
206
|
+
numquestion: unique_id(parameters[:order_id]),
|
207
|
+
site: @options[:login].to_s[0, 7],
|
208
|
+
rang: @options[:rang] || @options[:login].to_s[7..-1],
|
209
|
+
cle: @options[:password],
|
210
|
+
pays: '',
|
211
|
+
archivage: parameters[:order_id]
|
188
212
|
)
|
189
213
|
|
190
214
|
parameters.collect { |key, value| "#{key.to_s.upcase}=#{CGI.escape(value.to_s)}" }.join('&')
|