activemerchant 1.79.2 → 1.129.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG +1391 -0
- data/README.md +29 -14
- data/lib/active_merchant/billing/avs_result.rb +25 -28
- data/lib/active_merchant/billing/base.rb +0 -13
- data/lib/active_merchant/billing/check.rb +55 -22
- data/lib/active_merchant/billing/compatibility.rb +10 -12
- data/lib/active_merchant/billing/credit_card.rb +82 -62
- data/lib/active_merchant/billing/credit_card_formatting.rb +4 -4
- data/lib/active_merchant/billing/credit_card_methods.rb +328 -58
- data/lib/active_merchant/billing/cvv_result.rb +0 -1
- data/lib/active_merchant/billing/gateway.rb +61 -56
- data/lib/active_merchant/billing/gateways/adyen.rb +562 -87
- data/lib/active_merchant/billing/gateways/airwallex.rb +370 -0
- data/lib/active_merchant/billing/gateways/alelo.rb +256 -0
- data/lib/active_merchant/billing/gateways/allied_wallet.rb +35 -36
- data/lib/active_merchant/billing/gateways/authorize_net.rb +297 -196
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +31 -24
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +94 -98
- data/lib/active_merchant/billing/gateways/axcessms.rb +64 -66
- data/lib/active_merchant/billing/gateways/balanced.rb +72 -65
- data/lib/active_merchant/billing/gateways/bambora_apac.rb +222 -0
- data/lib/active_merchant/billing/gateways/bank_frick.rb +16 -16
- data/lib/active_merchant/billing/gateways/banwire.rb +12 -12
- data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +140 -69
- data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +7 -7
- data/lib/active_merchant/billing/gateways/be2bill.rb +7 -7
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +115 -115
- data/lib/active_merchant/billing/gateways/beanstream.rb +39 -13
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +1 -2
- data/lib/active_merchant/billing/gateways/blue_pay.rb +87 -58
- data/lib/active_merchant/billing/gateways/blue_snap.rb +405 -104
- data/lib/active_merchant/billing/gateways/bogus.rb +34 -30
- data/lib/active_merchant/billing/gateways/borgun.rb +97 -47
- data/lib/active_merchant/billing/gateways/bpoint.rb +20 -20
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -3
- data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +1 -1
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +561 -259
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +1 -1
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +53 -54
- data/lib/active_merchant/billing/gateways/cams.rb +31 -31
- data/lib/active_merchant/billing/gateways/card_connect.rb +85 -33
- data/lib/active_merchant/billing/gateways/card_save.rb +7 -9
- data/lib/active_merchant/billing/gateways/card_stream.rb +187 -169
- data/lib/active_merchant/billing/gateways/cardknox.rb +24 -25
- data/lib/active_merchant/billing/gateways/cardprocess.rb +9 -7
- data/lib/active_merchant/billing/gateways/cashnet.rb +43 -27
- data/lib/active_merchant/billing/gateways/cc5.rb +14 -17
- data/lib/active_merchant/billing/gateways/cecabank.rb +62 -52
- data/lib/active_merchant/billing/gateways/cenpos.rb +63 -62
- data/lib/active_merchant/billing/gateways/checkout.rb +21 -23
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +391 -113
- data/lib/active_merchant/billing/gateways/citrus_pay.rb +1 -3
- data/lib/active_merchant/billing/gateways/clearhaus.rb +40 -41
- data/lib/active_merchant/billing/gateways/commerce_hub.rb +361 -0
- data/lib/active_merchant/billing/gateways/commercegate.rb +11 -12
- data/lib/active_merchant/billing/gateways/conekta.rb +35 -30
- data/lib/active_merchant/billing/gateways/creditcall.rb +59 -59
- data/lib/active_merchant/billing/gateways/credorax.rb +326 -145
- data/lib/active_merchant/billing/gateways/ct_payment.rb +269 -0
- data/lib/active_merchant/billing/gateways/culqi.rb +53 -53
- data/lib/active_merchant/billing/gateways/cyber_source/cyber_source_common.rb +36 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +566 -208
- data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +456 -0
- data/lib/active_merchant/billing/gateways/d_local.rb +342 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +40 -56
- data/lib/active_merchant/billing/gateways/decidir.rb +358 -0
- data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
- data/lib/active_merchant/billing/gateways/dibs.rb +34 -40
- data/lib/active_merchant/billing/gateways/digitzs.rb +48 -45
- data/lib/active_merchant/billing/gateways/ebanx.rb +110 -60
- data/lib/active_merchant/billing/gateways/efsnet.rb +46 -50
- data/lib/active_merchant/billing/gateways/elavon.rb +351 -189
- data/lib/active_merchant/billing/gateways/element.rb +106 -56
- data/lib/active_merchant/billing/gateways/epay.rb +74 -64
- data/lib/active_merchant/billing/gateways/evo_ca.rb +13 -14
- data/lib/active_merchant/billing/gateways/eway.rb +74 -73
- data/lib/active_merchant/billing/gateways/eway_managed.rb +85 -87
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +105 -60
- data/lib/active_merchant/billing/gateways/exact.rb +29 -37
- data/lib/active_merchant/billing/gateways/ezic.rb +21 -22
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +70 -48
- data/lib/active_merchant/billing/gateways/federated_canada.rb +11 -13
- data/lib/active_merchant/billing/gateways/finansbank.rb +3 -4
- data/lib/active_merchant/billing/gateways/first_giving.rb +23 -23
- data/lib/active_merchant/billing/gateways/first_pay.rb +33 -13
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +106 -105
- data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +505 -0
- data/lib/active_merchant/billing/gateways/flo2cash.rb +36 -36
- data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +2 -2
- data/lib/active_merchant/billing/gateways/forte.rb +70 -40
- data/lib/active_merchant/billing/gateways/garanti.rb +24 -31
- data/lib/active_merchant/billing/gateways/global_collect.rb +378 -154
- data/lib/active_merchant/billing/gateways/global_transport.rb +12 -13
- data/lib/active_merchant/billing/gateways/hdfc.rb +55 -57
- data/lib/active_merchant/billing/gateways/hps.rb +236 -69
- data/lib/active_merchant/billing/gateways/iats_payments.rb +61 -39
- data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +1 -1
- data/lib/active_merchant/billing/gateways/inspire.rb +41 -47
- data/lib/active_merchant/billing/gateways/instapay.rb +10 -14
- data/lib/active_merchant/billing/gateways/ipg.rb +420 -0
- data/lib/active_merchant/billing/gateways/ipp.rb +25 -24
- data/lib/active_merchant/billing/gateways/iridium.rb +243 -244
- data/lib/active_merchant/billing/gateways/itransact.rb +14 -14
- data/lib/active_merchant/billing/gateways/iveri.rb +73 -34
- data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +145 -152
- data/lib/active_merchant/billing/gateways/jetpay_v2.rb +154 -159
- data/lib/active_merchant/billing/gateways/komoju.rb +16 -16
- data/lib/active_merchant/billing/gateways/kushki.rb +127 -57
- data/lib/active_merchant/billing/gateways/latitude19.rb +111 -115
- data/lib/active_merchant/billing/gateways/linkpoint.rb +82 -85
- data/lib/active_merchant/billing/gateways/litle.rb +247 -53
- data/lib/active_merchant/billing/gateways/mastercard.rb +41 -23
- data/lib/active_merchant/billing/gateways/maxipago.rb +5 -5
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +135 -49
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +62 -29
- data/lib/active_merchant/billing/gateways/merchant_one.rb +16 -20
- data/lib/active_merchant/billing/gateways/merchant_partners.rb +40 -40
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +54 -60
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +42 -44
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +52 -14
- data/lib/active_merchant/billing/gateways/mercury.rb +47 -51
- data/lib/active_merchant/billing/gateways/metrics_global.rb +32 -42
- data/lib/active_merchant/billing/gateways/micropayment.rb +42 -45
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +7 -7
- data/lib/active_merchant/billing/gateways/migs.rb +45 -40
- data/lib/active_merchant/billing/gateways/mit.rb +260 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +2 -2
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +29 -31
- data/lib/active_merchant/billing/gateways/moka.rb +290 -0
- data/lib/active_merchant/billing/gateways/monei.rb +255 -138
- data/lib/active_merchant/billing/gateways/moneris.rb +226 -88
- data/lib/active_merchant/billing/gateways/money_movers.rb +11 -13
- data/lib/active_merchant/billing/gateways/mundipagg.rb +117 -43
- data/lib/active_merchant/billing/gateways/nab_transact.rb +28 -31
- data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +13 -15
- data/lib/active_merchant/billing/gateways/net_registry.rb +12 -12
- data/lib/active_merchant/billing/gateways/netaxept.rb +33 -34
- data/lib/active_merchant/billing/gateways/netbanx.rb +167 -80
- data/lib/active_merchant/billing/gateways/netbilling.rb +27 -30
- data/lib/active_merchant/billing/gateways/netpay.rb +10 -10
- data/lib/active_merchant/billing/gateways/network_merchants.rb +7 -11
- data/lib/active_merchant/billing/gateways/nmi.rb +134 -48
- data/lib/active_merchant/billing/gateways/ogone.rb +88 -58
- data/lib/active_merchant/billing/gateways/omise.rb +30 -31
- data/lib/active_merchant/billing/gateways/openpay.rb +45 -26
- data/lib/active_merchant/billing/gateways/opp.rb +166 -144
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +67 -64
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +5 -7
- data/lib/active_merchant/billing/gateways/orbital.rb +726 -382
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +26 -27
- data/lib/active_merchant/billing/gateways/pagarme.rb +47 -56
- data/lib/active_merchant/billing/gateways/pago_facil.rb +12 -14
- data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
- data/lib/active_merchant/billing/gateways/pay_conex.rb +39 -40
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +65 -65
- data/lib/active_merchant/billing/gateways/pay_hub.rb +39 -39
- data/lib/active_merchant/billing/gateways/pay_junction.rb +37 -37
- data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +70 -54
- data/lib/active_merchant/billing/gateways/pay_secure.rb +15 -17
- data/lib/active_merchant/billing/gateways/pay_trace.rb +450 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +71 -47
- data/lib/active_merchant/billing/gateways/payeezy.rb +159 -32
- data/lib/active_merchant/billing/gateways/payex.rb +39 -42
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +41 -36
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +11 -8
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +3 -3
- data/lib/active_merchant/billing/gateways/payflow.rb +178 -54
- data/lib/active_merchant/billing/gateways/payflow_express.rb +61 -65
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +0 -1
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +1 -2
- data/lib/active_merchant/billing/gateways/payment_express.rb +66 -58
- data/lib/active_merchant/billing/gateways/paymentez.rb +114 -25
- data/lib/active_merchant/billing/gateways/paymill.rb +134 -133
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +2 -1
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +4 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +27 -14
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +1 -1
- data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +2 -2
- data/lib/active_merchant/billing/gateways/paypal_express.rb +5 -2
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +1 -1
- data/lib/active_merchant/billing/gateways/paysafe.rb +420 -0
- data/lib/active_merchant/billing/gateways/payscout.rb +10 -13
- data/lib/active_merchant/billing/gateways/paystation.rb +79 -82
- data/lib/active_merchant/billing/gateways/payu_in.rb +59 -58
- data/lib/active_merchant/billing/gateways/payu_latam.rb +139 -97
- data/lib/active_merchant/billing/gateways/payway.rb +27 -27
- data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
- data/lib/active_merchant/billing/gateways/pin.rb +87 -34
- data/lib/active_merchant/billing/gateways/plexo.rb +308 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +82 -82
- data/lib/active_merchant/billing/gateways/priority.rb +392 -0
- data/lib/active_merchant/billing/gateways/pro_pay.rb +139 -140
- data/lib/active_merchant/billing/gateways/psigate.rb +44 -44
- data/lib/active_merchant/billing/gateways/psl_card.rb +29 -37
- data/lib/active_merchant/billing/gateways/qbms.rb +75 -76
- data/lib/active_merchant/billing/gateways/quantum.rb +21 -23
- data/lib/active_merchant/billing/gateways/quickbooks.rb +142 -55
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +103 -107
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +156 -158
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +7 -8
- data/lib/active_merchant/billing/gateways/quickpay.rb +1 -3
- data/lib/active_merchant/billing/gateways/qvalent.rb +137 -68
- data/lib/active_merchant/billing/gateways/rapyd.rb +319 -0
- data/lib/active_merchant/billing/gateways/reach.rb +277 -0
- data/lib/active_merchant/billing/gateways/realex.rb +132 -50
- data/lib/active_merchant/billing/gateways/redsys.rb +382 -186
- data/lib/active_merchant/billing/gateways/s5.rb +16 -16
- data/lib/active_merchant/billing/gateways/safe_charge.rb +83 -47
- data/lib/active_merchant/billing/gateways/sage.rb +49 -48
- data/lib/active_merchant/billing/gateways/sage_pay.rb +76 -83
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +13 -15
- data/lib/active_merchant/billing/gateways/secure_net.rb +32 -40
- data/lib/active_merchant/billing/gateways/secure_pay.rb +30 -40
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +23 -26
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +14 -16
- data/lib/active_merchant/billing/gateways/securion_pay.rb +69 -31
- data/lib/active_merchant/billing/gateways/shift4.rb +342 -0
- data/lib/active_merchant/billing/gateways/simetrik.rb +368 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +52 -53
- data/lib/active_merchant/billing/gateways/smart_ps.rb +51 -60
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +29 -29
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +66 -47
- data/lib/active_merchant/billing/gateways/stripe.rb +309 -148
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +556 -0
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +18 -23
- data/lib/active_merchant/billing/gateways/telr.rb +46 -48
- data/lib/active_merchant/billing/gateways/tns.rb +8 -7
- data/lib/active_merchant/billing/gateways/trans_first.rb +37 -37
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +249 -245
- data/lib/active_merchant/billing/gateways/transact_pro.rb +25 -27
- data/lib/active_merchant/billing/gateways/transax.rb +6 -8
- data/lib/active_merchant/billing/gateways/transnational.rb +1 -2
- data/lib/active_merchant/billing/gateways/trexle.rb +22 -18
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +161 -88
- data/lib/active_merchant/billing/gateways/usa_epay.rb +5 -6
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +231 -238
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +129 -55
- data/lib/active_merchant/billing/gateways/vanco.rb +42 -33
- data/lib/active_merchant/billing/gateways/verifi.rb +52 -53
- data/lib/active_merchant/billing/gateways/viaklix.rb +18 -22
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +115 -74
- data/lib/active_merchant/billing/gateways/vpos.rb +223 -0
- data/lib/active_merchant/billing/gateways/webpay.rb +9 -9
- data/lib/active_merchant/billing/gateways/wepay.rb +38 -41
- data/lib/active_merchant/billing/gateways/wirecard.rb +36 -37
- data/lib/active_merchant/billing/gateways/wompi.rb +197 -0
- data/lib/active_merchant/billing/gateways/world_net.rb +39 -38
- data/lib/active_merchant/billing/gateways/worldpay.rb +756 -142
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +73 -83
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +31 -31
- data/lib/active_merchant/billing/model.rb +2 -2
- data/lib/active_merchant/billing/network_tokenization_credit_card.rb +3 -3
- data/lib/active_merchant/billing/rails.rb +1 -1
- data/lib/active_merchant/billing/response.rb +32 -13
- data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
- data/lib/active_merchant/billing.rb +1 -0
- data/lib/active_merchant/connection.rb +24 -38
- data/lib/active_merchant/country.rb +9 -5
- data/lib/active_merchant/errors.rb +4 -1
- data/lib/active_merchant/net_http_ssl_connection.rb +2 -0
- data/lib/active_merchant/network_connection_retries.rb +28 -31
- data/lib/active_merchant/post_data.rb +5 -3
- data/lib/active_merchant/posts_data.rb +5 -7
- data/lib/active_merchant/version.rb +1 -1
- data/lib/active_merchant.rb +3 -3
- data/lib/activemerchant.rb +1 -1
- data/lib/certs/cacert.pem +1592 -2329
- data/lib/support/gateway_support.rb +8 -10
- data/lib/support/ssl_verify.rb +9 -14
- data/lib/support/ssl_version.rb +9 -10
- metadata +98 -37
- data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +0 -246
- data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +0 -13
- data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +0 -29
- data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +0 -66
- data/lib/active_merchant/billing/gateways/moneris_us.rb +0 -309
@@ -3,22 +3,24 @@ require 'nokogiri'
|
|
3
3
|
module ActiveMerchant
|
4
4
|
module Billing
|
5
5
|
class BlueSnapGateway < Gateway
|
6
|
-
self.test_url =
|
7
|
-
self.live_url =
|
8
|
-
self.supported_countries = %w(US CA GB AT BE BG HR CY CZ DK EE FI FR DE GR HU IE IT LV LT LU MT NL PL PT RO SK SI ES SE)
|
6
|
+
self.test_url = 'https://sandbox.bluesnap.com/services/2'
|
7
|
+
self.live_url = 'https://ws.bluesnap.com/services/2'
|
8
|
+
self.supported_countries = %w(US CA GB AT BE BG HR CY CZ DK EE FI FR DE GR HU IE IT LV LT LU MT NL PL PT RO SK SI ES SE AR BO BR BZ CL CO CR DO EC GF GP GT HN HT MF MQ MX NI PA PE PR PY SV UY VE)
|
9
9
|
|
10
10
|
self.default_currency = 'USD'
|
11
|
-
self.supported_cardtypes = [
|
11
|
+
self.supported_cardtypes = %i[visa master american_express discover jcb diners_club maestro naranja cabal]
|
12
|
+
self.currencies_without_fractions = %w(BYR CLP ILS JPY KRW VND XOF)
|
13
|
+
self.currencies_with_three_decimal_places = %w(BHD JOD KWD OMR TND)
|
12
14
|
|
13
15
|
self.homepage_url = 'https://home.bluesnap.com/'
|
14
16
|
self.display_name = 'BlueSnap'
|
15
17
|
|
16
18
|
TRANSACTIONS = {
|
17
|
-
purchase:
|
18
|
-
authorize:
|
19
|
-
capture:
|
20
|
-
void:
|
21
|
-
refund:
|
19
|
+
purchase: 'AUTH_CAPTURE',
|
20
|
+
authorize: 'AUTH_ONLY',
|
21
|
+
capture: 'CAPTURE',
|
22
|
+
void: 'AUTH_REVERSAL',
|
23
|
+
refund: 'REFUND'
|
22
24
|
}
|
23
25
|
|
24
26
|
CVC_CODE_TRANSLATOR = {
|
@@ -56,67 +58,101 @@ module ActiveMerchant
|
|
56
58
|
'line1: N, zip: M, name: N' => 'W',
|
57
59
|
'line1: N, zip: N, name: U' => 'N',
|
58
60
|
'line1: N, zip: N, name: M' => 'K',
|
59
|
-
'line1: N, zip: N, name: N' => 'N'
|
61
|
+
'line1: N, zip: N, name: N' => 'N'
|
60
62
|
}
|
61
63
|
|
62
|
-
|
64
|
+
BANK_ACCOUNT_TYPE_MAPPING = {
|
65
|
+
'personal_checking' => 'CONSUMER_CHECKING',
|
66
|
+
'personal_savings' => 'CONSUMER_SAVINGS',
|
67
|
+
'business_checking' => 'CORPORATE_CHECKING',
|
68
|
+
'business_savings' => 'CORPORATE_SAVINGS'
|
69
|
+
}
|
70
|
+
|
71
|
+
SHOPPER_INITIATOR = %w(CUSTOMER CARDHOLDER)
|
72
|
+
|
73
|
+
STATE_CODE_COUNTRIES = %w(US CA)
|
74
|
+
|
75
|
+
def initialize(options = {})
|
63
76
|
requires!(options, :api_username, :api_password)
|
64
77
|
super
|
65
78
|
end
|
66
79
|
|
67
|
-
def purchase(money, payment_method, options={})
|
68
|
-
|
69
|
-
|
80
|
+
def purchase(money, payment_method, options = {})
|
81
|
+
payment_method_details = PaymentMethodDetails.new(payment_method)
|
82
|
+
|
83
|
+
commit(:purchase, options, :post, payment_method_details) do |doc|
|
84
|
+
if payment_method_details.alt_transaction?
|
85
|
+
add_alt_transaction_purchase(doc, money, payment_method_details, options)
|
86
|
+
else
|
87
|
+
add_auth_purchase(doc, money, payment_method, options)
|
88
|
+
end
|
70
89
|
end
|
71
90
|
end
|
72
91
|
|
73
|
-
def authorize(money, payment_method, options={})
|
74
|
-
commit(:authorize) do |doc|
|
92
|
+
def authorize(money, payment_method, options = {})
|
93
|
+
commit(:authorize, options) do |doc|
|
75
94
|
add_auth_purchase(doc, money, payment_method, options)
|
76
95
|
end
|
77
96
|
end
|
78
97
|
|
79
|
-
def capture(money, authorization, options={})
|
80
|
-
commit(:capture, :put) do |doc|
|
98
|
+
def capture(money, authorization, options = {})
|
99
|
+
commit(:capture, options, :put) do |doc|
|
81
100
|
add_authorization(doc, authorization)
|
82
101
|
add_order(doc, options)
|
102
|
+
add_amount(doc, money, options) if options[:include_capture_amount] == true
|
83
103
|
end
|
84
104
|
end
|
85
105
|
|
86
|
-
def refund(money, authorization, options={})
|
87
|
-
|
88
|
-
|
89
|
-
add_amount(doc, money, options)
|
90
|
-
|
106
|
+
def refund(money, authorization, options = {})
|
107
|
+
options[:endpoint] = options[:merchant_transaction_id] ? "/refund/merchant/#{options[:merchant_transaction_id]}" : "/refund/#{authorization}"
|
108
|
+
commit(:refund, options, :post) do |doc|
|
109
|
+
add_amount(doc, money, options) if money
|
110
|
+
%i[reason cancel_subscription tax_amount].each { |field| send_when_present(doc, field, options) }
|
111
|
+
add_metadata(doc, options)
|
91
112
|
end
|
92
113
|
end
|
93
114
|
|
94
|
-
def void(authorization, options={})
|
95
|
-
commit(:void, :put) do |doc|
|
115
|
+
def void(authorization, options = {})
|
116
|
+
commit(:void, options, :put) do |doc|
|
96
117
|
add_authorization(doc, authorization)
|
97
118
|
add_order(doc, options)
|
98
119
|
end
|
99
120
|
end
|
100
121
|
|
101
|
-
def verify(payment_method, options={})
|
122
|
+
def verify(payment_method, options = {})
|
102
123
|
authorize(0, payment_method, options)
|
103
124
|
end
|
104
125
|
|
105
|
-
def store(
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
126
|
+
def store(payment_method, options = {})
|
127
|
+
payment_method_details = PaymentMethodDetails.new(payment_method)
|
128
|
+
|
129
|
+
commit(:store, options, :post, payment_method_details) do |doc|
|
130
|
+
add_personal_info(doc, payment_method, options)
|
131
|
+
add_echeck_company(doc, payment_method) if payment_method_details.check?
|
132
|
+
doc.send('payment-sources') do
|
133
|
+
payment_method_details.check? ? store_echeck(doc, payment_method) : store_credit_card(doc, payment_method)
|
112
134
|
end
|
113
135
|
add_order(doc, options)
|
114
136
|
end
|
115
137
|
end
|
116
138
|
|
139
|
+
def store_credit_card(doc, payment_method)
|
140
|
+
doc.send('credit-card-info') do
|
141
|
+
add_credit_card(doc, payment_method)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def store_echeck(doc, payment_method)
|
146
|
+
doc.send('ecp-info') do
|
147
|
+
doc.send('ecp') do
|
148
|
+
add_echeck(doc, payment_method)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
117
153
|
def verify_credentials
|
118
154
|
begin
|
119
|
-
ssl_get(
|
155
|
+
ssl_get(url.to_s, headers(options))
|
120
156
|
rescue ResponseError => e
|
121
157
|
return false if e.response.code.to_i == 401
|
122
158
|
end
|
@@ -132,64 +168,102 @@ module ActiveMerchant
|
|
132
168
|
transcript.
|
133
169
|
gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
|
134
170
|
gsub(%r((<card-number>).+(</card-number>)), '\1[FILTERED]\2').
|
135
|
-
gsub(%r((<security-code>).+(</security-code>)), '\1[FILTERED]\2')
|
171
|
+
gsub(%r((<security-code>).+(</security-code>)), '\1[FILTERED]\2').
|
172
|
+
gsub(%r((<(?:public-)?account-number>).+(</(?:public-)?account-number>)), '\1[FILTERED]\2').
|
173
|
+
gsub(%r((<(?:public-)?routing-number>).+(</(?:public-)?routing-number>)), '\1[FILTERED]\2')
|
136
174
|
end
|
137
175
|
|
138
176
|
private
|
139
177
|
|
140
178
|
def add_auth_purchase(doc, money, payment_method, options)
|
141
|
-
doc.send(
|
179
|
+
doc.send('recurring-transaction', options[:recurring] ? 'RECURRING' : 'ECOMMERCE')
|
142
180
|
add_order(doc, options)
|
181
|
+
doc.send('store-card', options[:store_card] || false)
|
143
182
|
add_amount(doc, money, options)
|
144
|
-
doc
|
145
|
-
|
146
|
-
end
|
183
|
+
add_fraud_info(doc, payment_method, options)
|
184
|
+
add_stored_credentials(doc, options)
|
147
185
|
|
148
186
|
if payment_method.is_a?(String)
|
149
|
-
doc.send(
|
187
|
+
doc.send('vaulted-shopper-id', payment_method)
|
150
188
|
else
|
151
|
-
doc.send(
|
189
|
+
doc.send('card-holder-info') do
|
152
190
|
add_personal_info(doc, payment_method, options)
|
153
191
|
end
|
154
192
|
add_credit_card(doc, payment_method)
|
155
193
|
end
|
156
194
|
end
|
157
195
|
|
196
|
+
def add_stored_credentials(doc, options)
|
197
|
+
return unless stored_credential = options[:stored_credential]
|
198
|
+
|
199
|
+
initiator = stored_credential[:initiator]&.upcase
|
200
|
+
initiator = 'SHOPPER' if SHOPPER_INITIATOR.include?(initiator)
|
201
|
+
doc.send('transaction-initiator', initiator) if stored_credential[:initiator]
|
202
|
+
if stored_credential[:network_transaction_id]
|
203
|
+
doc.send('network-transaction-info') do
|
204
|
+
doc.send('original-network-transaction-id', stored_credential[:network_transaction_id])
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
158
209
|
def add_amount(doc, money, options)
|
159
|
-
|
160
|
-
doc.
|
210
|
+
currency = options[:currency] || currency(money)
|
211
|
+
doc.amount(localized_amount(money, currency))
|
212
|
+
doc.currency(currency)
|
161
213
|
end
|
162
214
|
|
163
|
-
def add_personal_info(doc,
|
164
|
-
doc.send(
|
165
|
-
doc.send(
|
215
|
+
def add_personal_info(doc, payment_method, options)
|
216
|
+
doc.send('first-name', payment_method.first_name)
|
217
|
+
doc.send('last-name', payment_method.last_name)
|
218
|
+
doc.send('personal-identification-number', options[:personal_identification_number]) if options[:personal_identification_number]
|
166
219
|
doc.email(options[:email]) if options[:email]
|
220
|
+
doc.phone(options[:phone_number]) if options[:phone_number]
|
167
221
|
add_address(doc, options)
|
168
222
|
end
|
169
223
|
|
170
224
|
def add_credit_card(doc, card)
|
171
|
-
doc.send(
|
172
|
-
doc.send(
|
173
|
-
doc.send(
|
174
|
-
doc.send(
|
175
|
-
doc.send(
|
225
|
+
doc.send('credit-card') do
|
226
|
+
doc.send('card-number', card.number)
|
227
|
+
doc.send('security-code', card.verification_value)
|
228
|
+
doc.send('expiration-month', card.month)
|
229
|
+
doc.send('expiration-year', card.year)
|
176
230
|
end
|
177
231
|
end
|
178
232
|
|
179
|
-
def
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
233
|
+
def add_metadata(doc, options)
|
234
|
+
transaction_meta_data = options[:transaction_meta_data] || []
|
235
|
+
return if transaction_meta_data.empty? && !options[:description]
|
236
|
+
|
237
|
+
doc.send('transaction-meta-data') do
|
238
|
+
# ensure backwards compatibility for calls expecting :description
|
239
|
+
# to become meta-data fields.
|
240
|
+
if options[:description]
|
241
|
+
doc.send('meta-data') do
|
242
|
+
doc.send('meta-key', 'description')
|
243
|
+
doc.send('meta-value', truncate(options[:description], 500))
|
244
|
+
doc.send('meta-description', 'Description')
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
# https://developers.bluesnap.com/v8976-XML/docs/meta-data
|
249
|
+
transaction_meta_data.each do |entry|
|
250
|
+
doc.send('meta-data') do
|
251
|
+
doc.send('meta-key', truncate(entry[:meta_key], 40))
|
252
|
+
doc.send('meta-value', truncate(entry[:meta_value], 500))
|
253
|
+
doc.send('meta-description', truncate(entry[:meta_description], 40))
|
254
|
+
doc.send('is-visible', truncate(entry[:meta_is_visible], 5))
|
255
|
+
end
|
185
256
|
end
|
186
257
|
end
|
187
258
|
end
|
188
259
|
|
189
260
|
def add_order(doc, options)
|
190
|
-
doc.send(
|
191
|
-
doc.send(
|
192
|
-
|
261
|
+
doc.send('merchant-transaction-id', truncate(options[:order_id], 50)) if options[:order_id]
|
262
|
+
doc.send('soft-descriptor', options[:soft_descriptor]) if options[:soft_descriptor]
|
263
|
+
doc.send('descriptor-phone-number', options[:descriptor_phone_number]) if options[:descriptor_phone_number]
|
264
|
+
add_metadata(doc, options)
|
265
|
+
add_3ds(doc, options[:three_d_secure]) if options[:three_d_secure]
|
266
|
+
add_level_3_data(doc, options)
|
193
267
|
end
|
194
268
|
|
195
269
|
def add_address(doc, options)
|
@@ -197,77 +271,221 @@ module ActiveMerchant
|
|
197
271
|
return unless address
|
198
272
|
|
199
273
|
doc.country(address[:country]) if address[:country]
|
200
|
-
doc.state(address[:state]) if address[:state]
|
201
|
-
doc.address(address[:
|
274
|
+
doc.state(address[:state]) if address[:state] && STATE_CODE_COUNTRIES.include?(address[:country])
|
275
|
+
doc.address(address[:address1]) if address[:address1]
|
276
|
+
doc.address2(address[:address2]) if address[:address2]
|
202
277
|
doc.city(address[:city]) if address[:city]
|
203
278
|
doc.zip(address[:zip]) if address[:zip]
|
204
279
|
end
|
205
280
|
|
281
|
+
def add_3ds(doc, three_d_secure_options)
|
282
|
+
eci = three_d_secure_options[:eci]
|
283
|
+
cavv = three_d_secure_options[:cavv]
|
284
|
+
xid = three_d_secure_options[:xid]
|
285
|
+
ds_transaction_id = three_d_secure_options[:ds_transaction_id]
|
286
|
+
version = three_d_secure_options[:version]
|
287
|
+
|
288
|
+
doc.send('three-d-secure') do
|
289
|
+
doc.eci(eci) if eci
|
290
|
+
doc.cavv(cavv) if cavv
|
291
|
+
doc.xid(xid) if xid
|
292
|
+
doc.send('three-d-secure-version', version) if version
|
293
|
+
doc.send('ds-transaction-id', ds_transaction_id) if ds_transaction_id
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
def add_level_3_data(doc, options)
|
298
|
+
return unless options[:customer_reference_number]
|
299
|
+
|
300
|
+
doc.send('level-3-data') do
|
301
|
+
send_when_present(doc, :customer_reference_number, options)
|
302
|
+
send_when_present(doc, :sales_tax_amount, options)
|
303
|
+
send_when_present(doc, :freight_amount, options)
|
304
|
+
send_when_present(doc, :duty_amount, options)
|
305
|
+
send_when_present(doc, :destination_zip_code, options)
|
306
|
+
send_when_present(doc, :destination_country_code, options)
|
307
|
+
send_when_present(doc, :ship_from_zip_code, options)
|
308
|
+
send_when_present(doc, :discount_amount, options)
|
309
|
+
send_when_present(doc, :tax_amount, options)
|
310
|
+
send_when_present(doc, :tax_rate, options)
|
311
|
+
add_level_3_data_items(doc, options[:level_3_data_items]) if options[:level_3_data_items]
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
def send_when_present(doc, options_key, options, xml_element_name = nil)
|
316
|
+
return unless options[options_key]
|
317
|
+
|
318
|
+
xml_element_name ||= options_key.to_s
|
319
|
+
|
320
|
+
doc.send(xml_element_name.dasherize, options[options_key])
|
321
|
+
end
|
322
|
+
|
323
|
+
def add_level_3_data_items(doc, items)
|
324
|
+
items.each do |item|
|
325
|
+
doc.send('level-3-data-item') do
|
326
|
+
item.each do |key, value|
|
327
|
+
key = key.to_s.dasherize
|
328
|
+
doc.send(key, value)
|
329
|
+
end
|
330
|
+
end
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
206
334
|
def add_authorization(doc, authorization)
|
207
|
-
doc.send(
|
335
|
+
doc.send('transaction-id', authorization)
|
336
|
+
end
|
337
|
+
|
338
|
+
def add_fraud_info(doc, payment_method, options)
|
339
|
+
doc.send('transaction-fraud-info') do
|
340
|
+
doc.send('shopper-ip-address', options[:ip]) if options[:ip]
|
341
|
+
if fraud_info = options[:transaction_fraud_info]
|
342
|
+
doc.send('fraud-session-id', fraud_info[:fraud_session_id]) if fraud_info[:fraud_session_id]
|
343
|
+
end
|
344
|
+
unless payment_method.is_a? String
|
345
|
+
doc.send('shipping-contact-info') do
|
346
|
+
add_shipping_contact_info(doc, payment_method, options)
|
347
|
+
end
|
348
|
+
end
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
def add_shipping_contact_info(doc, payment_method, options)
|
353
|
+
if address = options[:shipping_address]
|
354
|
+
# https://developers.bluesnap.com/v8976-XML/docs/shipping-contact-info
|
355
|
+
doc.send('first-name', payment_method.first_name)
|
356
|
+
doc.send('last-name', payment_method.last_name)
|
357
|
+
|
358
|
+
doc.country(address[:country]) if address[:country]
|
359
|
+
doc.state(address[:state]) if address[:state] && STATE_CODE_COUNTRIES.include?(address[:country])
|
360
|
+
doc.address1(address[:address1]) if address[:address1]
|
361
|
+
doc.address2(address[:address2]) if address[:address2]
|
362
|
+
doc.city(address[:city]) if address[:city]
|
363
|
+
doc.zip(address[:zip]) if address[:zip]
|
364
|
+
end
|
365
|
+
end
|
366
|
+
|
367
|
+
def add_alt_transaction_purchase(doc, money, payment_method_details, options)
|
368
|
+
doc.send('merchant-transaction-id', truncate(options[:order_id], 50)) if options[:order_id]
|
369
|
+
doc.send('soft-descriptor', options[:soft_descriptor]) if options[:soft_descriptor]
|
370
|
+
doc.send('descriptor-phone-number', options[:descriptor_phone_number]) if options[:descriptor_phone_number]
|
371
|
+
add_amount(doc, money, options)
|
372
|
+
|
373
|
+
vaulted_shopper_id = payment_method_details.vaulted_shopper_id
|
374
|
+
doc.send('vaulted-shopper-id', vaulted_shopper_id) if vaulted_shopper_id
|
375
|
+
|
376
|
+
add_echeck_transaction(doc, payment_method_details.payment_method, options, vaulted_shopper_id.present?) if payment_method_details.check?
|
377
|
+
|
378
|
+
add_fraud_info(doc, payment_method_details.payment_method, options)
|
379
|
+
add_stored_credentials(doc, options)
|
380
|
+
add_metadata(doc, options)
|
381
|
+
end
|
382
|
+
|
383
|
+
def add_echeck_transaction(doc, check, options, vaulted_shopper)
|
384
|
+
unless vaulted_shopper
|
385
|
+
doc.send('payer-info') do
|
386
|
+
add_personal_info(doc, check, options)
|
387
|
+
add_echeck_company(doc, check)
|
388
|
+
end
|
389
|
+
end
|
390
|
+
|
391
|
+
doc.send('ecp-transaction') do
|
392
|
+
add_echeck(doc, check) unless vaulted_shopper
|
393
|
+
end
|
394
|
+
|
395
|
+
doc.send('authorized-by-shopper', options[:authorized_by_shopper])
|
396
|
+
end
|
397
|
+
|
398
|
+
def add_echeck_company(doc, check)
|
399
|
+
doc.send('company-name', truncate(check.name, 50)) if check.account_holder_type = 'business'
|
400
|
+
end
|
401
|
+
|
402
|
+
def add_echeck(doc, check)
|
403
|
+
doc.send('account-number', check.account_number)
|
404
|
+
doc.send('routing-number', check.routing_number)
|
405
|
+
doc.send('account-type', BANK_ACCOUNT_TYPE_MAPPING["#{check.account_holder_type}_#{check.account_type}"])
|
208
406
|
end
|
209
407
|
|
210
408
|
def parse(response)
|
211
409
|
return bad_authentication_response if response.code.to_i == 401
|
410
|
+
return generic_error_response(response.body) if [403, 405, 429].include?(response.code.to_i)
|
212
411
|
|
213
412
|
parsed = {}
|
214
413
|
doc = Nokogiri::XML(response.body)
|
215
414
|
doc.root.xpath('*').each do |node|
|
216
|
-
|
217
|
-
|
415
|
+
name = node.name.downcase
|
416
|
+
if node.elements.empty?
|
417
|
+
parsed[name] = node.text
|
418
|
+
elsif name == 'transaction-meta-data'
|
419
|
+
metadata = []
|
420
|
+
node.elements.each { |m|
|
421
|
+
metadata.push parse_metadata_entry(m)
|
422
|
+
}
|
423
|
+
|
424
|
+
parsed['transaction-meta-data'] = metadata
|
218
425
|
else
|
219
|
-
node.elements.each
|
426
|
+
node.elements.each { |childnode|
|
220
427
|
parse_element(parsed, childnode)
|
221
|
-
|
428
|
+
}
|
222
429
|
end
|
223
430
|
end
|
224
431
|
|
225
|
-
parsed[
|
432
|
+
parsed['content-location-header'] = response['content-location']
|
226
433
|
parsed
|
227
434
|
end
|
228
435
|
|
436
|
+
def parse_metadata_entry(node)
|
437
|
+
entry = {}
|
438
|
+
|
439
|
+
node.elements.each { |e|
|
440
|
+
entry = entry.merge({
|
441
|
+
e.name => e.text
|
442
|
+
})
|
443
|
+
}
|
444
|
+
|
445
|
+
entry
|
446
|
+
end
|
447
|
+
|
229
448
|
def parse_element(parsed, node)
|
230
449
|
if !node.elements.empty?
|
231
|
-
node.elements.each {|e| parse_element(parsed, e) }
|
450
|
+
node.elements.each { |e| parse_element(parsed, e) }
|
232
451
|
else
|
233
452
|
parsed[node.name.downcase] = node.text
|
234
453
|
end
|
235
454
|
end
|
236
455
|
|
237
|
-
def api_request(action, request, verb)
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
e.response
|
242
|
-
end
|
456
|
+
def api_request(action, request, verb, payment_method_details, options)
|
457
|
+
ssl_request(verb, url(action, options, payment_method_details), request, headers(options))
|
458
|
+
rescue ResponseError => e
|
459
|
+
e.response
|
243
460
|
end
|
244
461
|
|
245
|
-
def commit(action, verb = :post)
|
246
|
-
request = build_xml_request(action) { |doc| yield(doc) }
|
247
|
-
response = api_request(action, request, verb)
|
462
|
+
def commit(action, options, verb = :post, payment_method_details = PaymentMethodDetails.new())
|
463
|
+
request = build_xml_request(action, payment_method_details) { |doc| yield(doc) }
|
464
|
+
response = api_request(action, request, verb, payment_method_details, options)
|
248
465
|
parsed = parse(response)
|
249
466
|
|
250
467
|
succeeded = success_from(action, response)
|
251
468
|
Response.new(
|
252
469
|
succeeded,
|
253
|
-
message_from(succeeded,
|
470
|
+
message_from(succeeded, response),
|
254
471
|
parsed,
|
255
|
-
authorization: authorization_from(action, parsed),
|
472
|
+
authorization: authorization_from(action, parsed, payment_method_details),
|
256
473
|
avs_result: avs_result(parsed),
|
257
474
|
cvv_result: cvv_result(parsed),
|
258
475
|
error_code: error_code_from(parsed),
|
259
|
-
test: test
|
476
|
+
test: test?
|
260
477
|
)
|
261
478
|
end
|
262
479
|
|
263
|
-
def url(action = nil)
|
480
|
+
def url(action = nil, options = {}, payment_method_details = PaymentMethodDetails.new())
|
264
481
|
base = test? ? test_url : live_url
|
265
|
-
resource =
|
482
|
+
resource = action == :store ? 'vaulted-shoppers' : payment_method_details.resource_url
|
483
|
+
resource += options[:endpoint] if action == :refund
|
266
484
|
"#{base}/#{resource}"
|
267
485
|
end
|
268
486
|
|
269
487
|
def cvv_result(parsed)
|
270
|
-
CVVResult.new(CVC_CODE_TRANSLATOR[parsed[
|
488
|
+
CVVResult.new(CVC_CODE_TRANSLATOR[parsed['cvv-response-code']])
|
271
489
|
end
|
272
490
|
|
273
491
|
def avs_result(parsed)
|
@@ -279,48 +497,86 @@ module ActiveMerchant
|
|
279
497
|
end
|
280
498
|
|
281
499
|
def success_from(action, response)
|
282
|
-
(200...300).
|
500
|
+
(200...300).cover?(response.code.to_i)
|
283
501
|
end
|
284
502
|
|
285
|
-
def message_from(succeeded,
|
286
|
-
return
|
287
|
-
|
503
|
+
def message_from(succeeded, response)
|
504
|
+
return 'Success' if succeeded
|
505
|
+
|
506
|
+
parsed = parse(response)
|
507
|
+
if parsed.dig('error-name') == 'FRAUD_DETECTED'
|
508
|
+
fraud_codes_from(response)
|
509
|
+
else
|
510
|
+
parsed['description']
|
511
|
+
end
|
288
512
|
end
|
289
513
|
|
290
|
-
def
|
291
|
-
|
514
|
+
def fraud_codes_from(response)
|
515
|
+
event_summary = {}
|
516
|
+
doc = Nokogiri::XML(response.body)
|
517
|
+
fraud_events = doc.xpath('//xmlns:fraud-events', 'xmlns' => 'http://ws.plimus.com')
|
518
|
+
fraud_events.children.each do |child|
|
519
|
+
if child.children.children.any?
|
520
|
+
event_summary[child.name] = event_summary[child.name] || []
|
521
|
+
event = {}
|
522
|
+
child.children.each do |chi|
|
523
|
+
event[chi.name] = chi.text
|
524
|
+
end
|
525
|
+
event_summary[child.name] << event
|
526
|
+
else
|
527
|
+
event_summary[child.name] = child.text
|
528
|
+
end
|
529
|
+
end
|
530
|
+
event_summary.to_json
|
292
531
|
end
|
293
532
|
|
294
|
-
def
|
295
|
-
return
|
296
|
-
|
533
|
+
def authorization_from(action, parsed_response, payment_method_details)
|
534
|
+
return vaulted_shopper_id(parsed_response, payment_method_details) if action == :store
|
535
|
+
|
536
|
+
parsed_response['refund-transaction-id'] || parsed_response['transaction-id']
|
537
|
+
end
|
538
|
+
|
539
|
+
def vaulted_shopper_id(parsed_response, payment_method_details)
|
540
|
+
return nil unless parsed_response['content-location-header']
|
541
|
+
|
542
|
+
vaulted_shopper_id = parsed_response['content-location-header'].split('/').last
|
543
|
+
vaulted_shopper_id += "|#{payment_method_details.payment_method_type}" if payment_method_details.alt_transaction?
|
544
|
+
vaulted_shopper_id
|
297
545
|
end
|
298
546
|
|
299
547
|
def error_code_from(parsed_response)
|
300
|
-
parsed_response[
|
548
|
+
parsed_response['code']
|
301
549
|
end
|
302
550
|
|
303
551
|
def root_attributes
|
304
552
|
{
|
305
|
-
xmlns:
|
553
|
+
xmlns: 'http://ws.plimus.com'
|
306
554
|
}
|
307
555
|
end
|
308
556
|
|
309
|
-
def root_element(action)
|
310
|
-
|
557
|
+
def root_element(action, payment_method_details)
|
558
|
+
return 'refund' if action == :refund
|
559
|
+
return 'vaulted-shopper' if action == :store
|
560
|
+
|
561
|
+
payment_method_details.root_element
|
311
562
|
end
|
312
563
|
|
313
|
-
def headers
|
314
|
-
|
564
|
+
def headers(options)
|
565
|
+
idempotency_key = options[:idempotency_key] if options[:idempotency_key]
|
566
|
+
|
567
|
+
headers = {
|
315
568
|
'Content-Type' => 'application/xml',
|
316
|
-
'Authorization' => ('Basic ' + Base64.strict_encode64("#{@options[:api_username]}:#{@options[:api_password]}").strip)
|
569
|
+
'Authorization' => ('Basic ' + Base64.strict_encode64("#{@options[:api_username]}:#{@options[:api_password]}").strip)
|
317
570
|
}
|
571
|
+
|
572
|
+
headers['Idempotency-Key'] = idempotency_key if idempotency_key
|
573
|
+
headers
|
318
574
|
end
|
319
575
|
|
320
|
-
def build_xml_request(action)
|
576
|
+
def build_xml_request(action, payment_method_details)
|
321
577
|
builder = Nokogiri::XML::Builder.new
|
322
|
-
builder.__send__(root_element(action), root_attributes) do |doc|
|
323
|
-
doc.send(
|
578
|
+
builder.__send__(root_element(action, payment_method_details), root_attributes) do |doc|
|
579
|
+
doc.send('card-transaction-type', TRANSACTIONS[action]) if TRANSACTIONS[action] && !payment_method_details.alt_transaction? && action != :refund
|
324
580
|
yield(doc)
|
325
581
|
end
|
326
582
|
builder.doc.root.to_xml
|
@@ -336,7 +592,52 @@ module ActiveMerchant
|
|
336
592
|
end
|
337
593
|
|
338
594
|
def bad_authentication_response
|
339
|
-
{
|
595
|
+
{ 'description' => 'Unable to authenticate. Please check your credentials.' }
|
596
|
+
end
|
597
|
+
|
598
|
+
def generic_error_response(body)
|
599
|
+
{ 'description' => body }
|
600
|
+
end
|
601
|
+
end
|
602
|
+
|
603
|
+
class PaymentMethodDetails
|
604
|
+
attr_reader :payment_method, :vaulted_shopper_id, :payment_method_type
|
605
|
+
|
606
|
+
def initialize(payment_method = nil)
|
607
|
+
@payment_method = payment_method
|
608
|
+
@payment_method_type = nil
|
609
|
+
parse(payment_method)
|
610
|
+
end
|
611
|
+
|
612
|
+
def check?
|
613
|
+
@payment_method.is_a?(Check) || @payment_method_type == 'check'
|
614
|
+
end
|
615
|
+
|
616
|
+
def alt_transaction?
|
617
|
+
check?
|
618
|
+
end
|
619
|
+
|
620
|
+
def root_element
|
621
|
+
alt_transaction? ? 'alt-transaction' : 'card-transaction'
|
622
|
+
end
|
623
|
+
|
624
|
+
def resource_url
|
625
|
+
alt_transaction? ? 'alt-transactions' : 'transactions'
|
626
|
+
end
|
627
|
+
|
628
|
+
private
|
629
|
+
|
630
|
+
def parse(payment_method)
|
631
|
+
return unless payment_method
|
632
|
+
|
633
|
+
if payment_method.is_a?(String)
|
634
|
+
@vaulted_shopper_id, payment_method_type = payment_method.split('|')
|
635
|
+
@payment_method_type = payment_method_type if payment_method_type.present?
|
636
|
+
elsif payment_method.is_a?(Check)
|
637
|
+
@payment_method_type = payment_method.type
|
638
|
+
else
|
639
|
+
@payment_method_type = 'credit_card'
|
640
|
+
end
|
340
641
|
end
|
341
642
|
end
|
342
643
|
end
|