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,450 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
class SkipJackGateway < Gateway
|
6
|
+
API_VERSION = '?.?'
|
7
|
+
|
8
|
+
self.live_url = 'https://www.skipjackic.com'
|
9
|
+
self.test_url = 'https://developer.skipjackic.com'
|
10
|
+
|
11
|
+
BASIC_PATH = '/scripts/evolvcc.dll'
|
12
|
+
ADVANCED_PATH = '/evolvcc/evolvcc.aspx'
|
13
|
+
|
14
|
+
ACTIONS = {
|
15
|
+
:authorization => 'AuthorizeAPI',
|
16
|
+
:change_status => 'SJAPI_TransactionChangeStatusRequest',
|
17
|
+
:get_status => 'SJAPI_TransactionStatusRequest'
|
18
|
+
}
|
19
|
+
|
20
|
+
SUCCESS_MESSAGE = 'The transaction was successful.'
|
21
|
+
|
22
|
+
MONETARY_CHANGE_STATUSES = ['SETTLE', 'AUTHORIZE', 'AUTHORIZE ADDITIONAL', 'CREDIT', 'SPLITSETTLE']
|
23
|
+
|
24
|
+
CARD_CODE_ERRORS = %w( N S "" )
|
25
|
+
|
26
|
+
CARD_CODE_MESSAGES = {
|
27
|
+
'M' => 'Card verification number matched',
|
28
|
+
'N' => "Card verification number didn't match",
|
29
|
+
'P' => 'Card verification number was not processed',
|
30
|
+
'S' => 'Card verification number should be on card but was not indicated',
|
31
|
+
'U' => 'Issuer was not certified for card verification',
|
32
|
+
'' => 'Transaction failed because incorrect card verification number was entered or no number was entered'
|
33
|
+
}
|
34
|
+
|
35
|
+
AVS_ERRORS = %w( A B C E I N O P R W Z )
|
36
|
+
|
37
|
+
AVS_MESSAGES = {
|
38
|
+
'A' => 'Street address matches billing information, zip/postal code does not',
|
39
|
+
'B' => 'Street address match for international transaction. Postal code not verified due to incompatible formats',
|
40
|
+
'C' => 'Street address and postal code not verified for internation transaction due to incompatible formats',
|
41
|
+
'D' => 'Street address and postal code match for international transaction',
|
42
|
+
'E' => 'Address verification service error',
|
43
|
+
'I' => 'Address information not verified by international issuer',
|
44
|
+
'M' => 'Street address and postal code match for international transaction',
|
45
|
+
'N' => 'Neither street address nor zip/postal match billing information',
|
46
|
+
'O' => 'Non-US issuer does not participate',
|
47
|
+
'P' => 'Postal codes match for international transaction but street address not verified due to incompatible formats',
|
48
|
+
'R' => 'Payment gateway was unavailable or timed out',
|
49
|
+
'S' => 'Address verification service not supported by issuer',
|
50
|
+
'U' => 'Address information is unavailable',
|
51
|
+
'W' => '9-digit zip/postal code matches billing information, street address does not',
|
52
|
+
'X' => 'Street address and 9-digit zip/postal code matches billing information',
|
53
|
+
'Y' => 'Street address and 5-digit zip/postal code matches billing information',
|
54
|
+
'Z' => '5-digit zip/postal code matches billing information, street address does not',
|
55
|
+
}
|
56
|
+
|
57
|
+
CHANGE_STATUS_ERROR_MESSAGES = {
|
58
|
+
'0' => 'Success',
|
59
|
+
'-1' => 'Invalid Command',
|
60
|
+
'-2' => 'Parameter Missing',
|
61
|
+
'-3' => 'Failed retrieving response',
|
62
|
+
'-4' => 'Invalid Status',
|
63
|
+
'-5' => 'Failed reading security flags',
|
64
|
+
'-6' => 'Developer serial number not found',
|
65
|
+
'-7' => 'Invalid Serial Number'
|
66
|
+
}
|
67
|
+
|
68
|
+
TRANSACTION_CURRENT_STATUS = {
|
69
|
+
'0' => 'Idle',
|
70
|
+
'1' => 'Authorized',
|
71
|
+
'2' => 'Denied',
|
72
|
+
'3' => 'Settled',
|
73
|
+
'4' => 'Credited',
|
74
|
+
'5' => 'Deleted',
|
75
|
+
'6' => 'Archived',
|
76
|
+
'7' => 'Pre-Authorized',
|
77
|
+
'8' => 'Split Settled'
|
78
|
+
}
|
79
|
+
|
80
|
+
TRANSACTION_PENDING_STATUS = {
|
81
|
+
'0' => 'Idle',
|
82
|
+
'1' => 'Pending Credit',
|
83
|
+
'2' => 'Pending Settlement',
|
84
|
+
'3' => 'Pending Authorization',
|
85
|
+
'4' => 'Pending Manual Settlement',
|
86
|
+
'5' => 'Pending Recurring'
|
87
|
+
}
|
88
|
+
|
89
|
+
RETURN_CODE_MESSAGES = {
|
90
|
+
'-1' => 'Data was not by received intact by Skipjack Transaction Network.',
|
91
|
+
'0' => 'Communication Failure. Error in Request and Response at IP level.',
|
92
|
+
'1' => 'Valid Data. Authorization request was valid.',
|
93
|
+
'-35' => 'Invalid credit card number. Retry with correct credit card number.',
|
94
|
+
'-37' => 'Merchant Processor Unavailable. Skipjack is unable to communicate with payment Processor. Retry',
|
95
|
+
'-39' => 'Length or value of HTML Serial. Number Invalid serial number. Check HTML Serial Number length and that it is a correct/valid number. Confirm you are sending to the correct environment (Development or Production)',
|
96
|
+
'-51' => 'The value or length for billing zip code is incorrect.',
|
97
|
+
'-52' => 'The value or length for shipping zip code is incorrect.',
|
98
|
+
'-53' => 'The value or length for credit card expiration month is incorrect.',
|
99
|
+
'-54' => 'The value or length of the month or year of the credit card account number was incorrect.',
|
100
|
+
'-55' => 'The value or length or billing street address is incorrect.',
|
101
|
+
'-56' => 'The value or length of the shipping address is incorrect.',
|
102
|
+
'-57' => 'The length of the transaction amount must be at least 3 digits long (excluding the decimal place).',
|
103
|
+
'-58' => 'Length or value in Merchant Name Merchant Name associated with Skipjack account is misconfigured or invalid',
|
104
|
+
'-59' => 'Length or value in Merchant Address Merchant Address associated with Skipjack account is misconfigured or invalid',
|
105
|
+
'-60' => 'Length or value in Merchant State Merchant State associated with Skipjack account is misconfigured or invalid',
|
106
|
+
'-61' => 'The value or length for shipping state/province is empty.',
|
107
|
+
'-62' => 'The value for length orderstring is empty.',
|
108
|
+
'-64' => 'The value for the phone number is incorrect.',
|
109
|
+
'-65' => 'The value or length for billing name is empty.',
|
110
|
+
'-66' => 'The value or length for billing e-mail is empty.',
|
111
|
+
'-67' => 'The value or length for billing street address is empty.',
|
112
|
+
'-68' => 'The value or length for billing city is empty.',
|
113
|
+
'-69' => 'The value or length for billing state is empty.',
|
114
|
+
'-70' => 'Empty zipcode Zip Code field is empty.',
|
115
|
+
'-71' => 'Empty ordernumber Ordernumber field is empty.',
|
116
|
+
'-72' => 'Empty accountnumber Accountnumber field is empty',
|
117
|
+
'-73' => 'Empty month Month field is empty.',
|
118
|
+
'-74' => 'Empty year Year field is empty.',
|
119
|
+
'-75' => 'Empty serialnumber Serialnumber field is empty.',
|
120
|
+
'-76' => 'Empty transactionamount Transaction amount field is empty.',
|
121
|
+
'-77' => 'Empty orderstring Orderstring field is empty.',
|
122
|
+
'-78' => 'Empty shiptophone Shiptophone field is empty.',
|
123
|
+
'-79' => 'The value or length for billing name is empty.',
|
124
|
+
'-80' => 'Length shipto name Error in the length or value of shiptophone.',
|
125
|
+
'-81' => 'Length or value of Customer location',
|
126
|
+
'-82' => 'The value or length for billing state is empty.',
|
127
|
+
'-83' => 'The value or length for shipping phone is empty.',
|
128
|
+
'-84' => 'There is already an existing pending transaction in the register sharing the posted Order Number.',
|
129
|
+
'-85' => 'Airline leg info invalid Airline leg field value is invalid or empty.',
|
130
|
+
'-86' => 'Airline ticket info invalid Airline ticket info field is invalid or empty',
|
131
|
+
'-87' => 'Point of Sale check routing number must be 9 numeric digits Point of Sale check routing number is invalid or empty.',
|
132
|
+
'-88' => 'Point of Sale check account number missing or invalid Point of Sale check account number is invalid or empty.',
|
133
|
+
'-89' => 'Point of Sale check MICR missing or invalid Point of Sale check MICR invalid or empty.',
|
134
|
+
'-90' => 'Point of Sale check number missing or invalid Point of Sale check number invalid or empty.',
|
135
|
+
'-91' => 'CVV2 Invalid or empty "Make CVV a required field feature" enabled (New feature 01 April 2006) in the Merchant Account Setup interface but no CVV code was sent in the transaction data.',
|
136
|
+
'-92' => 'Approval Code Invalid Approval Code Invalid. Approval Code is a 6 digit code.',
|
137
|
+
'-93' => 'Blind Credits Request Refused "Allow Blind Credits" option must be enabled on the Skipjack Merchant Account.',
|
138
|
+
'-94' => 'Blind Credits Failed',
|
139
|
+
'-95' => 'Voice Authorization Request Refused Voice Authorization option must be enabled on the Skipjack Merchant Account.',
|
140
|
+
'-96' => 'Voice Authorizations Failed',
|
141
|
+
'-97' => 'Fraud Rejection Violates Velocity Settling.',
|
142
|
+
'-98' => 'Invalid Discount Amount',
|
143
|
+
'-99' => 'POS PIN Debit Pin Block Debit-specific',
|
144
|
+
'-100' => 'POS PIN Debit Invalid Key Serial Number Debit-specific',
|
145
|
+
'-101' => 'Invalid Authentication Data Data for Verified by Visa/MC Secure Code is invalid.',
|
146
|
+
'-102' => 'Authentication Data Not Allowed',
|
147
|
+
'-103' => 'POS Check Invalid Birth Date POS check dateofbirth variable contains a birth date in an incorrect format. Use MM/DD/YYYY format for this variable.',
|
148
|
+
'-104' => 'POS Check Invalid Identification Type POS check identificationtype variable contains a identification type value which is invalid. Use the single digit value where Social Security Number=1, Drivers License=2 for this variable.',
|
149
|
+
'-105' => 'Invalid trackdata Track Data is in invalid format.',
|
150
|
+
'-106' => 'POS Check Invalid Account Type',
|
151
|
+
'-107' => 'POS PIN Debit Invalid Sequence Number',
|
152
|
+
'-108' => 'Invalid Transaction ID',
|
153
|
+
'-109' => 'Invalid From Account Type',
|
154
|
+
'-110' => 'Pos Error Invalid To Account Type',
|
155
|
+
'-112' => 'Pos Error Invalid Auth Option',
|
156
|
+
'-113' => 'Pos Error Transaction Failed',
|
157
|
+
'-114' => 'Pos Error Invalid Incoming Eci',
|
158
|
+
'-115' => 'POS Check Invalid Check Type',
|
159
|
+
'-116' => 'POS Check Invalid Lane Number POS Check lane or cash register number is invalid. Use a valid lane or cash register number that has been configured in the Skipjack Merchant Account.',
|
160
|
+
'-117' => 'POS Check Invalid Cashier Number'
|
161
|
+
}
|
162
|
+
|
163
|
+
self.supported_countries = ['US', 'CA']
|
164
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :jcb, :discover, :diners_club]
|
165
|
+
self.homepage_url = 'http://www.skipjack.com/'
|
166
|
+
self.display_name = 'SkipJack'
|
167
|
+
|
168
|
+
# Creates a new SkipJackGateway
|
169
|
+
#
|
170
|
+
# The gateway requires that a valid login and password be passed
|
171
|
+
# in the +options+ hash.
|
172
|
+
#
|
173
|
+
# ==== Options
|
174
|
+
#
|
175
|
+
# * <tt>:login</tt> -- The SkipJack Merchant Serial Number.
|
176
|
+
# * <tt>:password</tt> -- The SkipJack Developer Serial Number.
|
177
|
+
# * <tt>:test => +true+ or +false+</tt> -- Use the test or live SkipJack url.
|
178
|
+
# * <tt>:advanced => +true+ or +false+</tt> -- Set to true if you're using an advanced processor
|
179
|
+
# See the SkipJack Integration Guide for details. (default: +false+)
|
180
|
+
def initialize(options = {})
|
181
|
+
requires!(options, :login, :password)
|
182
|
+
super
|
183
|
+
end
|
184
|
+
|
185
|
+
def authorize(money, creditcard, options = {})
|
186
|
+
requires!(options, :order_id, :email)
|
187
|
+
post = {}
|
188
|
+
add_invoice(post, options)
|
189
|
+
add_creditcard(post, creditcard)
|
190
|
+
add_address(post, options)
|
191
|
+
add_customer_data(post, options)
|
192
|
+
commit(:authorization, money, post)
|
193
|
+
end
|
194
|
+
|
195
|
+
def purchase(money, creditcard, options = {})
|
196
|
+
authorization = authorize(money, creditcard, options)
|
197
|
+
if authorization.success?
|
198
|
+
capture(money, authorization.authorization)
|
199
|
+
else
|
200
|
+
authorization
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
# Captures the funds from an authorized transaction.
|
205
|
+
#
|
206
|
+
# ==== Parameters
|
207
|
+
#
|
208
|
+
# * <tt>money</tt> -- The amount to be capture as an Integer in cents.
|
209
|
+
# * <tt>authorization</tt> -- The authorization returned from the previous authorize request.
|
210
|
+
# * <tt>options</tt> -- A hash of optional parameters.
|
211
|
+
#
|
212
|
+
# ==== Options
|
213
|
+
#
|
214
|
+
# * <tt>:force_settlement</tt> -- Force the settlement to occur as soon as possible. This option is not supported by other gateways. See the SkipJack API reference for more details
|
215
|
+
def capture(money, authorization, options = {})
|
216
|
+
post = { }
|
217
|
+
add_status_action(post, 'SETTLE')
|
218
|
+
add_forced_settlement(post, options)
|
219
|
+
add_transaction_id(post, authorization)
|
220
|
+
commit(:change_status, money, post)
|
221
|
+
end
|
222
|
+
|
223
|
+
def void(authorization, options = {})
|
224
|
+
post = {}
|
225
|
+
add_status_action(post, 'DELETE')
|
226
|
+
add_forced_settlement(post, options)
|
227
|
+
add_transaction_id(post, authorization)
|
228
|
+
commit(:change_status, nil, post)
|
229
|
+
end
|
230
|
+
|
231
|
+
def refund(money, identification, options = {})
|
232
|
+
post = {}
|
233
|
+
add_status_action(post, 'CREDIT')
|
234
|
+
add_forced_settlement(post, options)
|
235
|
+
add_transaction_id(post, identification)
|
236
|
+
commit(:change_status, money, post)
|
237
|
+
end
|
238
|
+
|
239
|
+
def credit(money, identification, options = {})
|
240
|
+
ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
|
241
|
+
refund(money, identification, options)
|
242
|
+
end
|
243
|
+
|
244
|
+
def status(order_id)
|
245
|
+
commit(:get_status, nil, :szOrderNumber => order_id)
|
246
|
+
end
|
247
|
+
|
248
|
+
private
|
249
|
+
|
250
|
+
def advanced?
|
251
|
+
@options[:advanced]
|
252
|
+
end
|
253
|
+
|
254
|
+
def add_forced_settlement(post, options)
|
255
|
+
post[:szForceSettlement] = options[:force_settlment] ? 1 : 0
|
256
|
+
end
|
257
|
+
|
258
|
+
def add_status_action(post, action)
|
259
|
+
post[:szDesiredStatus] = action
|
260
|
+
end
|
261
|
+
|
262
|
+
def commit(action, money, parameters)
|
263
|
+
response = parse(ssl_post(url_for(action), post_data(action, money, parameters)), action)
|
264
|
+
|
265
|
+
# Pass along the original transaction id in the case an update transaction
|
266
|
+
Response.new(response[:success], message_from(response, action), response,
|
267
|
+
:test => test?,
|
268
|
+
:authorization => response[:szTransactionFileName] || parameters[:szTransactionId],
|
269
|
+
:avs_result => { :code => response[:szAVSResponseCode] },
|
270
|
+
:cvv_result => response[:szCVV2ResponseCode]
|
271
|
+
)
|
272
|
+
end
|
273
|
+
|
274
|
+
def url_for(action)
|
275
|
+
result = test? ? self.test_url : self.live_url
|
276
|
+
result += advanced? && action == :authorization ? ADVANCED_PATH : BASIC_PATH
|
277
|
+
result + "?#{ACTIONS[action]}"
|
278
|
+
end
|
279
|
+
|
280
|
+
def add_credentials(params, action)
|
281
|
+
if action == :authorization
|
282
|
+
params[:SerialNumber] = @options[:login]
|
283
|
+
params[:DeveloperSerialNumber] = @options[:password]
|
284
|
+
else
|
285
|
+
params[:szSerialNumber] = @options[:login]
|
286
|
+
params[:szDeveloperSerialNumber] = @options[:password]
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
def add_amount(params, action, money)
|
291
|
+
if action == :authorization
|
292
|
+
params[:TransactionAmount] = amount(money)
|
293
|
+
else
|
294
|
+
params[:szAmount] = amount(money) if MONETARY_CHANGE_STATUSES.include?(params[:szDesiredStatus])
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
def parse(body, action)
|
299
|
+
case action
|
300
|
+
when :authorization
|
301
|
+
parse_authorization_response(body)
|
302
|
+
when :get_status
|
303
|
+
parse_status_response(body, [ :SerialNumber, :TransactionAmount, :TransactionStatusCode, :TransactionStatusMessage, :OrderNumber, :TransactionDateTime, :TransactionID, :ApprovalCode, :BatchNumber ])
|
304
|
+
else
|
305
|
+
parse_status_response(body, [ :SerialNumber, :TransactionAmount, :DesiredStatus, :StatusResponse, :StatusResponseMessage, :OrderNumber, :AuditID ])
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
def split_lines(body)
|
310
|
+
body.split(/[\r\n]+/)
|
311
|
+
end
|
312
|
+
|
313
|
+
def split_line(line)
|
314
|
+
line.split(/","/).collect { |key| key.sub(/"*([^"]*)"*/, '\1').strip; }
|
315
|
+
end
|
316
|
+
|
317
|
+
def authorize_response_map(body)
|
318
|
+
lines = split_lines(body)
|
319
|
+
keys, values = split_line(lines[0]), split_line(lines[1])
|
320
|
+
Hash[*keys.zip(values).flatten].symbolize_keys
|
321
|
+
end
|
322
|
+
|
323
|
+
def parse_authorization_response(body)
|
324
|
+
result = authorize_response_map(body)
|
325
|
+
result[:success] = (result[:szIsApproved] == '1')
|
326
|
+
result
|
327
|
+
end
|
328
|
+
|
329
|
+
def parse_status_response(body, response_keys)
|
330
|
+
lines = split_lines(body)
|
331
|
+
|
332
|
+
keys = [ :szSerialNumber, :szErrorCode, :szNumberRecords]
|
333
|
+
values = split_line(lines[0])[0..2]
|
334
|
+
|
335
|
+
result = Hash[*keys.zip(values).flatten]
|
336
|
+
|
337
|
+
result[:szErrorMessage] = ''
|
338
|
+
result[:success] = (result[:szErrorCode] == '0')
|
339
|
+
|
340
|
+
if result[:success]
|
341
|
+
lines[1..-1].each do |line|
|
342
|
+
values = split_line(line)
|
343
|
+
response_keys.each_with_index do |key, index|
|
344
|
+
result[key] = values[index]
|
345
|
+
end
|
346
|
+
end
|
347
|
+
else
|
348
|
+
result[:szErrorMessage] = lines[1]
|
349
|
+
end
|
350
|
+
result
|
351
|
+
end
|
352
|
+
|
353
|
+
def post_data(action, money, params = {})
|
354
|
+
add_credentials(params, action)
|
355
|
+
add_amount(params, action, money)
|
356
|
+
sorted_params = params.to_a.sort_by(&:to_s).reverse
|
357
|
+
sorted_params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
|
358
|
+
end
|
359
|
+
|
360
|
+
def add_transaction_id(post, transaction_id)
|
361
|
+
post[:szTransactionId] = transaction_id
|
362
|
+
end
|
363
|
+
|
364
|
+
def add_invoice(post, options)
|
365
|
+
post[:OrderNumber] = sanitize_order_id(options[:order_id])
|
366
|
+
post[:CustomerCode] = options[:customer].to_s.slice(0, 17)
|
367
|
+
post[:InvoiceNumber] = options[:invoice]
|
368
|
+
post[:OrderDescription] = options[:description]
|
369
|
+
|
370
|
+
if order_items = options[:items]
|
371
|
+
post[:OrderString] = order_items.collect { |item| "#{item[:sku]}~#{item[:description].tr('~', '-')}~#{item[:declared_value]}~#{item[:quantity]}~#{item[:taxable]}~~~~~~~~#{item[:tax_rate]}~||" }.join
|
372
|
+
else
|
373
|
+
post[:OrderString] = '1~None~0.00~0~N~||'
|
374
|
+
end
|
375
|
+
end
|
376
|
+
|
377
|
+
def add_creditcard(post, creditcard)
|
378
|
+
post[:AccountNumber] = creditcard.number
|
379
|
+
post[:Month] = creditcard.month
|
380
|
+
post[:Year] = creditcard.year
|
381
|
+
post[:CVV2] = creditcard.verification_value if creditcard.verification_value?
|
382
|
+
post[:SJName] = creditcard.name
|
383
|
+
end
|
384
|
+
|
385
|
+
def add_customer_data(post, options)
|
386
|
+
post[:Email] = options[:email]
|
387
|
+
end
|
388
|
+
|
389
|
+
def add_address(post, options)
|
390
|
+
if address = options[:billing_address] || options[:address]
|
391
|
+
post[:StreetAddress] = address[:address1]
|
392
|
+
post[:StreetAddress2] = address[:address2]
|
393
|
+
post[:City] = address[:city]
|
394
|
+
post[:State] = address[:state] || 'XX'
|
395
|
+
post[:ZipCode] = address[:zip]
|
396
|
+
post[:Country] = address[:country]
|
397
|
+
post[:Phone] = address[:phone]
|
398
|
+
post[:Fax] = address[:fax]
|
399
|
+
end
|
400
|
+
|
401
|
+
if address = options[:shipping_address]
|
402
|
+
post[:ShipToName] = address[:name]
|
403
|
+
post[:ShipToStreetAddress] = address[:address1]
|
404
|
+
post[:ShipToStreetAddress2] = address[:address2]
|
405
|
+
post[:ShipToCity] = address[:city]
|
406
|
+
post[:ShipToState] = address[:state] || 'XX'
|
407
|
+
post[:ShipToZipCode] = address[:zip]
|
408
|
+
post[:ShipToCountry] = address[:country]
|
409
|
+
post[:ShipToPhone] = address[:phone]
|
410
|
+
post[:ShipToFax] = address[:fax]
|
411
|
+
end
|
412
|
+
|
413
|
+
# The phone number for the shipping address is required
|
414
|
+
# Use the billing address phone number if a shipping address
|
415
|
+
# phone number wasn't provided
|
416
|
+
post[:ShipToPhone] = post[:Phone] if post[:ShipToPhone].blank?
|
417
|
+
end
|
418
|
+
|
419
|
+
def message_from(response, action)
|
420
|
+
case action
|
421
|
+
when :authorization
|
422
|
+
message_from_authorization(response)
|
423
|
+
when :get_status
|
424
|
+
message_from_status(response)
|
425
|
+
else
|
426
|
+
message_from_status(response)
|
427
|
+
end
|
428
|
+
end
|
429
|
+
|
430
|
+
def message_from_authorization(response)
|
431
|
+
if response[:success]
|
432
|
+
return SUCCESS_MESSAGE
|
433
|
+
else
|
434
|
+
return CARD_CODE_MESSAGES[response[:szCVV2ResponseCode]] if CARD_CODE_ERRORS.include?(response[:szCVV2ResponseCode])
|
435
|
+
return AVS_MESSAGES[response[:szAVSResponseMessage]] if AVS_ERRORS.include?(response[:szAVSResponseCode])
|
436
|
+
return RETURN_CODE_MESSAGES[response[:szReturnCode]] if response[:szReturnCode] != '1'
|
437
|
+
return response[:szAuthorizationDeclinedMessage]
|
438
|
+
end
|
439
|
+
end
|
440
|
+
|
441
|
+
def message_from_status(response)
|
442
|
+
response[:success] ? SUCCESS_MESSAGE : response[:szErrorMessage]
|
443
|
+
end
|
444
|
+
|
445
|
+
def sanitize_order_id(value)
|
446
|
+
value.to_s.gsub(/[^\w.]/, '')
|
447
|
+
end
|
448
|
+
end
|
449
|
+
end
|
450
|
+
end
|
@@ -0,0 +1,280 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'check.rb')
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
class SmartPs < Gateway #:nodoc:
|
6
|
+
|
7
|
+
##
|
8
|
+
# This is the base gateway for processors who use the smartPS processing system
|
9
|
+
|
10
|
+
self.abstract_class = true
|
11
|
+
|
12
|
+
def initialize(options = {})
|
13
|
+
requires!(options, :login, :password)
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
# Pass :store => true in the options to store the
|
18
|
+
# payment info at the gateway and get a generated
|
19
|
+
# customer_vault_id in the response.
|
20
|
+
# Pass :store => some_number_or_string to specify the
|
21
|
+
# customer_vault_id the gateway should use (make sure it's
|
22
|
+
# unique).
|
23
|
+
def authorize(money, creditcard, options = {})
|
24
|
+
post = {}
|
25
|
+
add_invoice(post, options)
|
26
|
+
add_payment_source(post, creditcard, options)
|
27
|
+
add_address(post, options[:billing_address] || options[:address])
|
28
|
+
add_address(post, options[:shipping_address], 'shipping')
|
29
|
+
add_customer_data(post, options)
|
30
|
+
add_currency(post, money, options)
|
31
|
+
add_taxes(post, options)
|
32
|
+
add_processor(post, options)
|
33
|
+
commit('auth', money, post)
|
34
|
+
end
|
35
|
+
|
36
|
+
def purchase(money, payment_source, options = {})
|
37
|
+
post = {}
|
38
|
+
add_invoice(post, options)
|
39
|
+
add_payment_source(post, payment_source, options)
|
40
|
+
add_address(post, options[:billing_address] || options[:address])
|
41
|
+
add_address(post, options[:shipping_address], 'shipping')
|
42
|
+
add_customer_data(post, options)
|
43
|
+
add_currency(post, money, options)
|
44
|
+
add_taxes(post, options)
|
45
|
+
add_processor(post, options)
|
46
|
+
add_eci(post, options)
|
47
|
+
commit('sale', money, post)
|
48
|
+
end
|
49
|
+
|
50
|
+
def capture(money, authorization, options = {})
|
51
|
+
post ={}
|
52
|
+
post[:transactionid] = authorization
|
53
|
+
commit('capture', money, post)
|
54
|
+
end
|
55
|
+
|
56
|
+
def void(authorization, options = {})
|
57
|
+
post ={}
|
58
|
+
post[:transactionid] = authorization
|
59
|
+
commit('void', nil, post)
|
60
|
+
end
|
61
|
+
|
62
|
+
def credit(money, payment_source, options = {})
|
63
|
+
post = {}
|
64
|
+
add_invoice(post, options)
|
65
|
+
add_payment_source(post, payment_source, options)
|
66
|
+
add_address(post, options[:billing_address] || options[:address])
|
67
|
+
add_customer_data(post, options)
|
68
|
+
add_sku(post, options)
|
69
|
+
add_currency(post, money, options)
|
70
|
+
add_processor(post, options)
|
71
|
+
commit('credit', money, post)
|
72
|
+
end
|
73
|
+
|
74
|
+
def refund(money, auth, options = {})
|
75
|
+
post = {}
|
76
|
+
add_transaction(post, auth)
|
77
|
+
commit('refund', money, post)
|
78
|
+
end
|
79
|
+
|
80
|
+
def verify(credit_card, options = {})
|
81
|
+
MultiResponse.run(:use_first_response) do |r|
|
82
|
+
r.process { authorize(100, credit_card, options) }
|
83
|
+
r.process(:ignore_result) { void(r.authorization, options) }
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# Update the values (such as CC expiration) stored at
|
88
|
+
# the gateway. The CC number must be supplied in the
|
89
|
+
# CreditCard object.
|
90
|
+
def update(vault_id, creditcard, options = {})
|
91
|
+
post = {}
|
92
|
+
post[:customer_vault] = 'update_customer'
|
93
|
+
add_customer_vault_id(post, vault_id)
|
94
|
+
add_creditcard(post, creditcard, options)
|
95
|
+
add_address(post, options[:billing_address] || options[:address])
|
96
|
+
add_customer_data(post, options)
|
97
|
+
|
98
|
+
commit(nil, nil, post)
|
99
|
+
end
|
100
|
+
|
101
|
+
# Amend an existing transaction
|
102
|
+
def amend(auth, options = {})
|
103
|
+
post = {}
|
104
|
+
add_invoice(post, options)
|
105
|
+
add_transaction(post, auth)
|
106
|
+
commit('update', nil, post)
|
107
|
+
end
|
108
|
+
|
109
|
+
def delete(vault_id)
|
110
|
+
post = {}
|
111
|
+
post[:customer_vault] = 'delete_customer'
|
112
|
+
add_customer_vault_id(post, vault_id)
|
113
|
+
commit(nil, nil, post)
|
114
|
+
end
|
115
|
+
|
116
|
+
# To match the other stored-value gateways, like TrustCommerce,
|
117
|
+
# store and unstore need to be defined
|
118
|
+
def store(payment_source, options = {})
|
119
|
+
post = {}
|
120
|
+
billing_id = options.delete(:billing_id).to_s || true
|
121
|
+
add_payment_source(post, payment_source, :store => billing_id)
|
122
|
+
add_address(post, options[:billing_address] || options[:address])
|
123
|
+
add_customer_data(post, options)
|
124
|
+
commit(nil, nil, post)
|
125
|
+
end
|
126
|
+
|
127
|
+
alias_method :unstore, :delete
|
128
|
+
|
129
|
+
private
|
130
|
+
|
131
|
+
def add_customer_data(post, options)
|
132
|
+
if options.has_key? :email
|
133
|
+
post[:email] = options[:email]
|
134
|
+
end
|
135
|
+
|
136
|
+
if options.has_key? :ip
|
137
|
+
post[:ipaddress] = options[:ip]
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def add_address(post, address, prefix='')
|
142
|
+
prefix +='_' unless prefix.blank?
|
143
|
+
unless address.blank? or address.values.blank?
|
144
|
+
post[prefix+'address1'] = address[:address1].to_s
|
145
|
+
post[prefix+'address2'] = address[:address2].to_s unless address[:address2].blank?
|
146
|
+
post[prefix+'company'] = address[:company].to_s
|
147
|
+
post[prefix+'phone'] = address[:phone].to_s
|
148
|
+
post[prefix+'zip'] = address[:zip].to_s
|
149
|
+
post[prefix+'city'] = address[:city].to_s
|
150
|
+
post[prefix+'country'] = address[:country].to_s
|
151
|
+
post[prefix+'state'] = address[:state].blank? ? 'n/a' : address[:state]
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def add_currency(post, money, options)
|
156
|
+
post[:currency] = options[:currency] || currency(money)
|
157
|
+
end
|
158
|
+
|
159
|
+
def add_taxes(post, options)
|
160
|
+
post[:tax] = amount(options[:tax])
|
161
|
+
end
|
162
|
+
|
163
|
+
def add_processor(post, options)
|
164
|
+
post[:processor] = options[:processor] unless options[:processor].nil?
|
165
|
+
end
|
166
|
+
|
167
|
+
def add_invoice(post, options)
|
168
|
+
post[:orderid] = options[:order_id].to_s.gsub(/[^\w.]/, '')
|
169
|
+
end
|
170
|
+
|
171
|
+
def add_payment_source(params, source, options={})
|
172
|
+
case determine_funding_source(source)
|
173
|
+
when :vault then add_customer_vault_id(params, source)
|
174
|
+
when :credit_card then add_creditcard(params, source, options)
|
175
|
+
when :check then add_check(params, source, options)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def add_customer_vault_id(params, vault_id)
|
180
|
+
params[:customer_vault_id] = vault_id
|
181
|
+
end
|
182
|
+
|
183
|
+
def add_creditcard(post, creditcard, options)
|
184
|
+
if options[:store]
|
185
|
+
post[:customer_vault] = 'add_customer'
|
186
|
+
post[:customer_vault_id] = options[:store] unless options[:store] == true
|
187
|
+
end
|
188
|
+
post[:ccnumber] = creditcard.number
|
189
|
+
post[:cvv] = creditcard.verification_value if creditcard.verification_value?
|
190
|
+
post[:ccexp] = expdate(creditcard)
|
191
|
+
post[:firstname] = creditcard.first_name
|
192
|
+
post[:lastname] = creditcard.last_name
|
193
|
+
end
|
194
|
+
|
195
|
+
def add_check(post, check, options)
|
196
|
+
if options[:store]
|
197
|
+
post[:customer_vault] = 'add_customer'
|
198
|
+
post[:customer_vault_id] = options[:store] unless options[:store] == true
|
199
|
+
end
|
200
|
+
|
201
|
+
post[:payment] = 'check' # Set transaction to ACH
|
202
|
+
post[:checkname] = check.name # The name on the customer's Checking Account
|
203
|
+
post[:checkaba] = check.routing_number # The customer's bank routing number
|
204
|
+
post[:checkaccount] = check.account_number # The customer's account number
|
205
|
+
post[:account_holder_type] = check.account_holder_type # The customer's type of ACH account
|
206
|
+
post[:account_type] = check.account_type # The customer's type of ACH account
|
207
|
+
end
|
208
|
+
|
209
|
+
def add_sku(post, options)
|
210
|
+
post['product_sku_#'] = options[:sku] || options['product_sku_#']
|
211
|
+
end
|
212
|
+
|
213
|
+
def add_transaction(post, auth)
|
214
|
+
post[:transactionid] = auth
|
215
|
+
end
|
216
|
+
|
217
|
+
def add_eci(post, options)
|
218
|
+
post[:billing_method] = options[:eci] if options[:eci]
|
219
|
+
end
|
220
|
+
|
221
|
+
def parse(body)
|
222
|
+
results = {}
|
223
|
+
body.split(/&/).each do |pair|
|
224
|
+
key, val = pair.split(/=/)
|
225
|
+
results[key] = val
|
226
|
+
end
|
227
|
+
|
228
|
+
results
|
229
|
+
end
|
230
|
+
|
231
|
+
def commit(action, money, parameters)
|
232
|
+
parameters[:amount] = localized_amount(money, parameters[:currency] || default_currency) if money
|
233
|
+
response = parse(ssl_post(self.live_url, post_data(action, parameters)))
|
234
|
+
Response.new(response['response'] == '1', message_from(response), response,
|
235
|
+
:authorization => (response['transactionid'] || response['customer_vault_id']),
|
236
|
+
:test => test?,
|
237
|
+
:cvv_result => response['cvvresponse'],
|
238
|
+
:avs_result => { :code => response['avsresponse'] }
|
239
|
+
)
|
240
|
+
end
|
241
|
+
|
242
|
+
def expdate(creditcard)
|
243
|
+
year = sprintf('%.04i', creditcard.year)
|
244
|
+
month = sprintf('%.02i', creditcard.month)
|
245
|
+
|
246
|
+
"#{month}#{year[-2..-1]}"
|
247
|
+
end
|
248
|
+
|
249
|
+
def message_from(response)
|
250
|
+
case response['responsetext']
|
251
|
+
when 'SUCCESS', 'Approved', nil # This is dubious, but responses from UPDATE are nil.
|
252
|
+
'This transaction has been approved'
|
253
|
+
when 'DECLINE'
|
254
|
+
'This transaction has been declined'
|
255
|
+
else
|
256
|
+
response['responsetext']
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
def post_data(action, parameters = {})
|
261
|
+
post = {}
|
262
|
+
post[:username] = @options[:login]
|
263
|
+
post[:password] = @options[:password]
|
264
|
+
post[:type] = action if action
|
265
|
+
|
266
|
+
request = post.merge(parameters).map { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
|
267
|
+
request
|
268
|
+
end
|
269
|
+
|
270
|
+
def determine_funding_source(source)
|
271
|
+
case
|
272
|
+
when source.is_a?(String) then :vault
|
273
|
+
when CreditCard.card_companies.include?(card_brand(source)) then :credit_card
|
274
|
+
when card_brand(source) == 'check' then :check
|
275
|
+
else raise ArgumentError, 'Unsupported funding source provided'
|
276
|
+
end
|
277
|
+
end
|
278
|
+
end
|
279
|
+
end
|
280
|
+
end
|