activemerchant 1.45.0 → 1.126.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG +2167 -2
- data/CONTRIBUTORS +57 -0
- data/README.md +62 -41
- data/lib/active_merchant/billing/avs_result.rb +25 -28
- data/lib/active_merchant/billing/base.rb +11 -35
- data/lib/active_merchant/billing/check.rb +28 -24
- data/lib/active_merchant/billing/compatibility.rb +10 -12
- data/lib/active_merchant/billing/credit_card.rb +141 -69
- data/lib/active_merchant/billing/credit_card_formatting.rb +4 -4
- data/lib/active_merchant/billing/credit_card_methods.rb +348 -52
- data/lib/active_merchant/billing/cvv_result.rb +0 -1
- data/lib/active_merchant/billing/gateway.rb +125 -61
- data/lib/active_merchant/billing/gateways/adyen.rb +633 -127
- data/lib/active_merchant/billing/gateways/airwallex.rb +341 -0
- data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +883 -195
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +31 -24
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +104 -103
- data/lib/active_merchant/billing/gateways/axcessms.rb +179 -0
- 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 +24 -13
- data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +397 -0
- 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 +143 -62
- data/lib/active_merchant/billing/gateways/beanstream.rb +45 -13
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +13 -10
- data/lib/active_merchant/billing/gateways/blue_pay.rb +549 -506
- data/lib/active_merchant/billing/gateways/blue_snap.rb +623 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +82 -36
- data/lib/active_merchant/billing/gateways/borgun.rb +61 -40
- data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +21 -2
- data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +3 -3
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +592 -203
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +3 -4
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +116 -61
- data/lib/active_merchant/billing/gateways/cams.rb +230 -0
- data/lib/active_merchant/billing/gateways/card_connect.rb +320 -0
- data/lib/active_merchant/billing/gateways/card_save.rb +7 -9
- data/lib/active_merchant/billing/gateways/card_stream.rb +248 -97
- data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
- data/lib/active_merchant/billing/gateways/cardprocess.rb +256 -0
- data/lib/active_merchant/billing/gateways/cashnet.rb +70 -26
- data/lib/active_merchant/billing/gateways/cc5.rb +14 -17
- data/lib/active_merchant/billing/gateways/cecabank.rb +73 -53
- data/lib/active_merchant/billing/gateways/cenpos.rb +328 -0
- data/lib/active_merchant/billing/gateways/checkout.rb +32 -33
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +340 -0
- data/lib/active_merchant/billing/gateways/citrus_pay.rb +21 -0
- data/lib/active_merchant/billing/gateways/clearhaus.rb +219 -0
- data/lib/active_merchant/billing/gateways/commercegate.rb +11 -12
- data/lib/active_merchant/billing/gateways/conekta.rb +55 -34
- data/lib/active_merchant/billing/gateways/creditcall.rb +272 -0
- data/lib/active_merchant/billing/gateways/credorax.rb +506 -0
- data/lib/active_merchant/billing/gateways/ct_payment.rb +269 -0
- data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +637 -221
- data/lib/active_merchant/billing/gateways/d_local.rb +303 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +57 -355
- data/lib/active_merchant/billing/gateways/decidir.rb +347 -0
- data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
- data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
- data/lib/active_merchant/billing/gateways/digitzs.rb +295 -0
- data/lib/active_merchant/billing/gateways/ebanx.rb +334 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +46 -50
- data/lib/active_merchant/billing/gateways/elavon.rb +377 -250
- data/lib/active_merchant/billing/gateways/element.rb +386 -0
- data/lib/active_merchant/billing/gateways/epay.rb +92 -71
- data/lib/active_merchant/billing/gateways/evo_ca.rb +13 -14
- data/lib/active_merchant/billing/gateways/eway.rb +85 -73
- data/lib/active_merchant/billing/gateways/eway_managed.rb +85 -87
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +134 -80
- data/lib/active_merchant/billing/gateways/exact.rb +37 -36
- data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +124 -74
- data/lib/active_merchant/billing/gateways/federated_canada.rb +11 -13
- data/lib/active_merchant/billing/gateways/finansbank.rb +4 -5
- data/lib/active_merchant/billing/gateways/first_giving.rb +23 -23
- data/lib/active_merchant/billing/gateways/first_pay.rb +45 -23
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +184 -87
- data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +505 -0
- data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
- data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
- data/lib/active_merchant/billing/gateways/forte.rb +286 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +31 -32
- data/lib/active_merchant/billing/gateways/global_collect.rb +507 -0
- data/lib/active_merchant/billing/gateways/global_transport.rb +25 -15
- data/lib/active_merchant/billing/gateways/hdfc.rb +55 -57
- data/lib/active_merchant/billing/gateways/hps.rb +252 -68
- data/lib/active_merchant/billing/gateways/iats_payments.rb +99 -38
- data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
- data/lib/active_merchant/billing/gateways/inspire.rb +48 -48
- data/lib/active_merchant/billing/gateways/instapay.rb +10 -14
- data/lib/active_merchant/billing/gateways/ipg.rb +415 -0
- data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +254 -244
- data/lib/active_merchant/billing/gateways/itransact.rb +14 -14
- data/lib/active_merchant/billing/gateways/iveri.rb +254 -0
- data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +200 -80
- data/lib/active_merchant/billing/gateways/jetpay_v2.rb +432 -0
- data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
- data/lib/active_merchant/billing/gateways/kushki.rb +277 -0
- data/lib/active_merchant/billing/gateways/latitude19.rb +412 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +95 -85
- data/lib/active_merchant/billing/gateways/litle.rb +371 -94
- data/lib/active_merchant/billing/gateways/mastercard.rb +293 -0
- data/lib/active_merchant/billing/gateways/maxipago.rb +146 -123
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +331 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +47 -23
- data/lib/active_merchant/billing/gateways/merchant_one.rb +16 -20
- data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +54 -60
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +60 -44
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +76 -23
- data/lib/active_merchant/billing/gateways/mercury.rb +73 -54
- data/lib/active_merchant/billing/gateways/metrics_global.rb +33 -43
- data/lib/active_merchant/billing/gateways/micropayment.rb +182 -0
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +7 -7
- data/lib/active_merchant/billing/gateways/migs.rb +101 -37
- data/lib/active_merchant/billing/gateways/mit.rb +260 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +3 -3
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +30 -34
- data/lib/active_merchant/billing/gateways/moka.rb +290 -0
- data/lib/active_merchant/billing/gateways/monei.rb +422 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +236 -72
- data/lib/active_merchant/billing/gateways/money_movers.rb +11 -13
- data/lib/active_merchant/billing/gateways/mundipagg.rb +363 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +87 -68
- data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +163 -0
- 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 +376 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +82 -43
- 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 +279 -174
- data/lib/active_merchant/billing/gateways/ogone.rb +96 -50
- data/lib/active_merchant/billing/gateways/omise.rb +323 -0
- data/lib/active_merchant/billing/gateways/openpay.rb +58 -23
- data/lib/active_merchant/billing/gateways/opp.rb +394 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +87 -69
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +5 -7
- data/lib/active_merchant/billing/gateways/orbital.rb +771 -328
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +31 -32
- data/lib/active_merchant/billing/gateways/pagarme.rb +239 -0
- 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 +245 -0
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +84 -68
- data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +37 -37
- data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +206 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +15 -17
- data/lib/active_merchant/billing/gateways/pay_trace.rb +404 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +85 -49
- data/lib/active_merchant/billing/gateways/payeezy.rb +458 -0
- data/lib/active_merchant/billing/gateways/payex.rb +39 -42
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +67 -41
- 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 +215 -46
- data/lib/active_merchant/billing/gateways/payflow_express.rb +64 -68
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +2 -3
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +5 -6
- data/lib/active_merchant/billing/gateways/payment_express.rb +78 -58
- data/lib/active_merchant/billing/gateways/paymentez.rb +353 -0
- data/lib/active_merchant/billing/gateways/paymill.rb +163 -75
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +55 -7
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +1 -1
- data/lib/active_merchant/billing/gateways/paypal.rb +37 -18
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +2 -2
- data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +5 -5
- data/lib/active_merchant/billing/gateways/paypal_express.rb +12 -6
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +3 -3
- data/lib/active_merchant/billing/gateways/paysafe.rb +412 -0
- data/lib/active_merchant/billing/gateways/payscout.rb +10 -13
- data/lib/active_merchant/billing/gateways/paystation.rb +96 -91
- data/lib/active_merchant/billing/gateways/payu_in.rb +249 -0
- data/lib/active_merchant/billing/gateways/payu_latam.rb +479 -0
- 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 +113 -37
- data/lib/active_merchant/billing/gateways/plugnpay.rb +82 -82
- data/lib/active_merchant/billing/gateways/priority.rb +369 -0
- data/lib/active_merchant/billing/gateways/pro_pay.rb +325 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +55 -44
- data/lib/active_merchant/billing/gateways/psl_card.rb +32 -40
- data/lib/active_merchant/billing/gateways/qbms.rb +86 -76
- data/lib/active_merchant/billing/gateways/quantum.rb +21 -23
- data/lib/active_merchant/billing/gateways/quickbooks.rb +377 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +297 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +10 -353
- data/lib/active_merchant/billing/gateways/qvalent.rb +305 -0
- data/lib/active_merchant/billing/gateways/rapyd.rb +258 -0
- data/lib/active_merchant/billing/gateways/realex.rb +154 -52
- data/lib/active_merchant/billing/gateways/redsys.rb +488 -161
- data/lib/active_merchant/billing/gateways/s5.rb +247 -0
- data/lib/active_merchant/billing/gateways/safe_charge.rb +298 -0
- data/lib/active_merchant/billing/gateways/sage.rb +404 -133
- data/lib/active_merchant/billing/gateways/sage_pay.rb +145 -109
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +13 -15
- data/lib/active_merchant/billing/gateways/secure_net.rb +62 -54
- data/lib/active_merchant/billing/gateways/secure_pay.rb +32 -42
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +36 -27
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +14 -16
- data/lib/active_merchant/billing/gateways/securion_pay.rb +265 -0
- data/lib/active_merchant/billing/gateways/simetrik.rb +362 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +52 -54
- 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 +108 -43
- data/lib/active_merchant/billing/gateways/stripe.rb +536 -120
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +516 -0
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +19 -25
- data/lib/active_merchant/billing/gateways/telr.rb +273 -0
- data/lib/active_merchant/billing/gateways/tns.rb +16 -217
- data/lib/active_merchant/billing/gateways/trans_first.rb +148 -34
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +612 -0
- data/lib/active_merchant/billing/gateways/transact_pro.rb +222 -0
- 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 +221 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +162 -89
- data/lib/active_merchant/billing/gateways/usa_epay.rb +5 -6
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +332 -236
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +185 -72
- data/lib/active_merchant/billing/gateways/vanco.rb +294 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +52 -53
- data/lib/active_merchant/billing/gateways/viaklix.rb +19 -31
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +250 -0
- data/lib/active_merchant/billing/gateways/vpos.rb +220 -0
- data/lib/active_merchant/billing/gateways/webpay.rb +9 -9
- data/lib/active_merchant/billing/gateways/wepay.rb +108 -62
- data/lib/active_merchant/billing/gateways/wirecard.rb +52 -43
- data/lib/active_merchant/billing/gateways/wompi.rb +193 -0
- data/lib/active_merchant/billing/gateways/world_net.rb +345 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +725 -121
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +208 -0
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +79 -39
- data/lib/active_merchant/billing/gateways.rb +8 -11
- data/lib/active_merchant/billing/model.rb +2 -2
- data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
- data/lib/active_merchant/billing/payment_token.rb +1 -1
- data/lib/active_merchant/billing/rails.rb +1 -1
- data/lib/active_merchant/billing/response.rb +19 -13
- data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
- data/lib/active_merchant/billing.rb +3 -0
- data/lib/active_merchant/connection.rb +196 -0
- data/lib/active_merchant/country.rb +13 -8
- data/lib/active_merchant/errors.rb +6 -0
- data/lib/active_merchant/net_http_ssl_connection.rb +11 -0
- data/lib/active_merchant/network_connection_retries.rb +78 -0
- data/lib/active_merchant/post_data.rb +26 -0
- data/lib/active_merchant/posts_data.rb +92 -0
- data/lib/active_merchant/version.rb +1 -1
- data/lib/active_merchant.rb +14 -59
- data/lib/activemerchant.rb +1 -1
- data/lib/certs/cacert.pem +3214 -0
- data/lib/support/gateway_support.rb +8 -10
- data/lib/support/outbound_hosts.rb +13 -10
- data/lib/support/ssl_verify.rb +9 -14
- data/lib/support/ssl_version.rb +86 -0
- metadata +136 -94
- checksums.yaml.gz.sig +0 -1
- data/lib/active_merchant/billing/gateways/app55.rb +0 -176
- data/lib/active_merchant/billing/gateways/barclays_epdq.rb +0 -314
- data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -278
- 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 -291
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +0 -87
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +0 -114
- data/lib/active_merchant/billing/gateways/sage/sage_vault.rb +0 -149
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +0 -102
- data/lib/active_merchant/billing/gateways/vindicia.rb +0 -385
- data/lib/active_merchant/offsite_payments_shim.rb +0 -19
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -0
@@ -1,348 +1,475 @@
|
|
1
|
-
require
|
1
|
+
require 'active_merchant/billing/gateways/viaklix'
|
2
|
+
require 'nokogiri'
|
2
3
|
|
3
4
|
module ActiveMerchant #:nodoc:
|
4
5
|
module Billing #:nodoc:
|
5
|
-
# = Elavon Virtual Merchant Gateway
|
6
|
-
#
|
7
|
-
# == Example use:
|
8
|
-
#
|
9
|
-
# gateway = ActiveMerchant::Billing::ElavonGateway.new(
|
10
|
-
# :login => "my_virtual_merchant_id",
|
11
|
-
# :password => "my_virtual_merchant_pin",
|
12
|
-
# :user => "my_virtual_merchant_user_id" # optional
|
13
|
-
# )
|
14
|
-
#
|
15
|
-
# # set up credit card obj as in main ActiveMerchant example
|
16
|
-
# creditcard = ActiveMerchant::Billing::CreditCard.new(
|
17
|
-
# :type => 'visa',
|
18
|
-
# :number => '41111111111111111',
|
19
|
-
# :month => 10,
|
20
|
-
# :year => 2011,
|
21
|
-
# :first_name => 'Bob',
|
22
|
-
# :last_name => 'Bobsen'
|
23
|
-
# )
|
24
|
-
#
|
25
|
-
# # run request
|
26
|
-
# response = gateway.purchase(1000, creditcard) # authorize and capture 10 USD
|
27
|
-
#
|
28
|
-
# puts response.success? # Check whether the transaction was successful
|
29
|
-
# puts response.message # Retrieve the message returned by Elavon
|
30
|
-
# puts response.authorization # Retrieve the unique transaction ID returned by Elavon
|
31
|
-
#
|
32
6
|
class ElavonGateway < Gateway
|
7
|
+
include Empty
|
8
|
+
|
33
9
|
class_attribute :test_url, :live_url, :delimiter, :actions
|
34
10
|
|
35
|
-
self.test_url = 'https://demo.
|
36
|
-
self.live_url = 'https://
|
11
|
+
self.test_url = 'https://api.demo.convergepay.com/VirtualMerchantDemo/processxml.do'
|
12
|
+
self.live_url = 'https://api.convergepay.com/VirtualMerchant/processxml.do'
|
37
13
|
|
38
14
|
self.display_name = 'Elavon MyVirtualMerchant'
|
39
|
-
self.supported_countries = %w(US CA PR DE IE NO PL LU BE NL)
|
40
|
-
self.supported_cardtypes = [
|
15
|
+
self.supported_countries = %w(US CA PR DE IE NO PL LU BE NL MX)
|
16
|
+
self.supported_cardtypes = %i[visa master american_express discover]
|
41
17
|
self.homepage_url = 'http://www.elavon.com/'
|
18
|
+
self.money_format = :dollars
|
19
|
+
self.default_currency = 'USD'
|
42
20
|
|
43
21
|
self.delimiter = "\n"
|
44
22
|
self.actions = {
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
48
|
-
:
|
49
|
-
:
|
50
|
-
:
|
51
|
-
:
|
52
|
-
:
|
23
|
+
purchase: 'CCSALE',
|
24
|
+
credit: 'CCCREDIT',
|
25
|
+
refund: 'CCRETURN',
|
26
|
+
authorize: 'CCAUTHONLY',
|
27
|
+
capture: 'CCFORCE',
|
28
|
+
capture_complete: 'CCCOMPLETE',
|
29
|
+
void: 'CCDELETE',
|
30
|
+
store: 'CCGETTOKEN',
|
31
|
+
update: 'CCUPDATETOKEN',
|
32
|
+
verify: 'CCVERIFY'
|
53
33
|
}
|
54
34
|
|
55
|
-
# Initialize the Gateway
|
56
|
-
#
|
57
|
-
# The gateway requires that a valid login and password be passed
|
58
|
-
# in the +options+ hash.
|
59
|
-
#
|
60
|
-
# ==== Options
|
61
|
-
#
|
62
|
-
# * <tt>:login</tt> -- Merchant ID
|
63
|
-
# * <tt>:password</tt> -- PIN
|
64
|
-
# * <tt>:user</tt> -- Specify a subuser of the account (optional)
|
65
|
-
# * <tt>:test => +true+ or +false+</tt> -- Force test transactions
|
66
35
|
def initialize(options = {})
|
67
36
|
requires!(options, :login, :password)
|
68
37
|
super
|
69
38
|
end
|
70
39
|
|
71
|
-
# Make a purchase
|
72
40
|
def purchase(money, payment_method, options = {})
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
41
|
+
request = build_xml_request do |xml|
|
42
|
+
xml.ssl_vendor_id @options[:ssl_vendor_id] || options[:ssl_vendor_id]
|
43
|
+
xml.ssl_transaction_type self.actions[:purchase]
|
44
|
+
xml.ssl_amount amount(money)
|
45
|
+
|
46
|
+
if payment_method.is_a?(String)
|
47
|
+
add_token(xml, payment_method)
|
48
|
+
else
|
49
|
+
add_creditcard(xml, payment_method)
|
50
|
+
end
|
51
|
+
|
52
|
+
add_invoice(xml, options)
|
53
|
+
add_salestax(xml, options)
|
54
|
+
add_currency(xml, money, options)
|
55
|
+
add_address(xml, options)
|
56
|
+
add_customer_email(xml, options)
|
57
|
+
add_test_mode(xml, options)
|
58
|
+
add_ip(xml, options)
|
59
|
+
add_auth_purchase_params(xml, options)
|
60
|
+
add_level_3_fields(xml, options) if options[:level_3_data]
|
80
61
|
end
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
commit(:purchase, money, form)
|
85
|
-
end
|
86
|
-
|
87
|
-
# Authorize a credit card for a given amount.
|
88
|
-
#
|
89
|
-
# ==== Parameters
|
90
|
-
# * <tt>money</tt> - The amount to be authorized as an Integer value in cents.
|
91
|
-
# * <tt>credit_card</tt> - The CreditCard details for the transaction.
|
92
|
-
# * <tt>options</tt>
|
93
|
-
# * <tt>:billing_address</tt> - The billing address for the cardholder.
|
62
|
+
commit(request)
|
63
|
+
end
|
64
|
+
|
94
65
|
def authorize(money, creditcard, options = {})
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
66
|
+
request = build_xml_request do |xml|
|
67
|
+
xml.ssl_vendor_id @options[:ssl_vendor_id] || options[:ssl_vendor_id]
|
68
|
+
xml.ssl_transaction_type self.actions[:authorize]
|
69
|
+
xml.ssl_amount amount(money)
|
70
|
+
|
71
|
+
add_salestax(xml, options)
|
72
|
+
add_invoice(xml, options)
|
73
|
+
add_creditcard(xml, creditcard)
|
74
|
+
add_currency(xml, money, options)
|
75
|
+
add_address(xml, options)
|
76
|
+
add_customer_email(xml, options)
|
77
|
+
add_test_mode(xml, options)
|
78
|
+
add_ip(xml, options)
|
79
|
+
add_auth_purchase_params(xml, options)
|
80
|
+
add_level_3_fields(xml, options) if options[:level_3_data]
|
81
|
+
end
|
82
|
+
commit(request)
|
83
|
+
end
|
84
|
+
|
112
85
|
def capture(money, authorization, options = {})
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
86
|
+
request = build_xml_request do |xml|
|
87
|
+
xml.ssl_vendor_id @options[:ssl_vendor_id] || options[:ssl_vendor_id]
|
88
|
+
|
89
|
+
if options[:credit_card]
|
90
|
+
xml.ssl_transaction_type self.actions[:capture]
|
91
|
+
xml.ssl_amount amount(money)
|
92
|
+
add_salestax(xml, options)
|
93
|
+
add_approval_code(xml, authorization)
|
94
|
+
add_invoice(xml, options)
|
95
|
+
add_creditcard(xml, options[:credit_card])
|
96
|
+
add_currency(xml, money, options)
|
97
|
+
add_address(xml, options)
|
98
|
+
add_customer_email(xml, options)
|
99
|
+
add_test_mode(xml, options)
|
100
|
+
else
|
101
|
+
xml.ssl_transaction_type self.actions[:capture_complete]
|
102
|
+
xml.ssl_amount amount(money)
|
103
|
+
add_currency(xml, money, options)
|
104
|
+
add_txn_id(xml, authorization)
|
105
|
+
add_partial_shipment_flag(xml, options)
|
106
|
+
add_test_mode(xml, options)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
commit(request)
|
110
|
+
end
|
111
|
+
|
135
112
|
def refund(money, identification, options = {})
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
113
|
+
request = build_xml_request do |xml|
|
114
|
+
xml.ssl_vendor_id @options[:ssl_vendor_id] || options[:ssl_vendor_id]
|
115
|
+
xml.ssl_transaction_type self.actions[:refund]
|
116
|
+
xml.ssl_amount amount(money)
|
117
|
+
add_txn_id(xml, identification)
|
118
|
+
add_test_mode(xml, options)
|
119
|
+
end
|
120
|
+
commit(request)
|
140
121
|
end
|
141
122
|
|
142
|
-
# Void a previous transaction
|
143
|
-
#
|
144
|
-
# ==== Parameters
|
145
|
-
#
|
146
|
-
# * <tt>authorization</tt> - The authorization returned from the previous request.
|
147
123
|
def void(identification, options = {})
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
# Make a credit to a card. Use the refund method if you'd like to credit using
|
155
|
-
# previous transaction
|
156
|
-
#
|
157
|
-
# ==== Parameters
|
158
|
-
# * <tt>money</tt> - The amount to be credited as an Integer value in cents.
|
159
|
-
# * <tt>creditcard</tt> - The credit card to be credited.
|
160
|
-
# * <tt>options</tt>
|
161
|
-
def credit(money, creditcard, options = {})
|
162
|
-
if creditcard.is_a?(String)
|
163
|
-
raise ArgumentError, "Reference credits are not supported. Please supply the original credit card or use the #refund method."
|
124
|
+
request = build_xml_request do |xml|
|
125
|
+
xml.ssl_vendor_id @options[:ssl_vendor_id] || options[:ssl_vendor_id]
|
126
|
+
xml.ssl_transaction_type self.actions[:void]
|
127
|
+
|
128
|
+
add_txn_id(xml, identification)
|
129
|
+
add_test_mode(xml, options)
|
164
130
|
end
|
131
|
+
commit(request)
|
132
|
+
end
|
165
133
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
134
|
+
def credit(money, creditcard, options = {})
|
135
|
+
raise ArgumentError, 'Reference credits are not supported. Please supply the original credit card or use the #refund method.' if creditcard.is_a?(String)
|
136
|
+
|
137
|
+
request = build_xml_request do |xml|
|
138
|
+
xml.ssl_vendor_id @options[:ssl_vendor_id] || options[:ssl_vendor_id]
|
139
|
+
xml.ssl_transaction_type self.actions[:credit]
|
140
|
+
xml.ssl_amount amount(money)
|
141
|
+
add_invoice(xml, options)
|
142
|
+
add_creditcard(xml, creditcard)
|
143
|
+
add_currency(xml, money, options)
|
144
|
+
add_address(xml, options)
|
145
|
+
add_customer_email(xml, options)
|
146
|
+
add_test_mode(xml, options)
|
147
|
+
end
|
148
|
+
commit(request)
|
173
149
|
end
|
174
150
|
|
175
151
|
def verify(credit_card, options = {})
|
176
|
-
|
177
|
-
|
178
|
-
|
152
|
+
request = build_xml_request do |xml|
|
153
|
+
xml.ssl_vendor_id @options[:ssl_vendor_id] || options[:ssl_vendor_id]
|
154
|
+
xml.ssl_transaction_type self.actions[:verify]
|
155
|
+
add_creditcard(xml, credit_card)
|
156
|
+
add_address(xml, options)
|
157
|
+
add_test_mode(xml, options)
|
158
|
+
add_ip(xml, options)
|
179
159
|
end
|
160
|
+
commit(request)
|
180
161
|
end
|
181
162
|
|
182
163
|
def store(creditcard, options = {})
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
164
|
+
request = build_xml_request do |xml|
|
165
|
+
xml.ssl_vendor_id @options[:ssl_vendor_id] || options[:ssl_vendor_id]
|
166
|
+
xml.ssl_transaction_type self.actions[:store]
|
167
|
+
xml.ssl_add_token 'Y'
|
168
|
+
add_creditcard(xml, creditcard)
|
169
|
+
add_address(xml, options)
|
170
|
+
add_customer_email(xml, options)
|
171
|
+
add_test_mode(xml, options)
|
172
|
+
add_verification(xml, options)
|
173
|
+
end
|
174
|
+
commit(request)
|
191
175
|
end
|
192
176
|
|
193
177
|
def update(token, creditcard, options = {})
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
178
|
+
request = build_xml_request do |xml|
|
179
|
+
xml.ssl_vendor_id @options[:ssl_vendor_id] || options[:ssl_vendor_id]
|
180
|
+
xml.ssl_transaction_type self.actions[:update]
|
181
|
+
add_token(xml, token)
|
182
|
+
add_creditcard(xml, creditcard)
|
183
|
+
add_address(xml, options)
|
184
|
+
add_customer_email(xml, options)
|
185
|
+
add_test_mode(xml, options)
|
186
|
+
end
|
187
|
+
commit(request)
|
201
188
|
end
|
202
189
|
|
203
|
-
|
190
|
+
def supports_scrubbing?
|
191
|
+
true
|
192
|
+
end
|
204
193
|
|
205
|
-
def
|
206
|
-
|
207
|
-
|
194
|
+
def scrub(transcript)
|
195
|
+
transcript.
|
196
|
+
gsub(%r((<ssl_pin>)(.*)(</ssl_pin>)), '\1[FILTERED]\3').
|
197
|
+
gsub(%r((<ssl_card_number>)(.*)(</ssl_card_number>)), '\1[FILTERED]\3').
|
198
|
+
gsub(%r((<ssl_cvv2cvc2>)(.*)(</ssl_cvv2cvc2>)), '\1[FILTERED]\3')
|
208
199
|
end
|
209
200
|
|
210
|
-
|
211
|
-
|
201
|
+
private
|
202
|
+
|
203
|
+
def add_invoice(xml, options)
|
204
|
+
xml.ssl_invoice_number url_encode_truncate((options[:order_id] || options[:invoice]), 25)
|
205
|
+
xml.ssl_description url_encode_truncate(options[:description], 255)
|
212
206
|
end
|
213
207
|
|
214
|
-
def
|
215
|
-
|
208
|
+
def add_approval_code(xml, authorization)
|
209
|
+
xml.ssl_approval_code authorization.split(';').first
|
216
210
|
end
|
217
211
|
|
218
|
-
def
|
219
|
-
|
212
|
+
def add_txn_id(xml, authorization)
|
213
|
+
xml.ssl_txn_id authorization.split(';').last
|
220
214
|
end
|
221
215
|
|
222
|
-
def add_creditcard(
|
223
|
-
|
224
|
-
|
216
|
+
def add_creditcard(xml, creditcard)
|
217
|
+
xml.ssl_card_number creditcard.number
|
218
|
+
xml.ssl_exp_date expdate(creditcard)
|
225
219
|
|
226
|
-
if creditcard.verification_value?
|
227
|
-
add_verification_value(form, creditcard)
|
228
|
-
end
|
220
|
+
add_verification_value(xml, creditcard) if creditcard.verification_value?
|
229
221
|
|
230
|
-
|
231
|
-
|
222
|
+
xml.ssl_first_name url_encode_truncate(creditcard.first_name, 20)
|
223
|
+
xml.ssl_last_name url_encode_truncate(creditcard.last_name, 30)
|
232
224
|
end
|
233
225
|
|
234
|
-
def
|
235
|
-
|
226
|
+
def add_currency(xml, money, options)
|
227
|
+
currency = options[:currency] || currency(money)
|
228
|
+
return unless currency && (@options[:multi_currency] || options[:multi_currency])
|
229
|
+
|
230
|
+
xml.ssl_transaction_currency currency
|
231
|
+
end
|
232
|
+
|
233
|
+
def add_token(xml, token)
|
234
|
+
xml.ssl_token token
|
236
235
|
end
|
237
236
|
|
238
|
-
def add_verification_value(
|
239
|
-
|
240
|
-
|
237
|
+
def add_verification_value(xml, creditcard)
|
238
|
+
xml.ssl_cvv2cvc2 creditcard.verification_value
|
239
|
+
xml.ssl_cvv2cvc2_indicator 1
|
241
240
|
end
|
242
241
|
|
243
|
-
def
|
244
|
-
|
245
|
-
form[:customer_code] = options[:customer].to_s.slice(0, 10) unless options[:customer].blank?
|
242
|
+
def add_customer_email(xml, options)
|
243
|
+
xml.ssl_email url_encode_truncate(options[:email], 100) unless empty?(options[:email])
|
246
244
|
end
|
247
245
|
|
248
|
-
def add_salestax(
|
249
|
-
|
246
|
+
def add_salestax(xml, options)
|
247
|
+
return unless options[:tax].present?
|
248
|
+
|
249
|
+
xml.ssl_salestax options[:tax]
|
250
250
|
end
|
251
251
|
|
252
|
-
def add_address(
|
252
|
+
def add_address(xml, options)
|
253
253
|
billing_address = options[:billing_address] || options[:address]
|
254
254
|
|
255
255
|
if billing_address
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
256
|
+
xml.ssl_avs_address url_encode_truncate(billing_address[:address1], 30)
|
257
|
+
xml.ssl_address2 url_encode_truncate(billing_address[:address2], 30)
|
258
|
+
xml.ssl_avs_zip url_encode_truncate(billing_address[:zip].to_s.gsub(/[^a-zA-Z0-9]/, ''), 9)
|
259
|
+
xml.ssl_city url_encode_truncate(billing_address[:city], 30)
|
260
|
+
xml.ssl_state url_encode_truncate(billing_address[:state], 10)
|
261
|
+
xml.ssl_company url_encode_truncate(billing_address[:company], 50)
|
262
|
+
xml.ssl_phone url_encode_truncate(billing_address[:phone], 20)
|
263
|
+
xml.ssl_country url_encode_truncate(billing_address[:country], 50)
|
264
264
|
end
|
265
265
|
|
266
266
|
if shipping_address = options[:shipping_address]
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
267
|
+
xml.ssl_ship_to_address1 url_encode_truncate(shipping_address[:address1], 30)
|
268
|
+
xml.ssl_ship_to_address2 url_encode_truncate(shipping_address[:address2], 30)
|
269
|
+
xml.ssl_ship_to_city url_encode_truncate(shipping_address[:city], 30)
|
270
|
+
xml.ssl_ship_to_company url_encode_truncate(shipping_address[:company], 50)
|
271
|
+
xml.ssl_ship_to_country url_encode_truncate(shipping_address[:country], 50)
|
272
|
+
xml.ssl_ship_to_first_name url_encode_truncate(shipping_address[:first_name], 20)
|
273
|
+
xml.ssl_ship_to_last_name url_encode_truncate(shipping_address[:last_name], 30)
|
274
|
+
xml.ssl_ship_to_phone url_encode_truncate(shipping_address[:phone], 10)
|
275
|
+
xml.ssl_ship_to_state url_encode_truncate(shipping_address[:state], 2)
|
276
|
+
xml.ssl_ship_to_zip url_encode_truncate(shipping_address[:zip], 10)
|
277
277
|
end
|
278
278
|
end
|
279
279
|
|
280
|
-
def add_verification(
|
281
|
-
|
280
|
+
def add_verification(xml, options)
|
281
|
+
xml.ssl_verify 'Y' if options[:verify]
|
282
282
|
end
|
283
283
|
|
284
|
-
def
|
285
|
-
|
284
|
+
def add_test_mode(xml, options)
|
285
|
+
xml.ssl_test_mode 'TRUE' if options[:test_mode]
|
286
|
+
end
|
286
287
|
|
287
|
-
|
288
|
-
|
289
|
-
[ first_name, last_name ]
|
288
|
+
def add_partial_shipment_flag(xml, options)
|
289
|
+
xml.ssl_partial_shipment_flag 'Y' if options[:partial_shipment_flag]
|
290
290
|
end
|
291
291
|
|
292
|
-
def
|
293
|
-
|
292
|
+
def add_ip(xml, options)
|
293
|
+
xml.ssl_cardholder_ip options[:ip] if options.has_key?(:ip)
|
294
294
|
end
|
295
295
|
|
296
|
-
|
297
|
-
|
296
|
+
# add_recurring_token is a field that can be sent in to obtain a token from Elavon for use with their tokenization program
|
297
|
+
def add_auth_purchase_params(xml, options)
|
298
|
+
xml.ssl_dynamic_dba options[:dba] if options.has_key?(:dba)
|
299
|
+
xml.ssl_merchant_initiated_unscheduled merchant_initiated_unscheduled(options) if merchant_initiated_unscheduled(options)
|
300
|
+
xml.ssl_add_token options[:add_recurring_token] if options.has_key?(:add_recurring_token)
|
301
|
+
xml.ssl_token options[:ssl_token] if options[:ssl_token]
|
302
|
+
xml.ssl_customer_code options[:customer] if options.has_key?(:customer)
|
303
|
+
xml.ssl_customer_number options[:customer_number] if options.has_key?(:customer_number)
|
304
|
+
xml.ssl_entry_mode entry_mode(options) if entry_mode(options)
|
305
|
+
add_custom_fields(xml, options) if options[:custom_fields]
|
306
|
+
add_stored_credential(xml, options) if options[:stored_credential]
|
298
307
|
end
|
299
308
|
|
300
|
-
def
|
301
|
-
|
309
|
+
def add_custom_fields(xml, options)
|
310
|
+
options[:custom_fields]&.each do |key, value|
|
311
|
+
xml.send(key.to_sym, value)
|
312
|
+
end
|
302
313
|
end
|
303
314
|
|
304
|
-
def
|
305
|
-
|
306
|
-
|
315
|
+
def add_level_3_fields(xml, options)
|
316
|
+
level_3_data = options[:level_3_data]
|
317
|
+
xml.ssl_customer_code level_3_data[:customer_code] if level_3_data[:customer_code]
|
318
|
+
xml.ssl_salestax level_3_data[:salestax] if level_3_data[:salestax]
|
319
|
+
xml.ssl_salestax_indicator level_3_data[:salestax_indicator] if level_3_data[:salestax_indicator]
|
320
|
+
xml.ssl_level3_indicator level_3_data[:level3_indicator] if level_3_data[:level3_indicator]
|
321
|
+
xml.ssl_ship_to_zip level_3_data[:ship_to_zip] if level_3_data[:ship_to_zip]
|
322
|
+
xml.ssl_ship_to_country level_3_data[:ship_to_country] if level_3_data[:ship_to_country]
|
323
|
+
xml.ssl_shipping_amount level_3_data[:shipping_amount] if level_3_data[:shipping_amount]
|
324
|
+
xml.ssl_ship_from_postal_code level_3_data[:ship_from_postal_code] if level_3_data[:ship_from_postal_code]
|
325
|
+
xml.ssl_discount_amount level_3_data[:discount_amount] if level_3_data[:discount_amount]
|
326
|
+
xml.ssl_duty_amount level_3_data[:duty_amount] if level_3_data[:duty_amount]
|
327
|
+
xml.ssl_national_tax_indicator level_3_data[:national_tax_indicator] if level_3_data[:national_tax_indicator]
|
328
|
+
xml.ssl_national_tax_amount level_3_data[:national_tax_amount] if level_3_data[:national_tax_amount]
|
329
|
+
xml.ssl_order_date level_3_data[:order_date] if level_3_data[:order_date]
|
330
|
+
xml.ssl_other_tax level_3_data[:other_tax] if level_3_data[:other_tax]
|
331
|
+
xml.ssl_summary_commodity_code level_3_data[:summary_commodity_code] if level_3_data[:summary_commodity_code]
|
332
|
+
xml.ssl_merchant_vat_number level_3_data[:merchant_vat_number] if level_3_data[:merchant_vat_number]
|
333
|
+
xml.ssl_customer_vat_number level_3_data[:customer_vat_number] if level_3_data[:customer_vat_number]
|
334
|
+
xml.ssl_freight_tax_amount level_3_data[:freight_tax_amount] if level_3_data[:freight_tax_amount]
|
335
|
+
xml.ssl_vat_invoice_number level_3_data[:vat_invoice_number] if level_3_data[:vat_invoice_number]
|
336
|
+
xml.ssl_tracking_number level_3_data[:tracking_number] if level_3_data[:tracking_number]
|
337
|
+
xml.ssl_shipping_company level_3_data[:shipping_company] if level_3_data[:shipping_company]
|
338
|
+
xml.ssl_other_fees level_3_data[:other_fees] if level_3_data[:other_fees]
|
339
|
+
add_line_items(xml, level_3_data) if level_3_data[:line_items]
|
340
|
+
end
|
307
341
|
|
308
|
-
|
342
|
+
def add_line_items(xml, level_3_data)
|
343
|
+
xml.LineItemProducts {
|
344
|
+
level_3_data[:line_items].each do |line_item|
|
345
|
+
xml.product {
|
346
|
+
line_item.each do |key, value|
|
347
|
+
prefixed_key = "ssl_line_Item_#{key}"
|
348
|
+
xml.send(prefixed_key, value)
|
349
|
+
end
|
350
|
+
}
|
351
|
+
end
|
352
|
+
}
|
353
|
+
end
|
354
|
+
|
355
|
+
def add_stored_credential(xml, options)
|
356
|
+
network_transaction_id = options.dig(:stored_credential, :network_transaction_id)
|
357
|
+
case
|
358
|
+
when network_transaction_id.nil?
|
359
|
+
return
|
360
|
+
when network_transaction_id.to_s.include?('|')
|
361
|
+
oar_data, ps2000_data = options[:stored_credential][:network_transaction_id].split('|')
|
362
|
+
xml.ssl_oar_data oar_data unless oar_data.nil? || oar_data.empty?
|
363
|
+
xml.ssl_ps2000_data ps2000_data unless ps2000_data.nil? || ps2000_data.empty?
|
364
|
+
when network_transaction_id.to_s.length > 22
|
365
|
+
xml.ssl_oar_data options.dig(:stored_credential, :network_transaction_id)
|
366
|
+
else
|
367
|
+
xml.ssl_ps2000_data options.dig(:stored_credential, :network_transaction_id)
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
371
|
+
def merchant_initiated_unscheduled(options)
|
372
|
+
return options[:merchant_initiated_unscheduled] if options[:merchant_initiated_unscheduled]
|
373
|
+
return 'Y' if options.dig(:stored_credential, :initiator) == 'merchant' && options.dig(:stored_credential, :reason_type) == 'unscheduled' || options.dig(:stored_credential, :reason_type) == 'recurring'
|
374
|
+
end
|
309
375
|
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
376
|
+
def entry_mode(options)
|
377
|
+
return options[:entry_mode] if options[:entry_mode]
|
378
|
+
return 12 if options[:stored_credential]
|
379
|
+
end
|
380
|
+
|
381
|
+
def build_xml_request
|
382
|
+
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
383
|
+
xml.txn do
|
384
|
+
xml.ssl_merchant_id @options[:login]
|
385
|
+
xml.ssl_user_id @options[:user]
|
386
|
+
xml.ssl_pin @options[:password]
|
387
|
+
yield(xml)
|
388
|
+
end
|
389
|
+
end
|
390
|
+
|
391
|
+
builder.to_xml.gsub("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", '')
|
392
|
+
end
|
393
|
+
|
394
|
+
def commit(request)
|
395
|
+
request = "xmldata=#{request}".delete('&')
|
396
|
+
store_action = request.match?('CCGETTOKEN')
|
397
|
+
|
398
|
+
response = parse(ssl_post(test? ? self.test_url : self.live_url, request, headers))
|
399
|
+
response = hash_html_decode(response)
|
400
|
+
|
401
|
+
Response.new(
|
402
|
+
response[:result] == '0',
|
403
|
+
response[:result_message] || response[:errorMessage],
|
404
|
+
response,
|
405
|
+
test: @options[:test] || test?,
|
406
|
+
authorization: authorization_from(response, store_action),
|
407
|
+
error_code: response[:errorCode],
|
408
|
+
avs_result: { code: response[:avs_response] },
|
409
|
+
cvv_result: response[:cvv2_response],
|
410
|
+
network_transaction_id: build_network_transaction_id(response)
|
315
411
|
)
|
316
412
|
end
|
317
413
|
|
318
|
-
def
|
319
|
-
|
320
|
-
result.merge!(parameters)
|
321
|
-
result.collect { |key, value| "ssl_#{key}=#{CGI.escape(value.to_s)}" }.join("&")
|
414
|
+
def build_network_transaction_id(response)
|
415
|
+
"#{response[:oar_data]}|#{response[:ps2000_data]}"
|
322
416
|
end
|
323
417
|
|
324
|
-
def
|
325
|
-
|
326
|
-
'
|
327
|
-
'
|
328
|
-
'show_form' => 'false',
|
329
|
-
'result_format' => 'ASCII'
|
418
|
+
def headers
|
419
|
+
{
|
420
|
+
'Accept' => 'application/xml',
|
421
|
+
'Content-type' => 'application/x-www-form-urlencoded;charset=utf8'
|
330
422
|
}
|
423
|
+
end
|
331
424
|
|
332
|
-
|
333
|
-
|
425
|
+
def parse(body)
|
426
|
+
xml = Nokogiri::XML(body)
|
427
|
+
response = Hash.from_xml(xml.to_s)['txn']
|
428
|
+
|
429
|
+
response.deep_transform_keys { |key| key.gsub('ssl_', '').to_sym }
|
430
|
+
end
|
431
|
+
|
432
|
+
def authorization_from(response, store_action)
|
433
|
+
return response[:token] if store_action
|
434
|
+
|
435
|
+
[response[:approval_code], response[:txn_id]].join(';')
|
436
|
+
end
|
437
|
+
|
438
|
+
def url_encode_truncate(value, size)
|
439
|
+
return nil unless value
|
440
|
+
|
441
|
+
encoded = url_encode(value)
|
442
|
+
|
443
|
+
while encoded.length > size
|
444
|
+
value.chop!
|
445
|
+
encoded = url_encode(value)
|
446
|
+
end
|
447
|
+
encoded
|
334
448
|
end
|
335
449
|
|
336
|
-
def
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
450
|
+
def url_encode(value)
|
451
|
+
if value.is_a?(String)
|
452
|
+
encoded = CGI.escape(value)
|
453
|
+
encoded = encoded.tr('+', ' ') # don't encode spaces
|
454
|
+
encoded = encoded.gsub('%26', '%26amp;') # account for Elavon's weird '&' handling
|
455
|
+
encoded
|
456
|
+
else
|
457
|
+
value.to_s
|
458
|
+
end
|
343
459
|
end
|
344
460
|
|
461
|
+
def hash_html_decode(hash)
|
462
|
+
hash.each do |k, v|
|
463
|
+
if v.is_a?(String)
|
464
|
+
# decode all string params
|
465
|
+
v = v.gsub('&amp;', '&') # account for Elavon's weird '&' handling
|
466
|
+
hash[k] = CGI.unescape_html(v)
|
467
|
+
elsif v.is_a?(Hash)
|
468
|
+
hash_html_decode(v)
|
469
|
+
end
|
470
|
+
end
|
471
|
+
hash
|
472
|
+
end
|
345
473
|
end
|
346
474
|
end
|
347
475
|
end
|
348
|
-
|