archetype2142_activemerchant 1.124.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +3640 -0
- data/CONTRIBUTORS +568 -0
- data/MIT-LICENSE +20 -0
- data/README.md +249 -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 +80 -0
- data/lib/active_merchant/billing/compatibility.rb +118 -0
- data/lib/active_merchant/billing/credit_card.rb +414 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +24 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +444 -0
- data/lib/active_merchant/billing/cvv_result.rb +37 -0
- data/lib/active_merchant/billing/gateway.rb +331 -0
- data/lib/active_merchant/billing/gateways/adyen.rb +712 -0
- data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +1107 -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 +179 -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 +396 -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 +220 -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 +613 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +186 -0
- data/lib/active_merchant/billing/gateways/borgun.rb +231 -0
- data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +23 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +832 -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 +320 -0
- data/lib/active_merchant/billing/gateways/card_save.rb +21 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +371 -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 +225 -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 +311 -0
- data/lib/active_merchant/billing/gateways/citrus_pay.rb +21 -0
- data/lib/active_merchant/billing/gateways/clearhaus.rb +219 -0
- data/lib/active_merchant/billing/gateways/commercegate.rb +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 +496 -0
- data/lib/active_merchant/billing/gateways/ct_payment.rb +269 -0
- data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +1074 -0
- data/lib/active_merchant/billing/gateways/d_local.rb +253 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +302 -0
- data/lib/active_merchant/billing/gateways/decidir.rb +331 -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 +333 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +215 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +472 -0
- data/lib/active_merchant/billing/gateways/element.rb +386 -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/forte.rb +286 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +256 -0
- data/lib/active_merchant/billing/gateways/global_collect.rb +463 -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 +390 -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 +254 -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/komoju.rb +115 -0
- data/lib/active_merchant/billing/gateways/kushki.rb +270 -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 +531 -0
- data/lib/active_merchant/billing/gateways/mastercard.rb +293 -0
- data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +329 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +194 -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 +422 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +446 -0
- data/lib/active_merchant/billing/gateways/money_movers.rb +150 -0
- data/lib/active_merchant/billing/gateways/mundipagg.rb +363 -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 +356 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +481 -0
- data/lib/active_merchant/billing/gateways/omise.rb +323 -0
- data/lib/active_merchant/billing/gateways/openpay.rb +229 -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 +1209 -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 +404 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +224 -0
- data/lib/active_merchant/billing/gateways/payeezy.rb +458 -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 +411 -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 +327 -0
- data/lib/active_merchant/billing/gateways/paymill.rb +369 -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 +65 -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 +270 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
- data/lib/active_merchant/billing/gateways/paysafe.rb +412 -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 +469 -0
- data/lib/active_merchant/billing/gateways/payu_polska.rb +178 -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 +246 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +283 -0
- data/lib/active_merchant/billing/gateways/priority.rb +390 -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/realex.rb +400 -0
- data/lib/active_merchant/billing/gateways/redsys.rb +718 -0
- data/lib/active_merchant/billing/gateways/s5.rb +247 -0
- data/lib/active_merchant/billing/gateways/safe_charge.rb +301 -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 +265 -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 +312 -0
- data/lib/active_merchant/billing/gateways/stripe.rb +813 -0
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +463 -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 +26 -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 +489 -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 +353 -0
- data/lib/active_merchant/billing/gateways/vanco.rb +294 -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 +246 -0
- data/lib/active_merchant/billing/gateways/vpos.rb +220 -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 +153 -0
- data/lib/active_merchant/billing/gateways/world_net.rb +345 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +923 -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 +97 -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 +196 -0
- data/lib/active_merchant/country.rb +337 -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 +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 +463 -0
@@ -0,0 +1,371 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class CardStreamGateway < Gateway
|
4
|
+
THREEDSECURE_REQUIRED_DEPRECATION_MESSAGE = 'Specifying the :threeDSRequired initialization option is deprecated. Please use the `:threeds_required => true` *transaction* option instead.'
|
5
|
+
|
6
|
+
self.test_url = self.live_url = 'https://gateway.cardstream.com/direct/'
|
7
|
+
self.money_format = :cents
|
8
|
+
self.default_currency = 'GBP'
|
9
|
+
self.currencies_without_fractions = %w(CVE ISK JPY UGX)
|
10
|
+
self.supported_countries = %w[GB US CH SE SG NO JP IS HK NL CZ CA AU]
|
11
|
+
self.supported_cardtypes = %i[visa master american_express diners_club discover jcb maestro]
|
12
|
+
self.homepage_url = 'http://www.cardstream.com/'
|
13
|
+
self.display_name = 'CardStream'
|
14
|
+
|
15
|
+
CURRENCY_CODES = {
|
16
|
+
'AED' => '784',
|
17
|
+
'ALL' => '008',
|
18
|
+
'AMD' => '051',
|
19
|
+
'ANG' => '532',
|
20
|
+
'ARS' => '032',
|
21
|
+
'AUD' => '036',
|
22
|
+
'AWG' => '533',
|
23
|
+
'BAM' => '977',
|
24
|
+
'BBD' => '052',
|
25
|
+
'BGN' => '975',
|
26
|
+
'BMD' => '060',
|
27
|
+
'BOB' => '068',
|
28
|
+
'BRL' => '986',
|
29
|
+
'BSD' => '044',
|
30
|
+
'BWP' => '072',
|
31
|
+
'BZD' => '084',
|
32
|
+
'CAD' => '124',
|
33
|
+
'CHF' => '756',
|
34
|
+
'CLP' => '152',
|
35
|
+
'CNY' => '156',
|
36
|
+
'COP' => '170',
|
37
|
+
'CRC' => '188',
|
38
|
+
'CZK' => '203',
|
39
|
+
'DKK' => '208',
|
40
|
+
'DOP' => '214',
|
41
|
+
'EGP' => '818',
|
42
|
+
'EUR' => '978',
|
43
|
+
'GBP' => '826',
|
44
|
+
'GEL' => '981',
|
45
|
+
'GIP' => '292',
|
46
|
+
'GTQ' => '320',
|
47
|
+
'GYD' => '328',
|
48
|
+
'HKD' => '344',
|
49
|
+
'HNL' => '340',
|
50
|
+
'HRK' => '191',
|
51
|
+
'HUF' => '348',
|
52
|
+
'ISK' => '352',
|
53
|
+
'IDR' => '360',
|
54
|
+
'ILS' => '376',
|
55
|
+
'INR' => '356',
|
56
|
+
'JPY' => '392',
|
57
|
+
'JMD' => '388',
|
58
|
+
'KES' => '404',
|
59
|
+
'KRW' => '410',
|
60
|
+
'KYD' => '136',
|
61
|
+
'LBP' => '422',
|
62
|
+
'LKR' => '144',
|
63
|
+
'MAD' => '504',
|
64
|
+
'MVR' => '462',
|
65
|
+
'MWK' => '454',
|
66
|
+
'MXN' => '484',
|
67
|
+
'MYR' => '458',
|
68
|
+
'NAD' => '516',
|
69
|
+
'NGN' => '566',
|
70
|
+
'NIO' => '558',
|
71
|
+
'NOK' => '578',
|
72
|
+
'NPR' => '524',
|
73
|
+
'NZD' => '554',
|
74
|
+
'PAB' => '590',
|
75
|
+
'PEN' => '604',
|
76
|
+
'PGK' => '598',
|
77
|
+
'PHP' => '608',
|
78
|
+
'PKR' => '586',
|
79
|
+
'PLN' => '985',
|
80
|
+
'PYG' => '600',
|
81
|
+
'QAR' => '634',
|
82
|
+
'RON' => '946',
|
83
|
+
'RSD' => '941',
|
84
|
+
'RUB' => '643',
|
85
|
+
'RWF' => '646',
|
86
|
+
'SAR' => '682',
|
87
|
+
'SEK' => '752',
|
88
|
+
'SGD' => '702',
|
89
|
+
'SRD' => '968',
|
90
|
+
'THB' => '764',
|
91
|
+
'TND' => '788',
|
92
|
+
'TRY' => '949',
|
93
|
+
'TTD' => '780',
|
94
|
+
'TWD' => '901',
|
95
|
+
'TZS' => '834',
|
96
|
+
'UAH' => '980',
|
97
|
+
'UGX' => '800',
|
98
|
+
'USD' => '840',
|
99
|
+
'UYU' => '858',
|
100
|
+
'VND' => '704',
|
101
|
+
'WST' => '882',
|
102
|
+
'XAF' => '950',
|
103
|
+
'XCD' => '951',
|
104
|
+
'XOF' => '952',
|
105
|
+
'ZAR' => '710'
|
106
|
+
}
|
107
|
+
|
108
|
+
CVV_CODE = {
|
109
|
+
'0' => 'U',
|
110
|
+
'1' => 'P',
|
111
|
+
'2' => 'M',
|
112
|
+
'4' => 'N'
|
113
|
+
}
|
114
|
+
|
115
|
+
# 0 - No additional information available.
|
116
|
+
# 1 - Postcode not checked.
|
117
|
+
# 2 - Postcode matched.
|
118
|
+
# 4 - Postcode not matched.
|
119
|
+
# 8 - Postcode partially matched.
|
120
|
+
AVS_POSTAL_MATCH = {
|
121
|
+
'0' => nil,
|
122
|
+
'1' => nil,
|
123
|
+
'2' => 'Y',
|
124
|
+
'4' => 'N',
|
125
|
+
'8' => 'N'
|
126
|
+
}
|
127
|
+
|
128
|
+
# 0 - No additional information available.
|
129
|
+
# 1 - Address numeric not checked.
|
130
|
+
# 2 - Address numeric matched.
|
131
|
+
# 4 - Address numeric not matched.
|
132
|
+
# 8 - Address numeric partially matched.
|
133
|
+
AVS_STREET_MATCH = {
|
134
|
+
'0' => nil,
|
135
|
+
'1' => nil,
|
136
|
+
'2' => 'Y',
|
137
|
+
'4' => 'N',
|
138
|
+
'8' => 'N'
|
139
|
+
}
|
140
|
+
|
141
|
+
def initialize(options = {})
|
142
|
+
requires!(options, :login, :shared_secret)
|
143
|
+
@threeds_required = false
|
144
|
+
if options[:threeDSRequired]
|
145
|
+
ActiveMerchant.deprecated(THREEDSECURE_REQUIRED_DEPRECATION_MESSAGE)
|
146
|
+
@threeds_required = options[:threeDSRequired]
|
147
|
+
end
|
148
|
+
super
|
149
|
+
end
|
150
|
+
|
151
|
+
def authorize(money, credit_card_or_reference, options = {})
|
152
|
+
post = {}
|
153
|
+
add_auth_purchase(post, -1, money, credit_card_or_reference, options)
|
154
|
+
commit('SALE', post)
|
155
|
+
end
|
156
|
+
|
157
|
+
def purchase(money, credit_card_or_reference, options = {})
|
158
|
+
post = {}
|
159
|
+
add_auth_purchase(post, 0, money, credit_card_or_reference, options)
|
160
|
+
commit('SALE', post)
|
161
|
+
end
|
162
|
+
|
163
|
+
def capture(money, authorization, options = {})
|
164
|
+
post = {}
|
165
|
+
add_pair(post, :xref, authorization)
|
166
|
+
add_pair(post, :amount, localized_amount(money, options[:currency] || currency(money)), required: true)
|
167
|
+
add_remote_address(post, options)
|
168
|
+
|
169
|
+
commit('CAPTURE', post)
|
170
|
+
end
|
171
|
+
|
172
|
+
def refund(money, authorization, options = {})
|
173
|
+
post = {}
|
174
|
+
add_pair(post, :xref, authorization)
|
175
|
+
add_amount(post, money, options)
|
176
|
+
add_remote_address(post, options)
|
177
|
+
add_country_code(post, options)
|
178
|
+
response = commit('REFUND_SALE', post)
|
179
|
+
|
180
|
+
return response if response.success?
|
181
|
+
return response unless options[:force_full_refund_if_unsettled]
|
182
|
+
|
183
|
+
if response.params['responseCode'] == '65541'
|
184
|
+
void(authorization, options)
|
185
|
+
else
|
186
|
+
response
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
def void(authorization, options = {})
|
191
|
+
post = {}
|
192
|
+
add_pair(post, :xref, authorization)
|
193
|
+
add_remote_address(post, options)
|
194
|
+
commit('CANCEL', post)
|
195
|
+
end
|
196
|
+
|
197
|
+
def verify(creditcard, options = {})
|
198
|
+
MultiResponse.run(:use_first_response) do |r|
|
199
|
+
r.process { authorize(100, creditcard, options) }
|
200
|
+
r.process(:ignore_result) { void(r.authorization, options) }
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
def supports_scrubbing?
|
205
|
+
true
|
206
|
+
end
|
207
|
+
|
208
|
+
def scrub(transcript)
|
209
|
+
transcript.
|
210
|
+
gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
|
211
|
+
gsub(%r((cardNumber=)\d+), '\1[FILTERED]').
|
212
|
+
gsub(%r((CVV=)\d+), '\1[FILTERED]')
|
213
|
+
end
|
214
|
+
|
215
|
+
private
|
216
|
+
|
217
|
+
def add_auth_purchase(post, pair_value, money, credit_card_or_reference, options)
|
218
|
+
add_pair(post, :captureDelay, pair_value)
|
219
|
+
add_amount(post, money, options)
|
220
|
+
add_invoice(post, credit_card_or_reference, money, options)
|
221
|
+
add_credit_card_or_reference(post, credit_card_or_reference)
|
222
|
+
add_customer_data(post, options)
|
223
|
+
add_remote_address(post, options)
|
224
|
+
add_country_code(post, options)
|
225
|
+
end
|
226
|
+
|
227
|
+
def add_amount(post, money, options)
|
228
|
+
currency = options[:currency] || currency(money)
|
229
|
+
add_pair(post, :amount, localized_amount(money, currency), required: true)
|
230
|
+
add_pair(post, :currencyCode, currency_code(currency))
|
231
|
+
end
|
232
|
+
|
233
|
+
def add_customer_data(post, options)
|
234
|
+
add_pair(post, :customerEmail, options[:email])
|
235
|
+
if (address = options[:billing_address] || options[:address])
|
236
|
+
add_pair(post, :customerAddress, "#{address[:address1]} #{address[:address2]}".strip)
|
237
|
+
add_pair(post, :customerPostCode, address[:zip])
|
238
|
+
add_pair(post, :customerPhone, options[:phone])
|
239
|
+
add_pair(post, :customerCountryCode, address[:country] || 'GB')
|
240
|
+
else
|
241
|
+
add_pair(post, :customerCountryCode, 'GB')
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
def add_invoice(post, credit_card_or_reference, money, options)
|
246
|
+
add_pair(post, :transactionUnique, options[:order_id], required: true)
|
247
|
+
add_pair(post, :orderRef, options[:description] || options[:order_id], required: true)
|
248
|
+
add_pair(post, :statementNarrative1, options[:merchant_name]) if options[:merchant_name]
|
249
|
+
add_pair(post, :statementNarrative2, options[:dynamic_descriptor]) if options[:dynamic_descriptor]
|
250
|
+
if credit_card_or_reference.respond_to?(:number)
|
251
|
+
if %w[american_express diners_club].include?(card_brand(credit_card_or_reference).to_s)
|
252
|
+
add_pair(post, :item1Quantity, 1)
|
253
|
+
add_pair(post, :item1Description, (options[:description] || options[:order_id]).slice(0, 15))
|
254
|
+
add_pair(post, :item1GrossValue, localized_amount(money, options[:currency] || currency(money)))
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
add_pair(post, :type, options[:type] || '1')
|
259
|
+
add_threeds_required(post, options)
|
260
|
+
end
|
261
|
+
|
262
|
+
def add_credit_card_or_reference(post, credit_card_or_reference)
|
263
|
+
if credit_card_or_reference.respond_to?(:number)
|
264
|
+
add_credit_card(post, credit_card_or_reference)
|
265
|
+
else
|
266
|
+
add_reference(post, credit_card_or_reference.to_s)
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
def add_reference(post, reference)
|
271
|
+
add_pair(post, :xref, reference, required: true)
|
272
|
+
end
|
273
|
+
|
274
|
+
def add_credit_card(post, credit_card)
|
275
|
+
add_pair(post, :customerName, credit_card.name, required: true)
|
276
|
+
add_pair(post, :cardNumber, credit_card.number, required: true)
|
277
|
+
add_pair(post, :cardExpiryMonth, format(credit_card.month, :two_digits), required: true)
|
278
|
+
add_pair(post, :cardExpiryYear, format(credit_card.year, :two_digits), required: true)
|
279
|
+
add_pair(post, :cardCVV, credit_card.verification_value)
|
280
|
+
end
|
281
|
+
|
282
|
+
def add_threeds_required(post, options)
|
283
|
+
add_pair(post, :threeDSRequired, options[:threeds_required] || @threeds_required ? 'Y' : 'N')
|
284
|
+
end
|
285
|
+
|
286
|
+
def add_remote_address(post, options = {})
|
287
|
+
add_pair(post, :remoteAddress, options[:ip] || '1.1.1.1')
|
288
|
+
end
|
289
|
+
|
290
|
+
def add_country_code(post, options)
|
291
|
+
post[:countryCode] = options[:country_code] || self.supported_countries[0]
|
292
|
+
end
|
293
|
+
|
294
|
+
def normalize_line_endings(str)
|
295
|
+
str.gsub(/%0D%0A|%0A%0D|%0D/, '%0A')
|
296
|
+
end
|
297
|
+
|
298
|
+
def add_hmac(post)
|
299
|
+
result = post.sort.collect { |key, value| "#{key}=#{normalize_line_endings(CGI.escape(value.to_s))}" }.join('&')
|
300
|
+
result = Digest::SHA512.hexdigest("#{result}#{@options[:shared_secret]}")
|
301
|
+
|
302
|
+
add_pair(post, :signature, result)
|
303
|
+
end
|
304
|
+
|
305
|
+
def parse(body)
|
306
|
+
result = {}
|
307
|
+
pairs = body.split('&')
|
308
|
+
pairs.each do |pair|
|
309
|
+
a = pair.split('=')
|
310
|
+
# because some value pairs don't have a value
|
311
|
+
result[a[0].to_sym] = a[1] == nil ? '' : CGI.unescape(a[1])
|
312
|
+
end
|
313
|
+
result
|
314
|
+
end
|
315
|
+
|
316
|
+
def commit(action, parameters)
|
317
|
+
parameters.update(
|
318
|
+
merchantID: @options[:login],
|
319
|
+
action: action
|
320
|
+
)
|
321
|
+
# adds a signature to the post hash/array
|
322
|
+
add_hmac(parameters)
|
323
|
+
|
324
|
+
response = parse(ssl_post(self.live_url, post_data(action, parameters)))
|
325
|
+
|
326
|
+
Response.new(
|
327
|
+
response[:responseCode] == '0',
|
328
|
+
response[:responseCode] == '0' ? 'APPROVED' : response[:responseMessage],
|
329
|
+
response,
|
330
|
+
test: test?,
|
331
|
+
authorization: response[:xref],
|
332
|
+
cvv_result: CVV_CODE[response[:avscv2ResponseCode].to_s[0, 1]],
|
333
|
+
avs_result: avs_from(response)
|
334
|
+
)
|
335
|
+
end
|
336
|
+
|
337
|
+
def avs_from(response)
|
338
|
+
postal_match = AVS_POSTAL_MATCH[response[:avscv2ResponseCode].to_s[1, 1]]
|
339
|
+
street_match = AVS_STREET_MATCH[response[:avscv2ResponseCode].to_s[2, 1]]
|
340
|
+
|
341
|
+
code = if postal_match == 'Y' && street_match == 'Y'
|
342
|
+
'M'
|
343
|
+
elsif postal_match == 'Y'
|
344
|
+
'P'
|
345
|
+
elsif street_match == 'Y'
|
346
|
+
'A'
|
347
|
+
else
|
348
|
+
'I'
|
349
|
+
end
|
350
|
+
|
351
|
+
AVSResult.new({
|
352
|
+
code: code,
|
353
|
+
postal_match: postal_match,
|
354
|
+
street_match: street_match
|
355
|
+
})
|
356
|
+
end
|
357
|
+
|
358
|
+
def currency_code(currency)
|
359
|
+
CURRENCY_CODES[currency]
|
360
|
+
end
|
361
|
+
|
362
|
+
def post_data(action, parameters = {})
|
363
|
+
parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
|
364
|
+
end
|
365
|
+
|
366
|
+
def add_pair(post, key, value, options = {})
|
367
|
+
post[key] = value if !value.blank? || options[:required]
|
368
|
+
end
|
369
|
+
end
|
370
|
+
end
|
371
|
+
end
|
@@ -0,0 +1,327 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class CardknoxGateway < Gateway
|
4
|
+
self.live_url = 'https://x1.cardknox.com/gateway'
|
5
|
+
|
6
|
+
self.supported_countries = %w[US CA GB]
|
7
|
+
self.default_currency = 'USD'
|
8
|
+
self.supported_cardtypes = %i[visa master american_express discover diners_club jcb]
|
9
|
+
|
10
|
+
self.homepage_url = 'https://www.cardknox.com/'
|
11
|
+
self.display_name = 'Cardknox'
|
12
|
+
|
13
|
+
COMMANDS = {
|
14
|
+
credit_card: {
|
15
|
+
purchase: 'cc:sale',
|
16
|
+
authorization: 'cc:authonly',
|
17
|
+
capture: 'cc:capture',
|
18
|
+
refund: 'cc:refund',
|
19
|
+
void: 'cc:void',
|
20
|
+
save: 'cc:save'
|
21
|
+
},
|
22
|
+
check: {
|
23
|
+
purchase: 'check:sale',
|
24
|
+
refund: 'check:refund',
|
25
|
+
void: 'check:void',
|
26
|
+
save: 'check:save'
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
def initialize(options = {})
|
31
|
+
requires!(options, :api_key)
|
32
|
+
super
|
33
|
+
end
|
34
|
+
|
35
|
+
# There are three sources for doing a purchase transation:
|
36
|
+
# - credit card
|
37
|
+
# - check
|
38
|
+
# - cardknox token, which is returned in the the authorization string "ref_num;token;command"
|
39
|
+
|
40
|
+
def purchase(amount, source, options = {})
|
41
|
+
post = {}
|
42
|
+
add_amount(post, amount, options)
|
43
|
+
add_invoice(post, options)
|
44
|
+
add_source(post, source)
|
45
|
+
add_address(post, source, options)
|
46
|
+
add_customer_data(post, options)
|
47
|
+
add_custom_fields(post, options)
|
48
|
+
commit(:purchase, source_type(source), post)
|
49
|
+
end
|
50
|
+
|
51
|
+
def authorize(amount, source, options = {})
|
52
|
+
post = {}
|
53
|
+
add_amount(post, amount)
|
54
|
+
add_invoice(post, options)
|
55
|
+
add_source(post, source)
|
56
|
+
add_address(post, source, options)
|
57
|
+
add_customer_data(post, options)
|
58
|
+
add_custom_fields(post, options)
|
59
|
+
commit(:authorization, source_type(source), post)
|
60
|
+
end
|
61
|
+
|
62
|
+
def capture(amount, authorization, options = {})
|
63
|
+
post = {}
|
64
|
+
add_reference(post, authorization)
|
65
|
+
add_amount(post, amount)
|
66
|
+
commit(:capture, source_type(authorization), post)
|
67
|
+
end
|
68
|
+
|
69
|
+
def refund(amount, authorization, options = {})
|
70
|
+
post = {}
|
71
|
+
add_reference(post, authorization)
|
72
|
+
add_amount(post, amount)
|
73
|
+
commit(:refund, source_type(authorization), post)
|
74
|
+
end
|
75
|
+
|
76
|
+
def void(authorization, options = {})
|
77
|
+
post = {}
|
78
|
+
add_reference(post, authorization)
|
79
|
+
commit(:void, source_type(authorization), post)
|
80
|
+
end
|
81
|
+
|
82
|
+
def verify(credit_card, options = {})
|
83
|
+
MultiResponse.run(:use_first_response) do |r|
|
84
|
+
r.process { authorize(100, credit_card, options) }
|
85
|
+
r.process(:ignore_result) { void(r.authorization, options) }
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def store(source, options = {})
|
90
|
+
post = {}
|
91
|
+
add_source(post, source)
|
92
|
+
add_address(post, source, options)
|
93
|
+
add_invoice(post, options)
|
94
|
+
add_customer_data(post, options)
|
95
|
+
add_custom_fields(post, options)
|
96
|
+
commit(:save, source_type(source), post)
|
97
|
+
end
|
98
|
+
|
99
|
+
def supports_scrubbing?
|
100
|
+
true
|
101
|
+
end
|
102
|
+
|
103
|
+
def scrub(transcript)
|
104
|
+
transcript.
|
105
|
+
gsub(%r((xCardNum=)\d+), '\1[FILTERED]').
|
106
|
+
gsub(%r((xCVV=)\d+), '\1[FILTERED]').
|
107
|
+
gsub(%r((xAccount=)\d+), '\1[FILTERED]').
|
108
|
+
gsub(%r((xRouting=)\d+), '\1[FILTERED]').
|
109
|
+
gsub(%r((xKey=)\w+), '\1[FILTERED]')
|
110
|
+
end
|
111
|
+
|
112
|
+
private
|
113
|
+
|
114
|
+
def split_authorization(authorization)
|
115
|
+
authorization.split(';')
|
116
|
+
end
|
117
|
+
|
118
|
+
def add_reference(post, reference)
|
119
|
+
reference, = split_authorization(reference)
|
120
|
+
post[:Refnum] = reference
|
121
|
+
end
|
122
|
+
|
123
|
+
def source_type(source)
|
124
|
+
if source.respond_to?(:brand)
|
125
|
+
:credit_card
|
126
|
+
elsif source.respond_to?(:routing_number)
|
127
|
+
:check
|
128
|
+
elsif source.kind_of?(String)
|
129
|
+
source_type_from(source)
|
130
|
+
else
|
131
|
+
raise ArgumentError, "Unknown source #{source.inspect}"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def source_type_from(authorization)
|
136
|
+
_, _, source_type = split_authorization(authorization)
|
137
|
+
(source_type || 'credit_card').to_sym
|
138
|
+
end
|
139
|
+
|
140
|
+
def add_source(post, source)
|
141
|
+
if source.respond_to?(:brand)
|
142
|
+
add_credit_card(post, source)
|
143
|
+
elsif source.respond_to?(:routing_number)
|
144
|
+
add_check(post, source)
|
145
|
+
elsif source.kind_of?(String)
|
146
|
+
add_cardknox_token(post, source)
|
147
|
+
else
|
148
|
+
raise ArgumentError, "Invalid payment source #{source.inspect}"
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
# Subtotal + Tax + Tip = Amount.
|
153
|
+
|
154
|
+
def add_amount(post, money, options = {})
|
155
|
+
post[:Tip] = amount(options[:tip])
|
156
|
+
post[:Amount] = amount(money)
|
157
|
+
end
|
158
|
+
|
159
|
+
def expdate(credit_card)
|
160
|
+
year = format(credit_card.year, :two_digits)
|
161
|
+
month = format(credit_card.month, :two_digits)
|
162
|
+
"#{month}#{year}"
|
163
|
+
end
|
164
|
+
|
165
|
+
def add_customer_data(post, options)
|
166
|
+
address = options[:billing_address] || {}
|
167
|
+
post[:Street] = address[:address1]
|
168
|
+
post[:Zip] = address[:zip]
|
169
|
+
post[:PONum] = options[:po_number]
|
170
|
+
post[:Fax] = options[:fax]
|
171
|
+
post[:Email] = options[:email]
|
172
|
+
post[:IP] = options[:ip]
|
173
|
+
end
|
174
|
+
|
175
|
+
def add_address(post, source, options)
|
176
|
+
add_address_for_type(:billing, post, source, options[:billing_address]) if options[:billing_address]
|
177
|
+
add_address_for_type(:shipping, post, source, options[:shipping_address]) if options[:shipping_address]
|
178
|
+
end
|
179
|
+
|
180
|
+
def add_address_for_type(type, post, source, address)
|
181
|
+
prefix = address_key_prefix(type)
|
182
|
+
if source.respond_to?(:first_name)
|
183
|
+
post[address_key(prefix, 'FirstName')] = source.first_name
|
184
|
+
post[address_key(prefix, 'LastName')] = source.last_name
|
185
|
+
else
|
186
|
+
post[address_key(prefix, 'FirstName')] = address[:first_name]
|
187
|
+
post[address_key(prefix, 'LastName')] = address[:last_name]
|
188
|
+
end
|
189
|
+
post[address_key(prefix, 'MiddleName')] = address[:middle_name]
|
190
|
+
|
191
|
+
post[address_key(prefix, 'Company')] = address[:company]
|
192
|
+
post[address_key(prefix, 'Street')] = address[:address1]
|
193
|
+
post[address_key(prefix, 'Street2')] = address[:address2]
|
194
|
+
post[address_key(prefix, 'City')] = address[:city]
|
195
|
+
post[address_key(prefix, 'State')] = address[:state]
|
196
|
+
post[address_key(prefix, 'Zip')] = address[:zip]
|
197
|
+
post[address_key(prefix, 'Country')] = address[:country]
|
198
|
+
post[address_key(prefix, 'Phone')] = address[:phone]
|
199
|
+
post[address_key(prefix, 'Mobile')] = address[:mobile]
|
200
|
+
end
|
201
|
+
|
202
|
+
def address_key_prefix(type)
|
203
|
+
case type
|
204
|
+
when :shipping then 'Ship'
|
205
|
+
when :billing then 'Bill'
|
206
|
+
else
|
207
|
+
raise ArgumentError, "Unknown address key prefix: #{type}"
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
def address_key(prefix, key)
|
212
|
+
"#{prefix}#{key}".to_sym
|
213
|
+
end
|
214
|
+
|
215
|
+
def add_invoice(post, options)
|
216
|
+
post[:Invoice] = options[:invoice]
|
217
|
+
post[:OrderID] = options[:order_id]
|
218
|
+
post[:Comments] = options[:comments]
|
219
|
+
post[:Description] = options[:description]
|
220
|
+
post[:Tax] = amount(options[:tax])
|
221
|
+
end
|
222
|
+
|
223
|
+
def add_custom_fields(post, options)
|
224
|
+
options.keys.grep(/^custom(?:[01]\d|20)$/) do |key|
|
225
|
+
post[key.to_s.capitalize] = options[key]
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
def add_credit_card(post, credit_card)
|
230
|
+
if credit_card.track_data.present?
|
231
|
+
post[:Magstripe] = credit_card.track_data
|
232
|
+
post[:Cardpresent] = true
|
233
|
+
else
|
234
|
+
post[:CardNum] = credit_card.number
|
235
|
+
post[:CVV] = credit_card.verification_value
|
236
|
+
post[:Exp] = expdate(credit_card)
|
237
|
+
post[:Name] = credit_card.name
|
238
|
+
post[:CardPresent] = true if credit_card.manual_entry
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
def add_check(post, check)
|
243
|
+
post[:Routing] = check.routing_number
|
244
|
+
post[:Account] = check.account_number
|
245
|
+
post[:Name] = check.name
|
246
|
+
post[:CheckNum] = check.number
|
247
|
+
end
|
248
|
+
|
249
|
+
def add_cardknox_token(post, authorization)
|
250
|
+
_, token, = split_authorization(authorization)
|
251
|
+
|
252
|
+
post[:Token] = token
|
253
|
+
end
|
254
|
+
|
255
|
+
def parse(body)
|
256
|
+
fields = {}
|
257
|
+
for line in body.split('&')
|
258
|
+
key, value = *line.scan(%r{^(\w+)\=(.*)$}).flatten
|
259
|
+
fields[key] = CGI.unescape(value.to_s)
|
260
|
+
end
|
261
|
+
|
262
|
+
{
|
263
|
+
result: fields['xResult'],
|
264
|
+
status: fields['xStatus'],
|
265
|
+
error: fields['xError'],
|
266
|
+
auth_code: fields['xAuthCode'],
|
267
|
+
ref_num: fields['xRefNum'],
|
268
|
+
current_ref_num: fields['xRefNumCurrent'],
|
269
|
+
token: fields['xToken'],
|
270
|
+
batch: fields['xBatch'],
|
271
|
+
avs_result: fields['xAvsResult'],
|
272
|
+
avs_result_code: fields['xAvsResultCode'],
|
273
|
+
cvv_result: fields['xCvvResult'],
|
274
|
+
cvv_result_code: fields['xCvvResultCode'],
|
275
|
+
remaining_balance: fields['xRemainingBalance'],
|
276
|
+
amount: fields['xAuthAmount'],
|
277
|
+
masked_card_num: fields['xMaskedCardNumber'],
|
278
|
+
masked_account_number: fields['MaskedAccountNumber']
|
279
|
+
}.delete_if { |_k, v| v.nil? }
|
280
|
+
end
|
281
|
+
|
282
|
+
def commit(action, source_type, parameters)
|
283
|
+
response = parse(ssl_post(live_url, post_data(COMMANDS[source_type][action], parameters)))
|
284
|
+
|
285
|
+
Response.new(
|
286
|
+
(response[:status] == 'Approved'),
|
287
|
+
message_from(response),
|
288
|
+
response,
|
289
|
+
authorization: authorization_from(response, source_type),
|
290
|
+
avs_result: { code: response[:avs_result_code] },
|
291
|
+
cvv_result: response[:cvv_result_code]
|
292
|
+
)
|
293
|
+
end
|
294
|
+
|
295
|
+
def message_from(response)
|
296
|
+
if response[:status] == 'Approved'
|
297
|
+
'Success'
|
298
|
+
elsif response[:error].blank?
|
299
|
+
'Unspecified error'
|
300
|
+
else
|
301
|
+
response[:error]
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
def authorization_from(response, source_type)
|
306
|
+
"#{response[:ref_num]};#{response[:token]};#{source_type}"
|
307
|
+
end
|
308
|
+
|
309
|
+
def post_data(command, parameters = {})
|
310
|
+
initial_parameters = {
|
311
|
+
Key: @options[:api_key],
|
312
|
+
Version: '4.5.4',
|
313
|
+
SoftwareName: 'Active Merchant',
|
314
|
+
SoftwareVersion: ActiveMerchant::VERSION.to_s,
|
315
|
+
Command: command
|
316
|
+
}
|
317
|
+
|
318
|
+
seed = SecureRandom.hex(32).upcase
|
319
|
+
hash = Digest::SHA1.hexdigest("#{initial_parameters[:command]}:#{@options[:pin]}:#{parameters[:amount]}:#{parameters[:invoice]}:#{seed}")
|
320
|
+
initial_parameters[:Hash] = "s/#{seed}/#{hash}/n" unless @options[:pin].blank?
|
321
|
+
parameters = initial_parameters.merge(parameters)
|
322
|
+
|
323
|
+
parameters.reject { |_k, v| v.blank? }.collect { |key, value| "x#{key}=#{CGI.escape(value.to_s)}" }.join('&')
|
324
|
+
end
|
325
|
+
end
|
326
|
+
end
|
327
|
+
end
|