active_accountability_merchant 1.97.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +2948 -0
- data/CONTRIBUTORS +568 -0
- data/MIT-LICENSE +20 -0
- data/README.md +246 -0
- data/lib/active_merchant.rb +63 -0
- data/lib/active_merchant/billing.rb +15 -0
- data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
- data/lib/active_merchant/billing/avs_result.rb +96 -0
- data/lib/active_merchant/billing/base.rb +61 -0
- data/lib/active_merchant/billing/check.rb +80 -0
- data/lib/active_merchant/billing/compatibility.rb +117 -0
- data/lib/active_merchant/billing/credit_card.rb +406 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +23 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +343 -0
- data/lib/active_merchant/billing/cvv_result.rb +38 -0
- data/lib/active_merchant/billing/gateway.rb +330 -0
- data/lib/active_merchant/billing/gateways.rb +14 -0
- data/lib/active_merchant/billing/gateways/adyen.rb +503 -0
- data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +1055 -0
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +417 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +980 -0
- data/lib/active_merchant/billing/gateways/axcessms.rb +181 -0
- data/lib/active_merchant/billing/gateways/balanced.rb +256 -0
- data/lib/active_merchant/billing/gateways/bambora_apac.rb +226 -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 +384 -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.rb +217 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +473 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +57 -0
- data/lib/active_merchant/billing/gateways/blue_pay.rb +522 -0
- data/lib/active_merchant/billing/gateways/blue_snap.rb +522 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +186 -0
- data/lib/active_merchant/billing/gateways/borgun.rb +220 -0
- data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +22 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +740 -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 +316 -0
- data/lib/active_merchant/billing/gateways/card_save.rb +22 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +367 -0
- data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
- data/lib/active_merchant/billing/gateways/cardprocess.rb +254 -0
- data/lib/active_merchant/billing/gateways/cashnet.rb +219 -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 +327 -0
- data/lib/active_merchant/billing/gateways/checkout.rb +214 -0
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +270 -0
- data/lib/active_merchant/billing/gateways/citrus_pay.rb +22 -0
- data/lib/active_merchant/billing/gateways/clearhaus.rb +220 -0
- data/lib/active_merchant/billing/gateways/commercegate.rb +142 -0
- data/lib/active_merchant/billing/gateways/conekta.rb +228 -0
- data/lib/active_merchant/billing/gateways/creditcall.rb +271 -0
- data/lib/active_merchant/billing/gateways/credorax.rb +382 -0
- data/lib/active_merchant/billing/gateways/ct_payment.rb +268 -0
- data/lib/active_merchant/billing/gateways/culqi.rb +277 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +828 -0
- data/lib/active_merchant/billing/gateways/d_local.rb +226 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +305 -0
- data/lib/active_merchant/billing/gateways/decidir.rb +233 -0
- data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
- data/lib/active_merchant/billing/gateways/digitzs.rb +292 -0
- data/lib/active_merchant/billing/gateways/ebanx.rb +296 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +215 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +320 -0
- data/lib/active_merchant/billing/gateways/element.rb +356 -0
- data/lib/active_merchant/billing/gateways/epay.rb +285 -0
- data/lib/active_merchant/billing/gateways/evo_ca.rb +308 -0
- data/lib/active_merchant/billing/gateways/eway.rb +226 -0
- data/lib/active_merchant/billing/gateways/eway_managed.rb +290 -0
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +563 -0
- data/lib/active_merchant/billing/gateways/exact.rb +224 -0
- data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +218 -0
- data/lib/active_merchant/billing/gateways/federated_canada.rb +159 -0
- data/lib/active_merchant/billing/gateways/finansbank.rb +22 -0
- data/lib/active_merchant/billing/gateways/first_giving.rb +142 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +182 -0
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +451 -0
- data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +485 -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 +270 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +259 -0
- data/lib/active_merchant/billing/gateways/global_collect.rb +336 -0
- data/lib/active_merchant/billing/gateways/global_transport.rb +194 -0
- data/lib/active_merchant/billing/gateways/hdfc.rb +206 -0
- data/lib/active_merchant/billing/gateways/hps.rb +350 -0
- data/lib/active_merchant/billing/gateways/iats_payments.rb +290 -0
- data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
- data/lib/active_merchant/billing/gateways/inspire.rb +218 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +162 -0
- data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +468 -0
- data/lib/active_merchant/billing/gateways/itransact.rb +447 -0
- data/lib/active_merchant/billing/gateways/iveri.rb +251 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +402 -0
- data/lib/active_merchant/billing/gateways/jetpay_v2.rb +437 -0
- data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
- data/lib/active_merchant/billing/gateways/kushki.rb +219 -0
- data/lib/active_merchant/billing/gateways/latitude19.rb +411 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +449 -0
- data/lib/active_merchant/billing/gateways/litle.rb +507 -0
- data/lib/active_merchant/billing/gateways/mastercard.rb +267 -0
- data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +277 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +194 -0
- data/lib/active_merchant/billing/gateways/merchant_one.rb +113 -0
- data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +319 -0
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +286 -0
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +210 -0
- data/lib/active_merchant/billing/gateways/mercury.rb +356 -0
- data/lib/active_merchant/billing/gateways/metrics_global.rb +303 -0
- data/lib/active_merchant/billing/gateways/micropayment.rb +183 -0
- data/lib/active_merchant/billing/gateways/migs.rb +332 -0
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +217 -0
- data/lib/active_merchant/billing/gateways/monei.rb +338 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +377 -0
- data/lib/active_merchant/billing/gateways/moneris_us.rb +352 -0
- data/lib/active_merchant/billing/gateways/money_movers.rb +151 -0
- data/lib/active_merchant/billing/gateways/mundipagg.rb +293 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +301 -0
- data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +165 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +199 -0
- data/lib/active_merchant/billing/gateways/netaxept.rb +180 -0
- data/lib/active_merchant/billing/gateways/netbanx.rb +294 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +232 -0
- data/lib/active_merchant/billing/gateways/netpay.rb +222 -0
- data/lib/active_merchant/billing/gateways/network_merchants.rb +241 -0
- data/lib/active_merchant/billing/gateways/nmi.rb +324 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +478 -0
- data/lib/active_merchant/billing/gateways/omise.rb +324 -0
- data/lib/active_merchant/billing/gateways/openpay.rb +228 -0
- data/lib/active_merchant/billing/gateways/opp.rb +388 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +332 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +1006 -0
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +47 -0
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +206 -0
- data/lib/active_merchant/billing/gateways/pagarme.rb +246 -0
- data/lib/active_merchant/billing/gateways/pago_facil.rb +122 -0
- data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +280 -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 +188 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +111 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +200 -0
- data/lib/active_merchant/billing/gateways/payeezy.rb +410 -0
- data/lib/active_merchant/billing/gateways/payex.rb +410 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +383 -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 +43 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -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 +369 -0
- data/lib/active_merchant/billing/gateways/paymentez.rb +300 -0
- data/lib/active_merchant/billing/gateways/paymill.rb +371 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +128 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +717 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +65 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -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 +269 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
- data/lib/active_merchant/billing/gateways/payscout.rb +160 -0
- data/lib/active_merchant/billing/gateways/paystation.rb +207 -0
- data/lib/active_merchant/billing/gateways/payu_in.rb +248 -0
- data/lib/active_merchant/billing/gateways/payu_latam.rb +449 -0
- data/lib/active_merchant/billing/gateways/payway.rb +207 -0
- data/lib/active_merchant/billing/gateways/pin.rb +234 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +284 -0
- data/lib/active_merchant/billing/gateways/pro_pay.rb +326 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +227 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +296 -0
- data/lib/active_merchant/billing/gateways/qbms.rb +303 -0
- data/lib/active_merchant/billing/gateways/quantum.rb +276 -0
- data/lib/active_merchant/billing/gateways/quickbooks.rb +290 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +25 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +301 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
- data/lib/active_merchant/billing/gateways/qvalent.rb +289 -0
- data/lib/active_merchant/billing/gateways/realex.rb +374 -0
- data/lib/active_merchant/billing/gateways/redsys.rb +534 -0
- data/lib/active_merchant/billing/gateways/s5.rb +246 -0
- data/lib/active_merchant/billing/gateways/safe_charge.rb +262 -0
- data/lib/active_merchant/billing/gateways/sage.rb +448 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +434 -0
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +142 -0
- data/lib/active_merchant/billing/gateways/secure_net.rb +267 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +200 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +292 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +104 -0
- data/lib/active_merchant/billing/gateways/securion_pay.rb +264 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +450 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +280 -0
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +306 -0
- data/lib/active_merchant/billing/gateways/stripe.rb +790 -0
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +267 -0
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +152 -0
- data/lib/active_merchant/billing/gateways/telr.rb +274 -0
- data/lib/active_merchant/billing/gateways/tns.rb +22 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +239 -0
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +608 -0
- data/lib/active_merchant/billing/gateways/transact_pro.rb +224 -0
- data/lib/active_merchant/billing/gateways/transax.rb +22 -0
- data/lib/active_merchant/billing/gateways/transnational.rb +9 -0
- data/lib/active_merchant/billing/gateways/trexle.rb +218 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +490 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +25 -0
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1620 -0
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +355 -0
- data/lib/active_merchant/billing/gateways/vanco.rb +294 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +225 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +176 -0
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +245 -0
- data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
- data/lib/active_merchant/billing/gateways/wepay.rb +237 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +432 -0
- data/lib/active_merchant/billing/gateways/world_net.rb +344 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +634 -0
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +215 -0
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -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 +92 -0
- data/lib/active_merchant/connection.rb +195 -0
- data/lib/active_merchant/country.rb +336 -0
- data/lib/active_merchant/empty.rb +20 -0
- data/lib/active_merchant/errors.rb +35 -0
- data/lib/active_merchant/net_http_ssl_connection.rb +10 -0
- data/lib/active_merchant/network_connection_retries.rb +80 -0
- data/lib/active_merchant/post_data.rb +25 -0
- data/lib/active_merchant/posts_data.rb +92 -0
- data/lib/active_merchant/version.rb +3 -0
- data/lib/activemerchant.rb +1 -0
- data/lib/certs/cacert.pem +3988 -0
- data/lib/support/gateway_support.rb +69 -0
- data/lib/support/outbound_hosts.rb +28 -0
- data/lib/support/ssl_verify.rb +92 -0
- data/lib/support/ssl_version.rb +87 -0
- metadata +435 -0
@@ -0,0 +1,522 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module ActiveMerchant
|
4
|
+
module Billing
|
5
|
+
class BlueSnapGateway < Gateway
|
6
|
+
self.test_url = 'https://sandbox.bluesnap.com/services/2'
|
7
|
+
self.live_url = 'https://ws.bluesnap.com/services/2'
|
8
|
+
self.supported_countries = %w(US CA GB AT BE BG HR CY CZ DK EE FI FR DE GR HU IE IT LV LT LU MT NL PL PT RO SK SI ES SE AR BO BR BZ CL CO CR DO EC GF GP GT HN HT MF MQ MX NI PA PE PR PY SV UY VE)
|
9
|
+
|
10
|
+
self.default_currency = 'USD'
|
11
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club, :maestro, :naranja, :cabal]
|
12
|
+
|
13
|
+
self.homepage_url = 'https://home.bluesnap.com/'
|
14
|
+
self.display_name = 'BlueSnap'
|
15
|
+
|
16
|
+
TRANSACTIONS = {
|
17
|
+
purchase: 'AUTH_CAPTURE',
|
18
|
+
authorize: 'AUTH_ONLY',
|
19
|
+
capture: 'CAPTURE',
|
20
|
+
void: 'AUTH_REVERSAL',
|
21
|
+
refund: 'REFUND'
|
22
|
+
}
|
23
|
+
|
24
|
+
CVC_CODE_TRANSLATOR = {
|
25
|
+
'MA' => 'M',
|
26
|
+
'NC' => 'U',
|
27
|
+
'ND' => 'P',
|
28
|
+
'NM' => 'N',
|
29
|
+
'NP' => 'S'
|
30
|
+
}
|
31
|
+
|
32
|
+
AVS_CODE_TRANSLATOR = {
|
33
|
+
'line1: U, zip: U, name: U' => 'I',
|
34
|
+
'line1: U, zip: U, name: M' => 'I',
|
35
|
+
'line1: U, zip: U, name: N' => 'I',
|
36
|
+
'line1: U, zip: M, name: U' => 'P',
|
37
|
+
'line1: U, zip: M, name: M' => 'P',
|
38
|
+
'line1: U, zip: M, name: N' => 'F',
|
39
|
+
'line1: U, zip: N, name: U' => 'O',
|
40
|
+
'line1: U, zip: N, name: M' => 'O',
|
41
|
+
'line1: U, zip: N, name: N' => 'O',
|
42
|
+
'line1: M, zip: U, name: U' => 'B',
|
43
|
+
'line1: M, zip: U, name: M' => 'B',
|
44
|
+
'line1: M, zip: U, name: N' => 'T',
|
45
|
+
'line1: M, zip: M, name: U' => 'M',
|
46
|
+
'line1: M, zip: M, name: M' => 'V',
|
47
|
+
'line1: M, zip: M, name: N' => 'H',
|
48
|
+
'line1: M, zip: N, name: U' => 'A',
|
49
|
+
'line1: M, zip: N, name: M' => 'O',
|
50
|
+
'line1: M, zip: N, name: N' => 'A',
|
51
|
+
'line1: N, zip: U, name: U' => 'C',
|
52
|
+
'line1: N, zip: U, name: M' => 'C',
|
53
|
+
'line1: N, zip: U, name: N' => 'C',
|
54
|
+
'line1: N, zip: M, name: U' => 'W',
|
55
|
+
'line1: N, zip: M, name: M' => 'L',
|
56
|
+
'line1: N, zip: M, name: N' => 'W',
|
57
|
+
'line1: N, zip: N, name: U' => 'N',
|
58
|
+
'line1: N, zip: N, name: M' => 'K',
|
59
|
+
'line1: N, zip: N, name: N' => 'N',
|
60
|
+
}
|
61
|
+
|
62
|
+
BANK_ACCOUNT_TYPE_MAPPING = {
|
63
|
+
'personal_checking' => 'CONSUMER_CHECKING',
|
64
|
+
'personal_savings' => 'CONSUMER_SAVINGS',
|
65
|
+
'business_checking' => 'CORPORATE_CHECKING',
|
66
|
+
'business_savings' => 'CORPORATE_SAVINGS'
|
67
|
+
}
|
68
|
+
|
69
|
+
STATE_CODE_COUNTRIES = %w(US CA)
|
70
|
+
|
71
|
+
def initialize(options={})
|
72
|
+
requires!(options, :api_username, :api_password)
|
73
|
+
super
|
74
|
+
end
|
75
|
+
|
76
|
+
def purchase(money, payment_method, options={})
|
77
|
+
payment_method_details = PaymentMethodDetails.new(payment_method)
|
78
|
+
|
79
|
+
commit(:purchase, :post, payment_method_details) do |doc|
|
80
|
+
if payment_method_details.alt_transaction?
|
81
|
+
add_alt_transaction_purchase(doc, money, payment_method_details, options)
|
82
|
+
else
|
83
|
+
add_auth_purchase(doc, money, payment_method, options)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def authorize(money, payment_method, options={})
|
89
|
+
commit(:authorize) do |doc|
|
90
|
+
add_auth_purchase(doc, money, payment_method, options)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def capture(money, authorization, options={})
|
95
|
+
commit(:capture, :put) do |doc|
|
96
|
+
add_authorization(doc, authorization)
|
97
|
+
add_order(doc, options)
|
98
|
+
add_amount(doc, money, options) if options[:include_capture_amount] == true
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def refund(money, authorization, options={})
|
103
|
+
commit(:refund, :put) do |doc|
|
104
|
+
add_authorization(doc, authorization)
|
105
|
+
add_amount(doc, money, options)
|
106
|
+
add_order(doc, options)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def void(authorization, options={})
|
111
|
+
commit(:void, :put) do |doc|
|
112
|
+
add_authorization(doc, authorization)
|
113
|
+
add_order(doc, options)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def verify(payment_method, options={})
|
118
|
+
authorize(0, payment_method, options)
|
119
|
+
end
|
120
|
+
|
121
|
+
def store(payment_method, options = {})
|
122
|
+
payment_method_details = PaymentMethodDetails.new(payment_method)
|
123
|
+
|
124
|
+
commit(:store, :post, payment_method_details) do |doc|
|
125
|
+
add_personal_info(doc, payment_method, options)
|
126
|
+
add_echeck_company(doc, payment_method) if payment_method_details.check?
|
127
|
+
doc.send('payment-sources') do
|
128
|
+
payment_method_details.check? ? store_echeck(doc, payment_method) : store_credit_card(doc, payment_method)
|
129
|
+
end
|
130
|
+
add_order(doc, options)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def store_credit_card(doc, payment_method)
|
135
|
+
doc.send('credit-card-info') do
|
136
|
+
add_credit_card(doc, payment_method)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def store_echeck(doc, payment_method)
|
141
|
+
doc.send('ecp-info') do
|
142
|
+
doc.send('ecp') do
|
143
|
+
add_echeck(doc, payment_method)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def verify_credentials
|
149
|
+
begin
|
150
|
+
ssl_get(url.to_s, headers)
|
151
|
+
rescue ResponseError => e
|
152
|
+
return false if e.response.code.to_i == 401
|
153
|
+
end
|
154
|
+
|
155
|
+
true
|
156
|
+
end
|
157
|
+
|
158
|
+
def supports_scrubbing?
|
159
|
+
true
|
160
|
+
end
|
161
|
+
|
162
|
+
def scrub(transcript)
|
163
|
+
transcript.
|
164
|
+
gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
|
165
|
+
gsub(%r((<card-number>).+(</card-number>)), '\1[FILTERED]\2').
|
166
|
+
gsub(%r((<security-code>).+(</security-code>)), '\1[FILTERED]\2').
|
167
|
+
gsub(%r((<(?:public-)?account-number>).+(</(?:public-)?account-number>)), '\1[FILTERED]\2').
|
168
|
+
gsub(%r((<(?:public-)?routing-number>).+(</(?:public-)?routing-number>)), '\1[FILTERED]\2')
|
169
|
+
end
|
170
|
+
|
171
|
+
private
|
172
|
+
|
173
|
+
def add_auth_purchase(doc, money, payment_method, options)
|
174
|
+
doc.send('recurring-transaction', options[:recurring] ? 'RECURRING' : 'ECOMMERCE')
|
175
|
+
add_order(doc, options)
|
176
|
+
doc.send('store-card', options[:store_card] || false)
|
177
|
+
add_amount(doc, money, options)
|
178
|
+
add_fraud_info(doc, options)
|
179
|
+
|
180
|
+
if payment_method.is_a?(String)
|
181
|
+
doc.send('vaulted-shopper-id', payment_method)
|
182
|
+
else
|
183
|
+
doc.send('card-holder-info') do
|
184
|
+
add_personal_info(doc, payment_method, options)
|
185
|
+
end
|
186
|
+
add_credit_card(doc, payment_method)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
def add_amount(doc, money, options)
|
191
|
+
doc.amount(amount(money))
|
192
|
+
doc.currency(options[:currency] || currency(money))
|
193
|
+
end
|
194
|
+
|
195
|
+
def add_personal_info(doc, payment_method, options)
|
196
|
+
doc.send('first-name', payment_method.first_name)
|
197
|
+
doc.send('last-name', payment_method.last_name)
|
198
|
+
doc.send('personal-identification-number', options[:personal_identification_number]) if options[:personal_identification_number]
|
199
|
+
doc.email(options[:email]) if options[:email]
|
200
|
+
add_address(doc, options)
|
201
|
+
end
|
202
|
+
|
203
|
+
def add_credit_card(doc, card)
|
204
|
+
doc.send('credit-card') do
|
205
|
+
doc.send('card-number', card.number)
|
206
|
+
doc.send('security-code', card.verification_value)
|
207
|
+
doc.send('expiration-month', card.month)
|
208
|
+
doc.send('expiration-year', card.year)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
def add_description(doc, description)
|
213
|
+
doc.send('transaction-meta-data') do
|
214
|
+
doc.send('meta-data') do
|
215
|
+
doc.send('meta-key', 'description')
|
216
|
+
doc.send('meta-value', truncate(description, 500))
|
217
|
+
doc.send('meta-description', 'Description')
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
def add_order(doc, options)
|
223
|
+
doc.send('merchant-transaction-id', truncate(options[:order_id], 50)) if options[:order_id]
|
224
|
+
doc.send('soft-descriptor', options[:soft_descriptor]) if options[:soft_descriptor]
|
225
|
+
add_description(doc, options[:description]) if options[:description]
|
226
|
+
add_3ds(doc, options[:three_d_secure]) if options[:three_d_secure]
|
227
|
+
add_level_3_data(doc, options)
|
228
|
+
end
|
229
|
+
|
230
|
+
def add_address(doc, options)
|
231
|
+
address = options[:billing_address]
|
232
|
+
return unless address
|
233
|
+
|
234
|
+
doc.country(address[:country]) if address[:country]
|
235
|
+
doc.state(address[:state]) if address[:state] && STATE_CODE_COUNTRIES.include?(address[:country])
|
236
|
+
doc.address(address[:address]) if address[:address]
|
237
|
+
doc.city(address[:city]) if address[:city]
|
238
|
+
doc.zip(address[:zip]) if address[:zip]
|
239
|
+
end
|
240
|
+
|
241
|
+
def add_3ds(doc, three_d_secure_options)
|
242
|
+
eci = three_d_secure_options[:eci]
|
243
|
+
cavv = three_d_secure_options[:cavv]
|
244
|
+
xid = three_d_secure_options[:xid]
|
245
|
+
ds_transaction_id = three_d_secure_options[:ds_transaction_id]
|
246
|
+
version = three_d_secure_options[:version]
|
247
|
+
|
248
|
+
doc.send('three-d-secure') do
|
249
|
+
doc.eci(eci) if eci
|
250
|
+
doc.cavv(cavv) if cavv
|
251
|
+
doc.xid(xid) if xid
|
252
|
+
doc.send('three-d-secure-version', version) if version
|
253
|
+
doc.send('ds-transaction-id', ds_transaction_id) if ds_transaction_id
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
def add_level_3_data(doc, options)
|
258
|
+
return unless options[:customer_reference_number]
|
259
|
+
doc.send('level-3-data') do
|
260
|
+
send_when_present(doc, :customer_reference_number, options)
|
261
|
+
send_when_present(doc, :sales_tax_amount, options)
|
262
|
+
send_when_present(doc, :freight_amount, options)
|
263
|
+
send_when_present(doc, :duty_amount, options)
|
264
|
+
send_when_present(doc, :destination_zip_code, options)
|
265
|
+
send_when_present(doc, :destination_country_code, options)
|
266
|
+
send_when_present(doc, :ship_from_zip_code, options)
|
267
|
+
send_when_present(doc, :discount_amount, options)
|
268
|
+
send_when_present(doc, :tax_amount, options)
|
269
|
+
send_when_present(doc, :tax_rate, options)
|
270
|
+
add_level_3_data_items(doc, options[:level_3_data_items]) if options[:level_3_data_items]
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
def send_when_present(doc, options_key, options, xml_element_name = nil)
|
275
|
+
return unless options[options_key]
|
276
|
+
xml_element_name ||= options_key.to_s
|
277
|
+
|
278
|
+
doc.send(xml_element_name.dasherize, options[options_key])
|
279
|
+
end
|
280
|
+
|
281
|
+
def add_level_3_data_items(doc, items)
|
282
|
+
items.each do |item|
|
283
|
+
doc.send('level-3-data-item') do
|
284
|
+
item.each do |key, value|
|
285
|
+
key = key.to_s.dasherize
|
286
|
+
doc.send(key, value)
|
287
|
+
end
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
def add_authorization(doc, authorization)
|
293
|
+
doc.send('transaction-id', authorization)
|
294
|
+
end
|
295
|
+
|
296
|
+
def add_fraud_info(doc, options)
|
297
|
+
doc.send('transaction-fraud-info') do
|
298
|
+
doc.send('shopper-ip-address', options[:ip]) if options[:ip]
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
def add_alt_transaction_purchase(doc, money, payment_method_details, options)
|
303
|
+
doc.send('merchant-transaction-id', truncate(options[:order_id], 50)) if options[:order_id]
|
304
|
+
doc.send('soft-descriptor', options[:soft_descriptor]) if options[:soft_descriptor]
|
305
|
+
add_amount(doc, money, options)
|
306
|
+
|
307
|
+
vaulted_shopper_id = payment_method_details.vaulted_shopper_id
|
308
|
+
doc.send('vaulted-shopper-id', vaulted_shopper_id) if vaulted_shopper_id
|
309
|
+
|
310
|
+
if payment_method_details.check?
|
311
|
+
add_echeck_transaction(doc, payment_method_details.payment_method, options, vaulted_shopper_id.present?)
|
312
|
+
end
|
313
|
+
|
314
|
+
add_fraud_info(doc, options)
|
315
|
+
add_description(doc, options)
|
316
|
+
end
|
317
|
+
|
318
|
+
def add_echeck_transaction(doc, check, options, vaulted_shopper)
|
319
|
+
unless vaulted_shopper
|
320
|
+
doc.send('payer-info') do
|
321
|
+
add_personal_info(doc, check, options)
|
322
|
+
add_echeck_company(doc, check)
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
doc.send('ecp-transaction') do
|
327
|
+
add_echeck(doc, check) unless vaulted_shopper
|
328
|
+
end
|
329
|
+
|
330
|
+
doc.send('authorized-by-shopper', options[:authorized_by_shopper])
|
331
|
+
end
|
332
|
+
|
333
|
+
def add_echeck_company(doc, check)
|
334
|
+
doc.send('company-name', truncate(check.name, 50)) if check.account_holder_type = 'business'
|
335
|
+
end
|
336
|
+
|
337
|
+
def add_echeck(doc, check)
|
338
|
+
doc.send('account-number', check.account_number)
|
339
|
+
doc.send('routing-number', check.routing_number)
|
340
|
+
doc.send('account-type', BANK_ACCOUNT_TYPE_MAPPING["#{check.account_holder_type}_#{check.account_type}"])
|
341
|
+
end
|
342
|
+
|
343
|
+
def parse(response)
|
344
|
+
return bad_authentication_response if response.code.to_i == 401
|
345
|
+
return forbidden_response(response.body) if response.code.to_i == 403
|
346
|
+
|
347
|
+
parsed = {}
|
348
|
+
doc = Nokogiri::XML(response.body)
|
349
|
+
doc.root.xpath('*').each do |node|
|
350
|
+
if node.elements.empty?
|
351
|
+
parsed[node.name.downcase] = node.text
|
352
|
+
else
|
353
|
+
node.elements.each do |childnode|
|
354
|
+
parse_element(parsed, childnode)
|
355
|
+
end
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
359
|
+
parsed['content-location-header'] = response['content-location']
|
360
|
+
parsed
|
361
|
+
end
|
362
|
+
|
363
|
+
def parse_element(parsed, node)
|
364
|
+
if !node.elements.empty?
|
365
|
+
node.elements.each { |e| parse_element(parsed, e) }
|
366
|
+
else
|
367
|
+
parsed[node.name.downcase] = node.text
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
371
|
+
def api_request(action, request, verb, payment_method_details)
|
372
|
+
ssl_request(verb, url(action, payment_method_details), request, headers)
|
373
|
+
rescue ResponseError => e
|
374
|
+
e.response
|
375
|
+
end
|
376
|
+
|
377
|
+
def commit(action, verb = :post, payment_method_details = PaymentMethodDetails.new())
|
378
|
+
request = build_xml_request(action, payment_method_details) { |doc| yield(doc) }
|
379
|
+
response = api_request(action, request, verb, payment_method_details)
|
380
|
+
parsed = parse(response)
|
381
|
+
|
382
|
+
succeeded = success_from(action, response)
|
383
|
+
Response.new(
|
384
|
+
succeeded,
|
385
|
+
message_from(succeeded, parsed),
|
386
|
+
parsed,
|
387
|
+
authorization: authorization_from(action, parsed, payment_method_details),
|
388
|
+
avs_result: avs_result(parsed),
|
389
|
+
cvv_result: cvv_result(parsed),
|
390
|
+
error_code: error_code_from(parsed),
|
391
|
+
test: test?
|
392
|
+
)
|
393
|
+
end
|
394
|
+
|
395
|
+
def url(action = nil, payment_method_details = PaymentMethodDetails.new())
|
396
|
+
base = test? ? test_url : live_url
|
397
|
+
resource = action == :store ? 'vaulted-shoppers' : payment_method_details.resource_url
|
398
|
+
"#{base}/#{resource}"
|
399
|
+
end
|
400
|
+
|
401
|
+
def cvv_result(parsed)
|
402
|
+
CVVResult.new(CVC_CODE_TRANSLATOR[parsed['cvv-response-code']])
|
403
|
+
end
|
404
|
+
|
405
|
+
def avs_result(parsed)
|
406
|
+
AVSResult.new(code: AVS_CODE_TRANSLATOR[avs_lookup_key(parsed)])
|
407
|
+
end
|
408
|
+
|
409
|
+
def avs_lookup_key(p)
|
410
|
+
"line1: #{p['avs-response-code-address']}, zip: #{p['avs-response-code-zip']}, name: #{p['avs-response-code-name']}"
|
411
|
+
end
|
412
|
+
|
413
|
+
def success_from(action, response)
|
414
|
+
(200...300).cover?(response.code.to_i)
|
415
|
+
end
|
416
|
+
|
417
|
+
def message_from(succeeded, parsed_response)
|
418
|
+
return 'Success' if succeeded
|
419
|
+
parsed_response['description']
|
420
|
+
end
|
421
|
+
|
422
|
+
def authorization_from(action, parsed_response, payment_method_details)
|
423
|
+
action == :store ? vaulted_shopper_id(parsed_response, payment_method_details) : parsed_response['transaction-id']
|
424
|
+
end
|
425
|
+
|
426
|
+
def vaulted_shopper_id(parsed_response, payment_method_details)
|
427
|
+
return nil unless parsed_response['content-location-header']
|
428
|
+
vaulted_shopper_id = parsed_response['content-location-header'].split('/').last
|
429
|
+
vaulted_shopper_id += "|#{payment_method_details.payment_method_type}" if payment_method_details.alt_transaction?
|
430
|
+
vaulted_shopper_id
|
431
|
+
end
|
432
|
+
|
433
|
+
def error_code_from(parsed_response)
|
434
|
+
parsed_response['code']
|
435
|
+
end
|
436
|
+
|
437
|
+
def root_attributes
|
438
|
+
{
|
439
|
+
xmlns: 'http://ws.plimus.com'
|
440
|
+
}
|
441
|
+
end
|
442
|
+
|
443
|
+
def root_element(action, payment_method_details)
|
444
|
+
action == :store ? 'vaulted-shopper' : payment_method_details.root_element
|
445
|
+
end
|
446
|
+
|
447
|
+
def headers
|
448
|
+
{
|
449
|
+
'Content-Type' => 'application/xml',
|
450
|
+
'Authorization' => ('Basic ' + Base64.strict_encode64("#{@options[:api_username]}:#{@options[:api_password]}").strip),
|
451
|
+
}
|
452
|
+
end
|
453
|
+
|
454
|
+
def build_xml_request(action, payment_method_details)
|
455
|
+
builder = Nokogiri::XML::Builder.new
|
456
|
+
builder.__send__(root_element(action, payment_method_details), root_attributes) do |doc|
|
457
|
+
doc.send('card-transaction-type', TRANSACTIONS[action]) if TRANSACTIONS[action] && !payment_method_details.alt_transaction?
|
458
|
+
yield(doc)
|
459
|
+
end
|
460
|
+
builder.doc.root.to_xml
|
461
|
+
end
|
462
|
+
|
463
|
+
def handle_response(response)
|
464
|
+
case response.code.to_i
|
465
|
+
when 200...300
|
466
|
+
response
|
467
|
+
else
|
468
|
+
raise ResponseError.new(response)
|
469
|
+
end
|
470
|
+
end
|
471
|
+
|
472
|
+
def bad_authentication_response
|
473
|
+
{ 'description' => 'Unable to authenticate. Please check your credentials.' }
|
474
|
+
end
|
475
|
+
|
476
|
+
def forbidden_response(body)
|
477
|
+
{ 'description' => body }
|
478
|
+
end
|
479
|
+
end
|
480
|
+
|
481
|
+
class PaymentMethodDetails
|
482
|
+
attr_reader :payment_method, :vaulted_shopper_id, :payment_method_type
|
483
|
+
|
484
|
+
def initialize(payment_method = nil)
|
485
|
+
@payment_method = payment_method
|
486
|
+
@payment_method_type = nil
|
487
|
+
parse(payment_method)
|
488
|
+
end
|
489
|
+
|
490
|
+
def check?
|
491
|
+
@payment_method.is_a?(Check) || @payment_method_type == 'check'
|
492
|
+
end
|
493
|
+
|
494
|
+
def alt_transaction?
|
495
|
+
check?
|
496
|
+
end
|
497
|
+
|
498
|
+
def root_element
|
499
|
+
alt_transaction? ? 'alt-transaction' : 'card-transaction'
|
500
|
+
end
|
501
|
+
|
502
|
+
def resource_url
|
503
|
+
alt_transaction? ? 'alt-transactions' : 'transactions'
|
504
|
+
end
|
505
|
+
|
506
|
+
private
|
507
|
+
|
508
|
+
def parse(payment_method)
|
509
|
+
return unless payment_method
|
510
|
+
|
511
|
+
if payment_method.is_a?(String)
|
512
|
+
@vaulted_shopper_id, payment_method_type = payment_method.split('|')
|
513
|
+
@payment_method_type = payment_method_type if payment_method_type.present?
|
514
|
+
elsif payment_method.is_a?(Check)
|
515
|
+
@payment_method_type = payment_method.type
|
516
|
+
else
|
517
|
+
@payment_method_type = 'credit_card'
|
518
|
+
end
|
519
|
+
end
|
520
|
+
end
|
521
|
+
end
|
522
|
+
end
|