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
|
@@ -0,0 +1,573 @@
|
|
|
1
|
+
module ActiveMerchant
|
|
2
|
+
module Billing
|
|
3
|
+
class NuveiGateway < Gateway
|
|
4
|
+
version 'v1'
|
|
5
|
+
|
|
6
|
+
self.test_url = "https://ppp-test.nuvei.com/ppp/api/#{fetch_version}"
|
|
7
|
+
self.live_url = "https://secure.safecharge.com/ppp/api/#{fetch_version}"
|
|
8
|
+
|
|
9
|
+
self.supported_countries = %w[US CA IN NZ GB AU US]
|
|
10
|
+
self.default_currency = 'USD'
|
|
11
|
+
self.money_format = :dollars
|
|
12
|
+
self.supported_cardtypes = %i[visa master american_express discover union_pay]
|
|
13
|
+
self.currencies_without_fractions = %w[CLP KRW JPY ISK MMK PYG UGX VND XAF XOF]
|
|
14
|
+
self.homepage_url = 'https://www.nuvei.com/'
|
|
15
|
+
self.display_name = 'Nuvei'
|
|
16
|
+
|
|
17
|
+
ENDPOINTS_MAPPING = {
|
|
18
|
+
authenticate: '/getSessionToken',
|
|
19
|
+
purchase: '/payment', # /authorize with transactionType: "Auth"
|
|
20
|
+
capture: '/settleTransaction',
|
|
21
|
+
refund: '/refundTransaction',
|
|
22
|
+
void: '/voidTransaction',
|
|
23
|
+
general_credit: '/payout',
|
|
24
|
+
init_payment: '/initPayment'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
NETWORK_TOKENIZATION_CARD_MAPPING = {
|
|
28
|
+
'apple_pay' => 'ApplePay',
|
|
29
|
+
'google_pay' => 'GooglePay'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
def initialize(options = {})
|
|
33
|
+
requires!(options, :merchant_id, :merchant_site_id, :secret_key)
|
|
34
|
+
super
|
|
35
|
+
fetch_session_token unless session_token_valid?
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def authorize(money, payment, options = {}, transaction_type = 'Auth')
|
|
39
|
+
post = { transactionType: transaction_type }
|
|
40
|
+
post[:savePM] = options[:save_payment_method] ? options[:save_payment_method].to_s : 'false'
|
|
41
|
+
|
|
42
|
+
build_post_data(post, options)
|
|
43
|
+
add_amount(post, money, options)
|
|
44
|
+
add_payment_method(post, payment, :paymentOption, options)
|
|
45
|
+
add_3ds_global(post, options)
|
|
46
|
+
add_address(post, payment, options)
|
|
47
|
+
add_customer_ip(post, options)
|
|
48
|
+
add_stored_credentials(post, payment, options)
|
|
49
|
+
add_account_funding_transaction(post, payment, options)
|
|
50
|
+
add_cardholder_name_verification(post, payment, transaction_type, options)
|
|
51
|
+
post[:userTokenId] = options[:user_token_id] if options[:user_token_id]
|
|
52
|
+
post[:isPartialApproval] = options[:is_partial_approval] ? 1 : 0
|
|
53
|
+
post[:authenticationOnlyType] = options[:authentication_only_type] if options[:authentication_only_type]
|
|
54
|
+
|
|
55
|
+
if options[:execute_threed]
|
|
56
|
+
execute_3ds_flow(post, money, payment, transaction_type, options)
|
|
57
|
+
else
|
|
58
|
+
commit(:purchase, post)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def purchase(money, payment, options = {})
|
|
63
|
+
fetch_session_token if payment.is_a?(String)
|
|
64
|
+
authorize(money, payment, options, 'Sale')
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def capture(money, authorization, options = {})
|
|
68
|
+
post = { relatedTransactionId: authorization }
|
|
69
|
+
|
|
70
|
+
build_post_data(post, options)
|
|
71
|
+
add_amount(post, money, options)
|
|
72
|
+
|
|
73
|
+
commit(:capture, post)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def refund(money, authorization, options = {})
|
|
77
|
+
post = { relatedTransactionId: authorization }
|
|
78
|
+
|
|
79
|
+
build_post_data(post, options)
|
|
80
|
+
add_amount(post, money, options)
|
|
81
|
+
|
|
82
|
+
commit(:refund, post)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def void(authorization, options = {})
|
|
86
|
+
post = { relatedTransactionId: authorization }
|
|
87
|
+
build_post_data(post)
|
|
88
|
+
|
|
89
|
+
commit(:void, post)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def verify(credit_card, options = {})
|
|
93
|
+
MultiResponse.run(:use_first_response) do |r|
|
|
94
|
+
r.process { authorize(0, credit_card, options) }
|
|
95
|
+
r.process(:ignore_result) { void(r.authorization, options) }
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def store(credit_card, options = {})
|
|
100
|
+
options[:save_payment_method] = true
|
|
101
|
+
authorize(0, credit_card, options)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def credit(money, payment, options = {})
|
|
105
|
+
post = { userTokenId: options[:user_token_id] }
|
|
106
|
+
payment_key = payment.is_a?(NetworkTokenizationCreditCard) ? :userPaymentOption : :cardData
|
|
107
|
+
build_post_data(post, options)
|
|
108
|
+
add_amount(post, money, options)
|
|
109
|
+
options[:is_payout] ? send_payout_transaction(payment_key, post, payment, options) : send_unreferenced_refund_transaction(post, payment, options)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def send_payout_transaction(payment_key, post, payment, options = {})
|
|
113
|
+
add_payment_method(post, payment, payment_key, options)
|
|
114
|
+
add_customer_ip(post, options)
|
|
115
|
+
url_details(post, options)
|
|
116
|
+
add_user_details(post, options)
|
|
117
|
+
commit(:general_credit, post.compact)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def send_unreferenced_refund_transaction(post, payment, options = {})
|
|
121
|
+
post[:paymentOption] = { userPaymentOptionId: options[:user_payment_option_id] } if options[:user_payment_option_id]
|
|
122
|
+
unless options[:user_payment_option_id]
|
|
123
|
+
add_payment_method(post, payment, :paymentOption, options)
|
|
124
|
+
post[:paymentOption][:card].slice!(:cardNumber, :cardHolderName, :expirationMonth, :expirationYear, :CVV)
|
|
125
|
+
end
|
|
126
|
+
commit(:refund, post.compact)
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def add_stored_credentials(post, payment, options = {})
|
|
130
|
+
return unless options[:stored_credential]
|
|
131
|
+
|
|
132
|
+
post[:savePM] = options[:save_payment_method] || true
|
|
133
|
+
set_initiator_type(post, payment, options)
|
|
134
|
+
set_reason_type(post, options)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def set_initiator_type(post, payment, options)
|
|
138
|
+
stored_credential = options[:stored_credential]
|
|
139
|
+
return unless stored_credential
|
|
140
|
+
|
|
141
|
+
is_initial_transaction = stored_credential[:initial_transaction]
|
|
142
|
+
stored_credentials_mode = is_initial_transaction ? '0' : '1'
|
|
143
|
+
|
|
144
|
+
if payment.is_a?(CreditCard)
|
|
145
|
+
post[:paymentOption] ||= {}
|
|
146
|
+
post[:paymentOption][:card] ||= {}
|
|
147
|
+
post[:paymentOption][:card][:storedCredentials] ||= {}
|
|
148
|
+
post[:paymentOption][:card][:storedCredentials][:storedCredentialsMode] = stored_credentials_mode
|
|
149
|
+
end
|
|
150
|
+
post[:isRebilling] = options[:is_rebilling] ? '1' : '0' if mit?(options[:stored_credential])
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def mit?(stored_credential)
|
|
154
|
+
stored_credential[:reason_type] != 'unscheduled' && stored_credential[:initial_transaction] == false
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def add_account_funding_transaction(post, payment, options = {})
|
|
158
|
+
return unless options[:is_aft]
|
|
159
|
+
|
|
160
|
+
recipient_details = {
|
|
161
|
+
firstName: options[:aft_recipient_first_name],
|
|
162
|
+
lastName: options[:aft_recipient_last_name]
|
|
163
|
+
}.compact
|
|
164
|
+
|
|
165
|
+
address_details = {
|
|
166
|
+
firstName: payment.first_name,
|
|
167
|
+
lastName: payment.last_name,
|
|
168
|
+
country: options.dig(:billing_address, :country)
|
|
169
|
+
}.compact
|
|
170
|
+
|
|
171
|
+
post[:billingAddress] ||= {}
|
|
172
|
+
post[:billingAddress].merge!(address_details)
|
|
173
|
+
post[:recipientDetails] = recipient_details unless recipient_details.empty?
|
|
174
|
+
add_user_details(post, options)
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def add_user_details(post, options)
|
|
178
|
+
return unless options[:user_details]&.is_a?(Hash)
|
|
179
|
+
|
|
180
|
+
user_details = options[:user_details]
|
|
181
|
+
post[:userDetails] = {}
|
|
182
|
+
post[:userDetails][:firstName] = user_details[:first_name] if user_details[:first_name]
|
|
183
|
+
post[:userDetails][:lastName] = user_details[:last_name] if user_details[:last_name]
|
|
184
|
+
post[:userDetails][:address] = user_details[:address] if user_details[:address]
|
|
185
|
+
post[:userDetails][:streetNumber] = user_details[:street_number] if user_details[:street_number]
|
|
186
|
+
post[:userDetails][:phone] = user_details[:phone] if user_details[:phone]
|
|
187
|
+
post[:userDetails][:zip] = user_details[:zip] if user_details[:zip]
|
|
188
|
+
post[:userDetails][:city] = user_details[:city] if user_details[:city]
|
|
189
|
+
post[:userDetails][:country] = user_details[:country] if user_details[:country]
|
|
190
|
+
post[:userDetails][:state] = user_details[:state] if user_details[:state]
|
|
191
|
+
post[:userDetails][:email] = user_details[:email] if user_details[:email]
|
|
192
|
+
post[:userDetails][:county] = user_details[:county] if user_details[:county]
|
|
193
|
+
post[:userDetails][:language] = user_details[:language] if user_details[:language]
|
|
194
|
+
post[:userDetails][:identification] = user_details[:identification] if user_details[:identification]
|
|
195
|
+
|
|
196
|
+
# special case depending on AFT or Payout transactions
|
|
197
|
+
if user_details[:date_of_birth] && options[:is_aft]
|
|
198
|
+
post[:userDetails][:dateOfBirth] = user_details[:date_of_birth]
|
|
199
|
+
elsif user_details[:birth_date] && options[:is_payout]
|
|
200
|
+
post[:userDetails][:birthdate] = user_details[:birth_date]
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
def set_reason_type(post, options)
|
|
205
|
+
reason_type = options[:stored_credential][:reason_type]
|
|
206
|
+
|
|
207
|
+
case reason_type
|
|
208
|
+
when 'recurring'
|
|
209
|
+
reason_type = 'RECURRING'
|
|
210
|
+
when 'installment'
|
|
211
|
+
reason_type = 'INSTALLMENTS'
|
|
212
|
+
when 'unscheduled'
|
|
213
|
+
reason_type = 'ADDCARD'
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
unless reason_type == 'ADDCARD'
|
|
217
|
+
fetch_session_token
|
|
218
|
+
post[:relatedTransactionId] = options[:stored_credential][:network_transaction_id] if options[:stored_credential][:network_transaction_id]
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
post[:authenticationOnlyType] = reason_type
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
def supports_scrubbing?
|
|
225
|
+
true
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
def scrub(transcript)
|
|
229
|
+
transcript.
|
|
230
|
+
gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
|
|
231
|
+
gsub(%r(("cardNumber\\?":\\?")[^"\\]*)i, '\1[FILTERED]').
|
|
232
|
+
gsub(%r(("CVV\\?":\\?")\d+), '\1[FILTERED]').
|
|
233
|
+
gsub(%r(("merchantId\\?":\\?")\d+), '\1[FILTERED]').
|
|
234
|
+
gsub(%r(("merchantSiteId\\?":\\?")\d+), '\1[FILTERED]').
|
|
235
|
+
gsub(%r(("merchantKey\\?":\\?")\d+), '\1[FILTERED]').
|
|
236
|
+
gsub(%r(("accountNumber\\?":\\?")\d+), '\1[FILTERED]').
|
|
237
|
+
gsub(%r(("cryptogram\\?":\\?")[^"\\]*)i, '\1[FILTERED]')
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
private
|
|
241
|
+
|
|
242
|
+
def network_transaction_id_from(response)
|
|
243
|
+
response.dig('transactionId')
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
def add_customer_ip(post, options)
|
|
247
|
+
return unless options[:ip]
|
|
248
|
+
|
|
249
|
+
post[:deviceDetails] = { ipAddress: options[:ip] }
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
def url_details(post, options)
|
|
253
|
+
return unless options[:notification_url]
|
|
254
|
+
|
|
255
|
+
post[:urlDetails] = { notificationUrl: options[:notification_url] }
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
def add_amount(post, money, options)
|
|
259
|
+
post[:amount] = amount(money)
|
|
260
|
+
post[:currency] = (options[:currency] || currency(money))
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
def credit_card_hash(payment)
|
|
264
|
+
{
|
|
265
|
+
cardNumber: payment.number,
|
|
266
|
+
cardHolderName: payment.name,
|
|
267
|
+
expirationMonth: format(payment.month, :two_digits),
|
|
268
|
+
expirationYear: format(payment.year, :four_digits),
|
|
269
|
+
CVV: payment.verification_value,
|
|
270
|
+
last4Digits: get_last_four_digits(payment.number),
|
|
271
|
+
selectedBrand: payment.brand
|
|
272
|
+
}
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
def get_last_four_digits(number)
|
|
276
|
+
number[-4..-1]
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
def add_bank_account(post, payment, options)
|
|
280
|
+
post[:paymentOption] = {
|
|
281
|
+
alternativePaymentMethod: {
|
|
282
|
+
paymentMethod: 'apmgw_ACH',
|
|
283
|
+
AccountNumber: payment.account_number,
|
|
284
|
+
RoutingNumber: payment.routing_number,
|
|
285
|
+
SECCode: options[:account_type] || 'WEB'
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
def add_payment_method(post, payment, key, options = {})
|
|
291
|
+
return post[key] = { userPaymentOptionId: options[:user_payment_option_id] } if key == :userPaymentOption
|
|
292
|
+
|
|
293
|
+
payment_data = extract_payment_data(payment)
|
|
294
|
+
|
|
295
|
+
case payment
|
|
296
|
+
when NetworkTokenizationCreditCard
|
|
297
|
+
add_network_tokenization_data(post, payment, payment_data)
|
|
298
|
+
when CreditCard
|
|
299
|
+
post[key] = key == :paymentOption ? { card: payment_data } : payment_data
|
|
300
|
+
when Check
|
|
301
|
+
add_bank_account(post, payment, options)
|
|
302
|
+
url_details(post, options)
|
|
303
|
+
else
|
|
304
|
+
post[key] = { userPaymentOptionId: payment_data }
|
|
305
|
+
end
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
def extract_payment_data(payment)
|
|
309
|
+
if payment.is_a?(CreditCard) || payment.is_a?(NetworkTokenizationCreditCard)
|
|
310
|
+
credit_card_hash(payment)
|
|
311
|
+
else
|
|
312
|
+
payment
|
|
313
|
+
end
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
def add_network_tokenization_data(post, payment, payment_data)
|
|
317
|
+
payment_data[:brand] = payment.brand.upcase
|
|
318
|
+
external_token = {
|
|
319
|
+
externalTokenProvider: NETWORK_TOKENIZATION_CARD_MAPPING[payment.source.to_s],
|
|
320
|
+
cryptogram: payment.payment_cryptogram,
|
|
321
|
+
eciProvider: payment.eci
|
|
322
|
+
}.compact
|
|
323
|
+
|
|
324
|
+
payment_data.slice!(:cardNumber, :expirationMonth, :expirationYear, :last4Digits, :brand, :CVV)
|
|
325
|
+
post[:paymentOption] = { card: payment_data.merge(externalToken: external_token) }
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
def add_customer_names(full_name, payment_method)
|
|
329
|
+
split_names(full_name).tap do |names|
|
|
330
|
+
names[0] = payment_method&.first_name unless names[0].present? || payment_method.is_a?(String)
|
|
331
|
+
names[1] = payment_method&.last_name unless names[1].present? || payment_method.is_a?(String)
|
|
332
|
+
end
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
def add_3ds_global(post, options)
|
|
336
|
+
return unless (three_d_secure_options = options[:three_d_secure])
|
|
337
|
+
|
|
338
|
+
card_options = post[:paymentOption][:card] ||= {}
|
|
339
|
+
card_options[:threeD] = build_three_d_secure_options(three_d_secure_options, options)
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
def build_three_d_secure_options(three_d_secure_options, options)
|
|
343
|
+
three_d_secure_data = {
|
|
344
|
+
externalMpi: {
|
|
345
|
+
eci: three_d_secure_options[:eci],
|
|
346
|
+
cavv: three_d_secure_options[:cavv],
|
|
347
|
+
dsTransID: three_d_secure_options[:ds_transaction_id],
|
|
348
|
+
challengePreference: options[:challenge_preference]
|
|
349
|
+
}
|
|
350
|
+
}.compact
|
|
351
|
+
|
|
352
|
+
three_d_secure_data[:externalMpi][:exemptionRequestReason] = options[:exemption_request_reason] if options[:challenge_preference] == 'ExemptionRequest'
|
|
353
|
+
|
|
354
|
+
three_d_secure_data
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
def add_address(post, payment, options)
|
|
358
|
+
return unless address = options[:billing_address] || options[:address]
|
|
359
|
+
|
|
360
|
+
first_name, last_name = add_customer_names(address[:name], payment)
|
|
361
|
+
|
|
362
|
+
post[:billingAddress] = {
|
|
363
|
+
email: options[:email],
|
|
364
|
+
country: address[:country],
|
|
365
|
+
phone: options[:phone] || address[:phone],
|
|
366
|
+
firstName: first_name,
|
|
367
|
+
lastName: last_name,
|
|
368
|
+
address: address.dig(:address1),
|
|
369
|
+
city: address.dig(:city),
|
|
370
|
+
state: address.dig(:state),
|
|
371
|
+
zip: address.dig(:zip)
|
|
372
|
+
}.compact
|
|
373
|
+
end
|
|
374
|
+
|
|
375
|
+
def add_cardholder_name_verification(post, payment, transaction_type, options)
|
|
376
|
+
return unless transaction_type == 'Auth'
|
|
377
|
+
|
|
378
|
+
post[:cardHolderNameVerification] = { performNameVerification: 'true' } if options[:perform_name_verification]
|
|
379
|
+
|
|
380
|
+
cardholder_data = {
|
|
381
|
+
firstName: payment.first_name,
|
|
382
|
+
lastName: payment.last_name
|
|
383
|
+
}.compact
|
|
384
|
+
|
|
385
|
+
post[:billingAddress] ||= {}
|
|
386
|
+
post[:billingAddress].merge!(cardholder_data)
|
|
387
|
+
end
|
|
388
|
+
|
|
389
|
+
def execute_3ds_flow(post, money, payment, transaction_type, options = {})
|
|
390
|
+
post_3ds = post.dup
|
|
391
|
+
|
|
392
|
+
MultiResponse.run do |r|
|
|
393
|
+
r.process { commit(:init_payment, post) }
|
|
394
|
+
r.process do
|
|
395
|
+
three_d_params = r.params.dig('paymentOption', 'card', 'threeD')
|
|
396
|
+
three_d_supported = three_d_params['v2supported'] == 'true'
|
|
397
|
+
|
|
398
|
+
[true, 'true'].include?(options[:force_3d_secure])
|
|
399
|
+
|
|
400
|
+
next r.process { Response.new(false, '3D Secure is required but not supported') } if !three_d_supported && [true, 'true'].include?(options[:force_3d_secure])
|
|
401
|
+
|
|
402
|
+
if three_d_supported
|
|
403
|
+
add_3ds_data(post_3ds, options.merge(version: three_d_params['version']))
|
|
404
|
+
post_3ds[:relatedTransactionId] = r.authorization
|
|
405
|
+
end
|
|
406
|
+
|
|
407
|
+
commit(:purchase, post_3ds)
|
|
408
|
+
end
|
|
409
|
+
end
|
|
410
|
+
end
|
|
411
|
+
|
|
412
|
+
def add_3ds_data(post, options = {})
|
|
413
|
+
return unless options[:three_ds_2]
|
|
414
|
+
|
|
415
|
+
three_d_secure = options[:three_ds_2]
|
|
416
|
+
# 01 => Challenge requested, 02 => Exemption requested, 03 or not sending parameter => No preference
|
|
417
|
+
challenge_preference = if [true, 'true'].include?(options[:force_3d_secure])
|
|
418
|
+
'01'
|
|
419
|
+
elsif [false, 'false'].include?(options[:force_3d_secure])
|
|
420
|
+
'02'
|
|
421
|
+
end
|
|
422
|
+
browser_info_3ds = three_d_secure[:browser_info]
|
|
423
|
+
payment_options = post[:paymentOption] ||= {}
|
|
424
|
+
card = payment_options[:card] ||= {}
|
|
425
|
+
card[:threeD] = {
|
|
426
|
+
v2AdditionalParams: {
|
|
427
|
+
challengeWindowSize: browser_info_3ds[:browser_size],
|
|
428
|
+
challengePreference: challenge_preference
|
|
429
|
+
}.compact,
|
|
430
|
+
browserDetails: {
|
|
431
|
+
acceptHeader: browser_info_3ds[:accept_header],
|
|
432
|
+
ip: options[:ip],
|
|
433
|
+
javaEnabled: browser_info_3ds[:java],
|
|
434
|
+
javaScriptEnabled: browser_info_3ds[:javascript] || false,
|
|
435
|
+
language: browser_info_3ds[:language],
|
|
436
|
+
colorDepth: browser_info_3ds[:depth], # Possible values: 1, 4, 8, 15, 16, 24, 32, 48
|
|
437
|
+
screenHeight: browser_info_3ds[:height],
|
|
438
|
+
screenWidth: browser_info_3ds[:width],
|
|
439
|
+
timeZone: browser_info_3ds[:timezone],
|
|
440
|
+
userAgent: browser_info_3ds[:user_agent]
|
|
441
|
+
}.compact,
|
|
442
|
+
notificationURL: (options[:notification_url] || options[:callback_url]),
|
|
443
|
+
merchantURL: options[:merchant_url], # The URL of the merchant's fully qualified website.
|
|
444
|
+
version: options[:version], # returned from initPayment
|
|
445
|
+
methodCompletionInd: 'U', # to indicate "unavailable".
|
|
446
|
+
platformType: '02' # browser instead of app-based (app-based is only for SDK implementation)
|
|
447
|
+
}.compact
|
|
448
|
+
end
|
|
449
|
+
|
|
450
|
+
def current_timestamp
|
|
451
|
+
Time.now.utc.strftime('%Y%m%d%H%M%S')
|
|
452
|
+
end
|
|
453
|
+
|
|
454
|
+
def build_post_data(post, options = {})
|
|
455
|
+
post[:merchantId] = @options[:merchant_id]
|
|
456
|
+
post[:merchantSiteId] = @options[:merchant_site_id]
|
|
457
|
+
post[:timeStamp] = current_timestamp.to_i
|
|
458
|
+
post[:clientRequestId] = SecureRandom.uuid
|
|
459
|
+
post[:clientUniqueId] = options[:order_id] || generate_unique_id
|
|
460
|
+
end
|
|
461
|
+
|
|
462
|
+
def calculate_checksum(post, action)
|
|
463
|
+
common_keys = %i[merchantId merchantSiteId clientRequestId]
|
|
464
|
+
keys = case action
|
|
465
|
+
when :authenticate
|
|
466
|
+
[:timeStamp]
|
|
467
|
+
when :capture, :refund, :void
|
|
468
|
+
%i[clientUniqueId amount currency relatedTransactionId timeStamp]
|
|
469
|
+
else
|
|
470
|
+
%i[amount currency timeStamp]
|
|
471
|
+
end
|
|
472
|
+
|
|
473
|
+
to_sha = post.values_at(*common_keys.concat(keys)).push(@options[:secret_key]).join
|
|
474
|
+
Digest::SHA256.hexdigest(to_sha)
|
|
475
|
+
end
|
|
476
|
+
|
|
477
|
+
def send_session_request(post)
|
|
478
|
+
post[:checksum] = calculate_checksum(post, 'authenticate')
|
|
479
|
+
response = parse(ssl_post(url(:authenticate), post.to_json, headers)).with_indifferent_access
|
|
480
|
+
expiration_time = post[:timeStamp]
|
|
481
|
+
@options[:session_token] = response.dig('sessionToken')
|
|
482
|
+
@options[:token_expires] = expiration_time
|
|
483
|
+
|
|
484
|
+
Response.new(
|
|
485
|
+
response[:sessionToken].present?,
|
|
486
|
+
message_from(response),
|
|
487
|
+
response,
|
|
488
|
+
test: test?,
|
|
489
|
+
error_code: error_code_from(response)
|
|
490
|
+
)
|
|
491
|
+
end
|
|
492
|
+
|
|
493
|
+
def fetch_session_token(post = {})
|
|
494
|
+
build_post_data(post)
|
|
495
|
+
send_session_request(post)
|
|
496
|
+
end
|
|
497
|
+
|
|
498
|
+
def session_token_valid?
|
|
499
|
+
return false unless @options[:session_token] && @options[:token_expires]
|
|
500
|
+
|
|
501
|
+
(Time.now.utc.to_i - @options[:token_expires].to_i) < 900 # 15 minutes
|
|
502
|
+
end
|
|
503
|
+
|
|
504
|
+
def commit(action, post, authorization = nil, method = :post)
|
|
505
|
+
post[:sessionToken] = @options[:session_token] unless %i(capture refund).include?(action)
|
|
506
|
+
post[:checksum] = calculate_checksum(post, action)
|
|
507
|
+
|
|
508
|
+
response = parse(ssl_request(method, url(action, authorization), post.to_json, headers))
|
|
509
|
+
|
|
510
|
+
Response.new(
|
|
511
|
+
success_from(response),
|
|
512
|
+
message_from(response),
|
|
513
|
+
response,
|
|
514
|
+
authorization: authorization_from(action, response, post),
|
|
515
|
+
network_transaction_id: network_transaction_id_from(response),
|
|
516
|
+
test: test?,
|
|
517
|
+
error_code: error_code_from(response)
|
|
518
|
+
)
|
|
519
|
+
rescue ResponseError => e
|
|
520
|
+
response = parse(e.response.body)
|
|
521
|
+
@options[:session_token] = '' if e.response.code == '401'
|
|
522
|
+
|
|
523
|
+
Response.new(false, message_from(response), response, test: test?)
|
|
524
|
+
end
|
|
525
|
+
|
|
526
|
+
def url(action, id = nil)
|
|
527
|
+
"#{test? ? test_url : live_url}#{ENDPOINTS_MAPPING[action] % id}"
|
|
528
|
+
end
|
|
529
|
+
|
|
530
|
+
def error_code_from(response)
|
|
531
|
+
response[:errCode] == 0 ? response[:gwErrorCode] : response[:errCode]
|
|
532
|
+
end
|
|
533
|
+
|
|
534
|
+
def headers
|
|
535
|
+
{ 'Content-Type' => 'application/json' }.tap do |headers|
|
|
536
|
+
headers['Authorization'] = "Bearer #{@options[:session_token]}" if @options[:session_token]
|
|
537
|
+
end
|
|
538
|
+
end
|
|
539
|
+
|
|
540
|
+
def parse(body)
|
|
541
|
+
body = '{}' if body.blank?
|
|
542
|
+
|
|
543
|
+
JSON.parse(body).with_indifferent_access
|
|
544
|
+
rescue JSON::ParserError
|
|
545
|
+
{
|
|
546
|
+
errors: body,
|
|
547
|
+
status: 'Unable to parse JSON response'
|
|
548
|
+
}.with_indifferent_access
|
|
549
|
+
end
|
|
550
|
+
|
|
551
|
+
def success_from(response)
|
|
552
|
+
response[:status] == 'SUCCESS' && %w[APPROVED REDIRECT PENDING].include?(response[:transactionStatus])
|
|
553
|
+
end
|
|
554
|
+
|
|
555
|
+
def authorization_from(action, response, post)
|
|
556
|
+
if zero_auth?(post)
|
|
557
|
+
response.dig(:paymentOption, :userPaymentOptionId)
|
|
558
|
+
else
|
|
559
|
+
response[:transactionId]
|
|
560
|
+
end
|
|
561
|
+
end
|
|
562
|
+
|
|
563
|
+
def zero_auth?(post)
|
|
564
|
+
post[:userTokenId].present? && post[:transactionType] == 'Auth' && post[:amount].to_i == 0
|
|
565
|
+
end
|
|
566
|
+
|
|
567
|
+
def message_from(response)
|
|
568
|
+
reason = response[:reason]&.present? ? response[:reason] : nil
|
|
569
|
+
response[:gwErrorReason] || reason || response[:transactionStatus]
|
|
570
|
+
end
|
|
571
|
+
end
|
|
572
|
+
end
|
|
573
|
+
end
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
require 'rexml/document'
|
|
4
4
|
|
|
5
|
-
module ActiveMerchant
|
|
6
|
-
module Billing
|
|
5
|
+
module ActiveMerchant # :nodoc:
|
|
6
|
+
module Billing # :nodoc:
|
|
7
7
|
# = Ogone DirectLink Gateway
|
|
8
8
|
#
|
|
9
9
|
# DirectLink is the API version of the Ogone Payment Platform. It allows server to server
|
|
@@ -263,7 +263,7 @@ module ActiveMerchant #:nodoc:
|
|
|
263
263
|
end
|
|
264
264
|
|
|
265
265
|
def add_payment_source(post, payment_source, options)
|
|
266
|
-
add_d3d(post, options) if options[:d3d]
|
|
266
|
+
add_d3d(post, options) if options[:d3d] || three_d_secure(options)
|
|
267
267
|
if payment_source.is_a?(String)
|
|
268
268
|
add_alias(post, payment_source, options[:alias_operation])
|
|
269
269
|
add_eci(post, options[:eci] || '9')
|
|
@@ -460,7 +460,7 @@ module ActiveMerchant #:nodoc:
|
|
|
460
460
|
raise "Unknown signature algorithm #{algorithm}"
|
|
461
461
|
end
|
|
462
462
|
|
|
463
|
-
filtered_params = signed_parameters.
|
|
463
|
+
filtered_params = signed_parameters.reject { |_k, v| v.nil? || v == '' }
|
|
464
464
|
sha_encryptor.hexdigest(
|
|
465
465
|
filtered_params.sort_by { |k, _v| k.upcase }.map { |k, v| "#{k.upcase}=#{v}#{secret}" }.join('')
|
|
466
466
|
).upcase
|
|
@@ -494,6 +494,10 @@ module ActiveMerchant #:nodoc:
|
|
|
494
494
|
end
|
|
495
495
|
response_hash
|
|
496
496
|
end
|
|
497
|
+
|
|
498
|
+
def three_d_secure(options)
|
|
499
|
+
options[:three_d_secure] ? options[:three_d_secure][:required] : false
|
|
500
|
+
end
|
|
497
501
|
end
|
|
498
502
|
|
|
499
503
|
class OgoneResponse < Response
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'active_merchant/billing/rails'
|
|
2
2
|
|
|
3
|
-
module ActiveMerchant
|
|
4
|
-
module Billing
|
|
3
|
+
module ActiveMerchant # :nodoc:
|
|
4
|
+
module Billing # :nodoc:
|
|
5
5
|
class OmiseGateway < Gateway
|
|
6
6
|
API_URL = 'https://api.omise.co/'
|
|
7
7
|
VAULT_URL = 'https://vault.omise.co/'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
module ActiveMerchant
|
|
2
|
-
module Billing
|
|
1
|
+
module ActiveMerchant # :nodoc:
|
|
2
|
+
module Billing # :nodoc:
|
|
3
3
|
class OpenpayGateway < Gateway
|
|
4
4
|
class_attribute :mx_live_url, :mx_test_url
|
|
5
5
|
class_attribute :co_live_url, :co_test_url
|
|
@@ -201,11 +201,13 @@ module ActiveMerchant #:nodoc:
|
|
|
201
201
|
response = http_request(method, resource, parameters, options)
|
|
202
202
|
success = !error?(response)
|
|
203
203
|
|
|
204
|
-
Response.new(
|
|
204
|
+
Response.new(
|
|
205
|
+
success,
|
|
205
206
|
(success ? response['error_code'] : response['description']),
|
|
206
207
|
response,
|
|
207
208
|
test: test?,
|
|
208
|
-
authorization: response['id']
|
|
209
|
+
authorization: response['id']
|
|
210
|
+
)
|
|
209
211
|
end
|
|
210
212
|
|
|
211
213
|
def http_request(method, resource, parameters = {}, options = {})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
module ActiveMerchant
|
|
2
|
-
module Billing
|
|
1
|
+
module ActiveMerchant # :nodoc:
|
|
2
|
+
module Billing # :nodoc:
|
|
3
3
|
class OppGateway < Gateway
|
|
4
4
|
# = Open Payment Platform
|
|
5
5
|
#
|
|
@@ -125,8 +125,7 @@ module ActiveMerchant #:nodoc:
|
|
|
125
125
|
def purchase(money, payment, options = {})
|
|
126
126
|
# debit
|
|
127
127
|
options[:registrationId] = payment if payment.is_a?(String)
|
|
128
|
-
execute_dbpa(options[:risk_workflow] ? 'PA.CP' : 'DB',
|
|
129
|
-
money, payment, options)
|
|
128
|
+
execute_dbpa(options[:risk_workflow] ? 'PA.CP' : 'DB', money, payment, options)
|
|
130
129
|
end
|
|
131
130
|
|
|
132
131
|
def authorize(money, payment, options = {})
|