activemerchant 1.133.0 → 1.138.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +450 -0
- data/CONTRIBUTORS +1 -0
- data/lib/active_merchant/billing/apple_pay_payment_token.rb +2 -2
- data/lib/active_merchant/billing/base.rb +2 -2
- data/lib/active_merchant/billing/check.rb +16 -4
- data/lib/active_merchant/billing/compatibility.rb +4 -4
- data/lib/active_merchant/billing/credit_card.rb +35 -16
- data/lib/active_merchant/billing/credit_card_formatting.rb +13 -2
- data/lib/active_merchant/billing/credit_card_methods.rb +74 -19
- data/lib/active_merchant/billing/gateway.rb +22 -2
- data/lib/active_merchant/billing/gateways/adyen.rb +282 -87
- data/lib/active_merchant/billing/gateways/airwallex.rb +46 -25
- data/lib/active_merchant/billing/gateways/alelo.rb +29 -11
- data/lib/active_merchant/billing/gateways/allied_wallet.rb +2 -2
- data/lib/active_merchant/billing/gateways/authorize_net.rb +49 -41
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +14 -10
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +3 -5
- data/lib/active_merchant/billing/gateways/axcessms.rb +9 -5
- data/lib/active_merchant/billing/gateways/balanced.rb +2 -2
- data/lib/active_merchant/billing/gateways/bambora_apac.rb +2 -2
- data/lib/active_merchant/billing/gateways/bank_frick.rb +2 -2
- data/lib/active_merchant/billing/gateways/banwire.rb +6 -4
- data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +8 -8
- data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +2 -2
- data/lib/active_merchant/billing/gateways/be2bill.rb +2 -2
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +12 -8
- data/lib/active_merchant/billing/gateways/beanstream.rb +2 -2
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +2 -2
- data/lib/active_merchant/billing/gateways/blue_pay.rb +15 -7
- data/lib/active_merchant/billing/gateways/blue_snap.rb +5 -5
- data/lib/active_merchant/billing/gateways/bogus.rb +2 -2
- data/lib/active_merchant/billing/gateways/borgun.rb +2 -2
- data/lib/active_merchant/billing/gateways/bpoint.rb +2 -2
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +3 -1
- data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +68 -23
- data/lib/active_merchant/billing/gateways/braintree.rb +2 -2
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +266 -89
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +3 -3
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +2 -2
- data/lib/active_merchant/billing/gateways/cams.rb +2 -2
- data/lib/active_merchant/billing/gateways/card_connect.rb +7 -4
- data/lib/active_merchant/billing/gateways/card_save.rb +2 -2
- data/lib/active_merchant/billing/gateways/card_stream.rb +12 -13
- data/lib/active_merchant/billing/gateways/cardknox.rb +2 -2
- data/lib/active_merchant/billing/gateways/cardprocess.rb +2 -2
- data/lib/active_merchant/billing/gateways/cashnet.rb +4 -4
- data/lib/active_merchant/billing/gateways/cc5.rb +2 -2
- data/lib/active_merchant/billing/gateways/cecabank/cecabank_common.rb +36 -0
- data/lib/active_merchant/billing/gateways/cecabank/cecabank_json.rb +331 -0
- data/lib/active_merchant/billing/gateways/cecabank/cecabank_xml.rb +220 -0
- data/lib/active_merchant/billing/gateways/cecabank.rb +9 -242
- data/lib/active_merchant/billing/gateways/cenpos.rb +9 -3
- data/lib/active_merchant/billing/gateways/checkout.rb +5 -5
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +362 -50
- data/lib/active_merchant/billing/gateways/clearhaus.rb +2 -2
- data/lib/active_merchant/billing/gateways/commerce_hub.rb +117 -35
- data/lib/active_merchant/billing/gateways/commercegate.rb +4 -4
- data/lib/active_merchant/billing/gateways/conekta.rb +2 -2
- data/lib/active_merchant/billing/gateways/creditcall.rb +2 -2
- data/lib/active_merchant/billing/gateways/credorax.rb +109 -20
- data/lib/active_merchant/billing/gateways/ct_payment.rb +6 -6
- data/lib/active_merchant/billing/gateways/culqi.rb +2 -2
- data/lib/active_merchant/billing/gateways/cyber_source/cyber_source_common.rb +2 -2
- data/lib/active_merchant/billing/gateways/cyber_source.rb +379 -100
- data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +147 -76
- data/lib/active_merchant/billing/gateways/d_local.rb +45 -22
- data/lib/active_merchant/billing/gateways/data_cash.rb +22 -18
- data/lib/active_merchant/billing/gateways/datatrans.rb +284 -0
- data/lib/active_merchant/billing/gateways/decidir.rb +82 -46
- data/lib/active_merchant/billing/gateways/decidir_plus.rb +31 -35
- data/lib/active_merchant/billing/gateways/deepstack.rb +382 -0
- data/lib/active_merchant/billing/gateways/dibs.rb +3 -3
- data/lib/active_merchant/billing/gateways/digitzs.rb +2 -2
- data/lib/active_merchant/billing/gateways/ebanx.rb +116 -68
- data/lib/active_merchant/billing/gateways/efsnet.rb +13 -8
- data/lib/active_merchant/billing/gateways/elavon.rb +80 -47
- data/lib/active_merchant/billing/gateways/element.rb +39 -10
- data/lib/active_merchant/billing/gateways/epay.rb +8 -4
- data/lib/active_merchant/billing/gateways/evo_ca.rb +8 -4
- data/lib/active_merchant/billing/gateways/eway.rb +6 -4
- data/lib/active_merchant/billing/gateways/eway_managed.rb +8 -4
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +3 -3
- data/lib/active_merchant/billing/gateways/exact.rb +8 -4
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +37 -7
- data/lib/active_merchant/billing/gateways/federated_canada.rb +8 -4
- data/lib/active_merchant/billing/gateways/finansbank.rb +2 -2
- data/lib/active_merchant/billing/gateways/first_giving.rb +2 -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 +8 -174
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +8 -4
- data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +9 -5
- data/lib/active_merchant/billing/gateways/flex_charge.rb +359 -0
- data/lib/active_merchant/billing/gateways/flo2cash.rb +4 -2
- data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +2 -2
- data/lib/active_merchant/billing/gateways/forte.rb +6 -4
- data/lib/active_merchant/billing/gateways/fortis.rb +347 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +6 -4
- data/lib/active_merchant/billing/gateways/global_collect.rb +69 -50
- data/lib/active_merchant/billing/gateways/global_transport.rb +2 -2
- data/lib/active_merchant/billing/gateways/hdfc.rb +2 -2
- data/lib/active_merchant/billing/gateways/hi_pay.rb +287 -0
- data/lib/active_merchant/billing/gateways/hps.rb +40 -47
- data/lib/active_merchant/billing/gateways/iats_payments.rb +9 -4
- data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +2 -2
- data/lib/active_merchant/billing/gateways/inspire.rb +8 -6
- data/lib/active_merchant/billing/gateways/instapay.rb +9 -6
- data/lib/active_merchant/billing/gateways/ipg.rb +14 -10
- data/lib/active_merchant/billing/gateways/ipp.rb +2 -2
- data/lib/active_merchant/billing/gateways/iridium.rb +18 -8
- data/lib/active_merchant/billing/gateways/itransact.rb +8 -4
- data/lib/active_merchant/billing/gateways/iveri.rb +12 -9
- data/lib/active_merchant/billing/gateways/ixopay.rb +4 -4
- data/lib/active_merchant/billing/gateways/jetpay.rb +6 -4
- data/lib/active_merchant/billing/gateways/jetpay_v2.rb +9 -6
- data/lib/active_merchant/billing/gateways/komoju.rb +2 -2
- data/lib/active_merchant/billing/gateways/kushki.rb +79 -16
- data/lib/active_merchant/billing/gateways/latitude19.rb +2 -2
- data/lib/active_merchant/billing/gateways/linkpoint.rb +8 -4
- data/lib/active_merchant/billing/gateways/litle.rb +37 -54
- data/lib/active_merchant/billing/gateways/loan_payment_pro.rb +267 -0
- data/lib/active_merchant/billing/gateways/loan_payment_pro_ach.rb +93 -0
- data/lib/active_merchant/billing/gateways/mastercard.rb +4 -4
- data/lib/active_merchant/billing/gateways/maxipago.rb +4 -4
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +32 -11
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +10 -7
- data/lib/active_merchant/billing/gateways/merchant_one.rb +2 -2
- data/lib/active_merchant/billing/gateways/merchant_partners.rb +2 -2
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +13 -6
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +13 -6
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +21 -5
- data/lib/active_merchant/billing/gateways/mercury.rb +11 -5
- data/lib/active_merchant/billing/gateways/metrics_global.rb +10 -8
- data/lib/active_merchant/billing/gateways/micropayment.rb +2 -2
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +7 -6
- data/lib/active_merchant/billing/gateways/migs.rb +8 -4
- data/lib/active_merchant/billing/gateways/mit.rb +10 -5
- data/lib/active_merchant/billing/gateways/modern_payments.rb +2 -2
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +21 -13
- data/lib/active_merchant/billing/gateways/moka.rb +2 -2
- data/lib/active_merchant/billing/gateways/monei.rb +3 -3
- data/lib/active_merchant/billing/gateways/moneris.rb +11 -5
- data/lib/active_merchant/billing/gateways/money_movers.rb +8 -4
- data/lib/active_merchant/billing/gateways/multi_pay.rb +267 -0
- data/lib/active_merchant/billing/gateways/mundipagg.rb +5 -3
- data/lib/active_merchant/billing/gateways/nab_transact.rb +18 -10
- data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +2 -2
- data/lib/active_merchant/billing/gateways/net_registry.rb +6 -2
- data/lib/active_merchant/billing/gateways/netaxept.rb +4 -4
- data/lib/active_merchant/billing/gateways/netbanx.rb +4 -6
- data/lib/active_merchant/billing/gateways/netbilling.rb +8 -4
- data/lib/active_merchant/billing/gateways/netpay.rb +2 -2
- data/lib/active_merchant/billing/gateways/network_merchants.rb +9 -5
- data/lib/active_merchant/billing/gateways/nmi.rb +29 -8
- data/lib/active_merchant/billing/gateways/nuvei.rb +573 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +8 -4
- data/lib/active_merchant/billing/gateways/omise.rb +2 -2
- data/lib/active_merchant/billing/gateways/openpay.rb +6 -4
- data/lib/active_merchant/billing/gateways/opp.rb +3 -4
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +12 -6
- data/lib/active_merchant/billing/gateways/orbital/orbital_codes.rb +273 -0
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +3 -5
- data/lib/active_merchant/billing/gateways/orbital.rb +114 -94
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +9 -6
- data/lib/active_merchant/billing/gateways/pagarme.rb +2 -2
- data/lib/active_merchant/billing/gateways/pago_facil.rb +2 -2
- data/lib/active_merchant/billing/gateways/pay_arc.rb +9 -7
- data/lib/active_merchant/billing/gateways/pay_conex.rb +6 -4
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +8 -4
- data/lib/active_merchant/billing/gateways/pay_hub.rb +7 -5
- data/lib/active_merchant/billing/gateways/pay_junction.rb +8 -4
- data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +2 -2
- data/lib/active_merchant/billing/gateways/pay_secure.rb +8 -4
- data/lib/active_merchant/billing/gateways/pay_trace.rb +36 -22
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +14 -14
- data/lib/active_merchant/billing/gateways/payeezy.rb +26 -13
- data/lib/active_merchant/billing/gateways/payex.rb +8 -6
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +3 -3
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +2 -2
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +2 -2
- data/lib/active_merchant/billing/gateways/payflow.rb +12 -11
- data/lib/active_merchant/billing/gateways/payflow_express.rb +2 -2
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +2 -2
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +2 -2
- data/lib/active_merchant/billing/gateways/payment_express.rb +10 -6
- data/lib/active_merchant/billing/gateways/paymentez.rb +30 -16
- data/lib/active_merchant/billing/gateways/paymill.rb +6 -4
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +17 -12
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +2 -2
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +2 -2
- data/lib/active_merchant/billing/gateways/paypal.rb +4 -2
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +2 -2
- data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +2 -2
- data/lib/active_merchant/billing/gateways/paypal_express.rb +4 -2
- data/lib/active_merchant/billing/gateways/paysafe.rb +48 -24
- data/lib/active_merchant/billing/gateways/payscout.rb +9 -6
- data/lib/active_merchant/billing/gateways/paystation.rb +9 -5
- data/lib/active_merchant/billing/gateways/payu_in.rb +2 -2
- data/lib/active_merchant/billing/gateways/payu_latam.rb +7 -5
- data/lib/active_merchant/billing/gateways/payway.rb +6 -2
- data/lib/active_merchant/billing/gateways/payway_dot_com.rb +6 -6
- data/lib/active_merchant/billing/gateways/pin.rb +126 -41
- data/lib/active_merchant/billing/gateways/plexo.rb +71 -20
- data/lib/active_merchant/billing/gateways/plugnpay.rb +6 -2
- data/lib/active_merchant/billing/gateways/priority.rb +29 -24
- data/lib/active_merchant/billing/gateways/pro_pay.rb +2 -2
- data/lib/active_merchant/billing/gateways/psigate.rb +8 -4
- data/lib/active_merchant/billing/gateways/psl_card.rb +6 -2
- data/lib/active_merchant/billing/gateways/qbms.rb +9 -5
- data/lib/active_merchant/billing/gateways/quantum.rb +9 -5
- data/lib/active_merchant/billing/gateways/quickbooks.rb +27 -17
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +7 -4
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +8 -4
- data/lib/active_merchant/billing/gateways/quickpay.rb +2 -2
- data/lib/active_merchant/billing/gateways/qvalent.rb +2 -2
- data/lib/active_merchant/billing/gateways/rapyd.rb +172 -53
- data/lib/active_merchant/billing/gateways/reach.rb +16 -9
- data/lib/active_merchant/billing/gateways/redsys.rb +7 -15
- data/lib/active_merchant/billing/gateways/redsys_rest.rb +545 -0
- data/lib/active_merchant/billing/gateways/s5.rb +5 -5
- data/lib/active_merchant/billing/gateways/safe_charge.rb +47 -24
- data/lib/active_merchant/billing/gateways/sage.rb +14 -6
- data/lib/active_merchant/billing/gateways/sage_pay.rb +81 -7
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +8 -4
- data/lib/active_merchant/billing/gateways/secure_net.rb +9 -5
- data/lib/active_merchant/billing/gateways/secure_pay.rb +10 -8
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +25 -15
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +8 -4
- data/lib/active_merchant/billing/gateways/securion_pay.rb +26 -12
- data/lib/active_merchant/billing/gateways/shift4.rb +34 -26
- data/lib/active_merchant/billing/gateways/shift4_v2.rb +117 -0
- data/lib/active_merchant/billing/gateways/simetrik.rb +26 -17
- data/lib/active_merchant/billing/gateways/skip_jack.rb +8 -4
- data/lib/active_merchant/billing/gateways/smart_ps.rb +10 -7
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +6 -4
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +4 -6
- data/lib/active_merchant/billing/gateways/stripe.rb +88 -84
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +388 -77
- data/lib/active_merchant/billing/gateways/sum_up.rb +224 -0
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +6 -4
- data/lib/active_merchant/billing/gateways/telr.rb +6 -7
- data/lib/active_merchant/billing/gateways/trans_first.rb +6 -4
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +10 -18
- data/lib/active_merchant/billing/gateways/transact_pro.rb +3 -3
- data/lib/active_merchant/billing/gateways/transax.rb +2 -2
- data/lib/active_merchant/billing/gateways/transnational.rb +2 -2
- data/lib/active_merchant/billing/gateways/trexle.rb +2 -2
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +9 -5
- data/lib/active_merchant/billing/gateways/usa_epay.rb +2 -2
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +32 -31
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +8 -4
- data/lib/active_merchant/billing/gateways/vanco.rb +2 -4
- data/lib/active_merchant/billing/gateways/vantiv_express.rb +668 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +12 -8
- data/lib/active_merchant/billing/gateways/versa_pay.rb +307 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +8 -4
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +5 -5
- data/lib/active_merchant/billing/gateways/vpos.rb +25 -13
- data/lib/active_merchant/billing/gateways/webpay.rb +3 -3
- data/lib/active_merchant/billing/gateways/wepay.rb +6 -4
- data/lib/active_merchant/billing/gateways/wirecard.rb +10 -6
- data/lib/active_merchant/billing/gateways/wompi.rb +14 -7
- data/lib/active_merchant/billing/gateways/world_net.rb +2 -2
- data/lib/active_merchant/billing/gateways/worldpay.rb +297 -113
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +16 -13
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +2 -2
- data/lib/active_merchant/billing/gateways/xpay.rb +244 -0
- data/lib/active_merchant/billing/network_tokenization_credit_card.rb +15 -3
- data/lib/active_merchant/billing/payment_token.rb +2 -2
- data/lib/active_merchant/billing/response.rb +7 -6
- data/lib/active_merchant/billing.rb +1 -0
- data/lib/active_merchant/connection.rb +8 -20
- data/lib/active_merchant/country.rb +3 -1
- data/lib/active_merchant/errors.rb +12 -2
- data/lib/active_merchant/net_http_ssl_connection.rb +35 -0
- data/lib/active_merchant/posts_data.rb +19 -4
- data/lib/active_merchant/version.rb +1 -1
- data/lib/active_merchant/versionable.rb +29 -0
- data/lib/certs/cacert.pem +1326 -1491
- data/lib/support/gateway_support.rb +3 -3
- data/lib/support/ssl_verify.rb +6 -6
- data/lib/support/ssl_version.rb +8 -8
- metadata +35 -9
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
module ActiveMerchant
|
|
2
|
-
module Billing
|
|
1
|
+
module ActiveMerchant # :nodoc:
|
|
2
|
+
module Billing # :nodoc:
|
|
3
3
|
class ReachGateway < Gateway
|
|
4
4
|
self.test_url = 'https://checkout.rch.how/'
|
|
5
5
|
self.live_url = 'https://checkout.rch.io/'
|
|
6
6
|
|
|
7
|
-
self.supported_countries =
|
|
7
|
+
self.supported_countries = %w(AE AG AL AM AT AU AW AZ BA BB BD BE BF BG BH BJ BM BN BO BR BS BW BZ CA CD CF
|
|
8
|
+
CH CI CL CM CN CO CR CU CV CY CZ DE DJ DK DM DO DZ EE EG ES ET FI FJ FK FR GA
|
|
9
|
+
GB GD GE GG GH GI GN GR GT GU GW GY HK HN HR HU ID IE IL IM IN IS IT JE JM JO
|
|
10
|
+
JP KE KG KH KM KN KR KW KY KZ LA LC LK LR LT LU LV LY MA MD MK ML MN MO MR MS
|
|
11
|
+
MT MU MV MW MX MY MZ NA NC NE NG NI NL NO NP NZ OM PA PE PF PG PH PK PL PT PY
|
|
12
|
+
QA RO RS RW SA SB SC SE SG SH SI SK SL SN SO SR ST SV SY SZ TD TG TH TN TO TR
|
|
13
|
+
TT TV TW TZ UG US UY UZ VC VN VU WF WS YE ZM)
|
|
14
|
+
|
|
8
15
|
self.default_currency = 'USD'
|
|
9
16
|
self.supported_cardtypes = %i[visa diners_club american_express jcb master discover maestro]
|
|
10
17
|
|
|
@@ -12,7 +19,7 @@ module ActiveMerchant #:nodoc:
|
|
|
12
19
|
self.display_name = 'Reach'
|
|
13
20
|
self.currencies_without_fractions = %w(BIF BYR CLF CLP CVE DJF GNF ISK JPY KMF KRW PYG RWF UGX UYI VND VUV XAF XOF XPF IDR MGA MRO)
|
|
14
21
|
|
|
15
|
-
|
|
22
|
+
version 'v2.22'
|
|
16
23
|
STANDARD_ERROR_CODE_MAPPING = {}
|
|
17
24
|
PAYMENT_METHOD_MAP = {
|
|
18
25
|
american_express: 'AMEX',
|
|
@@ -40,7 +47,7 @@ module ActiveMerchant #:nodoc:
|
|
|
40
47
|
add_custom_fields_data(request, options)
|
|
41
48
|
add_customer_data(request, options, payment)
|
|
42
49
|
add_stored_credentials(request, options)
|
|
43
|
-
post = { request
|
|
50
|
+
post = { request:, card: add_payment(payment, options) }
|
|
44
51
|
if options[:stored_credential]
|
|
45
52
|
MultiResponse.run(:use_first_response) do |r|
|
|
46
53
|
r.process { commit('checkout', post) }
|
|
@@ -71,10 +78,10 @@ module ActiveMerchant #:nodoc:
|
|
|
71
78
|
|
|
72
79
|
def scrub(transcript)
|
|
73
80
|
transcript.
|
|
74
|
-
gsub(%r(((MerchantId)[% \w]
|
|
81
|
+
gsub(%r(((MerchantId)[% \w]+%\d{2})[\w -]+), '\1[FILTERED]').
|
|
75
82
|
gsub(%r((signature=)[\w%]+), '\1[FILTERED]\2').
|
|
76
|
-
gsub(%r((Number%22%3A%22)
|
|
77
|
-
gsub(%r((VerificationCode%22%3A)
|
|
83
|
+
gsub(%r((Number%22%3A%22)\d+), '\1[FILTERED]\2').
|
|
84
|
+
gsub(%r((VerificationCode%22%3A)\d+), '\1[FILTERED]\2')
|
|
78
85
|
end
|
|
79
86
|
|
|
80
87
|
def refund(amount, authorization, options = {})
|
|
@@ -270,7 +277,7 @@ module ActiveMerchant #:nodoc:
|
|
|
270
277
|
end
|
|
271
278
|
|
|
272
279
|
def url(action)
|
|
273
|
-
"#{test? ? test_url : live_url}#{
|
|
280
|
+
"#{test? ? test_url : live_url}#{fetch_version}/#{action}"
|
|
274
281
|
end
|
|
275
282
|
end
|
|
276
283
|
end
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
require 'nokogiri'
|
|
4
4
|
|
|
5
|
-
module ActiveMerchant
|
|
6
|
-
module Billing
|
|
5
|
+
module ActiveMerchant # :nodoc:
|
|
6
|
+
module Billing # :nodoc:
|
|
7
7
|
# = Redsys Merchant Gateway
|
|
8
8
|
#
|
|
9
9
|
# Gateway support for the Spanish "Redsys" payment gateway system. This is
|
|
@@ -44,7 +44,7 @@ module ActiveMerchant #:nodoc:
|
|
|
44
44
|
self.money_format = :cents
|
|
45
45
|
|
|
46
46
|
# Not all card types may be activated by the bank!
|
|
47
|
-
self.supported_cardtypes = %i[visa master american_express jcb diners_club unionpay]
|
|
47
|
+
self.supported_cardtypes = %i[visa master american_express jcb diners_club unionpay patagonia_365 tarjeta_sol]
|
|
48
48
|
self.homepage_url = 'http://www.redsys.es/'
|
|
49
49
|
self.display_name = 'Redsys'
|
|
50
50
|
|
|
@@ -247,7 +247,7 @@ module ActiveMerchant #:nodoc:
|
|
|
247
247
|
data = {}
|
|
248
248
|
add_action(data, :cancel)
|
|
249
249
|
order_id, amount, currency = split_authorization(authorization)
|
|
250
|
-
add_amount(data, amount, currency:
|
|
250
|
+
add_amount(data, amount, currency:)
|
|
251
251
|
add_order(data, order_id)
|
|
252
252
|
data[:description] = options[:description]
|
|
253
253
|
|
|
@@ -266,14 +266,7 @@ module ActiveMerchant #:nodoc:
|
|
|
266
266
|
end
|
|
267
267
|
|
|
268
268
|
def verify(creditcard, options = {})
|
|
269
|
-
|
|
270
|
-
purchase(0, creditcard, options)
|
|
271
|
-
else
|
|
272
|
-
MultiResponse.run(:use_first_response) do |r|
|
|
273
|
-
r.process { authorize(100, creditcard, options) }
|
|
274
|
-
r.process(:ignore_result) { void(r.authorization, options) }
|
|
275
|
-
end
|
|
276
|
-
end
|
|
269
|
+
purchase(0, creditcard, options)
|
|
277
270
|
end
|
|
278
271
|
|
|
279
272
|
def supports_scrubbing
|
|
@@ -328,7 +321,7 @@ module ActiveMerchant #:nodoc:
|
|
|
328
321
|
year = sprintf('%.4i', card.year)
|
|
329
322
|
month = sprintf('%.2i', card.month)
|
|
330
323
|
data[:card] = {
|
|
331
|
-
name
|
|
324
|
+
name:,
|
|
332
325
|
pan: card.number,
|
|
333
326
|
date: "#{year[2..3]}#{month}",
|
|
334
327
|
cvv: card.verification_value
|
|
@@ -696,8 +689,7 @@ module ActiveMerchant #:nodoc:
|
|
|
696
689
|
|
|
697
690
|
order_id += "\0" until order_id.bytesize % block_length == 0 # Pad with zeros
|
|
698
691
|
|
|
699
|
-
|
|
700
|
-
output
|
|
692
|
+
cipher.update(order_id) + cipher.final
|
|
701
693
|
end
|
|
702
694
|
|
|
703
695
|
def mac256(key, data)
|
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
module ActiveMerchant # :nodoc:
|
|
4
|
+
module Billing # :nodoc:
|
|
5
|
+
# = Redsys Merchant Gateway
|
|
6
|
+
#
|
|
7
|
+
# Gateway support for the Spanish "Redsys" payment gateway system. This is
|
|
8
|
+
# used by many banks in Spain and is particularly well supported by
|
|
9
|
+
# Catalunya Caixa's ecommerce department.
|
|
10
|
+
#
|
|
11
|
+
# Redsys requires an order_id be provided with each transaction and it must
|
|
12
|
+
# follow a specific format. The rules are as follows:
|
|
13
|
+
#
|
|
14
|
+
# * First 4 digits must be numerical
|
|
15
|
+
# * Remaining 8 digits may be alphanumeric
|
|
16
|
+
# * Max length: 12
|
|
17
|
+
#
|
|
18
|
+
# If an invalid order_id is provided, we do our best to clean it up.
|
|
19
|
+
#
|
|
20
|
+
# Written by Piers Chambers (Varyonic.com)
|
|
21
|
+
#
|
|
22
|
+
# *** SHA256 Authentication Update ***
|
|
23
|
+
#
|
|
24
|
+
# Redsys has dropped support for the SHA1 authentication method.
|
|
25
|
+
# Developer documentation: https://pagosonline.redsys.es/desarrolladores.html
|
|
26
|
+
class RedsysRestGateway < Gateway
|
|
27
|
+
self.test_url = 'https://sis-t.redsys.es:25443/sis/rest/'
|
|
28
|
+
self.live_url = 'https://sis.redsys.es/sis/rest/'
|
|
29
|
+
|
|
30
|
+
self.supported_countries = ['ES']
|
|
31
|
+
self.default_currency = 'EUR'
|
|
32
|
+
self.money_format = :cents
|
|
33
|
+
# Not all card types may be activated by the bank!
|
|
34
|
+
self.supported_cardtypes = %i[visa master american_express jcb diners_club unionpay patagonia_365 tarjeta_sol]
|
|
35
|
+
self.homepage_url = 'http://www.redsys.es/'
|
|
36
|
+
self.display_name = 'Redsys (REST)'
|
|
37
|
+
|
|
38
|
+
CURRENCY_CODES = {
|
|
39
|
+
'AED' => '784',
|
|
40
|
+
'ARS' => '32',
|
|
41
|
+
'AUD' => '36',
|
|
42
|
+
'BRL' => '986',
|
|
43
|
+
'BOB' => '68',
|
|
44
|
+
'CAD' => '124',
|
|
45
|
+
'CHF' => '756',
|
|
46
|
+
'CLP' => '152',
|
|
47
|
+
'CNY' => '156',
|
|
48
|
+
'COP' => '170',
|
|
49
|
+
'CRC' => '188',
|
|
50
|
+
'CZK' => '203',
|
|
51
|
+
'DKK' => '208',
|
|
52
|
+
'DOP' => '214',
|
|
53
|
+
'EUR' => '978',
|
|
54
|
+
'GBP' => '826',
|
|
55
|
+
'GTQ' => '320',
|
|
56
|
+
'HUF' => '348',
|
|
57
|
+
'IDR' => '360',
|
|
58
|
+
'INR' => '356',
|
|
59
|
+
'JPY' => '392',
|
|
60
|
+
'KRW' => '410',
|
|
61
|
+
'MYR' => '458',
|
|
62
|
+
'MXN' => '484',
|
|
63
|
+
'NOK' => '578',
|
|
64
|
+
'NZD' => '554',
|
|
65
|
+
'PEN' => '604',
|
|
66
|
+
'PLN' => '985',
|
|
67
|
+
'RUB' => '643',
|
|
68
|
+
'SAR' => '682',
|
|
69
|
+
'SEK' => '752',
|
|
70
|
+
'SGD' => '702',
|
|
71
|
+
'THB' => '764',
|
|
72
|
+
'TWD' => '901',
|
|
73
|
+
'USD' => '840',
|
|
74
|
+
'UYU' => '858'
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
THREEDS_EXEMPTIONS = {
|
|
78
|
+
corporate_card: 'COR',
|
|
79
|
+
delegated_authentication: 'ATD',
|
|
80
|
+
low_risk: 'TRA',
|
|
81
|
+
low_value: 'LWV',
|
|
82
|
+
stored_credential: 'MIT',
|
|
83
|
+
trusted_merchant: 'NDF'
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
# The set of supported transactions for this gateway.
|
|
87
|
+
# More operations are supported by the gateway itself, but
|
|
88
|
+
# are not supported in this library.
|
|
89
|
+
SUPPORTED_TRANSACTIONS = {
|
|
90
|
+
purchase: '0',
|
|
91
|
+
authorize: '1',
|
|
92
|
+
capture: '2',
|
|
93
|
+
refund: '3',
|
|
94
|
+
cancel: '9',
|
|
95
|
+
verify: '7'
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
# These are the text meanings sent back by the acquirer when
|
|
99
|
+
# a card has been rejected. Syntax or general request errors
|
|
100
|
+
# are not covered here.
|
|
101
|
+
RESPONSE_TEXTS = {
|
|
102
|
+
0 => 'Transaction Approved',
|
|
103
|
+
400 => 'Cancellation Accepted',
|
|
104
|
+
481 => 'Cancellation Accepted',
|
|
105
|
+
500 => 'Reconciliation Accepted',
|
|
106
|
+
900 => 'Refund / Confirmation approved',
|
|
107
|
+
|
|
108
|
+
101 => 'Card expired',
|
|
109
|
+
102 => 'Card blocked temporarily or under susciption of fraud',
|
|
110
|
+
104 => 'Transaction not permitted',
|
|
111
|
+
107 => 'Contact the card issuer',
|
|
112
|
+
109 => 'Invalid identification by merchant or POS terminal',
|
|
113
|
+
110 => 'Invalid amount',
|
|
114
|
+
114 => 'Card cannot be used to the requested transaction',
|
|
115
|
+
116 => 'Insufficient credit',
|
|
116
|
+
118 => 'Non-registered card',
|
|
117
|
+
125 => 'Card not effective',
|
|
118
|
+
129 => 'CVV2/CVC2 Error',
|
|
119
|
+
167 => 'Contact the card issuer: suspected fraud',
|
|
120
|
+
180 => 'Card out of service',
|
|
121
|
+
181 => 'Card with credit or debit restrictions',
|
|
122
|
+
182 => 'Card with credit or debit restrictions',
|
|
123
|
+
184 => 'Authentication error',
|
|
124
|
+
190 => 'Refusal with no specific reason',
|
|
125
|
+
191 => 'Expiry date incorrect',
|
|
126
|
+
195 => 'Requires SCA authentication',
|
|
127
|
+
|
|
128
|
+
201 => 'Card expired',
|
|
129
|
+
202 => 'Card blocked temporarily or under suspicion of fraud',
|
|
130
|
+
204 => 'Transaction not permitted',
|
|
131
|
+
207 => 'Contact the card issuer',
|
|
132
|
+
208 => 'Lost or stolen card',
|
|
133
|
+
209 => 'Lost or stolen card',
|
|
134
|
+
280 => 'CVV2/CVC2 Error',
|
|
135
|
+
290 => 'Declined with no specific reason',
|
|
136
|
+
|
|
137
|
+
480 => 'Original transaction not located, or time-out exceeded',
|
|
138
|
+
501 => 'Original transaction not located, or time-out exceeded',
|
|
139
|
+
502 => 'Original transaction not located, or time-out exceeded',
|
|
140
|
+
503 => 'Original transaction not located, or time-out exceeded',
|
|
141
|
+
|
|
142
|
+
904 => 'Merchant not registered at FUC',
|
|
143
|
+
909 => 'System error',
|
|
144
|
+
912 => 'Issuer not available',
|
|
145
|
+
913 => 'Duplicate transmission',
|
|
146
|
+
916 => 'Amount too low',
|
|
147
|
+
928 => 'Time-out exceeded',
|
|
148
|
+
940 => 'Transaction cancelled previously',
|
|
149
|
+
941 => 'Authorization operation already cancelled',
|
|
150
|
+
942 => 'Original authorization declined',
|
|
151
|
+
943 => 'Different details from origin transaction',
|
|
152
|
+
944 => 'Session error',
|
|
153
|
+
945 => 'Duplicate transmission',
|
|
154
|
+
946 => 'Cancellation of transaction while in progress',
|
|
155
|
+
947 => 'Duplicate tranmission while in progress',
|
|
156
|
+
949 => 'POS Inoperative',
|
|
157
|
+
950 => 'Refund not possible',
|
|
158
|
+
9064 => 'Card number incorrect',
|
|
159
|
+
9078 => 'No payment method available',
|
|
160
|
+
9093 => 'Non-existent card',
|
|
161
|
+
9218 => 'Recursive transaction in bad gateway',
|
|
162
|
+
9253 => 'Check-digit incorrect',
|
|
163
|
+
9256 => 'Preauth not allowed for merchant',
|
|
164
|
+
9257 => 'Preauth not allowed for card',
|
|
165
|
+
9261 => 'Operating limit exceeded',
|
|
166
|
+
9912 => 'Issuer not available',
|
|
167
|
+
9913 => 'Confirmation error',
|
|
168
|
+
9914 => 'KO Confirmation'
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
# Expected values as per documentation
|
|
172
|
+
THREE_DS_V2 = '2.1.0'
|
|
173
|
+
|
|
174
|
+
# Creates a new instance
|
|
175
|
+
#
|
|
176
|
+
# Redsys requires a login and secret_key, and optionally also accepts a
|
|
177
|
+
# non-default terminal.
|
|
178
|
+
#
|
|
179
|
+
# ==== Options
|
|
180
|
+
#
|
|
181
|
+
# * <tt>:login</tt> -- The Redsys Merchant ID (REQUIRED)
|
|
182
|
+
# * <tt>:secret_key</tt> -- The Redsys Secret Key. (REQUIRED)
|
|
183
|
+
# * <tt>:terminal</tt> -- The Redsys Terminal. Defaults to 1. (OPTIONAL)
|
|
184
|
+
# * <tt>:test</tt> -- +true+ or +false+. Defaults to +false+. (OPTIONAL)
|
|
185
|
+
def initialize(options = {})
|
|
186
|
+
requires!(options, :login, :secret_key)
|
|
187
|
+
options[:terminal] ||= 1
|
|
188
|
+
options[:signature_algorithm] = 'sha256'
|
|
189
|
+
super
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def purchase(money, payment, options = {})
|
|
193
|
+
requires!(options, :order_id)
|
|
194
|
+
|
|
195
|
+
post = {}
|
|
196
|
+
add_action(post, :purchase, options)
|
|
197
|
+
add_amount(post, money, options)
|
|
198
|
+
add_stored_credentials(post, options)
|
|
199
|
+
add_threeds_exemption_data(post, options)
|
|
200
|
+
add_order(post, options[:order_id])
|
|
201
|
+
add_payment(post, payment)
|
|
202
|
+
add_description(post, options)
|
|
203
|
+
add_direct_payment(post, options)
|
|
204
|
+
add_threeds(post, options)
|
|
205
|
+
|
|
206
|
+
commit(post, options)
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def authorize(money, payment, options = {})
|
|
210
|
+
requires!(options, :order_id)
|
|
211
|
+
|
|
212
|
+
post = {}
|
|
213
|
+
add_action(post, :authorize, options)
|
|
214
|
+
add_amount(post, money, options)
|
|
215
|
+
add_stored_credentials(post, options)
|
|
216
|
+
add_threeds_exemption_data(post, options)
|
|
217
|
+
add_order(post, options[:order_id])
|
|
218
|
+
add_payment(post, payment)
|
|
219
|
+
add_description(post, options)
|
|
220
|
+
add_direct_payment(post, options)
|
|
221
|
+
add_threeds(post, options)
|
|
222
|
+
|
|
223
|
+
commit(post, options)
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
def capture(money, authorization, options = {})
|
|
227
|
+
post = {}
|
|
228
|
+
add_action(post, :capture)
|
|
229
|
+
add_amount(post, money, options)
|
|
230
|
+
order_id, = split_authorization(authorization)
|
|
231
|
+
add_order(post, order_id)
|
|
232
|
+
add_description(post, options)
|
|
233
|
+
|
|
234
|
+
commit(post, options)
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
def void(authorization, options = {})
|
|
238
|
+
requires!(options, :order_id)
|
|
239
|
+
|
|
240
|
+
post = {}
|
|
241
|
+
add_action(post, :cancel)
|
|
242
|
+
order_id, amount, currency = split_authorization(authorization)
|
|
243
|
+
add_amount(post, amount, currency:)
|
|
244
|
+
add_order(post, order_id)
|
|
245
|
+
add_description(post, options)
|
|
246
|
+
|
|
247
|
+
commit(post, options)
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
def refund(money, authorization, options = {})
|
|
251
|
+
requires!(options, :order_id)
|
|
252
|
+
|
|
253
|
+
post = {}
|
|
254
|
+
add_action(post, :refund)
|
|
255
|
+
add_amount(post, money, options)
|
|
256
|
+
order_id, = split_authorization(authorization)
|
|
257
|
+
add_order(post, order_id)
|
|
258
|
+
add_description(post, options)
|
|
259
|
+
|
|
260
|
+
commit(post, options)
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
def verify(creditcard, options = {})
|
|
264
|
+
requires!(options, :order_id)
|
|
265
|
+
|
|
266
|
+
post = {}
|
|
267
|
+
add_action(post, :verify, options)
|
|
268
|
+
add_amount(post, 0, options)
|
|
269
|
+
add_order(post, options[:order_id])
|
|
270
|
+
add_payment(post, creditcard)
|
|
271
|
+
add_description(post, options)
|
|
272
|
+
add_direct_payment(post, options)
|
|
273
|
+
add_threeds(post, options)
|
|
274
|
+
|
|
275
|
+
commit(post, options)
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
def supports_scrubbing?
|
|
279
|
+
true
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
def scrub(transcript)
|
|
283
|
+
merchant_parameters = filter_merchant_parameters(transcript)
|
|
284
|
+
|
|
285
|
+
transcript.
|
|
286
|
+
gsub(%r((Ds_MerchantParameters=)(\w+)), '\1' + merchant_parameters.to_s + '\3').
|
|
287
|
+
gsub(%r((PAN\"=>\")(\d+)), '\1[FILTERED]').
|
|
288
|
+
gsub(%r((CVV2\"=>\")(\d+)), '\1[FILTERED]')
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
private
|
|
292
|
+
|
|
293
|
+
def add_direct_payment(post, options)
|
|
294
|
+
# Direct payment skips 3DS authentication. We should only apply this if execute_threed is false
|
|
295
|
+
# or authentication data is not present. Authentication data support to be added in the future.
|
|
296
|
+
return if options[:execute_threed] || options[:authentication_data] || options[:three_ds_exemption_type] == 'moto'
|
|
297
|
+
|
|
298
|
+
post[:DS_MERCHANT_DIRECTPAYMENT] = true
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
def add_threeds(post, options)
|
|
302
|
+
return unless options[:execute_threed] || options[:three_ds_2]
|
|
303
|
+
|
|
304
|
+
post[:DS_MERCHANT_EMV3DS] = if options[:execute_threed]
|
|
305
|
+
{ threeDSInfo: 'CardData' }
|
|
306
|
+
else
|
|
307
|
+
add_browser_info(post, options)
|
|
308
|
+
end
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
def add_browser_info(post, options)
|
|
312
|
+
return unless browser_info = options.dig(:three_ds_2, :browser_info)
|
|
313
|
+
|
|
314
|
+
{
|
|
315
|
+
browserAcceptHeader: browser_info[:accept_header],
|
|
316
|
+
browserUserAgent: browser_info[:user_agent],
|
|
317
|
+
browserJavaEnabled: browser_info[:java],
|
|
318
|
+
browserJavascriptEnabled: browser_info[:java],
|
|
319
|
+
browserLanguage: browser_info[:language],
|
|
320
|
+
browserColorDepth: browser_info[:depth],
|
|
321
|
+
browserScreenHeight: browser_info[:height],
|
|
322
|
+
browserScreenWidth: browser_info[:width],
|
|
323
|
+
browserTZ: browser_info[:timezone]
|
|
324
|
+
}
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
def add_action(post, action, options = {})
|
|
328
|
+
post[:DS_MERCHANT_TRANSACTIONTYPE] = transaction_code(action)
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
def add_amount(post, money, options)
|
|
332
|
+
post[:DS_MERCHANT_AMOUNT] = amount(money).to_s
|
|
333
|
+
post[:DS_MERCHANT_CURRENCY] = currency_code(options[:currency] || currency(money))
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
def add_description(post, options)
|
|
337
|
+
post[:DS_MERCHANT_PRODUCTDESCRIPTION] = CGI.escape(options[:description]) if options[:description]
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
def add_order(post, order_id)
|
|
341
|
+
post[:DS_MERCHANT_ORDER] = clean_order_id(order_id)
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
def add_payment(post, payment_method)
|
|
345
|
+
year = sprintf('%.4i', payment_method.year)
|
|
346
|
+
month = sprintf('%.2i', payment_method.month)
|
|
347
|
+
|
|
348
|
+
if payment_method.is_a?(NetworkTokenizationCreditCard)
|
|
349
|
+
post[:Ds_Merchant_TokenData] = {
|
|
350
|
+
tokenCryptogram: payment_method.payment_cryptogram,
|
|
351
|
+
expirationDate: "#{year[2..3]}#{month}",
|
|
352
|
+
token: payment_method.number
|
|
353
|
+
}
|
|
354
|
+
else
|
|
355
|
+
name = [payment_method.first_name, payment_method.last_name].join(' ').slice(0, 60)
|
|
356
|
+
post['DS_MERCHANT_TITULAR'] = CGI.escape(name)
|
|
357
|
+
post['DS_MERCHANT_PAN'] = payment_method.number
|
|
358
|
+
post['DS_MERCHANT_EXPIRYDATE'] = "#{year[2..3]}#{month}"
|
|
359
|
+
post['DS_MERCHANT_CVV2'] = payment_method.verification_value if payment_method.verification_value.present?
|
|
360
|
+
end
|
|
361
|
+
end
|
|
362
|
+
|
|
363
|
+
def determine_action(options)
|
|
364
|
+
# If execute_threed is true, we need to use iniciaPeticionREST to set up authentication
|
|
365
|
+
# Otherwise we are skipping 3DS or we should have 3DS authentication results
|
|
366
|
+
options[:execute_threed] ? 'iniciaPeticionREST' : 'trataPeticionREST'
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
def commit(post, options)
|
|
370
|
+
url = (test? ? test_url : live_url)
|
|
371
|
+
action = determine_action(options)
|
|
372
|
+
raw_response = parse(ssl_post(url + action, post_data(post, options)))
|
|
373
|
+
payload = raw_response['Ds_MerchantParameters']
|
|
374
|
+
return Response.new(false, "#{raw_response['errorCode']} ERROR") unless payload
|
|
375
|
+
|
|
376
|
+
begin
|
|
377
|
+
response = JSON.parse(Base64.decode64(payload)).transform_keys!(&:downcase).with_indifferent_access
|
|
378
|
+
rescue JSON::ParserError
|
|
379
|
+
response = JSON.parse(Base64.urlsafe_decode64(payload)).transform_keys!(&:downcase).with_indifferent_access
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
return Response.new(false, 'Unable to verify response') unless validate_signature(payload, raw_response['Ds_Signature'], response[:ds_order])
|
|
383
|
+
|
|
384
|
+
succeeded = success_from(response, options)
|
|
385
|
+
Response.new(
|
|
386
|
+
succeeded,
|
|
387
|
+
message_from(response),
|
|
388
|
+
response,
|
|
389
|
+
authorization: authorization_from(response, post, options),
|
|
390
|
+
test: test?,
|
|
391
|
+
error_code: succeeded ? nil : response[:ds_response]
|
|
392
|
+
)
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
def post_data(post, options)
|
|
396
|
+
add_authentication(post, options)
|
|
397
|
+
merchant_parameters = JSON.generate(post)
|
|
398
|
+
encoded_parameters = Base64.strict_encode64(merchant_parameters)
|
|
399
|
+
post_data = PostData.new
|
|
400
|
+
post_data['Ds_SignatureVersion'] = 'HMAC_SHA256_V1'
|
|
401
|
+
post_data['Ds_MerchantParameters'] = encoded_parameters
|
|
402
|
+
post_data['Ds_Signature'] = sign_request(encoded_parameters, post[:DS_MERCHANT_ORDER])
|
|
403
|
+
post_data.to_post_data
|
|
404
|
+
end
|
|
405
|
+
|
|
406
|
+
def add_authentication(post, options)
|
|
407
|
+
post[:DS_MERCHANT_TERMINAL] = options[:terminal] || @options[:terminal]
|
|
408
|
+
post[:DS_MERCHANT_MERCHANTCODE] = @options[:login]
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
def add_stored_credentials(post, options)
|
|
412
|
+
return unless stored_credential = options[:stored_credential]
|
|
413
|
+
|
|
414
|
+
post[:DS_MERCHANT_COF_INI] = stored_credential[:initial_transaction] ? 'S' : 'N'
|
|
415
|
+
|
|
416
|
+
post[:DS_MERCHANT_COF_TYPE] = case stored_credential[:reason_type]
|
|
417
|
+
when 'recurring'
|
|
418
|
+
'R'
|
|
419
|
+
when 'installment'
|
|
420
|
+
'I'
|
|
421
|
+
else
|
|
422
|
+
'C'
|
|
423
|
+
end
|
|
424
|
+
|
|
425
|
+
post[:DS_MERCHANT_IDENTIFIER] = 'REQUIRED' if stored_credential[:initiator] == 'cardholder'
|
|
426
|
+
post[:DS_MERCHANT_COF_TXNID] = stored_credential[:network_transaction_id] if stored_credential[:network_transaction_id]
|
|
427
|
+
end
|
|
428
|
+
|
|
429
|
+
def add_threeds_exemption_data(post, options)
|
|
430
|
+
return unless options[:three_ds_exemption_type]
|
|
431
|
+
|
|
432
|
+
if options[:three_ds_exemption_type] == 'moto'
|
|
433
|
+
post[:DS_MERCHANT_DIRECTPAYMENT] = 'MOTO'
|
|
434
|
+
else
|
|
435
|
+
exemption = options[:three_ds_exemption_type].to_sym
|
|
436
|
+
post[:DS_MERCHANT_EXCEP_SCA] = THREEDS_EXEMPTIONS[exemption]
|
|
437
|
+
end
|
|
438
|
+
end
|
|
439
|
+
|
|
440
|
+
def parse(body)
|
|
441
|
+
JSON.parse(body)
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
def success_from(response, options)
|
|
445
|
+
return true if response[:ds_emv3ds] && options[:execute_threed]
|
|
446
|
+
|
|
447
|
+
# Need to get updated for 3DS support
|
|
448
|
+
if code = response[:ds_response]
|
|
449
|
+
(code.to_i < 100) || [195, 400, 481, 500, 900].include?(code.to_i)
|
|
450
|
+
else
|
|
451
|
+
false
|
|
452
|
+
end
|
|
453
|
+
end
|
|
454
|
+
|
|
455
|
+
def message_from(response)
|
|
456
|
+
return response.dig(:ds_emv3ds, :threeDSInfo) if response[:ds_emv3ds]
|
|
457
|
+
|
|
458
|
+
code = response[:ds_response]&.to_i
|
|
459
|
+
code = 0 if code < 100
|
|
460
|
+
RESPONSE_TEXTS[code] || 'Unknown code, please check in manual'
|
|
461
|
+
end
|
|
462
|
+
|
|
463
|
+
def validate_signature(data, signature, order_number)
|
|
464
|
+
key = encrypt(@options[:secret_key], order_number)
|
|
465
|
+
Base64.urlsafe_encode64(mac256(key, data)) == signature
|
|
466
|
+
end
|
|
467
|
+
|
|
468
|
+
def authorization_from(response, post, options)
|
|
469
|
+
array_resp = if success_from(response, options) && options[:execute_threed] # 3DS Case
|
|
470
|
+
[post[:DS_MERCHANT_AMOUNT], post[:DS_MERCHANT_CURRENCY]]
|
|
471
|
+
else
|
|
472
|
+
[response[:ds_amount], response[:ds_currency]]
|
|
473
|
+
end
|
|
474
|
+
([response[:ds_order]] << array_resp).join('|')
|
|
475
|
+
end
|
|
476
|
+
|
|
477
|
+
def split_authorization(authorization)
|
|
478
|
+
order_id, amount, currency = authorization.split('|')
|
|
479
|
+
[order_id, amount.to_i, currency]
|
|
480
|
+
end
|
|
481
|
+
|
|
482
|
+
def currency_code(currency)
|
|
483
|
+
return currency if currency =~ /^\d+$/
|
|
484
|
+
raise ArgumentError, "Unknown currency #{currency}" unless CURRENCY_CODES[currency]
|
|
485
|
+
|
|
486
|
+
CURRENCY_CODES[currency]
|
|
487
|
+
end
|
|
488
|
+
|
|
489
|
+
def transaction_code(type)
|
|
490
|
+
SUPPORTED_TRANSACTIONS[type]
|
|
491
|
+
end
|
|
492
|
+
|
|
493
|
+
def clean_order_id(order_id)
|
|
494
|
+
cleansed = order_id.gsub(/[^\da-zA-Z]/, '')
|
|
495
|
+
if /^\d{4}/.match?(cleansed)
|
|
496
|
+
cleansed[0..11]
|
|
497
|
+
else
|
|
498
|
+
('%04d' % [rand(0..9999)]) + cleansed[0...8]
|
|
499
|
+
end
|
|
500
|
+
end
|
|
501
|
+
|
|
502
|
+
def sign_request(encoded_parameters, order_id)
|
|
503
|
+
raise(ArgumentError, 'missing order_id') unless order_id
|
|
504
|
+
|
|
505
|
+
key = encrypt(@options[:secret_key], order_id)
|
|
506
|
+
Base64.strict_encode64(mac256(key, encoded_parameters))
|
|
507
|
+
end
|
|
508
|
+
|
|
509
|
+
def encrypt(key, order_id)
|
|
510
|
+
block_length = 8
|
|
511
|
+
cipher = OpenSSL::Cipher.new('DES3')
|
|
512
|
+
cipher.encrypt
|
|
513
|
+
|
|
514
|
+
cipher.key = Base64.urlsafe_decode64(key)
|
|
515
|
+
# The OpenSSL default of an all-zeroes ("\\0") IV is used.
|
|
516
|
+
cipher.padding = 0
|
|
517
|
+
|
|
518
|
+
order_id += "\0" until order_id.bytesize % block_length == 0 # Pad with zeros
|
|
519
|
+
|
|
520
|
+
cipher.update(order_id) + cipher.final
|
|
521
|
+
end
|
|
522
|
+
|
|
523
|
+
def mac256(key, data)
|
|
524
|
+
OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), key, data)
|
|
525
|
+
end
|
|
526
|
+
|
|
527
|
+
def filter_merchant_parameters(transcript)
|
|
528
|
+
# Enhancement, the gateway response with base64 and it contians sensible data.
|
|
529
|
+
# Decode + Scrub + Encode the returned sensitive dat.
|
|
530
|
+
pre_filter_data = transcript.match(%r(Ds_MerchantParameters=(\w+)))
|
|
531
|
+
return unless pre_filter_data
|
|
532
|
+
|
|
533
|
+
decoded_pre_filter_data = Base64.decode64(pre_filter_data[1])
|
|
534
|
+
|
|
535
|
+
filter_data = decoded_pre_filter_data.
|
|
536
|
+
gsub(%r((PAN\":\")(\d+)), '\1[FILTERED]').
|
|
537
|
+
gsub(%r((CVV2\":\")(\d+)), '\1[FILTERED]').
|
|
538
|
+
gsub(%r((token\":\")(\d+)), '\1[FILTERED]').
|
|
539
|
+
gsub(%r((tokenCryptogram\":\")([^*]*?")), '\1[FILTERED]"')
|
|
540
|
+
|
|
541
|
+
Base64.strict_encode64(filter_data)
|
|
542
|
+
end
|
|
543
|
+
end
|
|
544
|
+
end
|
|
545
|
+
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'nokogiri'
|
|
2
2
|
|
|
3
|
-
module ActiveMerchant
|
|
4
|
-
module Billing
|
|
3
|
+
module ActiveMerchant # :nodoc:
|
|
4
|
+
module Billing # :nodoc:
|
|
5
5
|
class S5Gateway < Gateway
|
|
6
6
|
self.test_url = 'https://test.ctpe.io/payment/ctpe'
|
|
7
7
|
self.live_url = 'https://ctpe.io/payment/ctpe'
|
|
@@ -128,9 +128,7 @@ module ActiveMerchant #:nodoc:
|
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
def add_account(xml, payment_method)
|
|
131
|
-
if
|
|
132
|
-
xml.Account(registration: payment_method)
|
|
133
|
-
else
|
|
131
|
+
if payment_method.respond_to?(:number)
|
|
134
132
|
xml.Account do
|
|
135
133
|
xml.Number payment_method.number
|
|
136
134
|
xml.Holder "#{payment_method.first_name} #{payment_method.last_name}"
|
|
@@ -138,6 +136,8 @@ module ActiveMerchant #:nodoc:
|
|
|
138
136
|
xml.Expiry(year: payment_method.year, month: payment_method.month)
|
|
139
137
|
xml.Verification payment_method.verification_value
|
|
140
138
|
end
|
|
139
|
+
else
|
|
140
|
+
xml.Account(registration: payment_method)
|
|
141
141
|
end
|
|
142
142
|
end
|
|
143
143
|
|