swiss-crm-activemerchant 1.0.12
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 +7 -0
- data/CHANGELOG +4033 -0
- data/CONTRIBUTORS +568 -0
- data/MIT-LICENSE +20 -0
- data/README.md +252 -0
- data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
- data/lib/active_merchant/billing/avs_result.rb +95 -0
- data/lib/active_merchant/billing/base.rb +48 -0
- data/lib/active_merchant/billing/check.rb +112 -0
- data/lib/active_merchant/billing/compatibility.rb +118 -0
- data/lib/active_merchant/billing/credit_card.rb +451 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +24 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +512 -0
- data/lib/active_merchant/billing/cvv_result.rb +37 -0
- data/lib/active_merchant/billing/gateway.rb +332 -0
- data/lib/active_merchant/billing/gateways/adyen.rb +774 -0
- data/lib/active_merchant/billing/gateways/airwallex.rb +370 -0
- data/lib/active_merchant/billing/gateways/alelo.rb +256 -0
- data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +1125 -0
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +424 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +977 -0
- data/lib/active_merchant/billing/gateways/axcessms.rb +242 -0
- data/lib/active_merchant/billing/gateways/balanced.rb +263 -0
- data/lib/active_merchant/billing/gateways/bambora_apac.rb +222 -0
- data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
- data/lib/active_merchant/billing/gateways/banwire.rb +116 -0
- data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +397 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +15 -0
- data/lib/active_merchant/billing/gateways/be2bill.rb +131 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +474 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +238 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +57 -0
- data/lib/active_merchant/billing/gateways/blue_pay.rb +549 -0
- data/lib/active_merchant/billing/gateways/blue_snap.rb +644 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +190 -0
- data/lib/active_merchant/billing/gateways/borgun.rb +272 -0
- data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +28 -0
- data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +952 -0
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +19 -0
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +244 -0
- data/lib/active_merchant/billing/gateways/cams.rb +230 -0
- data/lib/active_merchant/billing/gateways/card_connect.rb +338 -0
- data/lib/active_merchant/billing/gateways/card_save.rb +21 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +394 -0
- 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 +235 -0
- data/lib/active_merchant/billing/gateways/cc5.rb +198 -0
- data/lib/active_merchant/billing/gateways/cecabank.rb +249 -0
- data/lib/active_merchant/billing/gateways/cenpos.rb +328 -0
- data/lib/active_merchant/billing/gateways/checkout.rb +212 -0
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +587 -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/commerce_hub.rb +366 -0
- data/lib/active_merchant/billing/gateways/commercegate.rb +142 -0
- data/lib/active_merchant/billing/gateways/conekta.rb +230 -0
- data/lib/active_merchant/billing/gateways/creditcall.rb +272 -0
- data/lib/active_merchant/billing/gateways/credorax.rb +526 -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/cyber_source_common.rb +36 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +1148 -0
- data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +454 -0
- data/lib/active_merchant/billing/gateways/d_local.rb +343 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +302 -0
- data/lib/active_merchant/billing/gateways/decidir.rb +358 -0
- data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
- data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
- data/lib/active_merchant/billing/gateways/digitzs.rb +295 -0
- data/lib/active_merchant/billing/gateways/ebanx.rb +346 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +215 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +475 -0
- data/lib/active_merchant/billing/gateways/element.rb +406 -0
- data/lib/active_merchant/billing/gateways/epay.rb +296 -0
- data/lib/active_merchant/billing/gateways/evo_ca.rb +307 -0
- data/lib/active_merchant/billing/gateways/eway.rb +226 -0
- data/lib/active_merchant/billing/gateways/eway_managed.rb +289 -0
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +578 -0
- data/lib/active_merchant/billing/gateways/exact.rb +219 -0
- data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +223 -0
- data/lib/active_merchant/billing/gateways/federated_canada.rb +158 -0
- data/lib/active_merchant/billing/gateways/finansbank.rb +22 -0
- data/lib/active_merchant/billing/gateways/first_giving.rb +143 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +182 -0
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +452 -0
- 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/fluidpay.rb +275 -0
- data/lib/active_merchant/billing/gateways/forte.rb +286 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +256 -0
- data/lib/active_merchant/billing/gateways/global_collect.rb +580 -0
- data/lib/active_merchant/billing/gateways/global_transport.rb +193 -0
- data/lib/active_merchant/billing/gateways/hdfc.rb +205 -0
- data/lib/active_merchant/billing/gateways/hps.rb +472 -0
- data/lib/active_merchant/billing/gateways/iats_payments.rb +312 -0
- data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
- data/lib/active_merchant/billing/gateways/inspire.rb +213 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +159 -0
- data/lib/active_merchant/billing/gateways/ipg.rb +420 -0
- data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +467 -0
- data/lib/active_merchant/billing/gateways/itransact.rb +448 -0
- data/lib/active_merchant/billing/gateways/iveri.rb +290 -0
- data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +395 -0
- data/lib/active_merchant/billing/gateways/jetpay_v2.rb +432 -0
- data/lib/active_merchant/billing/gateways/klarna.rb +317 -0
- data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
- data/lib/active_merchant/billing/gateways/kushki.rb +297 -0
- data/lib/active_merchant/billing/gateways/latitude19.rb +412 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +448 -0
- data/lib/active_merchant/billing/gateways/litle.rb +643 -0
- data/lib/active_merchant/billing/gateways/mastercard.rb +286 -0
- data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +348 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +228 -0
- data/lib/active_merchant/billing/gateways/merchant_one.rb +110 -0
- data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +313 -0
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +284 -0
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +248 -0
- data/lib/active_merchant/billing/gateways/mercury.rb +352 -0
- data/lib/active_merchant/billing/gateways/metrics_global.rb +293 -0
- data/lib/active_merchant/billing/gateways/micropayment.rb +182 -0
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
- data/lib/active_merchant/billing/gateways/migs.rb +329 -0
- data/lib/active_merchant/billing/gateways/mit.rb +260 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +215 -0
- data/lib/active_merchant/billing/gateways/moka.rb +290 -0
- data/lib/active_merchant/billing/gateways/monei.rb +424 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +488 -0
- data/lib/active_merchant/billing/gateways/money_movers.rb +150 -0
- data/lib/active_merchant/billing/gateways/mundipagg.rb +366 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +299 -0
- data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +163 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +198 -0
- data/lib/active_merchant/billing/gateways/netaxept.rb +180 -0
- data/lib/active_merchant/billing/gateways/netbanx.rb +376 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +229 -0
- data/lib/active_merchant/billing/gateways/netpay.rb +223 -0
- data/lib/active_merchant/billing/gateways/network_merchants.rb +238 -0
- data/lib/active_merchant/billing/gateways/nmi.rb +396 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +509 -0
- data/lib/active_merchant/billing/gateways/omise.rb +323 -0
- data/lib/active_merchant/billing/gateways/openpay.rb +246 -0
- data/lib/active_merchant/billing/gateways/opp.rb +394 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +331 -0
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +45 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +1267 -0
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +206 -0
- data/lib/active_merchant/billing/gateways/pagarme.rb +239 -0
- data/lib/active_merchant/billing/gateways/pago_facil.rb +120 -0
- 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 +277 -0
- data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +390 -0
- data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +206 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +110 -0
- data/lib/active_merchant/billing/gateways/pay_trace.rb +450 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +224 -0
- data/lib/active_merchant/billing/gateways/payeezy.rb +513 -0
- data/lib/active_merchant/billing/gateways/payex.rb +409 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +235 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +42 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +473 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +220 -0
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +14 -0
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +20 -0
- data/lib/active_merchant/billing/gateways/payment_express.rb +373 -0
- data/lib/active_merchant/billing/gateways/paymentez.rb +365 -0
- data/lib/active_merchant/billing/gateways/paymill.rb +369 -0
- data/lib/active_merchant/billing/gateways/paynetworx.rb +228 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +718 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +69 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +136 -0
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
- data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +44 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +272 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
- data/lib/active_merchant/billing/gateways/paypal_standard.rb +281 -0
- data/lib/active_merchant/billing/gateways/paysafe.rb +420 -0
- data/lib/active_merchant/billing/gateways/payscout.rb +159 -0
- data/lib/active_merchant/billing/gateways/paystation.rb +204 -0
- data/lib/active_merchant/billing/gateways/payu_in.rb +249 -0
- data/lib/active_merchant/billing/gateways/payu_latam.rb +482 -0
- data/lib/active_merchant/billing/gateways/payway.rb +207 -0
- data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
- data/lib/active_merchant/billing/gateways/pin.rb +273 -0
- data/lib/active_merchant/billing/gateways/pixxels.rb +263 -0
- data/lib/active_merchant/billing/gateways/plexo.rb +308 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +283 -0
- data/lib/active_merchant/billing/gateways/priority.rb +392 -0
- data/lib/active_merchant/billing/gateways/pro_pay.rb +325 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +227 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +295 -0
- data/lib/active_merchant/billing/gateways/qbms.rb +302 -0
- data/lib/active_merchant/billing/gateways/quantum.rb +274 -0
- 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 +24 -0
- data/lib/active_merchant/billing/gateways/qvalent.rb +305 -0
- data/lib/active_merchant/billing/gateways/rapyd.rb +319 -0
- data/lib/active_merchant/billing/gateways/reach.rb +277 -0
- data/lib/active_merchant/billing/gateways/realex.rb +400 -0
- data/lib/active_merchant/billing/gateways/redsys.rb +723 -0
- 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 +446 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +434 -0
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +141 -0
- data/lib/active_merchant/billing/gateways/secure_net.rb +260 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +191 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +290 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +103 -0
- data/lib/active_merchant/billing/gateways/securion_pay.rb +305 -0
- data/lib/active_merchant/billing/gateways/shift4.rb +345 -0
- data/lib/active_merchant/billing/gateways/simetrik.rb +368 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +450 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +274 -0
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +354 -0
- data/lib/active_merchant/billing/gateways/stripe.rb +866 -0
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +602 -0
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +151 -0
- data/lib/active_merchant/billing/gateways/telr.rb +273 -0
- data/lib/active_merchant/billing/gateways/tns.rb +23 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +240 -0
- 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 +21 -0
- data/lib/active_merchant/billing/gateways/transnational.rb +9 -0
- data/lib/active_merchant/billing/gateways/trexle.rb +221 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +500 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +24 -0
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1612 -0
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +367 -0
- data/lib/active_merchant/billing/gateways/vanco.rb +303 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +224 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +171 -0
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +250 -0
- data/lib/active_merchant/billing/gateways/vpos.rb +223 -0
- data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
- data/lib/active_merchant/billing/gateways/wepay.rb +235 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +430 -0
- data/lib/active_merchant/billing/gateways/wompi.rb +197 -0
- data/lib/active_merchant/billing/gateways/world_net.rb +345 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +1050 -0
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +208 -0
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
- data/lib/active_merchant/billing/gateways.rb +14 -0
- data/lib/active_merchant/billing/model.rb +30 -0
- data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
- data/lib/active_merchant/billing/payment_token.rb +21 -0
- data/lib/active_merchant/billing/rails.rb +3 -0
- data/lib/active_merchant/billing/response.rb +121 -0
- data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
- data/lib/active_merchant/billing.rb +16 -0
- data/lib/active_merchant/connection.rb +194 -0
- data/lib/active_merchant/country.rb +338 -0
- data/lib/active_merchant/empty.rb +20 -0
- data/lib/active_merchant/errors.rb +38 -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 +3 -0
- data/lib/active_merchant.rb +63 -0
- data/lib/activemerchant.rb +1 -0
- data/lib/certs/cacert.pem +3214 -0
- data/lib/support/gateway_support.rb +69 -0
- data/lib/support/outbound_hosts.rb +28 -0
- data/lib/support/ssl_verify.rb +88 -0
- data/lib/support/ssl_version.rb +86 -0
- metadata +506 -0
@@ -0,0 +1,367 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class UsaEpayTransactionGateway < Gateway
|
4
|
+
self.live_url = 'https://www.usaepay.com/gate'
|
5
|
+
self.test_url = 'https://sandbox.usaepay.com/gate'
|
6
|
+
|
7
|
+
self.supported_cardtypes = %i[visa master american_express]
|
8
|
+
self.supported_countries = ['US']
|
9
|
+
self.homepage_url = 'http://www.usaepay.com/'
|
10
|
+
self.display_name = 'USA ePay'
|
11
|
+
|
12
|
+
TRANSACTIONS = {
|
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'
|
21
|
+
}
|
22
|
+
|
23
|
+
STANDARD_ERROR_CODE_MAPPING = {
|
24
|
+
'00011' => STANDARD_ERROR_CODE[:incorrect_number],
|
25
|
+
'00012' => STANDARD_ERROR_CODE[:incorrect_number],
|
26
|
+
'00013' => STANDARD_ERROR_CODE[:incorrect_number],
|
27
|
+
'00014' => STANDARD_ERROR_CODE[:invalid_number],
|
28
|
+
'00015' => STANDARD_ERROR_CODE[:invalid_expiry_date],
|
29
|
+
'00016' => STANDARD_ERROR_CODE[:invalid_expiry_date],
|
30
|
+
'00017' => STANDARD_ERROR_CODE[:expired_card],
|
31
|
+
'10116' => STANDARD_ERROR_CODE[:incorrect_cvc],
|
32
|
+
'10107' => STANDARD_ERROR_CODE[:incorrect_zip],
|
33
|
+
'10109' => STANDARD_ERROR_CODE[:incorrect_address],
|
34
|
+
'10110' => STANDARD_ERROR_CODE[:incorrect_address],
|
35
|
+
'10111' => STANDARD_ERROR_CODE[:incorrect_address],
|
36
|
+
'10127' => STANDARD_ERROR_CODE[:card_declined],
|
37
|
+
'00043' => STANDARD_ERROR_CODE[:call_issuer],
|
38
|
+
'10205' => STANDARD_ERROR_CODE[:card_declined],
|
39
|
+
'10204' => STANDARD_ERROR_CODE[:pickup_card]
|
40
|
+
}
|
41
|
+
|
42
|
+
def initialize(options = {})
|
43
|
+
requires!(options, :login)
|
44
|
+
super
|
45
|
+
end
|
46
|
+
|
47
|
+
def authorize(money, payment, options = {})
|
48
|
+
post = {}
|
49
|
+
|
50
|
+
add_amount(post, money)
|
51
|
+
add_invoice(post, options)
|
52
|
+
add_payment(post, payment)
|
53
|
+
unless payment.is_a?(CreditCard) && payment.track_data.present?
|
54
|
+
add_address(post, payment, options)
|
55
|
+
add_customer_data(post, options)
|
56
|
+
end
|
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)
|
62
|
+
|
63
|
+
commit(:authorization, post)
|
64
|
+
end
|
65
|
+
|
66
|
+
def purchase(money, payment, options = {})
|
67
|
+
post = {}
|
68
|
+
|
69
|
+
add_amount(post, money)
|
70
|
+
add_invoice(post, options)
|
71
|
+
add_payment(post, payment, options)
|
72
|
+
unless payment.respond_to?(:track_data) && payment.track_data.present?
|
73
|
+
add_address(post, payment, options)
|
74
|
+
add_customer_data(post, options)
|
75
|
+
end
|
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)
|
81
|
+
|
82
|
+
payment.respond_to?(:routing_number) ? commit(:check_purchase, post) : commit(:purchase, post)
|
83
|
+
end
|
84
|
+
|
85
|
+
def capture(money, authorization, options = {})
|
86
|
+
post = { refNum: authorization }
|
87
|
+
|
88
|
+
add_amount(post, money)
|
89
|
+
add_test_mode(post, options)
|
90
|
+
commit(:capture, post)
|
91
|
+
end
|
92
|
+
|
93
|
+
def refund(money, authorization, options = {})
|
94
|
+
post = { refNum: authorization }
|
95
|
+
|
96
|
+
add_amount(post, money)
|
97
|
+
add_test_mode(post, options)
|
98
|
+
commit(:refund, post)
|
99
|
+
end
|
100
|
+
|
101
|
+
def store(payment, options = {})
|
102
|
+
post = {}
|
103
|
+
add_payment(post, payment, options)
|
104
|
+
commit(:store, post)
|
105
|
+
end
|
106
|
+
|
107
|
+
def verify(creditcard, options = {})
|
108
|
+
MultiResponse.run(:use_first_response) do |r|
|
109
|
+
r.process { authorize(1, creditcard, options) }
|
110
|
+
r.process(:ignore_result) { void(r.authorization, options) }
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# Pass `no_release: true` to keep the void from immediately settling
|
115
|
+
def void(authorization, options = {})
|
116
|
+
command = (options[:no_release] ? :void : :void_release)
|
117
|
+
post = { refNum: authorization }
|
118
|
+
add_test_mode(post, options)
|
119
|
+
commit(command, post)
|
120
|
+
end
|
121
|
+
|
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
|
136
|
+
|
137
|
+
def add_amount(post, money)
|
138
|
+
post[:amount] = amount(money)
|
139
|
+
end
|
140
|
+
|
141
|
+
def expdate(credit_card)
|
142
|
+
year = format(credit_card.year, :two_digits)
|
143
|
+
month = format(credit_card.month, :two_digits)
|
144
|
+
|
145
|
+
"#{month}#{year}"
|
146
|
+
end
|
147
|
+
|
148
|
+
def add_customer_data(post, options)
|
149
|
+
address = options[:billing_address] || options[:address] || {}
|
150
|
+
post[:street] = address[:address1]
|
151
|
+
post[:zip] = address[:zip]
|
152
|
+
|
153
|
+
if options.has_key? :email
|
154
|
+
post[:custemail] = options[:email]
|
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
|
161
|
+
end
|
162
|
+
|
163
|
+
post[:custid] = options[:customer] if options.has_key? :customer
|
164
|
+
|
165
|
+
post[:ip] = options[:ip] if options.has_key? :ip
|
166
|
+
end
|
167
|
+
|
168
|
+
def add_address(post, payment, options)
|
169
|
+
billing_address = options[:billing_address] || options[:address]
|
170
|
+
|
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]
|
173
|
+
end
|
174
|
+
|
175
|
+
def add_address_for_type(type, post, payment, address)
|
176
|
+
prefix = address_key_prefix(type)
|
177
|
+
first_name, last_name = split_names(address[:name])
|
178
|
+
|
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
|
181
|
+
post[address_key(prefix, 'company')] = address[:company] unless address[:company].blank?
|
182
|
+
post[address_key(prefix, 'street')] = address[:address1] unless address[:address1].blank?
|
183
|
+
post[address_key(prefix, 'street2')] = address[:address2] unless address[:address2].blank?
|
184
|
+
post[address_key(prefix, 'city')] = address[:city] unless address[:city].blank?
|
185
|
+
post[address_key(prefix, 'state')] = address[:state] unless address[:state].blank?
|
186
|
+
post[address_key(prefix, 'zip')] = address[:zip] unless address[:zip].blank?
|
187
|
+
post[address_key(prefix, 'country')] = address[:country] unless address[:country].blank?
|
188
|
+
post[address_key(prefix, 'phone')] = address[:phone] unless address[:phone].blank?
|
189
|
+
end
|
190
|
+
|
191
|
+
def address_key_prefix(type)
|
192
|
+
case type
|
193
|
+
when :shipping then 'ship'
|
194
|
+
when :billing then 'bill'
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
def address_key(prefix, key)
|
199
|
+
"#{prefix}#{key}".to_sym
|
200
|
+
end
|
201
|
+
|
202
|
+
def add_invoice(post, options)
|
203
|
+
post[:invoice] = options[:invoice]
|
204
|
+
post[:orderid] = options[:order_id]
|
205
|
+
post[:description] = options[:description]
|
206
|
+
end
|
207
|
+
|
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
|
222
|
+
post[:cardpresent] = true
|
223
|
+
elsif payment.is_a?(String)
|
224
|
+
post[:card] = payment
|
225
|
+
else
|
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
|
231
|
+
end
|
232
|
+
end
|
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
|
+
|
238
|
+
# see: http://wiki.usaepay.com/developer/transactionapi#split_payments
|
239
|
+
def add_split_payments(post, options)
|
240
|
+
return unless options[:split_payments].is_a?(Array)
|
241
|
+
|
242
|
+
options[:split_payments].each_with_index do |payment, index|
|
243
|
+
prefix = '%02d' % (index + 2)
|
244
|
+
post["#{prefix}key"] = payment[:key]
|
245
|
+
post["#{prefix}amount"] = amount(payment[:amount])
|
246
|
+
post["#{prefix}description"] = payment[:description]
|
247
|
+
end
|
248
|
+
|
249
|
+
# When blank it's 'Stop'. 'Continue' is another one
|
250
|
+
post['onError'] = options[:on_error] || 'Void'
|
251
|
+
end
|
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
|
+
|
300
|
+
def parse(body)
|
301
|
+
fields = {}
|
302
|
+
for line in body.split('&')
|
303
|
+
key, value = *line.scan(%r{^(\w+)\=(.*)$}).flatten
|
304
|
+
fields[key] = CGI.unescape(value.to_s)
|
305
|
+
end
|
306
|
+
|
307
|
+
{
|
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? }
|
324
|
+
end
|
325
|
+
|
326
|
+
def commit(action, parameters)
|
327
|
+
url = (test? ? self.test_url : self.live_url)
|
328
|
+
response = parse(ssl_post(url, post_data(action, parameters)))
|
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)
|
338
|
+
end
|
339
|
+
|
340
|
+
def message_from(response)
|
341
|
+
if response[:status] == 'Approved'
|
342
|
+
return 'Success'
|
343
|
+
else
|
344
|
+
return 'Unspecified error' if response[:error].blank?
|
345
|
+
|
346
|
+
return response[:error]
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
def authorization_from(action, response)
|
351
|
+
return (action == :store ? response[:card_ref] : response[:ref_num])
|
352
|
+
end
|
353
|
+
|
354
|
+
def post_data(action, parameters = {})
|
355
|
+
parameters[:command] = TRANSACTIONS[action]
|
356
|
+
parameters[:key] = @options[:login]
|
357
|
+
parameters[:software] = 'Active Merchant'
|
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"
|
362
|
+
|
363
|
+
parameters.collect { |key, value| "UM#{key}=#{CGI.escape(value.to_s)}" }.join('&')
|
364
|
+
end
|
365
|
+
end
|
366
|
+
end
|
367
|
+
end
|
@@ -0,0 +1,303 @@
|
|
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
|
+
SECONDS_PER_DAY = 3600 * 24
|
19
|
+
BUFFER_TIME_IN_SECS = 60 * 3
|
20
|
+
|
21
|
+
def initialize(options = {})
|
22
|
+
requires!(options, :user_id, :password, :client_id)
|
23
|
+
super
|
24
|
+
end
|
25
|
+
|
26
|
+
def purchase(money, payment_method, options = {})
|
27
|
+
moment_less_than_24_hours_ago = Time.now - SECONDS_PER_DAY - BUFFER_TIME_IN_SECS
|
28
|
+
|
29
|
+
if options[:session_id] && options[:session_id][:created_at] >= moment_less_than_24_hours_ago
|
30
|
+
commit(purchase_request(money, payment_method, options[:session_id][:id], options), :response_transactionref)
|
31
|
+
else
|
32
|
+
MultiResponse.run do |r|
|
33
|
+
r.process { login }
|
34
|
+
r.process { commit(purchase_request(money, payment_method, r.params['response_sessionid'], options), :response_transactionref) }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def refund(money, authorization, options = {})
|
40
|
+
MultiResponse.run do |r|
|
41
|
+
r.process { login }
|
42
|
+
r.process { commit(refund_request(money, authorization, r.params['response_sessionid']), :response_creditrequestreceived) }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def supports_scrubbing?
|
47
|
+
true
|
48
|
+
end
|
49
|
+
|
50
|
+
def scrub(transcript)
|
51
|
+
transcript.
|
52
|
+
gsub(%r((<Password>).+(</Password>))i, '\1[FILTERED]\2').
|
53
|
+
gsub(%r((<CardCVV2>).+(</CardCVV2>))i, '\1[FILTERED]\2').
|
54
|
+
gsub(%r((<AccountNumber>).+(</AccountNumber>))i, '\1[FILTERED]\2')
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def parse(xml)
|
60
|
+
response = {}
|
61
|
+
|
62
|
+
doc = Nokogiri::XML(xml)
|
63
|
+
doc.root.xpath('*').each do |node|
|
64
|
+
if node.elements.empty?
|
65
|
+
response[node.name.downcase.to_sym] = node.text
|
66
|
+
else
|
67
|
+
node.elements.each do |childnode|
|
68
|
+
childnode_to_response(response, node, childnode)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
response
|
74
|
+
end
|
75
|
+
|
76
|
+
def childnode_to_response(response, node, childnode)
|
77
|
+
name = "#{node.name.downcase}_#{childnode.name.downcase}"
|
78
|
+
if name == 'response_errors' && !childnode.elements.empty?
|
79
|
+
add_errors_to_response(response, childnode.to_s)
|
80
|
+
else
|
81
|
+
response[name.downcase.to_sym] = childnode.text
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def add_errors_to_response(response, errors_xml)
|
86
|
+
errors_hash = Hash.from_xml(errors_xml).values.first
|
87
|
+
response[:response_errors] = errors_hash
|
88
|
+
|
89
|
+
error = errors_hash['Error']
|
90
|
+
if error.kind_of?(Hash)
|
91
|
+
response[:error_message] = error['ErrorDescription']
|
92
|
+
response[:error_codes] = error['ErrorCode']
|
93
|
+
elsif error.kind_of?(Array)
|
94
|
+
error_str = error.map { |e| e['ErrorDescription'] }.join('. ')
|
95
|
+
error_codes = error.map { |e| e['ErrorCode'] }.join(', ')
|
96
|
+
response[:error_message] = "#{error_str}."
|
97
|
+
response[:error_codes] = error_codes
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def commit(request, success_field_name)
|
102
|
+
response = parse(ssl_post(url, request, headers))
|
103
|
+
succeeded = success_from(response, success_field_name)
|
104
|
+
|
105
|
+
Response.new(
|
106
|
+
succeeded,
|
107
|
+
message_from(succeeded, response),
|
108
|
+
response,
|
109
|
+
authorization: authorization_from(response),
|
110
|
+
test: test?
|
111
|
+
)
|
112
|
+
end
|
113
|
+
|
114
|
+
def success_from(response, success_field_name)
|
115
|
+
!empty?(response[success_field_name])
|
116
|
+
end
|
117
|
+
|
118
|
+
def message_from(succeeded, response)
|
119
|
+
return 'Success' if succeeded
|
120
|
+
|
121
|
+
response[:error_message]
|
122
|
+
end
|
123
|
+
|
124
|
+
def authorization_from(response)
|
125
|
+
[
|
126
|
+
response[:response_customerref],
|
127
|
+
response[:response_paymentmethodref],
|
128
|
+
response[:response_transactionref]
|
129
|
+
].join('|')
|
130
|
+
end
|
131
|
+
|
132
|
+
def split_authorization(authorization)
|
133
|
+
authorization.to_s.split('|')
|
134
|
+
end
|
135
|
+
|
136
|
+
def purchase_request(money, payment_method, session_id, options)
|
137
|
+
build_xml_request do |doc|
|
138
|
+
add_auth(doc, 'EFTAddCompleteTransaction', session_id)
|
139
|
+
|
140
|
+
doc.Request do
|
141
|
+
doc.RequestVars do
|
142
|
+
add_client_id(doc)
|
143
|
+
add_amount(doc, money, options)
|
144
|
+
add_payment_method(doc, payment_method, options)
|
145
|
+
add_options(doc, options)
|
146
|
+
add_purchase_noise(doc)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def refund_request(money, authorization, session_id)
|
153
|
+
build_xml_request do |doc|
|
154
|
+
add_auth(doc, 'EFTAddCredit', session_id)
|
155
|
+
|
156
|
+
doc.Request do
|
157
|
+
doc.RequestVars do
|
158
|
+
add_client_id(doc)
|
159
|
+
add_amount(doc, money, options)
|
160
|
+
add_reference(doc, authorization)
|
161
|
+
add_refund_noise(doc)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def add_request(doc, request_type)
|
168
|
+
doc.RequestType(request_type)
|
169
|
+
doc.RequestID(SecureRandom.hex(15))
|
170
|
+
doc.RequestTime(Time.now)
|
171
|
+
doc.Version(2)
|
172
|
+
end
|
173
|
+
|
174
|
+
def add_auth(doc, request_type, session_id)
|
175
|
+
doc.Auth do
|
176
|
+
add_request(doc, request_type)
|
177
|
+
doc.SessionID(session_id)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
def add_reference(doc, authorization)
|
182
|
+
customer_ref, payment_method_ref, transaction_ref = split_authorization(authorization)
|
183
|
+
doc.CustomerRef(customer_ref)
|
184
|
+
doc.PaymentMethodRef(payment_method_ref)
|
185
|
+
doc.TransactionRef(transaction_ref)
|
186
|
+
end
|
187
|
+
|
188
|
+
def add_amount(doc, money, options)
|
189
|
+
if empty?(options[:fund_id])
|
190
|
+
doc.Amount(amount(money))
|
191
|
+
else
|
192
|
+
doc.Funds do
|
193
|
+
doc.Fund do
|
194
|
+
doc.FundID(options[:fund_id])
|
195
|
+
doc.FundAmount(amount(money))
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def add_payment_method(doc, payment_method, options)
|
202
|
+
if card_brand(payment_method) == 'check'
|
203
|
+
add_echeck(doc, payment_method)
|
204
|
+
else
|
205
|
+
add_credit_card(doc, payment_method, options)
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
def add_credit_card(doc, credit_card, options)
|
210
|
+
doc.AccountNumber(credit_card.number)
|
211
|
+
doc.CustomerName("#{credit_card.last_name}, #{credit_card.first_name}")
|
212
|
+
doc.CardExpMonth(format(credit_card.month, :two_digits))
|
213
|
+
doc.CardExpYear(format(credit_card.year, :two_digits))
|
214
|
+
doc.CardCVV2(credit_card.verification_value)
|
215
|
+
doc.CardBillingName(credit_card.name)
|
216
|
+
doc.AccountType('CC')
|
217
|
+
add_billing_address(doc, options)
|
218
|
+
end
|
219
|
+
|
220
|
+
def add_billing_address(doc, options)
|
221
|
+
address = options[:billing_address]
|
222
|
+
return unless address
|
223
|
+
|
224
|
+
doc.CardBillingAddr1(address[:address1])
|
225
|
+
doc.CardBillingAddr2(address[:address2])
|
226
|
+
doc.CardBillingCity(address[:city])
|
227
|
+
doc.CardBillingState(address[:state])
|
228
|
+
doc.CardBillingZip(address[:zip])
|
229
|
+
doc.CardBillingCountryCode(address[:country])
|
230
|
+
end
|
231
|
+
|
232
|
+
def add_echeck(doc, echeck)
|
233
|
+
if echeck.account_type == 'savings'
|
234
|
+
doc.AccountType('S')
|
235
|
+
else
|
236
|
+
doc.AccountType('C')
|
237
|
+
end
|
238
|
+
|
239
|
+
doc.CustomerName("#{echeck.last_name}, #{echeck.first_name}")
|
240
|
+
doc.AccountNumber(echeck.account_number)
|
241
|
+
doc.RoutingNumber(echeck.routing_number)
|
242
|
+
doc.TransactionTypeCode('WEB')
|
243
|
+
end
|
244
|
+
|
245
|
+
def add_purchase_noise(doc)
|
246
|
+
doc.StartDate('0000-00-00')
|
247
|
+
doc.FrequencyCode('O')
|
248
|
+
end
|
249
|
+
|
250
|
+
def add_refund_noise(doc)
|
251
|
+
doc.ContactName('Bilbo Baggins')
|
252
|
+
doc.ContactPhone('1234567890')
|
253
|
+
doc.ContactExtension('None')
|
254
|
+
doc.ReasonForCredit('Refund requested')
|
255
|
+
end
|
256
|
+
|
257
|
+
def add_options(doc, options)
|
258
|
+
doc.CustomerIPAddress(options[:ip]) if options[:ip]
|
259
|
+
end
|
260
|
+
|
261
|
+
def add_client_id(doc)
|
262
|
+
doc.ClientID(@options[:client_id])
|
263
|
+
end
|
264
|
+
|
265
|
+
def login
|
266
|
+
commit(login_request, :response_sessionid)
|
267
|
+
end
|
268
|
+
|
269
|
+
def login_request
|
270
|
+
build_xml_request do |doc|
|
271
|
+
doc.Auth do
|
272
|
+
add_request(doc, 'Login')
|
273
|
+
end
|
274
|
+
|
275
|
+
doc.Request do
|
276
|
+
doc.RequestVars do
|
277
|
+
doc.UserID(@options[:user_id])
|
278
|
+
doc.Password(@options[:password])
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
def build_xml_request
|
285
|
+
builder = Nokogiri::XML::Builder.new
|
286
|
+
builder.__send__('VancoWS') do |doc|
|
287
|
+
yield(doc)
|
288
|
+
end
|
289
|
+
builder.to_xml
|
290
|
+
end
|
291
|
+
|
292
|
+
def url
|
293
|
+
(test? ? test_url : live_url)
|
294
|
+
end
|
295
|
+
|
296
|
+
def headers
|
297
|
+
{
|
298
|
+
'Content-Type' => 'text/xml'
|
299
|
+
}
|
300
|
+
end
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|