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,376 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class NetbanxGateway < Gateway
|
4
|
+
# Netbanx is the new REST based API for Optimal Payments / Paysafe
|
5
|
+
self.test_url = 'https://api.test.netbanx.com/'
|
6
|
+
self.live_url = 'https://api.netbanx.com/'
|
7
|
+
|
8
|
+
self.supported_countries = %w(AF AX AL DZ AS AD AO AI AQ AG AR AM AW AU AT AZ BS BH BD BB BY BE BZ BJ BM BT BO BQ BA BW BV BR IO BN BG BF BI KH CM CA CV KY CF TD CL CN CX CC CO KM CG CD CK CR CI HR CU CW CY CZ DK DJ DM DO EC EG SV GQ ER EE ET FK FO FJ FI FR GF PF TF GA GM GE DE GH GI GR GL GD GP GU GT GG GN GW GY HT HM HN HK HU IS IN ID IR IQ IE IM IL IT JM JP JE JO KZ KE KI KP KR KW KG LA LV LB LS LR LY LI LT LU MO MK MG MW MY MV ML MT MH MQ MR MU YT MX FM MD MC MN ME MS MA MZ MM NA NR NP NC NZ NI NE NG NU NF MP NO OM PK PW PS PA PG PY PE PH PN PL PT PR QA RE RO RU RW BL SH KN LC MF VC WS SM ST SA SN RS SC SL SG SX SK SI SB SO ZA GS SS ES LK PM SD SR SJ SZ SE CH SY TW TJ TZ TH NL TL TG TK TO TT TN TR TM TC TV UG UA AE GB US UM UY UZ VU VA VE VN VG VI WF EH YE ZM ZW)
|
9
|
+
self.default_currency = 'CAD'
|
10
|
+
self.supported_cardtypes = %i[
|
11
|
+
american_express
|
12
|
+
diners_club
|
13
|
+
discover
|
14
|
+
jcb
|
15
|
+
master
|
16
|
+
maestro
|
17
|
+
visa
|
18
|
+
]
|
19
|
+
|
20
|
+
self.money_format = :cents
|
21
|
+
|
22
|
+
self.homepage_url = 'https://processing.paysafe.com/'
|
23
|
+
self.display_name = 'Netbanx by PaySafe'
|
24
|
+
|
25
|
+
AVS_CODE_CONVERTER = {
|
26
|
+
'MATCH' => 'X',
|
27
|
+
'MATCH_ADDRESS_ONLY' => 'A',
|
28
|
+
'MATCH_ZIP_ONLY' => 'Z',
|
29
|
+
'NO_MATCH' => 'N',
|
30
|
+
'NOT_PROCESSED' => 'U',
|
31
|
+
'UNKNOWN' => 'Q'
|
32
|
+
}
|
33
|
+
|
34
|
+
CVV_CODE_CONVERTER = {
|
35
|
+
'MATCH' => 'M',
|
36
|
+
'NO_MATCH' => 'N',
|
37
|
+
'NOT_PROCESSED' => 'P',
|
38
|
+
'UNKNOWN' => 'U'
|
39
|
+
}
|
40
|
+
|
41
|
+
def initialize(options = {})
|
42
|
+
requires!(options, :account_number, :api_key)
|
43
|
+
super
|
44
|
+
end
|
45
|
+
|
46
|
+
def purchase(money, payment, options = {})
|
47
|
+
# Do a Verification with AVS prior to purchase
|
48
|
+
verification_response = verify(payment, options)
|
49
|
+
return verification_response if verification_response.message != 'OK'
|
50
|
+
|
51
|
+
post = {}
|
52
|
+
add_invoice(post, money, options)
|
53
|
+
add_settle_with_auth(post)
|
54
|
+
add_payment(post, payment, options)
|
55
|
+
add_customer_detail_data(post, options)
|
56
|
+
|
57
|
+
commit(:post, 'auths', post)
|
58
|
+
end
|
59
|
+
|
60
|
+
def authorize(money, payment, options = {})
|
61
|
+
# Do a Verification with AVS prior to Auth + Settle
|
62
|
+
verification_response = verify(payment, options)
|
63
|
+
return verification_response if verification_response.message != 'OK'
|
64
|
+
|
65
|
+
post = {}
|
66
|
+
add_invoice(post, money, options)
|
67
|
+
add_payment(post, payment, options)
|
68
|
+
add_customer_detail_data(post, options)
|
69
|
+
|
70
|
+
commit(:post, 'auths', post)
|
71
|
+
end
|
72
|
+
|
73
|
+
def capture(money, authorization, options = {})
|
74
|
+
post = {}
|
75
|
+
add_invoice(post, money, options)
|
76
|
+
|
77
|
+
commit(:post, "auths/#{authorization}/settlements", post)
|
78
|
+
end
|
79
|
+
|
80
|
+
def refund(money, authorization, options = {})
|
81
|
+
# If the transactions that are pending, API call needs to be Cancellation
|
82
|
+
settlement_data = get_settlement(authorization)
|
83
|
+
return settlement_data if settlement_data.message != 'OK'
|
84
|
+
|
85
|
+
post = {}
|
86
|
+
if settlement_data.params['status'] == 'PENDING' && money == settlement_data.params['amount']
|
87
|
+
post[:status] = 'CANCELLED'
|
88
|
+
commit(:put, "settlements/#{authorization}", post)
|
89
|
+
elsif settlement_data.params['status'] == 'PENDING' && (money < settlement_data.params['amount'] || money > settlement_data.params['amount'])
|
90
|
+
return Response.new(false, 'Transaction not settled. Either do a full refund or try partial refund after settlement.')
|
91
|
+
else
|
92
|
+
add_invoice(post, money, options)
|
93
|
+
|
94
|
+
# Setting merchantRefNumber to a unique id for each refund
|
95
|
+
# This is to support multiple partial refunds for the same order
|
96
|
+
post[:merchantRefNum] = SecureRandom.uuid
|
97
|
+
|
98
|
+
commit(:post, "settlements/#{authorization}/refunds", post)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def get_settlement(authorization)
|
103
|
+
post = {}
|
104
|
+
commit(:get, "settlements/#{authorization}", post)
|
105
|
+
end
|
106
|
+
|
107
|
+
def void(authorization, options = {})
|
108
|
+
post = {}
|
109
|
+
add_order_id(post, options)
|
110
|
+
|
111
|
+
commit(:post, "auths/#{authorization}/voidauths", post)
|
112
|
+
end
|
113
|
+
|
114
|
+
def verify(credit_card, options = {})
|
115
|
+
post = {}
|
116
|
+
add_payment(post, credit_card, options)
|
117
|
+
add_order_id(post, options)
|
118
|
+
|
119
|
+
commit(:post, 'verifications', post)
|
120
|
+
end
|
121
|
+
|
122
|
+
# note: when passing options[:customer] we only attempt to add the
|
123
|
+
# card to the profile_id passed as the options[:customer]
|
124
|
+
def store(credit_card, options = {})
|
125
|
+
# locale can only be one of en_US, fr_CA, en_GB
|
126
|
+
requires!(options, :locale)
|
127
|
+
post = {}
|
128
|
+
add_credit_card(post, credit_card, options)
|
129
|
+
add_customer_data(post, options)
|
130
|
+
|
131
|
+
commit(:post, 'customervault/v1/profiles', post)
|
132
|
+
end
|
133
|
+
|
134
|
+
def unstore(identification, options = {})
|
135
|
+
customer_id, card_id = identification.split('|')
|
136
|
+
|
137
|
+
if card_id.nil?
|
138
|
+
# deleting the profile
|
139
|
+
commit(:delete, "customervault/v1/profiles/#{CGI.escape(customer_id)}", nil)
|
140
|
+
else
|
141
|
+
# deleting the card from the profile
|
142
|
+
commit(:delete, "customervault/v1/profiles/#{CGI.escape(customer_id)}/cards/#{CGI.escape(card_id)}", nil)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def supports_scrubbing?
|
147
|
+
true
|
148
|
+
end
|
149
|
+
|
150
|
+
def scrub(transcript)
|
151
|
+
transcript.
|
152
|
+
gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
|
153
|
+
gsub(%r(("card\\?":{\\?"cardNum\\?":\\?")\d+), '\1[FILTERED]').
|
154
|
+
gsub(%r(("cvv\\?":\\?")\d+), '\1[FILTERED]')
|
155
|
+
end
|
156
|
+
|
157
|
+
private
|
158
|
+
|
159
|
+
def add_settle_with_auth(post)
|
160
|
+
post[:settleWithAuth] = true
|
161
|
+
end
|
162
|
+
|
163
|
+
def add_customer_data(post, options)
|
164
|
+
post[:merchantCustomerId] = (options[:merchant_customer_id] || SecureRandom.uuid)
|
165
|
+
post[:locale] = options[:locale]
|
166
|
+
end
|
167
|
+
|
168
|
+
def add_customer_detail_data(post, options)
|
169
|
+
post[:profile] ||= {}
|
170
|
+
post[:profile][:email] = options[:email] if options[:email]
|
171
|
+
post[:customerIp] = options[:ip] if options[:ip]
|
172
|
+
if (billing_address = options[:billing_address])
|
173
|
+
post[:profile][:firstName], post[:profile][:lastName] = split_names(billing_address[:name])
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def add_credit_card(post, credit_card, options = {})
|
178
|
+
post[:card] ||= {}
|
179
|
+
post[:card][:cardNum] = credit_card.number
|
180
|
+
post[:card][:holderName] = credit_card.name
|
181
|
+
post[:card][:cvv] = credit_card.verification_value
|
182
|
+
post[:card][:cardExpiry] = expdate(credit_card)
|
183
|
+
|
184
|
+
post[:authentication] = map_3ds(options[:three_d_secure]) if options[:three_d_secure]
|
185
|
+
post[:card][:billingAddress] = map_address(options[:billing_address]) if options[:billing_address]
|
186
|
+
end
|
187
|
+
|
188
|
+
def add_invoice(post, money, options)
|
189
|
+
post[:amount] = amount(money)
|
190
|
+
add_order_id(post, options)
|
191
|
+
end
|
192
|
+
|
193
|
+
def add_payment(post, credit_card_reference, options = {})
|
194
|
+
post[:card] ||= {}
|
195
|
+
if credit_card_reference.is_a?(String)
|
196
|
+
post[:card][:paymentToken] = credit_card_reference
|
197
|
+
else
|
198
|
+
post[:card][:cardNum] = credit_card_reference.number
|
199
|
+
post[:card][:cvv] = credit_card_reference.verification_value
|
200
|
+
post[:card][:cardExpiry] = expdate(credit_card_reference)
|
201
|
+
end
|
202
|
+
|
203
|
+
post[:currencyCode] = options[:currency] if options[:currency]
|
204
|
+
post[:billingDetails] = map_address(options[:billing_address]) if options[:billing_address]
|
205
|
+
post[:authentication] = map_3ds(options[:three_d_secure]) if options[:three_d_secure]
|
206
|
+
end
|
207
|
+
|
208
|
+
def expdate(credit_card)
|
209
|
+
year = format(credit_card.year, :four_digits)
|
210
|
+
month = format(credit_card.month, :two_digits)
|
211
|
+
|
212
|
+
# returns a hash (necessary in the card JSON object)
|
213
|
+
{ month: month, year: year }
|
214
|
+
end
|
215
|
+
|
216
|
+
def add_order_id(post, options)
|
217
|
+
post[:merchantRefNum] = (options[:order_id] || SecureRandom.uuid)
|
218
|
+
end
|
219
|
+
|
220
|
+
def map_address(address)
|
221
|
+
return {} if address.nil?
|
222
|
+
|
223
|
+
country = Country.find(address[:country]) if address[:country]
|
224
|
+
mapped = {
|
225
|
+
street: address[:address1],
|
226
|
+
city: address[:city],
|
227
|
+
zip: address[:zip],
|
228
|
+
state: address[:state]
|
229
|
+
}
|
230
|
+
mapped[:country] = country.code(:alpha2).value unless country.blank?
|
231
|
+
|
232
|
+
mapped
|
233
|
+
end
|
234
|
+
|
235
|
+
def map_3ds(three_d_secure_options)
|
236
|
+
mapped = {
|
237
|
+
eci: three_d_secure_options[:eci],
|
238
|
+
cavv: three_d_secure_options[:cavv],
|
239
|
+
xid: three_d_secure_options[:xid],
|
240
|
+
threeDResult: three_d_secure_options[:directory_response_status],
|
241
|
+
threeDSecureVersion: three_d_secure_options[:version],
|
242
|
+
directoryServerTransactionId: three_d_secure_options[:ds_transaction_id]
|
243
|
+
}
|
244
|
+
|
245
|
+
mapped
|
246
|
+
end
|
247
|
+
|
248
|
+
def parse(body)
|
249
|
+
body.blank? ? {} : JSON.parse(body)
|
250
|
+
end
|
251
|
+
|
252
|
+
def commit(method, uri, parameters)
|
253
|
+
params = parameters.to_json unless parameters.nil?
|
254
|
+
response =
|
255
|
+
begin
|
256
|
+
if method == :get
|
257
|
+
parse(ssl_request(method, get_url(uri), nil, headers))
|
258
|
+
else
|
259
|
+
parse(ssl_request(method, get_url(uri), params, headers))
|
260
|
+
end
|
261
|
+
rescue ResponseError => e
|
262
|
+
return Response.new(false, 'Invalid Login') if e.response.code == '401'
|
263
|
+
|
264
|
+
parse(e.response.body)
|
265
|
+
end
|
266
|
+
|
267
|
+
success = success_from(response)
|
268
|
+
Response.new(
|
269
|
+
success,
|
270
|
+
message_from(success, response),
|
271
|
+
response,
|
272
|
+
test: test?,
|
273
|
+
error_code: error_code_from(response),
|
274
|
+
authorization: authorization_from(success, get_url(uri), method, response),
|
275
|
+
avs_result: avs_result(response),
|
276
|
+
cvv_result: cvv_result(response)
|
277
|
+
)
|
278
|
+
end
|
279
|
+
|
280
|
+
def avs_result(response)
|
281
|
+
AVSResult.new(code: AVS_CODE_CONVERTER[response['avsResponse']])
|
282
|
+
end
|
283
|
+
|
284
|
+
def cvv_result(response)
|
285
|
+
CVVResult.new(CVV_CODE_CONVERTER[response['cvvVerification']])
|
286
|
+
end
|
287
|
+
|
288
|
+
def get_url(uri)
|
289
|
+
url = (test? ? test_url : live_url)
|
290
|
+
if /^customervault/.match?(uri)
|
291
|
+
"#{url}#{uri}"
|
292
|
+
else
|
293
|
+
"#{url}cardpayments/v1/accounts/#{@options[:account_number]}/#{uri}"
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
def success_from(response)
|
298
|
+
response.blank? || !response.key?('error')
|
299
|
+
end
|
300
|
+
|
301
|
+
def message_from(success, response)
|
302
|
+
success ? 'OK' : (response['error']['message'] || 'Unknown error - please contact Netbanx-Paysafe')
|
303
|
+
end
|
304
|
+
|
305
|
+
def authorization_from(success, url, method, response)
|
306
|
+
if success && response.present? && url.match(/cardpayments\/v1\/accounts\/.*\//)
|
307
|
+
response['id']
|
308
|
+
elsif method == :post && url.match(/customervault\/.*\//)
|
309
|
+
# auth for tokenised customer vault is returned as
|
310
|
+
# customer_profile_id|card_id|payment_method_token
|
311
|
+
#
|
312
|
+
# customer_profile_id is the uuid that identifies the customer
|
313
|
+
# card_id is the uuid that identifies the card
|
314
|
+
# payment_method_token is the token that needs to be used when
|
315
|
+
# calling purchase with a token
|
316
|
+
#
|
317
|
+
# both id's are used to unstore, the payment token is only used for
|
318
|
+
# purchase transactions
|
319
|
+
[response['id'], response['cards'].first['id'], response['cards'].first['paymentToken']].join('|')
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
# Builds the auth and U-A headers for the request
|
324
|
+
def headers
|
325
|
+
{
|
326
|
+
'Accept' => 'application/json',
|
327
|
+
'Content-type' => 'application/json',
|
328
|
+
'Authorization' => "Basic #{Base64.strict_encode64(@options[:api_key].to_s)}",
|
329
|
+
'User-Agent' => "Netbanx-Paysafe v1.0/ActiveMerchant #{ActiveMerchant::VERSION}"
|
330
|
+
}
|
331
|
+
end
|
332
|
+
|
333
|
+
def error_code_from(response)
|
334
|
+
unless success_from(response)
|
335
|
+
case response['errorCode']
|
336
|
+
when '3002' then STANDARD_ERROR_CODE[:invalid_number] # You submitted an invalid card number or brand or combination of card number and brand with your request.
|
337
|
+
when '3004' then STANDARD_ERROR_CODE[:incorrect_zip] # The zip/postal code must be provided for an AVS check request.
|
338
|
+
when '3005' then STANDARD_ERROR_CODE[:incorrect_cvc] # You submitted an incorrect CVC value with your request.
|
339
|
+
when '3006' then STANDARD_ERROR_CODE[:expired_card] # You submitted an expired credit card number with your request.
|
340
|
+
when '3009' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank.
|
341
|
+
when '3011' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank because the card used is a restricted card. Contact the cardholder's credit card company for further investigation.
|
342
|
+
when '3012' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank because the credit card expiry date submitted is invalid.
|
343
|
+
when '3013' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank due to problems with the credit card account.
|
344
|
+
when '3014' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined - the issuing bank has returned an unknown response. Contact the card holder's credit card company for further investigation.
|
345
|
+
when '3015' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you process the transaction manually by calling the cardholder's credit card company.
|
346
|
+
when '3016' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – it may be a lost or stolen card.
|
347
|
+
when '3017' then STANDARD_ERROR_CODE[:invalid_number] # You submitted an invalid credit card number with your request.
|
348
|
+
when '3022' then STANDARD_ERROR_CODE[:card_declined] # The card has been declined due to insufficient funds.
|
349
|
+
when '3023' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank due to its proprietary card activity regulations.
|
350
|
+
when '3024' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined because the issuing bank does not permit the transaction for this card.
|
351
|
+
when '3032' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank or external gateway because the card is probably in one of their negative databases.
|
352
|
+
when '3035' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to exceeded PIN attempts.
|
353
|
+
when '3036' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to an invalid issuer.
|
354
|
+
when '3037' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined because it is invalid.
|
355
|
+
when '3038' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to customer cancellation.
|
356
|
+
when '3039' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to an invalid authentication value.
|
357
|
+
when '3040' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined because the request type is not permitted on the card.
|
358
|
+
when '3041' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to a timeout.
|
359
|
+
when '3042' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to a cryptographic error.
|
360
|
+
when '3045' then STANDARD_ERROR_CODE[:invalid_expiry_date] # You submitted an invalid date format for this request.
|
361
|
+
when '3046' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined because the amount was set to zero.
|
362
|
+
when '3047' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined because the amount exceeds the floor limit.
|
363
|
+
when '3048' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined because the amount is less than the floor limit.
|
364
|
+
when '3049' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – the credit card has expired.
|
365
|
+
when '3050' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – fraudulent activity is suspected.
|
366
|
+
when '3051' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – contact the acquirer for more information.
|
367
|
+
when '3052' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – the credit card is restricted.
|
368
|
+
when '3053' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – please call the acquirer.
|
369
|
+
when '3054' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined due to suspected fraud.
|
370
|
+
else STANDARD_ERROR_CODE[:processing_error]
|
371
|
+
end
|
372
|
+
end
|
373
|
+
end
|
374
|
+
end
|
375
|
+
end
|
376
|
+
end
|
@@ -0,0 +1,229 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
# To perform PCI Compliant Repeat Billing
|
4
|
+
#
|
5
|
+
# Ensure that PCI Compliant Repeat Billing is enabled on your merchant account:
|
6
|
+
# "Enable PCI Compliant Repeat Billing, Up-selling and Cross-selling" in Step 6 of the Credit Cards setup page
|
7
|
+
#
|
8
|
+
# Instead of passing a credit_card to authorize or purchase, pass the transaction id (res.authorization)
|
9
|
+
# of a past Netbilling transaction
|
10
|
+
#
|
11
|
+
# To store billing information without performing an operation, use the 'store' method
|
12
|
+
# which invokes the tran_type 'Q' (Quasi) operation and returns a transaction id to use in future Repeat Billing operations
|
13
|
+
class NetbillingGateway < Gateway
|
14
|
+
self.live_url = self.test_url = 'https://secure.netbilling.com:1402/gw/sas/direct3.1'
|
15
|
+
|
16
|
+
TRANSACTIONS = {
|
17
|
+
authorization: 'A',
|
18
|
+
purchase: 'S',
|
19
|
+
refund: 'R',
|
20
|
+
credit: 'C',
|
21
|
+
capture: 'D',
|
22
|
+
void: 'U',
|
23
|
+
quasi: 'Q'
|
24
|
+
}
|
25
|
+
|
26
|
+
SUCCESS_CODES = %w[1 T]
|
27
|
+
SUCCESS_MESSAGE = 'The transaction was approved'
|
28
|
+
FAILURE_MESSAGE = 'The transaction failed'
|
29
|
+
TEST_LOGIN = '104901072025'
|
30
|
+
|
31
|
+
self.display_name = 'NETbilling'
|
32
|
+
self.homepage_url = 'http://www.netbilling.com'
|
33
|
+
self.supported_countries = ['US']
|
34
|
+
self.supported_cardtypes = %i[visa master american_express discover jcb diners_club]
|
35
|
+
|
36
|
+
def initialize(options = {})
|
37
|
+
requires!(options, :login)
|
38
|
+
super
|
39
|
+
end
|
40
|
+
|
41
|
+
def authorize(money, payment_source, options = {})
|
42
|
+
post = {}
|
43
|
+
add_amount(post, money)
|
44
|
+
add_invoice(post, options)
|
45
|
+
add_payment_source(post, payment_source)
|
46
|
+
add_address(post, payment_source, options)
|
47
|
+
add_customer_data(post, options)
|
48
|
+
add_user_data(post, options)
|
49
|
+
|
50
|
+
commit(:authorization, post)
|
51
|
+
end
|
52
|
+
|
53
|
+
def purchase(money, payment_source, options = {})
|
54
|
+
post = {}
|
55
|
+
add_amount(post, money)
|
56
|
+
add_invoice(post, options)
|
57
|
+
add_payment_source(post, payment_source)
|
58
|
+
add_address(post, payment_source, options)
|
59
|
+
add_customer_data(post, options)
|
60
|
+
add_user_data(post, options)
|
61
|
+
|
62
|
+
commit(:purchase, post)
|
63
|
+
end
|
64
|
+
|
65
|
+
def capture(money, authorization, options = {})
|
66
|
+
post = {}
|
67
|
+
add_reference(post, authorization)
|
68
|
+
commit(:capture, post)
|
69
|
+
end
|
70
|
+
|
71
|
+
def refund(money, source, options = {})
|
72
|
+
post = {}
|
73
|
+
add_amount(post, money)
|
74
|
+
add_reference(post, source)
|
75
|
+
commit(:refund, post)
|
76
|
+
end
|
77
|
+
|
78
|
+
def credit(money, credit_card, options = {})
|
79
|
+
post = {}
|
80
|
+
add_amount(post, money)
|
81
|
+
add_invoice(post, options)
|
82
|
+
add_credit_card(post, credit_card)
|
83
|
+
add_address(post, credit_card, options)
|
84
|
+
add_customer_data(post, options)
|
85
|
+
add_user_data(post, options)
|
86
|
+
|
87
|
+
commit(:credit, post)
|
88
|
+
end
|
89
|
+
|
90
|
+
def void(source, options = {})
|
91
|
+
post = {}
|
92
|
+
add_reference(post, source)
|
93
|
+
commit(:void, post)
|
94
|
+
end
|
95
|
+
|
96
|
+
def store(credit_card, options = {})
|
97
|
+
post = {}
|
98
|
+
add_amount(post, 0)
|
99
|
+
add_payment_source(post, credit_card)
|
100
|
+
add_address(post, credit_card, options)
|
101
|
+
add_customer_data(post, options)
|
102
|
+
|
103
|
+
commit(:quasi, post)
|
104
|
+
end
|
105
|
+
|
106
|
+
def test?
|
107
|
+
(@options[:login] == TEST_LOGIN || super)
|
108
|
+
end
|
109
|
+
|
110
|
+
def supports_scrubbing
|
111
|
+
true
|
112
|
+
end
|
113
|
+
|
114
|
+
def scrub(transcript)
|
115
|
+
transcript.
|
116
|
+
gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
|
117
|
+
gsub(%r((&?card_number=)[^&]*), '\1[FILTERED]').
|
118
|
+
gsub(%r((&?card_cvv2=)[^&]*), '\1[FILTERED]')
|
119
|
+
end
|
120
|
+
|
121
|
+
private
|
122
|
+
|
123
|
+
def add_amount(post, money)
|
124
|
+
post[:amount] = amount(money)
|
125
|
+
end
|
126
|
+
|
127
|
+
def add_reference(post, reference)
|
128
|
+
post[:orig_id] = reference
|
129
|
+
end
|
130
|
+
|
131
|
+
def add_customer_data(post, options)
|
132
|
+
post[:cust_email] = options[:email]
|
133
|
+
post[:cust_ip] = options[:ip]
|
134
|
+
end
|
135
|
+
|
136
|
+
def add_address(post, credit_card, options)
|
137
|
+
if billing_address = options[:billing_address] || options[:address]
|
138
|
+
post[:bill_street] = billing_address[:address1]
|
139
|
+
post[:cust_phone] = billing_address[:phone]
|
140
|
+
post[:bill_zip] = billing_address[:zip]
|
141
|
+
post[:bill_city] = billing_address[:city]
|
142
|
+
post[:bill_country] = billing_address[:country]
|
143
|
+
post[:bill_state] = billing_address[:state]
|
144
|
+
end
|
145
|
+
|
146
|
+
if shipping_address = options[:shipping_address]
|
147
|
+
post[:ship_name1], post[:ship_name2] = split_names(shipping_address[:name])
|
148
|
+
post[:ship_street] = shipping_address[:address1]
|
149
|
+
post[:ship_zip] = shipping_address[:zip]
|
150
|
+
post[:ship_city] = shipping_address[:city]
|
151
|
+
post[:ship_country] = shipping_address[:country]
|
152
|
+
post[:ship_state] = shipping_address[:state]
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def add_invoice(post, options)
|
157
|
+
post[:description] = options[:description]
|
158
|
+
end
|
159
|
+
|
160
|
+
def add_payment_source(params, source)
|
161
|
+
if source.is_a?(String)
|
162
|
+
add_transaction_id(params, source)
|
163
|
+
else
|
164
|
+
add_credit_card(params, source)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def add_user_data(post, options)
|
169
|
+
post[:user_data] = "order_id:#{options[:order_id]}" if options[:order_id]
|
170
|
+
end
|
171
|
+
|
172
|
+
def add_transaction_id(post, transaction_id)
|
173
|
+
post[:card_number] = 'CS:' + transaction_id
|
174
|
+
end
|
175
|
+
|
176
|
+
def add_credit_card(post, credit_card)
|
177
|
+
post[:bill_name1] = credit_card.first_name
|
178
|
+
post[:bill_name2] = credit_card.last_name
|
179
|
+
post[:card_number] = credit_card.number
|
180
|
+
post[:card_expire] = expdate(credit_card)
|
181
|
+
post[:card_cvv2] = credit_card.verification_value
|
182
|
+
end
|
183
|
+
|
184
|
+
def parse(body)
|
185
|
+
results = {}
|
186
|
+
body.split(/&/).each do |pair|
|
187
|
+
key, val = pair.split(/\=/)
|
188
|
+
results[key.to_sym] = CGI.unescape(val)
|
189
|
+
end
|
190
|
+
results
|
191
|
+
end
|
192
|
+
|
193
|
+
def commit(action, parameters)
|
194
|
+
response = parse(ssl_post(self.live_url, post_data(action, parameters)))
|
195
|
+
|
196
|
+
Response.new(success?(response), message_from(response), response,
|
197
|
+
test: test_response?(response),
|
198
|
+
authorization: response[:trans_id],
|
199
|
+
avs_result: { code: response[:avs_code] },
|
200
|
+
cvv_result: response[:cvv2_code])
|
201
|
+
rescue ActiveMerchant::ResponseError => e
|
202
|
+
raise unless e.response.code =~ /^[67]\d\d$/
|
203
|
+
|
204
|
+
return Response.new(false, e.response.message, { status_code: e.response.code }, test: test?)
|
205
|
+
end
|
206
|
+
|
207
|
+
def test_response?(response)
|
208
|
+
!!(test? || response[:auth_msg] =~ /TEST/)
|
209
|
+
end
|
210
|
+
|
211
|
+
def success?(response)
|
212
|
+
SUCCESS_CODES.include?(response[:status_code])
|
213
|
+
end
|
214
|
+
|
215
|
+
def message_from(response)
|
216
|
+
success?(response) ? SUCCESS_MESSAGE : (response[:auth_msg] || FAILURE_MESSAGE)
|
217
|
+
end
|
218
|
+
|
219
|
+
def post_data(action, parameters = {})
|
220
|
+
parameters[:account_id] = @options[:login]
|
221
|
+
parameters[:site_tag] = @options[:site_tag] if @options[:site_tag].present?
|
222
|
+
parameters[:pay_type] = 'C'
|
223
|
+
parameters[:tran_type] = TRANSACTIONS[action]
|
224
|
+
|
225
|
+
parameters.reject { |_k, v| v.blank? }.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|