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,21 +1,23 @@
|
|
1
1
|
module ActiveMerchant #:nodoc:
|
2
2
|
module Billing #:nodoc:
|
3
|
-
|
4
3
|
class UsaEpayTransactionGateway < Gateway
|
5
4
|
self.live_url = 'https://www.usaepay.com/gate'
|
6
5
|
self.test_url = 'https://sandbox.usaepay.com/gate'
|
7
6
|
|
8
|
-
self.supported_cardtypes = [
|
7
|
+
self.supported_cardtypes = %i[visa master american_express]
|
9
8
|
self.supported_countries = ['US']
|
10
9
|
self.homepage_url = 'http://www.usaepay.com/'
|
11
10
|
self.display_name = 'USA ePay'
|
12
11
|
|
13
12
|
TRANSACTIONS = {
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
13
|
+
authorization: 'cc:authonly',
|
14
|
+
purchase: 'cc:sale',
|
15
|
+
capture: 'cc:capture',
|
16
|
+
refund: 'cc:refund',
|
17
|
+
void: 'cc:void',
|
18
|
+
void_release: 'cc:void:release',
|
19
|
+
check_purchase: 'check:sale',
|
20
|
+
store: 'cc:save'
|
19
21
|
}
|
20
22
|
|
21
23
|
STANDARD_ERROR_CODE_MAPPING = {
|
@@ -32,9 +34,9 @@ module ActiveMerchant #:nodoc:
|
|
32
34
|
'10110' => STANDARD_ERROR_CODE[:incorrect_address],
|
33
35
|
'10111' => STANDARD_ERROR_CODE[:incorrect_address],
|
34
36
|
'10127' => STANDARD_ERROR_CODE[:card_declined],
|
35
|
-
'
|
36
|
-
'
|
37
|
-
'
|
37
|
+
'00043' => STANDARD_ERROR_CODE[:call_issuer],
|
38
|
+
'10205' => STANDARD_ERROR_CODE[:card_declined],
|
39
|
+
'10204' => STANDARD_ERROR_CODE[:pickup_card]
|
38
40
|
}
|
39
41
|
|
40
42
|
def initialize(options = {})
|
@@ -42,50 +44,66 @@ module ActiveMerchant #:nodoc:
|
|
42
44
|
super
|
43
45
|
end
|
44
46
|
|
45
|
-
def authorize(money,
|
47
|
+
def authorize(money, payment, options = {})
|
46
48
|
post = {}
|
47
49
|
|
48
50
|
add_amount(post, money)
|
49
51
|
add_invoice(post, options)
|
50
|
-
|
51
|
-
unless
|
52
|
-
add_address(post,
|
52
|
+
add_payment(post, payment)
|
53
|
+
unless payment.is_a?(CreditCard) && payment.track_data.present?
|
54
|
+
add_address(post, payment, options)
|
53
55
|
add_customer_data(post, options)
|
54
56
|
end
|
55
57
|
add_split_payments(post, options)
|
58
|
+
add_recurring_fields(post, options)
|
59
|
+
add_custom_fields(post, options)
|
60
|
+
add_line_items(post, options)
|
61
|
+
add_test_mode(post, options)
|
56
62
|
|
57
63
|
commit(:authorization, post)
|
58
64
|
end
|
59
65
|
|
60
|
-
def purchase(money,
|
66
|
+
def purchase(money, payment, options = {})
|
61
67
|
post = {}
|
62
68
|
|
63
69
|
add_amount(post, money)
|
64
70
|
add_invoice(post, options)
|
65
|
-
|
66
|
-
unless
|
67
|
-
add_address(post,
|
71
|
+
add_payment(post, payment, options)
|
72
|
+
unless payment.respond_to?(:track_data) && payment.track_data.present?
|
73
|
+
add_address(post, payment, options)
|
68
74
|
add_customer_data(post, options)
|
69
75
|
end
|
70
76
|
add_split_payments(post, options)
|
77
|
+
add_recurring_fields(post, options)
|
78
|
+
add_custom_fields(post, options)
|
79
|
+
add_line_items(post, options)
|
80
|
+
add_test_mode(post, options)
|
71
81
|
|
72
|
-
commit(:purchase, post)
|
82
|
+
payment.respond_to?(:routing_number) ? commit(:check_purchase, post) : commit(:purchase, post)
|
73
83
|
end
|
74
84
|
|
75
85
|
def capture(money, authorization, options = {})
|
76
|
-
post = { :
|
86
|
+
post = { refNum: authorization }
|
77
87
|
|
78
88
|
add_amount(post, money)
|
89
|
+
add_test_mode(post, options)
|
79
90
|
commit(:capture, post)
|
80
91
|
end
|
81
92
|
|
82
93
|
def refund(money, authorization, options = {})
|
83
|
-
post = { :
|
94
|
+
post = { refNum: authorization }
|
84
95
|
|
85
96
|
add_amount(post, money)
|
97
|
+
add_test_mode(post, options)
|
86
98
|
commit(:refund, post)
|
87
99
|
end
|
88
100
|
|
101
|
+
def store(payment, options = {})
|
102
|
+
post = {}
|
103
|
+
add_payment(post, payment, options)
|
104
|
+
commit(:store, post)
|
105
|
+
end
|
106
|
+
|
89
107
|
def verify(creditcard, options = {})
|
90
108
|
MultiResponse.run(:use_first_response) do |r|
|
91
109
|
r.process { authorize(1, creditcard, options) }
|
@@ -93,12 +111,28 @@ module ActiveMerchant #:nodoc:
|
|
93
111
|
end
|
94
112
|
end
|
95
113
|
|
114
|
+
# Pass `no_release: true` to keep the void from immediately settling
|
96
115
|
def void(authorization, options = {})
|
97
|
-
|
98
|
-
|
116
|
+
command = (options[:no_release] ? :void : :void_release)
|
117
|
+
post = { refNum: authorization }
|
118
|
+
add_test_mode(post, options)
|
119
|
+
commit(command, post)
|
99
120
|
end
|
100
121
|
|
101
|
-
|
122
|
+
def supports_scrubbing?
|
123
|
+
true
|
124
|
+
end
|
125
|
+
|
126
|
+
def scrub(transcript)
|
127
|
+
transcript.
|
128
|
+
gsub(%r((&?UMcard=)\d*(&?))i, '\1[FILTERED]\2').
|
129
|
+
gsub(%r((&?UMcvv2=)\d*(&?))i, '\1[FILTERED]\2').
|
130
|
+
gsub(%r((&?UMmagstripe=)[^&]*)i, '\1[FILTERED]\2').
|
131
|
+
gsub(%r((&?UMaccount=)[^&]*)i, '\1[FILTERED]').
|
132
|
+
gsub(%r((&?UMkey=)[^&]*)i, '\1[FILTERED]')
|
133
|
+
end
|
134
|
+
|
135
|
+
private
|
102
136
|
|
103
137
|
def add_amount(post, money)
|
104
138
|
post[:amount] = amount(money)
|
@@ -118,30 +152,32 @@ module ActiveMerchant #:nodoc:
|
|
118
152
|
|
119
153
|
if options.has_key? :email
|
120
154
|
post[:custemail] = options[:email]
|
121
|
-
|
155
|
+
if options[:cust_receipt]
|
156
|
+
post[:custreceipt] = options[:cust_receipt]
|
157
|
+
post[:custreceiptname] = options[:cust_receipt_name] if options[:cust_receipt_name]
|
158
|
+
else
|
159
|
+
post[:custreceipt] = 'No'
|
160
|
+
end
|
122
161
|
end
|
123
162
|
|
124
|
-
if options.has_key? :customer
|
125
|
-
post[:custid] = options[:customer]
|
126
|
-
end
|
163
|
+
post[:custid] = options[:customer] if options.has_key? :customer
|
127
164
|
|
128
|
-
if options.has_key? :ip
|
129
|
-
post[:ip] = options[:ip]
|
130
|
-
end
|
165
|
+
post[:ip] = options[:ip] if options.has_key? :ip
|
131
166
|
end
|
132
167
|
|
133
|
-
def add_address(post,
|
168
|
+
def add_address(post, payment, options)
|
134
169
|
billing_address = options[:billing_address] || options[:address]
|
135
170
|
|
136
|
-
add_address_for_type(:billing, post,
|
137
|
-
add_address_for_type(:shipping, post,
|
171
|
+
add_address_for_type(:billing, post, payment, billing_address) if billing_address
|
172
|
+
add_address_for_type(:shipping, post, payment, options[:shipping_address]) if options[:shipping_address]
|
138
173
|
end
|
139
174
|
|
140
|
-
def add_address_for_type(type, post,
|
175
|
+
def add_address_for_type(type, post, payment, address)
|
141
176
|
prefix = address_key_prefix(type)
|
177
|
+
first_name, last_name = split_names(address[:name])
|
142
178
|
|
143
|
-
post[address_key(prefix, 'fname')] =
|
144
|
-
post[address_key(prefix, 'lname')] =
|
179
|
+
post[address_key(prefix, 'fname')] = first_name.blank? && last_name.blank? ? payment.first_name : first_name
|
180
|
+
post[address_key(prefix, 'lname')] = first_name.blank? && last_name.blank? ? payment.last_name : last_name
|
145
181
|
post[address_key(prefix, 'company')] = address[:company] unless address[:company].blank?
|
146
182
|
post[address_key(prefix, 'street')] = address[:address1] unless address[:address1].blank?
|
147
183
|
post[address_key(prefix, 'street2')] = address[:address2] unless address[:address2].blank?
|
@@ -164,25 +200,45 @@ module ActiveMerchant #:nodoc:
|
|
164
200
|
end
|
165
201
|
|
166
202
|
def add_invoice(post, options)
|
167
|
-
post[:invoice] = options[:
|
203
|
+
post[:invoice] = options[:invoice]
|
204
|
+
post[:orderid] = options[:order_id]
|
168
205
|
post[:description] = options[:description]
|
169
206
|
end
|
170
207
|
|
171
|
-
def
|
172
|
-
if
|
173
|
-
post[:
|
208
|
+
def add_payment(post, payment, options = {})
|
209
|
+
if payment.respond_to?(:routing_number)
|
210
|
+
post[:checkformat] = options[:check_format] if options[:check_format]
|
211
|
+
if payment.account_type
|
212
|
+
account_type = payment.account_type.to_s.capitalize
|
213
|
+
raise ArgumentError, 'account_type must be checking or savings' unless %w(Checking Savings).include?(account_type)
|
214
|
+
|
215
|
+
post[:accounttype] = account_type
|
216
|
+
end
|
217
|
+
post[:account] = payment.account_number
|
218
|
+
post[:routing] = payment.routing_number
|
219
|
+
post[:name] = payment.name unless payment.name.blank?
|
220
|
+
elsif payment.respond_to?(:track_data) && payment.track_data.present?
|
221
|
+
post[:magstripe] = payment.track_data
|
174
222
|
post[:cardpresent] = true
|
223
|
+
elsif payment.is_a?(String)
|
224
|
+
post[:card] = payment
|
175
225
|
else
|
176
|
-
post[:card] =
|
177
|
-
post[:cvv2] =
|
178
|
-
post[:expir] = expdate(
|
179
|
-
post[:name] =
|
226
|
+
post[:card] = payment.number
|
227
|
+
post[:cvv2] = payment.verification_value if payment.verification_value?
|
228
|
+
post[:expir] = expdate(payment)
|
229
|
+
post[:name] = payment.name unless payment.name.blank?
|
230
|
+
post[:cardpresent] = true if payment.manual_entry
|
180
231
|
end
|
181
232
|
end
|
182
233
|
|
234
|
+
def add_test_mode(post, options)
|
235
|
+
post[:testmode] = (options[:test_mode] ? 1 : 0) if options.has_key?(:test_mode)
|
236
|
+
end
|
237
|
+
|
183
238
|
# see: http://wiki.usaepay.com/developer/transactionapi#split_payments
|
184
239
|
def add_split_payments(post, options)
|
185
240
|
return unless options[:split_payments].is_a?(Array)
|
241
|
+
|
186
242
|
options[:split_payments].each_with_index do |payment, index|
|
187
243
|
prefix = '%02d' % (index + 2)
|
188
244
|
post["#{prefix}key"] = payment[:key]
|
@@ -194,61 +250,118 @@ module ActiveMerchant #:nodoc:
|
|
194
250
|
post['onError'] = options[:on_error] || 'Void'
|
195
251
|
end
|
196
252
|
|
253
|
+
def add_recurring_fields(post, options)
|
254
|
+
return unless options[:recurring_fields].is_a?(Hash)
|
255
|
+
|
256
|
+
options[:recurring_fields].each do |key, value|
|
257
|
+
if value == true
|
258
|
+
value = 'yes'
|
259
|
+
elsif value == false
|
260
|
+
next
|
261
|
+
end
|
262
|
+
|
263
|
+
value = amount(value) if key == :bill_amount
|
264
|
+
|
265
|
+
post[key.to_s.delete('_')] = value
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
# see: https://wiki.usaepay.com/developer/transactionapi#merchant_defined_custom_fields
|
270
|
+
def add_custom_fields(post, options)
|
271
|
+
return unless options[:custom_fields].is_a?(Hash)
|
272
|
+
|
273
|
+
options[:custom_fields].each do |index, custom|
|
274
|
+
raise ArgumentError.new('Cannot specify custom field with index 0') if index.to_s.to_i.zero?
|
275
|
+
|
276
|
+
post["custom#{index}"] = custom
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
# see: https://wiki.usaepay.com/developer/transactionapi#line_item_details
|
281
|
+
def add_line_items(post, options)
|
282
|
+
return unless options[:line_items].is_a?(Array)
|
283
|
+
|
284
|
+
options[:line_items].each_with_index do |line_item, index|
|
285
|
+
%w(product_ref_num sku qty name description taxable tax_rate tax_amount commodity_code discount_rate discount_amount).each do |key|
|
286
|
+
post["line#{index}#{key.delete('_')}"] = line_item[key.to_sym] if line_item.has_key?(key.to_sym)
|
287
|
+
end
|
288
|
+
|
289
|
+
{
|
290
|
+
quantity: 'qty',
|
291
|
+
unit: 'um'
|
292
|
+
}.each do |key, umkey|
|
293
|
+
post["line#{index}#{umkey}"] = line_item[key.to_sym] if line_item.has_key?(key.to_sym)
|
294
|
+
end
|
295
|
+
|
296
|
+
post["line#{index}cost"] = amount(line_item[:cost])
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
197
300
|
def parse(body)
|
198
301
|
fields = {}
|
199
302
|
for line in body.split('&')
|
200
|
-
key, value = *line.scan(
|
303
|
+
key, value = *line.scan(%r{^(\w+)\=(.*)$}).flatten
|
201
304
|
fields[key] = CGI.unescape(value.to_s)
|
202
305
|
end
|
203
306
|
|
204
307
|
{
|
205
|
-
:
|
206
|
-
:
|
207
|
-
:
|
208
|
-
:
|
209
|
-
:
|
210
|
-
:
|
211
|
-
:
|
212
|
-
:
|
213
|
-
:
|
214
|
-
:
|
215
|
-
:
|
216
|
-
:
|
217
|
-
:
|
218
|
-
:
|
219
|
-
|
308
|
+
status: fields['UMstatus'],
|
309
|
+
auth_code: fields['UMauthCode'],
|
310
|
+
ref_num: fields['UMrefNum'],
|
311
|
+
card_ref: fields['UMcardRef'],
|
312
|
+
batch: fields['UMbatch'],
|
313
|
+
avs_result: fields['UMavsResult'],
|
314
|
+
avs_result_code: fields['UMavsResultCode'],
|
315
|
+
cvv2_result: fields['UMcvv2Result'],
|
316
|
+
cvv2_result_code: fields['UMcvv2ResultCode'],
|
317
|
+
vpas_result_code: fields['UMvpasResultCode'],
|
318
|
+
result: fields['UMresult'],
|
319
|
+
error: fields['UMerror'],
|
320
|
+
error_code: fields['UMerrorcode'],
|
321
|
+
acs_url: fields['UMacsurl'],
|
322
|
+
payload: fields['UMpayload']
|
323
|
+
}.delete_if { |_k, v| v.nil? }
|
220
324
|
end
|
221
325
|
|
222
326
|
def commit(action, parameters)
|
223
327
|
url = (test? ? self.test_url : self.live_url)
|
224
328
|
response = parse(ssl_post(url, post_data(action, parameters)))
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
:
|
230
|
-
:
|
231
|
-
|
329
|
+
approved = response[:status] == 'Approved'
|
330
|
+
error_code = nil
|
331
|
+
error_code = (STANDARD_ERROR_CODE_MAPPING[response[:error_code]] || STANDARD_ERROR_CODE[:processing_error]) unless approved
|
332
|
+
Response.new(approved, message_from(response), response,
|
333
|
+
test: test?,
|
334
|
+
authorization: authorization_from(action, response),
|
335
|
+
cvv_result: response[:cvv2_result_code],
|
336
|
+
avs_result: { code: response[:avs_result_code] },
|
337
|
+
error_code: error_code)
|
232
338
|
end
|
233
339
|
|
234
340
|
def message_from(response)
|
235
|
-
if response[:status] ==
|
341
|
+
if response[:status] == 'Approved'
|
236
342
|
return 'Success'
|
237
343
|
else
|
238
344
|
return 'Unspecified error' if response[:error].blank?
|
345
|
+
|
239
346
|
return response[:error]
|
240
347
|
end
|
241
348
|
end
|
242
349
|
|
350
|
+
def authorization_from(action, response)
|
351
|
+
return (action == :store ? response[:card_ref] : response[:ref_num])
|
352
|
+
end
|
353
|
+
|
243
354
|
def post_data(action, parameters = {})
|
244
355
|
parameters[:command] = TRANSACTIONS[action]
|
245
356
|
parameters[:key] = @options[:login]
|
246
357
|
parameters[:software] = 'Active Merchant'
|
247
|
-
parameters[:testmode] = (@options[:test] ? 1 : 0)
|
358
|
+
parameters[:testmode] = (@options[:test] ? 1 : 0) unless parameters.has_key?(:testmode)
|
359
|
+
seed = SecureRandom.hex(32).upcase
|
360
|
+
hash = Digest::SHA1.hexdigest("#{parameters[:command]}:#{@options[:pin] || @options[:password]}:#{parameters[:amount]}:#{parameters[:invoice]}:#{seed}")
|
361
|
+
parameters[:hash] = "s/#{seed}/#{hash}/n"
|
248
362
|
|
249
|
-
parameters.collect { |key, value| "UM#{key}=#{CGI.escape(value.to_s)}" }.join(
|
363
|
+
parameters.collect { |key, value| "UM#{key}=#{CGI.escape(value.to_s)}" }.join('&')
|
250
364
|
end
|
251
365
|
end
|
252
366
|
end
|
253
367
|
end
|
254
|
-
|
@@ -0,0 +1,294 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module ActiveMerchant
|
4
|
+
module Billing
|
5
|
+
class VancoGateway < Gateway
|
6
|
+
include Empty
|
7
|
+
|
8
|
+
self.test_url = 'https://uat.vancopayments.com/cgi-bin/ws2.vps'
|
9
|
+
self.live_url = 'https://myvanco.vancopayments.com/cgi-bin/ws2.vps'
|
10
|
+
|
11
|
+
self.supported_countries = ['US']
|
12
|
+
self.default_currency = 'USD'
|
13
|
+
self.supported_cardtypes = %i[visa master american_express discover]
|
14
|
+
|
15
|
+
self.homepage_url = 'http://vancopayments.com/'
|
16
|
+
self.display_name = 'Vanco Payment Solutions'
|
17
|
+
|
18
|
+
def initialize(options = {})
|
19
|
+
requires!(options, :user_id, :password, :client_id)
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def purchase(money, payment_method, options = {})
|
24
|
+
MultiResponse.run do |r|
|
25
|
+
r.process { login }
|
26
|
+
r.process { commit(purchase_request(money, payment_method, r.params['response_sessionid'], options), :response_transactionref) }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def refund(money, authorization, options = {})
|
31
|
+
MultiResponse.run do |r|
|
32
|
+
r.process { login }
|
33
|
+
r.process { commit(refund_request(money, authorization, r.params['response_sessionid']), :response_creditrequestreceived) }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def supports_scrubbing?
|
38
|
+
true
|
39
|
+
end
|
40
|
+
|
41
|
+
def scrub(transcript)
|
42
|
+
transcript.
|
43
|
+
gsub(%r((<Password>).+(</Password>))i, '\1[FILTERED]\2').
|
44
|
+
gsub(%r((<CardCVV2>).+(</CardCVV2>))i, '\1[FILTERED]\2').
|
45
|
+
gsub(%r((<AccountNumber>).+(</AccountNumber>))i, '\1[FILTERED]\2')
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def parse(xml)
|
51
|
+
response = {}
|
52
|
+
|
53
|
+
doc = Nokogiri::XML(xml)
|
54
|
+
doc.root.xpath('*').each do |node|
|
55
|
+
if node.elements.empty?
|
56
|
+
response[node.name.downcase.to_sym] = node.text
|
57
|
+
else
|
58
|
+
node.elements.each do |childnode|
|
59
|
+
childnode_to_response(response, node, childnode)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
response
|
65
|
+
end
|
66
|
+
|
67
|
+
def childnode_to_response(response, node, childnode)
|
68
|
+
name = "#{node.name.downcase}_#{childnode.name.downcase}"
|
69
|
+
if name == 'response_errors' && !childnode.elements.empty?
|
70
|
+
add_errors_to_response(response, childnode.to_s)
|
71
|
+
else
|
72
|
+
response[name.downcase.to_sym] = childnode.text
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def add_errors_to_response(response, errors_xml)
|
77
|
+
errors_hash = Hash.from_xml(errors_xml).values.first
|
78
|
+
response[:response_errors] = errors_hash
|
79
|
+
|
80
|
+
error = errors_hash['Error']
|
81
|
+
if error.kind_of?(Hash)
|
82
|
+
response[:error_message] = error['ErrorDescription']
|
83
|
+
response[:error_codes] = error['ErrorCode']
|
84
|
+
elsif error.kind_of?(Array)
|
85
|
+
error_str = error.map { |e| e['ErrorDescription'] }.join('. ')
|
86
|
+
error_codes = error.map { |e| e['ErrorCode'] }.join(', ')
|
87
|
+
response[:error_message] = "#{error_str}."
|
88
|
+
response[:error_codes] = error_codes
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def commit(request, success_field_name)
|
93
|
+
response = parse(ssl_post(url, request, headers))
|
94
|
+
succeeded = success_from(response, success_field_name)
|
95
|
+
|
96
|
+
Response.new(
|
97
|
+
succeeded,
|
98
|
+
message_from(succeeded, response),
|
99
|
+
response,
|
100
|
+
authorization: authorization_from(response),
|
101
|
+
test: test?
|
102
|
+
)
|
103
|
+
end
|
104
|
+
|
105
|
+
def success_from(response, success_field_name)
|
106
|
+
!empty?(response[success_field_name])
|
107
|
+
end
|
108
|
+
|
109
|
+
def message_from(succeeded, response)
|
110
|
+
return 'Success' if succeeded
|
111
|
+
|
112
|
+
response[:error_message]
|
113
|
+
end
|
114
|
+
|
115
|
+
def authorization_from(response)
|
116
|
+
[
|
117
|
+
response[:response_customerref],
|
118
|
+
response[:response_paymentmethodref],
|
119
|
+
response[:response_transactionref]
|
120
|
+
].join('|')
|
121
|
+
end
|
122
|
+
|
123
|
+
def split_authorization(authorization)
|
124
|
+
authorization.to_s.split('|')
|
125
|
+
end
|
126
|
+
|
127
|
+
def purchase_request(money, payment_method, session_id, options)
|
128
|
+
build_xml_request do |doc|
|
129
|
+
add_auth(doc, 'EFTAddCompleteTransaction', session_id)
|
130
|
+
|
131
|
+
doc.Request do
|
132
|
+
doc.RequestVars do
|
133
|
+
add_client_id(doc)
|
134
|
+
add_amount(doc, money, options)
|
135
|
+
add_payment_method(doc, payment_method, options)
|
136
|
+
add_options(doc, options)
|
137
|
+
add_purchase_noise(doc)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def refund_request(money, authorization, session_id)
|
144
|
+
build_xml_request do |doc|
|
145
|
+
add_auth(doc, 'EFTAddCredit', session_id)
|
146
|
+
|
147
|
+
doc.Request do
|
148
|
+
doc.RequestVars do
|
149
|
+
add_client_id(doc)
|
150
|
+
add_amount(doc, money, options)
|
151
|
+
add_reference(doc, authorization)
|
152
|
+
add_refund_noise(doc)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
def add_request(doc, request_type)
|
159
|
+
doc.RequestType(request_type)
|
160
|
+
doc.RequestID(SecureRandom.hex(15))
|
161
|
+
doc.RequestTime(Time.now)
|
162
|
+
doc.Version(2)
|
163
|
+
end
|
164
|
+
|
165
|
+
def add_auth(doc, request_type, session_id)
|
166
|
+
doc.Auth do
|
167
|
+
add_request(doc, request_type)
|
168
|
+
doc.SessionID(session_id)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def add_reference(doc, authorization)
|
173
|
+
customer_ref, payment_method_ref, transaction_ref = split_authorization(authorization)
|
174
|
+
doc.CustomerRef(customer_ref)
|
175
|
+
doc.PaymentMethodRef(payment_method_ref)
|
176
|
+
doc.TransactionRef(transaction_ref)
|
177
|
+
end
|
178
|
+
|
179
|
+
def add_amount(doc, money, options)
|
180
|
+
if empty?(options[:fund_id])
|
181
|
+
doc.Amount(amount(money))
|
182
|
+
else
|
183
|
+
doc.Funds do
|
184
|
+
doc.Fund do
|
185
|
+
doc.FundID(options[:fund_id])
|
186
|
+
doc.FundAmount(amount(money))
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def add_payment_method(doc, payment_method, options)
|
193
|
+
if card_brand(payment_method) == 'check'
|
194
|
+
add_echeck(doc, payment_method)
|
195
|
+
else
|
196
|
+
add_credit_card(doc, payment_method, options)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
def add_credit_card(doc, credit_card, options)
|
201
|
+
doc.AccountNumber(credit_card.number)
|
202
|
+
doc.CustomerName("#{credit_card.last_name}, #{credit_card.first_name}")
|
203
|
+
doc.CardExpMonth(format(credit_card.month, :two_digits))
|
204
|
+
doc.CardExpYear(format(credit_card.year, :two_digits))
|
205
|
+
doc.CardCVV2(credit_card.verification_value)
|
206
|
+
doc.CardBillingName(credit_card.name)
|
207
|
+
doc.AccountType('CC')
|
208
|
+
add_billing_address(doc, options)
|
209
|
+
end
|
210
|
+
|
211
|
+
def add_billing_address(doc, options)
|
212
|
+
address = options[:billing_address]
|
213
|
+
return unless address
|
214
|
+
|
215
|
+
doc.CardBillingAddr1(address[:address1])
|
216
|
+
doc.CardBillingAddr2(address[:address2])
|
217
|
+
doc.CardBillingCity(address[:city])
|
218
|
+
doc.CardBillingState(address[:state])
|
219
|
+
doc.CardBillingZip(address[:zip])
|
220
|
+
doc.CardBillingCountryCode(address[:country])
|
221
|
+
end
|
222
|
+
|
223
|
+
def add_echeck(doc, echeck)
|
224
|
+
if echeck.account_type == 'savings'
|
225
|
+
doc.AccountType('S')
|
226
|
+
else
|
227
|
+
doc.AccountType('C')
|
228
|
+
end
|
229
|
+
|
230
|
+
doc.CustomerName("#{echeck.last_name}, #{echeck.first_name}")
|
231
|
+
doc.AccountNumber(echeck.account_number)
|
232
|
+
doc.RoutingNumber(echeck.routing_number)
|
233
|
+
doc.TransactionTypeCode('WEB')
|
234
|
+
end
|
235
|
+
|
236
|
+
def add_purchase_noise(doc)
|
237
|
+
doc.StartDate('0000-00-00')
|
238
|
+
doc.FrequencyCode('O')
|
239
|
+
end
|
240
|
+
|
241
|
+
def add_refund_noise(doc)
|
242
|
+
doc.ContactName('Bilbo Baggins')
|
243
|
+
doc.ContactPhone('1234567890')
|
244
|
+
doc.ContactExtension('None')
|
245
|
+
doc.ReasonForCredit('Refund requested')
|
246
|
+
end
|
247
|
+
|
248
|
+
def add_options(doc, options)
|
249
|
+
doc.CustomerIPAddress(options[:ip]) if options[:ip]
|
250
|
+
end
|
251
|
+
|
252
|
+
def add_client_id(doc)
|
253
|
+
doc.ClientID(@options[:client_id])
|
254
|
+
end
|
255
|
+
|
256
|
+
def login
|
257
|
+
commit(login_request, :response_sessionid)
|
258
|
+
end
|
259
|
+
|
260
|
+
def login_request
|
261
|
+
build_xml_request do |doc|
|
262
|
+
doc.Auth do
|
263
|
+
add_request(doc, 'Login')
|
264
|
+
end
|
265
|
+
|
266
|
+
doc.Request do
|
267
|
+
doc.RequestVars do
|
268
|
+
doc.UserID(@options[:user_id])
|
269
|
+
doc.Password(@options[:password])
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
def build_xml_request
|
276
|
+
builder = Nokogiri::XML::Builder.new
|
277
|
+
builder.__send__('VancoWS') do |doc|
|
278
|
+
yield(doc)
|
279
|
+
end
|
280
|
+
builder.to_xml
|
281
|
+
end
|
282
|
+
|
283
|
+
def url
|
284
|
+
(test? ? test_url : live_url)
|
285
|
+
end
|
286
|
+
|
287
|
+
def headers
|
288
|
+
{
|
289
|
+
'Content-Type' => 'text/xml'
|
290
|
+
}
|
291
|
+
end
|
292
|
+
end
|
293
|
+
end
|
294
|
+
end
|