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,668 @@
|
|
|
1
|
+
require 'nokogiri'
|
|
2
|
+
require 'securerandom'
|
|
3
|
+
|
|
4
|
+
module ActiveMerchant # :nodoc:
|
|
5
|
+
module Billing # :nodoc:
|
|
6
|
+
class VantivExpressGateway < Gateway
|
|
7
|
+
self.test_url = 'https://certtransaction.elementexpress.com'
|
|
8
|
+
self.live_url = 'https://transaction.elementexpress.com'
|
|
9
|
+
|
|
10
|
+
self.supported_countries = ['US']
|
|
11
|
+
self.default_currency = 'USD'
|
|
12
|
+
self.supported_cardtypes = %i[visa master american_express discover diners_club jcb]
|
|
13
|
+
|
|
14
|
+
self.homepage_url = 'http://www.elementps.com'
|
|
15
|
+
self.display_name = 'Element'
|
|
16
|
+
|
|
17
|
+
SERVICE_TEST_URL = 'https://certservices.elementexpress.com'
|
|
18
|
+
SERVICE_LIVE_URL = 'https://services.elementexpress.com'
|
|
19
|
+
|
|
20
|
+
NETWORK_TOKEN_TYPE = {
|
|
21
|
+
apple_pay: 2,
|
|
22
|
+
google_pay: 1
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
CARD_PRESENT_CODE = {
|
|
26
|
+
'Unknown' => 1,
|
|
27
|
+
'Present' => 2,
|
|
28
|
+
'NotPresent' => 3
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
MARKET_CODE = {
|
|
32
|
+
'AutoRental' => 1,
|
|
33
|
+
'DirectMarketing' => 2,
|
|
34
|
+
'ECommerce' => 3,
|
|
35
|
+
'FoodRestaurant' => 4,
|
|
36
|
+
'HotelLodging' => 5,
|
|
37
|
+
'Petroleum' => 6,
|
|
38
|
+
'Retail' => 7,
|
|
39
|
+
'QSR' => 8,
|
|
40
|
+
'Grocery' => 9
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
PAYMENT_TYPE = {
|
|
44
|
+
'NotUsed' => 0,
|
|
45
|
+
'Recurring' => 1,
|
|
46
|
+
'Installment' => 2,
|
|
47
|
+
'CardHolderInitiated' => 3,
|
|
48
|
+
'CredentialOnFile' => 4
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
REVERSAL_TYPE = {
|
|
52
|
+
'System' => 0,
|
|
53
|
+
'Full' => 1,
|
|
54
|
+
'Partial' => 2
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
SUBMISSION_TYPE = {
|
|
58
|
+
'NotUsed' => 0,
|
|
59
|
+
'Initial' => 1,
|
|
60
|
+
'Subsequent' => 2,
|
|
61
|
+
'Resubmission' => 3,
|
|
62
|
+
'ReAuthorization' => 4,
|
|
63
|
+
'DelayedCharges' => 5,
|
|
64
|
+
'NoShow' => 6
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
LODGING_PPC = {
|
|
68
|
+
'NonParticipant' => 0,
|
|
69
|
+
'DollarLimit500' => 1,
|
|
70
|
+
'DollarLimit1000' => 2,
|
|
71
|
+
'DollarLimit1500' => 3
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
LODGING_SPC = {
|
|
75
|
+
'Default' => 0,
|
|
76
|
+
'Sale' => 1,
|
|
77
|
+
'NoShow' => 2,
|
|
78
|
+
'AdvanceDeposit' => 3
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
LODGING_CHARGE_TYPE = {
|
|
82
|
+
'Default' => 0,
|
|
83
|
+
'Restaurant' => 1,
|
|
84
|
+
'GiftShop' => 2
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
TERMINAL_TYPE = {
|
|
88
|
+
'Unknown' => 0,
|
|
89
|
+
'PointOfSale' => 1,
|
|
90
|
+
'ECommerce' => 2,
|
|
91
|
+
'MOTO' => 3,
|
|
92
|
+
'FuelPump' => 4,
|
|
93
|
+
'ATM' => 5,
|
|
94
|
+
'Voice' => 6,
|
|
95
|
+
'Mobile' => 7,
|
|
96
|
+
'WebSiteGiftCard' => 8
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
CARD_HOLDER_PRESENT_CODE = {
|
|
100
|
+
'Default' => 0,
|
|
101
|
+
'Unknown' => 1,
|
|
102
|
+
'Present' => 2,
|
|
103
|
+
'NotPresent' => 3,
|
|
104
|
+
'MailOrder' => 4,
|
|
105
|
+
'PhoneOrder' => 5,
|
|
106
|
+
'StandingAuth' => 6,
|
|
107
|
+
'ECommerce' => 7
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
CARD_INPUT_CODE = {
|
|
111
|
+
'Default' => 0,
|
|
112
|
+
'Unknown' => 1,
|
|
113
|
+
'MagstripeRead' => 2,
|
|
114
|
+
'ContactlessMagstripeRead' => 3,
|
|
115
|
+
'ManualKeyed' => 4,
|
|
116
|
+
'ManualKeyedMagstripeFailure' => 5,
|
|
117
|
+
'ChipRead' => 6,
|
|
118
|
+
'ContactlessChipRead' => 7,
|
|
119
|
+
'ManualKeyedChipReadFailure' => 8,
|
|
120
|
+
'MagstripeReadChipReadFailure' => 9,
|
|
121
|
+
'MagstripeReadNonTechnicalFallback' => 10
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
CVV_PRESENCE_CODE = {
|
|
125
|
+
'UseDefault' => 0,
|
|
126
|
+
'NotProvided' => 1,
|
|
127
|
+
'Provided' => 2,
|
|
128
|
+
'Illegible' => 3,
|
|
129
|
+
'CustomerIllegible' => 4
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
TERMINAL_CAPABILITY_CODE = {
|
|
133
|
+
'Default' => 0,
|
|
134
|
+
'Unknown' => 1,
|
|
135
|
+
'NoTerminal' => 2,
|
|
136
|
+
'MagstripeReader' => 3,
|
|
137
|
+
'ContactlessMagstripeReader' => 4,
|
|
138
|
+
'KeyEntered' => 5,
|
|
139
|
+
'ChipReader' => 6,
|
|
140
|
+
'ContactlessChipReader' => 7
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
TERMINAL_ENVIRONMENT_CODE = {
|
|
144
|
+
'Default' => 0,
|
|
145
|
+
'NoTerminal' => 1,
|
|
146
|
+
'LocalAttended' => 2,
|
|
147
|
+
'LocalUnattended' => 3,
|
|
148
|
+
'RemoteAttended' => 4,
|
|
149
|
+
'RemoteUnattended' => 5,
|
|
150
|
+
'ECommerce' => 6
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
DISCOUNT_CODE = {
|
|
154
|
+
'NotSupported' => 0,
|
|
155
|
+
'AmountIsDiscounted' => 1,
|
|
156
|
+
'AmountIsNotDiscounted' => 2
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
NET_GROSS_CODE = {
|
|
160
|
+
'NotSupported' => 0,
|
|
161
|
+
'ItemAmountIncludesTaxAmount' => 1,
|
|
162
|
+
'ItemAmountDoesNotIncludeTaxAmount' => 2
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
DEBIT_CREDIT_CODE = {
|
|
166
|
+
'NotSupported' => 0,
|
|
167
|
+
'ExtendedItemAmountIsCredit' => 1,
|
|
168
|
+
'ExtendedItemAmountIsDebit' => 2
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
def initialize(options = {})
|
|
172
|
+
requires!(options, :account_id, :account_token, :application_id, :acceptor_id, :application_name, :application_version)
|
|
173
|
+
super
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def purchase(money, payment, options = {})
|
|
177
|
+
action = payment.is_a?(Check) ? 'CheckSale' : 'CreditCardSale'
|
|
178
|
+
eci = parse_eci(payment)
|
|
179
|
+
|
|
180
|
+
request = build_xml_request do |xml|
|
|
181
|
+
xml.send(action, xmlns: live_url) do
|
|
182
|
+
add_credentials(xml)
|
|
183
|
+
add_payment_method(xml, payment)
|
|
184
|
+
add_transaction(xml, money, options, eci)
|
|
185
|
+
add_terminal(xml, options, eci)
|
|
186
|
+
add_address(xml, options)
|
|
187
|
+
add_lodging(xml, options)
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
commit(request, money, payment)
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def authorize(money, payment, options = {})
|
|
195
|
+
eci = parse_eci(payment)
|
|
196
|
+
|
|
197
|
+
request = build_xml_request do |xml|
|
|
198
|
+
xml.CreditCardAuthorization(xmlns: live_url) do
|
|
199
|
+
add_credentials(xml)
|
|
200
|
+
add_payment_method(xml, payment)
|
|
201
|
+
add_transaction(xml, money, options, eci)
|
|
202
|
+
add_terminal(xml, options, eci)
|
|
203
|
+
add_address(xml, options)
|
|
204
|
+
add_lodging(xml, options)
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
commit(request, money, payment)
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
def capture(money, authorization, options = {})
|
|
212
|
+
trans_id, _, eci = authorization.split('|')
|
|
213
|
+
options[:trans_id] = trans_id
|
|
214
|
+
|
|
215
|
+
request = build_xml_request do |xml|
|
|
216
|
+
xml.CreditCardAuthorizationCompletion(xmlns: live_url) do
|
|
217
|
+
add_credentials(xml)
|
|
218
|
+
add_transaction(xml, money, options, eci)
|
|
219
|
+
add_terminal(xml, options, eci)
|
|
220
|
+
add_level_3_data(xml, options)
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
commit(request, money)
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
def refund(money, authorization, options = {})
|
|
228
|
+
trans_id, _, eci = authorization.split('|')
|
|
229
|
+
options[:trans_id] = trans_id
|
|
230
|
+
|
|
231
|
+
request = build_xml_request do |xml|
|
|
232
|
+
xml.CreditCardReturn(xmlns: live_url) do
|
|
233
|
+
add_credentials(xml)
|
|
234
|
+
add_transaction(xml, money, options, eci)
|
|
235
|
+
add_terminal(xml, options, eci)
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
commit(request, money)
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
def credit(money, payment, options = {})
|
|
243
|
+
eci = parse_eci(payment)
|
|
244
|
+
|
|
245
|
+
request = build_xml_request do |xml|
|
|
246
|
+
xml.CreditCardCredit(xmlns: live_url) do
|
|
247
|
+
add_credentials(xml)
|
|
248
|
+
add_payment_method(xml, payment)
|
|
249
|
+
add_transaction(xml, money, options, eci)
|
|
250
|
+
add_terminal(xml, options, eci)
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
commit(request, money, payment)
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
def void(authorization, options = {})
|
|
258
|
+
trans_id, trans_amount, eci = authorization.split('|')
|
|
259
|
+
options.merge!({ trans_id:, trans_amount:, reversal_type: 1 })
|
|
260
|
+
|
|
261
|
+
request = build_xml_request do |xml|
|
|
262
|
+
xml.CreditCardReversal(xmlns: live_url) do
|
|
263
|
+
add_credentials(xml)
|
|
264
|
+
add_transaction(xml, trans_amount, options, eci)
|
|
265
|
+
add_terminal(xml, options, eci)
|
|
266
|
+
end
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
commit(request, trans_amount)
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
def store(payment, options = {})
|
|
273
|
+
request = build_xml_request do |xml|
|
|
274
|
+
xml.PaymentAccountCreate(xmlns: SERVICE_LIVE_URL) do
|
|
275
|
+
add_credentials(xml)
|
|
276
|
+
add_payment_method(xml, payment)
|
|
277
|
+
add_payment_account(xml, payment, options[:payment_account_reference_number] || SecureRandom.hex(20))
|
|
278
|
+
add_address(xml, options)
|
|
279
|
+
end
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
commit(request, payment, nil, :store)
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
def verify(payment, options = {})
|
|
286
|
+
eci = parse_eci(payment)
|
|
287
|
+
|
|
288
|
+
request = build_xml_request do |xml|
|
|
289
|
+
xml.CreditCardAVSOnly(xmlns: live_url) do
|
|
290
|
+
add_credentials(xml)
|
|
291
|
+
add_payment_method(xml, payment)
|
|
292
|
+
add_transaction(xml, 0, options, eci)
|
|
293
|
+
add_terminal(xml, options, eci)
|
|
294
|
+
add_address(xml, options)
|
|
295
|
+
end
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
commit(request)
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
def supports_scrubbing?
|
|
302
|
+
true
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
def scrub(transcript)
|
|
306
|
+
transcript.
|
|
307
|
+
gsub(%r((<AccountToken>).+?(</AccountToken>))i, '\1[FILTERED]\2').
|
|
308
|
+
gsub(%r((<CardNumber>).+?(</CardNumber>))i, '\1[FILTERED]\2').
|
|
309
|
+
gsub(%r((<CVV>).+?(</CVV>))i, '\1[FILTERED]\2').
|
|
310
|
+
gsub(%r((<AccountNumber>).+?(</AccountNumber>))i, '\1[FILTERED]\2').
|
|
311
|
+
gsub(%r((<RoutingNumber>).+?(</RoutingNumber>))i, '\1[FILTERED]\2')
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
private
|
|
315
|
+
|
|
316
|
+
def add_credentials(xml)
|
|
317
|
+
xml.Credentials do
|
|
318
|
+
xml.AccountID @options[:account_id]
|
|
319
|
+
xml.AccountToken @options[:account_token]
|
|
320
|
+
xml.AcceptorID @options[:acceptor_id]
|
|
321
|
+
end
|
|
322
|
+
xml.Application do
|
|
323
|
+
xml.ApplicationID @options[:application_id]
|
|
324
|
+
xml.ApplicationName @options[:application_name]
|
|
325
|
+
xml.ApplicationVersion @options[:application_version]
|
|
326
|
+
end
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
def add_payment_method(xml, payment)
|
|
330
|
+
if payment.is_a?(String)
|
|
331
|
+
add_payment_account_id(xml, payment)
|
|
332
|
+
elsif payment.is_a?(Check)
|
|
333
|
+
add_echeck(xml, payment)
|
|
334
|
+
elsif payment.is_a?(NetworkTokenizationCreditCard)
|
|
335
|
+
add_network_tokenization_card(xml, payment)
|
|
336
|
+
else
|
|
337
|
+
add_credit_card(xml, payment)
|
|
338
|
+
end
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
def add_payment_account(xml, payment, payment_account_reference_number)
|
|
342
|
+
xml.PaymentAccount do
|
|
343
|
+
xml.PaymentAccountType payment_account_type(payment)
|
|
344
|
+
xml.PaymentAccountReferenceNumber payment_account_reference_number
|
|
345
|
+
end
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
def add_payment_account_id(xml, payment)
|
|
349
|
+
xml.PaymentAccount do
|
|
350
|
+
xml.PaymentAccountID payment
|
|
351
|
+
end
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
def add_transaction(xml, money, options = {}, network_token_eci = nil)
|
|
355
|
+
xml.Transaction do
|
|
356
|
+
xml.ReversalType REVERSAL_TYPE[options[:reversal_type]] || options[:reversal_type] if options[:reversal_type]
|
|
357
|
+
xml.TransactionID options[:trans_id] if options[:trans_id]
|
|
358
|
+
xml.TransactionAmount amount(money.to_i) if money
|
|
359
|
+
xml.MarketCode market_code(money, options, network_token_eci) if options[:market_code] || money
|
|
360
|
+
xml.ReferenceNumber options[:order_id].present? ? options[:order_id][0, 50] : SecureRandom.hex(20)
|
|
361
|
+
xml.TicketNumber options[:ticket_number] || rand(1..999999)
|
|
362
|
+
xml.MerchantSuppliedTransactionID options[:merchant_supplied_transaction_id] if options[:merchant_supplied_transaction_id]
|
|
363
|
+
xml.PaymentType PAYMENT_TYPE[options[:payment_type]] || options[:payment_type] if options[:payment_type]
|
|
364
|
+
xml.SubmissionType SUBMISSION_TYPE[options[:submission_type]] || options[:submission_type] if options[:submission_type]
|
|
365
|
+
xml.DuplicateCheckDisableFlag 1 if options[:duplicate_check_disable_flag].to_s == 'true' || options[:duplicate_override_flag].to_s == 'true'
|
|
366
|
+
xml.SalesTaxAmount options[:sales_tax_amount] if options[:sales_tax_amount]
|
|
367
|
+
xml.CommercialCardCustomerCode options[:commercial_card_customer_code] if options[:commercial_card_customer_code]
|
|
368
|
+
end
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
def parse_eci(payment)
|
|
372
|
+
return nil unless payment.is_a?(NetworkTokenizationCreditCard)
|
|
373
|
+
|
|
374
|
+
if (eci = payment.eci)
|
|
375
|
+
eci = eci[0] == '0' ? eci.sub!(/^0/, '') : eci
|
|
376
|
+
return eci
|
|
377
|
+
else
|
|
378
|
+
payment.brand == 'american_express' ? '9' : '6'
|
|
379
|
+
end
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
def market_code(money, options, network_token_eci)
|
|
383
|
+
return 3 if network_token_eci
|
|
384
|
+
|
|
385
|
+
MARKET_CODE[options[:market_code]] || options[:market_code] || 0
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
def add_lodging(xml, options)
|
|
389
|
+
if options[:lodging]
|
|
390
|
+
lodging = parse_lodging(options[:lodging])
|
|
391
|
+
xml.ExtendedParameters do
|
|
392
|
+
xml.Lodging do
|
|
393
|
+
xml.LodgingAgreementNumber lodging[:agreement_number] if lodging[:agreement_number]
|
|
394
|
+
xml.LodgingCheckInDate lodging[:check_in_date] if lodging[:check_in_date]
|
|
395
|
+
xml.LodgingCheckOutDate lodging[:check_out_date] if lodging[:check_out_date]
|
|
396
|
+
xml.LodgingRoomAmount lodging[:room_amount] if lodging[:room_amount]
|
|
397
|
+
xml.LodgingRoomTax lodging[:room_tax] if lodging[:room_tax]
|
|
398
|
+
xml.LodgingNoShowIndicator lodging[:no_show_indicator] if lodging[:no_show_indicator]
|
|
399
|
+
xml.LodgingDuration lodging[:duration] if lodging[:duration]
|
|
400
|
+
xml.LodgingCustomerName lodging[:customer_name] if lodging[:customer_name]
|
|
401
|
+
xml.LodgingClientCode lodging[:client_code] if lodging[:client_code]
|
|
402
|
+
xml.LodgingExtraChargesDetail lodging[:extra_charges_detail] if lodging[:extra_charges_detail]
|
|
403
|
+
xml.LodgingExtraChargesAmounts lodging[:extra_charges_amounts] if lodging[:extra_charges_amounts]
|
|
404
|
+
xml.LodgingPrestigiousPropertyCode lodging[:prestigious_property_code] if lodging[:prestigious_property_code]
|
|
405
|
+
xml.LodgingSpecialProgramCode lodging[:special_program_code] if lodging[:special_program_code]
|
|
406
|
+
xml.LodgingChargeType lodging[:charge_type] if lodging[:charge_type]
|
|
407
|
+
end
|
|
408
|
+
end
|
|
409
|
+
end
|
|
410
|
+
end
|
|
411
|
+
|
|
412
|
+
def add_terminal(xml, options, network_token_eci = nil)
|
|
413
|
+
options = parse_terminal(options)
|
|
414
|
+
|
|
415
|
+
xml.Terminal do
|
|
416
|
+
xml.TerminalID options[:terminal_id] || '01'
|
|
417
|
+
xml.TerminalType options[:terminal_type] if options[:terminal_type]
|
|
418
|
+
xml.CardPresentCode options[:card_present_code] || 0
|
|
419
|
+
xml.CardholderPresentCode options[:card_holder_present_code] || 0
|
|
420
|
+
xml.CardInputCode options[:card_input_code] || 0
|
|
421
|
+
xml.CVVPresenceCode options[:cvv_presence_code] || 0
|
|
422
|
+
xml.TerminalCapabilityCode options[:terminal_capability_code] || 0
|
|
423
|
+
xml.TerminalEnvironmentCode options[:terminal_environment_code] || 0
|
|
424
|
+
xml.MotoECICode network_token_eci || 7
|
|
425
|
+
xml.PartialApprovedFlag options[:partial_approved_flag] if options[:partial_approved_flag]
|
|
426
|
+
end
|
|
427
|
+
end
|
|
428
|
+
|
|
429
|
+
def add_credit_card(xml, payment)
|
|
430
|
+
xml.Card do
|
|
431
|
+
xml.CardNumber payment.number
|
|
432
|
+
xml.ExpirationMonth format(payment.month, :two_digits)
|
|
433
|
+
xml.ExpirationYear format(payment.year, :two_digits)
|
|
434
|
+
xml.CardholderName "#{payment.first_name} #{payment.last_name}"
|
|
435
|
+
xml.CVV payment.verification_value
|
|
436
|
+
end
|
|
437
|
+
end
|
|
438
|
+
|
|
439
|
+
def add_echeck(xml, payment)
|
|
440
|
+
xml.DemandDepositAccount do
|
|
441
|
+
xml.AccountNumber payment.account_number
|
|
442
|
+
xml.RoutingNumber payment.routing_number
|
|
443
|
+
xml.DDAAccountType payment.account_type == 'checking' ? 0 : 1
|
|
444
|
+
end
|
|
445
|
+
end
|
|
446
|
+
|
|
447
|
+
def add_network_tokenization_card(xml, payment)
|
|
448
|
+
xml.Card do
|
|
449
|
+
xml.CardNumber payment.number
|
|
450
|
+
xml.ExpirationMonth format(payment.month, :two_digits)
|
|
451
|
+
xml.ExpirationYear format(payment.year, :two_digits)
|
|
452
|
+
xml.CardholderName "#{payment.first_name} #{payment.last_name}"
|
|
453
|
+
xml.Cryptogram payment.payment_cryptogram
|
|
454
|
+
xml.WalletType NETWORK_TOKEN_TYPE[payment.source]
|
|
455
|
+
end
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
def add_address(xml, options)
|
|
459
|
+
address = address = options[:billing_address] || options[:address]
|
|
460
|
+
shipping_address = options[:shipping_address]
|
|
461
|
+
|
|
462
|
+
if address || shipping_address
|
|
463
|
+
xml.Address do
|
|
464
|
+
if address
|
|
465
|
+
address[:email] ||= options[:email]
|
|
466
|
+
|
|
467
|
+
xml.BillingAddress1 address[:address1] if address[:address1]
|
|
468
|
+
xml.BillingAddress2 address[:address2] if address[:address2]
|
|
469
|
+
xml.BillingCity address[:city] if address[:city]
|
|
470
|
+
xml.BillingState address[:state] if address[:state]
|
|
471
|
+
xml.BillingZipcode address[:zip] if address[:zip]
|
|
472
|
+
xml.BillingEmail address[:email] if address[:email]
|
|
473
|
+
xml.BillingPhone address[:phone_number] if address[:phone_number]
|
|
474
|
+
xml.BillingName address[:name] if address[:name]
|
|
475
|
+
end
|
|
476
|
+
|
|
477
|
+
if shipping_address
|
|
478
|
+
xml.ShippingAddress1 shipping_address[:address1] if shipping_address[:address1]
|
|
479
|
+
xml.ShippingAddress2 shipping_address[:address2] if shipping_address[:address2]
|
|
480
|
+
xml.ShippingCity shipping_address[:city] if shipping_address[:city]
|
|
481
|
+
xml.ShippingState shipping_address[:state] if shipping_address[:state]
|
|
482
|
+
xml.ShippingZipcode shipping_address[:zip] if shipping_address[:zip]
|
|
483
|
+
xml.ShippingEmail shipping_address[:email] if shipping_address[:email]
|
|
484
|
+
xml.ShippingPhone shipping_address[:phone_number] if shipping_address[:phone_number]
|
|
485
|
+
end
|
|
486
|
+
end
|
|
487
|
+
end
|
|
488
|
+
end
|
|
489
|
+
|
|
490
|
+
# Add Enhanced Level III data to transaction requests
|
|
491
|
+
def add_level_3_data(xml, options)
|
|
492
|
+
return unless options[:level_3_data]
|
|
493
|
+
|
|
494
|
+
level_3 = options[:level_3_data]
|
|
495
|
+
xml.ExtendedParameters do
|
|
496
|
+
xml.EnhancedData do
|
|
497
|
+
# Header-level fields
|
|
498
|
+
xml.MerchantVATRegistrationNumber level_3[:merchant_vat_registration_number] if level_3[:merchant_vat_registration_number]
|
|
499
|
+
xml.CustomerVATRegistrationNumber level_3[:customer_vat_registration_number] if level_3[:customer_vat_registration_number]
|
|
500
|
+
xml.SummaryCommodityCode level_3[:summary_commodity_code] if level_3[:summary_commodity_code]
|
|
501
|
+
xml.DiscountAmount level_3[:discount_amount] if level_3[:discount_amount]
|
|
502
|
+
xml.FreightAmount level_3[:freight_amount] if level_3[:freight_amount]
|
|
503
|
+
xml.DutyAmount level_3[:duty_amount] if level_3[:duty_amount]
|
|
504
|
+
xml.DestinationZIPCode level_3[:destination_postal_code] if level_3[:destination_postal_code]
|
|
505
|
+
xml.ShipFromZIPCode level_3[:ship_from_postal_code] if level_3[:ship_from_postal_code]
|
|
506
|
+
xml.DestinationCountryCode level_3[:destination_country_code] if level_3[:destination_country_code]
|
|
507
|
+
xml.UniqueVATInvoiceReferenceNumber level_3[:unique_vat_invoice_reference_number] if level_3[:unique_vat_invoice_reference_number]
|
|
508
|
+
xml.OrderDate level_3[:order_date] if level_3[:order_date]
|
|
509
|
+
xml.VATAmount level_3[:vat_amount] if level_3[:vat_amount]
|
|
510
|
+
xml.VATRate level_3[:vat_rate] if level_3[:vat_rate]
|
|
511
|
+
xml.LineItemCount level_3[:line_items].size if level_3[:line_items]&.any?
|
|
512
|
+
xml.AlternateTaxAmount level_3[:alternate_tax_amount] if level_3[:alternate_tax_amount]
|
|
513
|
+
xml.NationalTaxAmount level_3[:national_tax_amount] if level_3[:national_tax_amount]
|
|
514
|
+
|
|
515
|
+
# Line item details
|
|
516
|
+
add_line_items(xml, level_3[:line_items]) if level_3[:line_items]&.any?
|
|
517
|
+
end
|
|
518
|
+
end
|
|
519
|
+
end
|
|
520
|
+
|
|
521
|
+
def add_line_items(xml, line_items)
|
|
522
|
+
return unless line_items
|
|
523
|
+
|
|
524
|
+
xml.LineItemDetail do
|
|
525
|
+
line_items.each do |item|
|
|
526
|
+
xml.LineItem do
|
|
527
|
+
xml.ItemCommodityCode item[:commodity_code] if item[:commodity_code]
|
|
528
|
+
xml.ItemDescription item[:description] if item[:description]
|
|
529
|
+
xml.ProductCode item[:product_code] if item[:product_code]
|
|
530
|
+
xml.Quantity item[:quantity] if item[:quantity]
|
|
531
|
+
xml.UnitOfMeasure item[:unit_measure] if item[:unit_measure]
|
|
532
|
+
xml.UnitCost item[:unit_price] if item[:unit_price]
|
|
533
|
+
xml.LineItemVATAmount item[:tax_amount] if item[:tax_amount]
|
|
534
|
+
xml.LineItemVATRate item[:tax_rate] if item[:tax_rate]
|
|
535
|
+
xml.LineItemDiscountAmount item[:discount_amount] if item[:discount_amount]
|
|
536
|
+
xml.LineItemTotalAmount item[:total_amount] if item[:total_amount]
|
|
537
|
+
xml.AlternateTaxIdentifier item[:alternate_tax_id] if item[:alternate_tax_id]
|
|
538
|
+
xml.VATType item[:vat_type] if item[:vat_type]
|
|
539
|
+
xml.DiscountCode DISCOUNT_CODE[item[:discount_code]] || item[:discount_code] if item[:discount_code]
|
|
540
|
+
xml.NetGrossCode NET_GROSS_CODE[item[:net_gross_code]] || item[:net_gross_code] if item[:net_gross_code]
|
|
541
|
+
xml.ExtendedItemAmount item[:extended_item_amount] if item[:extended_item_amount]
|
|
542
|
+
xml.DebitCreditCode DEBIT_CREDIT_CODE[item[:debit_credit_code]] || item[:debit_credit_code] if item[:debit_credit_code]
|
|
543
|
+
xml.ItemDiscountRate item[:item_discount_rate] if item[:item_discount_rate]
|
|
544
|
+
end
|
|
545
|
+
end
|
|
546
|
+
end
|
|
547
|
+
end
|
|
548
|
+
|
|
549
|
+
def parse(xml)
|
|
550
|
+
response = {}
|
|
551
|
+
|
|
552
|
+
doc = Nokogiri::XML(xml)
|
|
553
|
+
doc.remove_namespaces!
|
|
554
|
+
root = doc.root.xpath('//response/*')
|
|
555
|
+
|
|
556
|
+
root = doc.root.xpath('//Response/*') if root.empty?
|
|
557
|
+
|
|
558
|
+
root.each do |node|
|
|
559
|
+
if node.elements.empty?
|
|
560
|
+
response[node.name.downcase] = node.text
|
|
561
|
+
else
|
|
562
|
+
node_name = node.name.downcase
|
|
563
|
+
response[node_name] = {}
|
|
564
|
+
|
|
565
|
+
node.elements.each do |childnode|
|
|
566
|
+
response[node_name][childnode.name.downcase] = childnode.text
|
|
567
|
+
end
|
|
568
|
+
end
|
|
569
|
+
end
|
|
570
|
+
|
|
571
|
+
response
|
|
572
|
+
end
|
|
573
|
+
|
|
574
|
+
def parse_lodging(lodging)
|
|
575
|
+
lodging[:prestigious_property_code] = LODGING_PPC[lodging[:prestigious_property_code]] || lodging[:prestigious_property_code] if lodging[:prestigious_property_code]
|
|
576
|
+
lodging[:special_program_code] = LODGING_SPC[lodging[:special_program_code]] || lodging[:special_program_code] if lodging[:special_program_code]
|
|
577
|
+
lodging[:charge_type] = LODGING_CHARGE_TYPE[lodging[:charge_type]] || lodging[:charge_type] if lodging[:charge_type]
|
|
578
|
+
|
|
579
|
+
lodging
|
|
580
|
+
end
|
|
581
|
+
|
|
582
|
+
def parse_terminal(options)
|
|
583
|
+
options[:terminal_type] = TERMINAL_TYPE[options[:terminal_type]] || options[:terminal_type]
|
|
584
|
+
options[:card_present_code] = CARD_PRESENT_CODE[options[:card_present_code]] || options[:card_present_code]
|
|
585
|
+
options[:card_holder_present_code] = CARD_HOLDER_PRESENT_CODE[options[:card_holder_present_code]] || options[:card_holder_present_code]
|
|
586
|
+
options[:card_input_code] = CARD_INPUT_CODE[options[:card_input_code]] || options[:card_input_code]
|
|
587
|
+
options[:cvv_presence_code] = CVV_PRESENCE_CODE[options[:cvv_presence_code]] || options[:cvv_presence_code]
|
|
588
|
+
options[:terminal_capability_code] = TERMINAL_CAPABILITY_CODE[options[:terminal_capability_code]] || options[:terminal_capability_code]
|
|
589
|
+
options[:terminal_environment_code] = TERMINAL_ENVIRONMENT_CODE[options[:terminal_environment_code]] || options[:terminal_environment_code]
|
|
590
|
+
|
|
591
|
+
options
|
|
592
|
+
end
|
|
593
|
+
|
|
594
|
+
def commit(xml, amount = nil, payment = nil, action = nil)
|
|
595
|
+
response = parse(ssl_post(url(action), xml, headers))
|
|
596
|
+
success = success_from(response)
|
|
597
|
+
|
|
598
|
+
Response.new(
|
|
599
|
+
success,
|
|
600
|
+
message_from(response),
|
|
601
|
+
response,
|
|
602
|
+
authorization: authorization_from(action, response, amount, payment),
|
|
603
|
+
avs_result: success ? avs_from(response) : nil,
|
|
604
|
+
cvv_result: success ? cvv_from(response) : nil,
|
|
605
|
+
test: test?
|
|
606
|
+
)
|
|
607
|
+
end
|
|
608
|
+
|
|
609
|
+
def authorization_from(action, response, amount, payment)
|
|
610
|
+
return response.dig('paymentaccount', 'paymentaccountid') if action == :store
|
|
611
|
+
|
|
612
|
+
if response['transaction']
|
|
613
|
+
authorization = "#{response.dig('transaction', 'transactionid')}|#{amount}"
|
|
614
|
+
authorization << "|#{parse_eci(payment)}" if parse_eci(payment)
|
|
615
|
+
authorization
|
|
616
|
+
end
|
|
617
|
+
end
|
|
618
|
+
|
|
619
|
+
def success_from(response)
|
|
620
|
+
response['expressresponsecode'] == '0'
|
|
621
|
+
end
|
|
622
|
+
|
|
623
|
+
def message_from(response)
|
|
624
|
+
response['expressresponsemessage']
|
|
625
|
+
end
|
|
626
|
+
|
|
627
|
+
def avs_from(response)
|
|
628
|
+
AVSResult.new(code: response['card']['avsresponsecode']) if response['card']
|
|
629
|
+
end
|
|
630
|
+
|
|
631
|
+
def cvv_from(response)
|
|
632
|
+
CVVResult.new(response['card']['cvvresponsecode']) if response['card']
|
|
633
|
+
end
|
|
634
|
+
|
|
635
|
+
def build_xml_request(&block)
|
|
636
|
+
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8', &block)
|
|
637
|
+
|
|
638
|
+
builder.to_xml
|
|
639
|
+
end
|
|
640
|
+
|
|
641
|
+
def payment_account_type(payment)
|
|
642
|
+
return 0 unless payment.is_a?(Check)
|
|
643
|
+
|
|
644
|
+
if payment.account_type == 'checking'
|
|
645
|
+
1
|
|
646
|
+
elsif payment.account_type == 'savings'
|
|
647
|
+
2
|
|
648
|
+
else
|
|
649
|
+
3
|
|
650
|
+
end
|
|
651
|
+
end
|
|
652
|
+
|
|
653
|
+
def url(action)
|
|
654
|
+
if action == :store
|
|
655
|
+
test? ? SERVICE_TEST_URL : SERVICE_LIVE_URL
|
|
656
|
+
else
|
|
657
|
+
test? ? test_url : live_url
|
|
658
|
+
end
|
|
659
|
+
end
|
|
660
|
+
|
|
661
|
+
def headers
|
|
662
|
+
{
|
|
663
|
+
'Content-Type' => 'text/xml'
|
|
664
|
+
}
|
|
665
|
+
end
|
|
666
|
+
end
|
|
667
|
+
end
|
|
668
|
+
end
|