start_activemerchant 1.50.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +1769 -0
- data/CONTRIBUTORS +540 -0
- data/MIT-LICENSE +20 -0
- data/README.md +226 -0
- data/lib/active_merchant.rb +67 -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 +98 -0
- data/lib/active_merchant/billing/base.rb +72 -0
- data/lib/active_merchant/billing/check.rb +76 -0
- data/lib/active_merchant/billing/compatibility.rb +120 -0
- data/lib/active_merchant/billing/credit_card.rb +404 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +24 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +195 -0
- data/lib/active_merchant/billing/cvv_result.rb +38 -0
- data/lib/active_merchant/billing/gateway.rb +291 -0
- data/lib/active_merchant/billing/gateways.rb +14 -0
- data/lib/active_merchant/billing/gateways/allied_wallet.rb +203 -0
- data/lib/active_merchant/billing/gateways/app55.rb +176 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +510 -0
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +417 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +976 -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/bank_frick.rb +225 -0
- data/lib/active_merchant/billing/gateways/banwire.rb +105 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq.rb +314 -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 +192 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +389 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +58 -0
- data/lib/active_merchant/billing/gateways/blue_pay.rb +506 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +140 -0
- data/lib/active_merchant/billing/gateways/borgun.rb +211 -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 +9 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +574 -0
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +20 -0
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +189 -0
- data/lib/active_merchant/billing/gateways/card_save.rb +23 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +238 -0
- data/lib/active_merchant/billing/gateways/cashnet.rb +202 -0
- data/lib/active_merchant/billing/gateways/cc5.rb +201 -0
- data/lib/active_merchant/billing/gateways/cecabank.rb +229 -0
- data/lib/active_merchant/billing/gateways/cenpos.rb +262 -0
- data/lib/active_merchant/billing/gateways/certo_direct.rb +278 -0
- data/lib/active_merchant/billing/gateways/checkout.rb +216 -0
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +200 -0
- data/lib/active_merchant/billing/gateways/commercegate.rb +143 -0
- data/lib/active_merchant/billing/gateways/conekta.rb +210 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +720 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +600 -0
- data/lib/active_merchant/billing/gateways/dibs.rb +206 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +219 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +348 -0
- data/lib/active_merchant/billing/gateways/epay.rb +274 -0
- data/lib/active_merchant/billing/gateways/evo_ca.rb +308 -0
- data/lib/active_merchant/billing/gateways/eway.rb +214 -0
- data/lib/active_merchant/billing/gateways/eway_managed.rb +291 -0
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +522 -0
- data/lib/active_merchant/billing/gateways/exact.rb +227 -0
- data/lib/active_merchant/billing/gateways/ezic.rb +206 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +213 -0
- data/lib/active_merchant/billing/gateways/federated_canada.rb +160 -0
- data/lib/active_merchant/billing/gateways/finansbank.rb +23 -0
- data/lib/active_merchant/billing/gateways/first_giving.rb +143 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +160 -0
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +413 -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/garanti.rb +261 -0
- data/lib/active_merchant/billing/gateways/global_transport.rb +179 -0
- data/lib/active_merchant/billing/gateways/hdfc.rb +207 -0
- data/lib/active_merchant/billing/gateways/hps.rb +287 -0
- data/lib/active_merchant/billing/gateways/iats_payments.rb +277 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +246 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +13 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +29 -0
- data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +66 -0
- data/lib/active_merchant/billing/gateways/inspire.rb +219 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +163 -0
- data/lib/active_merchant/billing/gateways/ipp.rb +175 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +457 -0
- data/lib/active_merchant/billing/gateways/itransact.rb +448 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +275 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +438 -0
- data/lib/active_merchant/billing/gateways/litle.rb +345 -0
- data/lib/active_merchant/billing/gateways/maxipago.rb +197 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +170 -0
- data/lib/active_merchant/billing/gateways/merchant_one.rb +114 -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 +268 -0
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +195 -0
- data/lib/active_merchant/billing/gateways/mercury.rb +326 -0
- data/lib/active_merchant/billing/gateways/metrics_global.rb +303 -0
- data/lib/active_merchant/billing/gateways/migs.rb +280 -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 +219 -0
- data/lib/active_merchant/billing/gateways/monei.rb +307 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +309 -0
- data/lib/active_merchant/billing/gateways/moneris_us.rb +298 -0
- data/lib/active_merchant/billing/gateways/money_movers.rb +152 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +290 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +198 -0
- data/lib/active_merchant/billing/gateways/netaxept.rb +181 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +224 -0
- data/lib/active_merchant/billing/gateways/netpay.rb +223 -0
- data/lib/active_merchant/billing/gateways/network_merchants.rb +242 -0
- data/lib/active_merchant/billing/gateways/nmi.rb +256 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +435 -0
- data/lib/active_merchant/billing/gateways/omise.rb +319 -0
- data/lib/active_merchant/billing/gateways/openpay.rb +194 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +314 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +834 -0
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +47 -0
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +207 -0
- data/lib/active_merchant/billing/gateways/pago_facil.rb +122 -0
- data/lib/active_merchant/billing/gateways/pay_conex.rb +246 -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_secure.rb +112 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +188 -0
- data/lib/active_merchant/billing/gateways/payex.rb +412 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +308 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +220 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +39 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +224 -0
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +15 -0
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +21 -0
- data/lib/active_merchant/billing/gateways/payment_express.rb +353 -0
- data/lib/active_merchant/billing/gateways/paymill.rb +282 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +129 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +679 -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 +264 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
- data/lib/active_merchant/billing/gateways/payscout.rb +162 -0
- data/lib/active_merchant/billing/gateways/paystation.rb +199 -0
- data/lib/active_merchant/billing/gateways/payu_in.rb +247 -0
- data/lib/active_merchant/billing/gateways/payway.rb +207 -0
- data/lib/active_merchant/billing/gateways/pin.rb +207 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +283 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +216 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +303 -0
- data/lib/active_merchant/billing/gateways/qbms.rb +292 -0
- data/lib/active_merchant/billing/gateways/quantum.rb +276 -0
- data/lib/active_merchant/billing/gateways/quickbooks.rb +280 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +26 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +188 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +240 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +227 -0
- data/lib/active_merchant/billing/gateways/qvalent.rb +179 -0
- data/lib/active_merchant/billing/gateways/realex.rb +298 -0
- data/lib/active_merchant/billing/gateways/redsys.rb +406 -0
- data/lib/active_merchant/billing/gateways/s5.rb +226 -0
- data/lib/active_merchant/billing/gateways/sage.rb +173 -0
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +89 -0
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +115 -0
- data/lib/active_merchant/billing/gateways/sage/sage_vault.rb +149 -0
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +399 -0
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +143 -0
- data/lib/active_merchant/billing/gateways/secure_net.rb +263 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +201 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +281 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +105 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +451 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +283 -0
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +247 -0
- data/lib/active_merchant/billing/gateways/stripe.rb +489 -0
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +157 -0
- data/lib/active_merchant/billing/gateways/tns.rb +227 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +126 -0
- data/lib/active_merchant/billing/gateways/transax.rb +23 -0
- data/lib/active_merchant/billing/gateways/transnational.rb +10 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +416 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +25 -0
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1516 -0
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +259 -0
- data/lib/active_merchant/billing/gateways/vanco.rb +280 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +225 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +183 -0
- data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
- data/lib/active_merchant/billing/gateways/wepay.rb +205 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +420 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +331 -0
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +204 -0
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +181 -0
- data/lib/active_merchant/billing/model.rb +30 -0
- data/lib/active_merchant/billing/network_tokenization_credit_card.rb +24 -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 +172 -0
- data/lib/active_merchant/country.rb +332 -0
- data/lib/active_merchant/empty.rb +20 -0
- data/lib/active_merchant/errors.rb +35 -0
- data/lib/active_merchant/network_connection_retries.rb +79 -0
- data/lib/active_merchant/post_data.rb +24 -0
- data/lib/active_merchant/posts_data.rb +84 -0
- data/lib/active_merchant/version.rb +3 -0
- data/lib/activemerchant.rb +1 -0
- data/lib/certs/cacert.pem +3866 -0
- data/lib/support/gateway_support.rb +71 -0
- data/lib/support/outbound_hosts.rb +28 -0
- data/lib/support/ssl_verify.rb +93 -0
- metadata +387 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__),'smart_ps.rb')
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
class TransaxGateway < SmartPs
|
6
|
+
self.live_url = self.test_url = 'https://secure.nelixtransax.net/api/transact.php'
|
7
|
+
|
8
|
+
# The countries the gateway supports merchants from as 2 digit ISO country codes
|
9
|
+
self.supported_countries = ['US']
|
10
|
+
|
11
|
+
# The card types supported by the payment gateway
|
12
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
13
|
+
|
14
|
+
# The homepage URL of the gateway
|
15
|
+
self.homepage_url = 'https://www.nelixtransax.com/'
|
16
|
+
|
17
|
+
# The name of the gateway
|
18
|
+
self.display_name = 'NELiX TransaX'
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,416 @@
|
|
1
|
+
begin
|
2
|
+
require 'tclink'
|
3
|
+
rescue LoadError
|
4
|
+
# Falls back to an SSL post to TrustCommerce
|
5
|
+
end
|
6
|
+
|
7
|
+
module ActiveMerchant #:nodoc:
|
8
|
+
module Billing #:nodoc:
|
9
|
+
# TO USE:
|
10
|
+
# First, make sure you have everything setup correctly and all of your dependencies in place with:
|
11
|
+
#
|
12
|
+
# require 'rubygems'
|
13
|
+
# require 'active_merchant'
|
14
|
+
#
|
15
|
+
# ActiveMerchant expects amounts to be Integer values in cents
|
16
|
+
#
|
17
|
+
# tendollar = 1000
|
18
|
+
#
|
19
|
+
# Next, create a credit card object using a TC approved test card.
|
20
|
+
#
|
21
|
+
# creditcard = ActiveMerchant::Billing::CreditCard.new(
|
22
|
+
# :number => '4111111111111111',
|
23
|
+
# :month => 8,
|
24
|
+
# :year => 2006,
|
25
|
+
# :first_name => 'Longbob',
|
26
|
+
# :last_name => 'Longsen'
|
27
|
+
# )
|
28
|
+
#
|
29
|
+
# To finish setting up, create the active_merchant object you will be using, with the TrustCommerce gateway. If you have a
|
30
|
+
# functional TrustCommerce account, replace login and password with your account info. Otherwise the defaults will work for
|
31
|
+
# testing.
|
32
|
+
#
|
33
|
+
# gateway = ActiveMerchant::Billing::Base.gateway(:trust_commerce).new(:login => "TestMerchant", :password => "password")
|
34
|
+
#
|
35
|
+
# Now we are ready to process our transaction
|
36
|
+
#
|
37
|
+
# response = gateway.purchase(tendollar, creditcard)
|
38
|
+
#
|
39
|
+
# Sending a transaction to TrustCommerce with active_merchant returns a Response object, which consistently allows you to:
|
40
|
+
#
|
41
|
+
# 1) Check whether the transaction was successful
|
42
|
+
#
|
43
|
+
# response.success?
|
44
|
+
#
|
45
|
+
# 2) Retrieve any message returned by TrustCommerce, either a "transaction was successful" note or an explanation of why the
|
46
|
+
# transaction was rejected.
|
47
|
+
#
|
48
|
+
# response.message
|
49
|
+
#
|
50
|
+
# 3) Retrieve and store the unique transaction ID returned by Trust Commerece, for use in referencing the transaction in the future.
|
51
|
+
#
|
52
|
+
# response.params["transid"]
|
53
|
+
#
|
54
|
+
# For higher performance and failover with the TrustCommerceGateway you can install the TCLink library from http://www.trustcommerce.com/tclink.html.
|
55
|
+
# Follow the instructions available there to get it working on your system. ActiveMerchant will automatically use tclink if available.
|
56
|
+
#
|
57
|
+
# The TCLink library has the following added benefits:
|
58
|
+
# * Good transaction times. Transaction duration under 1.2 seconds are common.
|
59
|
+
# * Fail-over to geographically distributed servers for extreme reliability
|
60
|
+
#
|
61
|
+
# Once it is installed, you should be able to make sure
|
62
|
+
# that it is visible to your ruby install by opening irb and typing "require 'tclink'", which should return "true".
|
63
|
+
#
|
64
|
+
# This should be enough to get you started with Trust Commerce and active_merchant. For further information, review the methods
|
65
|
+
# below and the rest of active_merchant's documentation, as well as Trust Commerce's user and developer documentation.
|
66
|
+
|
67
|
+
class TrustCommerceGateway < Gateway
|
68
|
+
self.live_url = self.test_url = 'https://vault.trustcommerce.com/trans/'
|
69
|
+
|
70
|
+
SUCCESS_TYPES = ["approved", "accepted"]
|
71
|
+
|
72
|
+
DECLINE_CODES = {
|
73
|
+
"decline" => "The credit card was declined",
|
74
|
+
"avs" => "AVS failed; the address entered does not match the billing address on file at the bank",
|
75
|
+
"cvv" => "CVV failed; the number provided is not the correct verification number for the card",
|
76
|
+
"call" => "The card must be authorized manually over the phone",
|
77
|
+
"expiredcard" => "Issuer was not certified for card verification",
|
78
|
+
"carderror" => "Card number is invalid",
|
79
|
+
"authexpired" => "Attempt to postauth an expired (more than 14 days old) preauth",
|
80
|
+
"fraud" => "CrediGuard fraud score was below requested threshold",
|
81
|
+
"blacklist" => "CrediGuard blacklist value was triggered",
|
82
|
+
"velocity" => "CrediGuard velocity control value was triggered",
|
83
|
+
"dailylimit" => "Daily limit in transaction count or amount as been reached",
|
84
|
+
"weeklylimit" => "Weekly limit in transaction count or amount as been reached",
|
85
|
+
"monthlylimit" => "Monthly limit in transaction count or amount as been reached"
|
86
|
+
}
|
87
|
+
|
88
|
+
BADDATA_CODES = {
|
89
|
+
"missingfields" => "One or more parameters required for this transaction type were not sent",
|
90
|
+
"extrafields" => "Parameters not allowed for this transaction type were sent",
|
91
|
+
"badformat" => "A field was improperly formatted, such as non-digit characters in a number field",
|
92
|
+
"badlength" => "A field was longer or shorter than the server allows",
|
93
|
+
"merchantcantaccept" => "The merchant can't accept data passed in this field",
|
94
|
+
"mismatch" => "Data in one of the offending fields did not cross-check with the other offending field"
|
95
|
+
}
|
96
|
+
|
97
|
+
ERROR_CODES = {
|
98
|
+
"cantconnect" => "Couldn't connect to the TrustCommerce gateway",
|
99
|
+
"dnsfailure" => "The TCLink software was unable to resolve DNS hostnames",
|
100
|
+
"linkfailure" => "The connection was established, but was severed before the transaction could complete",
|
101
|
+
"failtoprocess" => "The bank servers are offline and unable to authorize transactions"
|
102
|
+
}
|
103
|
+
|
104
|
+
TEST_LOGIN = 'TestMerchant'
|
105
|
+
TEST_PASSWORD = 'password'
|
106
|
+
|
107
|
+
self.money_format = :cents
|
108
|
+
self.supported_cardtypes = [:visa, :master, :discover, :american_express, :diners_club, :jcb]
|
109
|
+
self.supported_countries = ['US']
|
110
|
+
self.homepage_url = 'http://www.trustcommerce.com/'
|
111
|
+
self.display_name = 'TrustCommerce'
|
112
|
+
|
113
|
+
def self.tclink?
|
114
|
+
defined?(TCLink)
|
115
|
+
end
|
116
|
+
|
117
|
+
# Creates a new TrustCommerceGateway
|
118
|
+
#
|
119
|
+
# The gateway requires that a valid login and password be passed
|
120
|
+
# in the +options+ hash.
|
121
|
+
#
|
122
|
+
# ==== Options
|
123
|
+
#
|
124
|
+
# * <tt>:login</tt> -- The TrustCommerce account login.
|
125
|
+
# * <tt>:password</tt> -- The TrustCommerce account password.
|
126
|
+
# * <tt>:test => +true+ or +false+</tt> -- Perform test transactions
|
127
|
+
#
|
128
|
+
# ==== Test Account Credentials
|
129
|
+
# * <tt>:login</tt> -- TestMerchant
|
130
|
+
# * <tt>:password</tt> -- password
|
131
|
+
def initialize(options = {})
|
132
|
+
requires!(options, :login, :password)
|
133
|
+
|
134
|
+
super
|
135
|
+
end
|
136
|
+
|
137
|
+
def tclink?
|
138
|
+
self.class.tclink?
|
139
|
+
end
|
140
|
+
|
141
|
+
def test?
|
142
|
+
((@options[:login] == TEST_LOGIN && @options[:password] == TEST_PASSWORD) || super)
|
143
|
+
end
|
144
|
+
|
145
|
+
# authorize() is the first half of the preauth(authorize)/postauth(capture) model. The TC API docs call this
|
146
|
+
# preauth, we preserve active_merchant's nomenclature of authorize() for consistency with the rest of the library. This
|
147
|
+
# method simply checks to make sure funds are available for a transaction, and returns a transid that can be used later to
|
148
|
+
# postauthorize (capture) the funds.
|
149
|
+
|
150
|
+
def authorize(money, creditcard_or_billing_id, options = {})
|
151
|
+
parameters = {
|
152
|
+
:amount => amount(money),
|
153
|
+
}
|
154
|
+
|
155
|
+
add_order_id(parameters, options)
|
156
|
+
add_customer_data(parameters, options)
|
157
|
+
add_payment_source(parameters, creditcard_or_billing_id)
|
158
|
+
add_addresses(parameters, options)
|
159
|
+
commit('preauth', parameters)
|
160
|
+
end
|
161
|
+
|
162
|
+
# purchase() is a simple sale. This is one of the most common types of transactions, and is extremely simple. All that you need
|
163
|
+
# to process a purchase are an amount in cents or a money object and a creditcard object or billingid string.
|
164
|
+
def purchase(money, creditcard_or_billing_id, options = {})
|
165
|
+
parameters = {
|
166
|
+
:amount => amount(money),
|
167
|
+
}
|
168
|
+
|
169
|
+
add_order_id(parameters, options)
|
170
|
+
add_customer_data(parameters, options)
|
171
|
+
add_payment_source(parameters, creditcard_or_billing_id)
|
172
|
+
add_addresses(parameters, options)
|
173
|
+
commit('sale', parameters)
|
174
|
+
end
|
175
|
+
|
176
|
+
# capture() is the second half of the preauth(authorize)/postauth(capture) model. The TC API docs call this
|
177
|
+
# postauth, we preserve active_merchant's nomenclature of capture() for consistency with the rest of the library. To process
|
178
|
+
# a postauthorization with TC, you need an amount in cents or a money object, and a TC transid.
|
179
|
+
def capture(money, authorization, options = {})
|
180
|
+
parameters = {
|
181
|
+
:amount => amount(money),
|
182
|
+
:transid => authorization,
|
183
|
+
}
|
184
|
+
|
185
|
+
commit('postauth', parameters)
|
186
|
+
end
|
187
|
+
|
188
|
+
# refund() allows you to return money to a card that was previously billed. You need to supply the amount, in cents or a money object,
|
189
|
+
# that you want to refund, and a TC transid for the transaction that you are refunding.
|
190
|
+
def refund(money, identification, options = {})
|
191
|
+
parameters = {
|
192
|
+
:amount => amount(money),
|
193
|
+
:transid => identification
|
194
|
+
}
|
195
|
+
|
196
|
+
commit('credit', parameters)
|
197
|
+
end
|
198
|
+
|
199
|
+
def credit(money, identification, options = {})
|
200
|
+
ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
|
201
|
+
refund(money, identification, options)
|
202
|
+
end
|
203
|
+
|
204
|
+
# void() clears an existing authorization and releases the reserved fund
|
205
|
+
# s back to the cardholder. The TC API refers to this transaction as a
|
206
|
+
# reversal. After voiding, you will no longer be able to capture funds
|
207
|
+
# from this authorization. TrustCommerce seems to always return a status
|
208
|
+
# of "accepted" even if the transid you are trying to deauthorize has
|
209
|
+
# already been captured. Note: Your account needs to be configured by
|
210
|
+
# TrustCommerce to allow for reversal transactions before you can use this
|
211
|
+
# method.
|
212
|
+
#
|
213
|
+
# NOTE: AMEX preauth's cannot be reversed. If you want to clear it more
|
214
|
+
# quickly than the automatic expiration (7-10 days), you will have to
|
215
|
+
# capture it and then immediately issue a credit for the same amount
|
216
|
+
# which should clear the customers credit card with 48 hours according to
|
217
|
+
# TC.
|
218
|
+
def void(authorization, options = {})
|
219
|
+
parameters = {
|
220
|
+
:transid => authorization,
|
221
|
+
}
|
222
|
+
|
223
|
+
commit('reversal', parameters)
|
224
|
+
end
|
225
|
+
|
226
|
+
# recurring() a TrustCommerce account that is activated for Citatdel, TrustCommerce's
|
227
|
+
# hosted customer billing info database.
|
228
|
+
#
|
229
|
+
# Recurring billing uses the same TC action as a plain-vanilla 'store', but we have a separate method for clarity. It can be called
|
230
|
+
# like store, with the addition of a required 'periodicity' parameter:
|
231
|
+
#
|
232
|
+
# The parameter :periodicity should be specified as either :bimonthly, :monthly, :biweekly, :weekly, :yearly or :daily
|
233
|
+
#
|
234
|
+
# gateway.recurring(tendollar, creditcard, :periodicity => :weekly)
|
235
|
+
#
|
236
|
+
# You can optionally specify how long you want payments to continue using 'payments'
|
237
|
+
def recurring(money, creditcard, options = {})
|
238
|
+
ActiveMerchant.deprecated RECURRING_DEPRECATION_MESSAGE
|
239
|
+
|
240
|
+
requires!(options, [:periodicity, :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily] )
|
241
|
+
|
242
|
+
cycle = case options[:periodicity]
|
243
|
+
when :monthly
|
244
|
+
'1m'
|
245
|
+
when :bimonthly
|
246
|
+
'2m'
|
247
|
+
when :weekly
|
248
|
+
'1w'
|
249
|
+
when :biweekly
|
250
|
+
'2w'
|
251
|
+
when :yearly
|
252
|
+
'1y'
|
253
|
+
when :daily
|
254
|
+
'1d'
|
255
|
+
end
|
256
|
+
|
257
|
+
parameters = {
|
258
|
+
:amount => amount(money),
|
259
|
+
:cycle => cycle,
|
260
|
+
:verify => options[:verify] || 'y',
|
261
|
+
:billingid => options[:billingid] || nil,
|
262
|
+
:payments => options[:payments] || nil,
|
263
|
+
}
|
264
|
+
|
265
|
+
add_creditcard(parameters, creditcard)
|
266
|
+
|
267
|
+
commit('store', parameters)
|
268
|
+
end
|
269
|
+
|
270
|
+
# store() requires a TrustCommerce account that is activated for Citatdel. You can call it with a credit card and a billing ID
|
271
|
+
# you would like to use to reference the stored credit card info for future captures. Use 'verify' to specify whether you want
|
272
|
+
# to simply store the card in the DB, or you want TC to verify the data first.
|
273
|
+
|
274
|
+
def store(creditcard, options = {})
|
275
|
+
parameters = {
|
276
|
+
:verify => options[:verify] || 'y',
|
277
|
+
:billingid => options[:billingid] || options[:billing_id] || nil,
|
278
|
+
}
|
279
|
+
|
280
|
+
add_creditcard(parameters, creditcard)
|
281
|
+
add_addresses(parameters, options)
|
282
|
+
commit('store', parameters)
|
283
|
+
end
|
284
|
+
|
285
|
+
# To unstore a creditcard stored in Citadel using store() or recurring(), all that is required is the billing id. When you run
|
286
|
+
# unstore() the information will be removed and a Response object will be returned indicating the success of the action.
|
287
|
+
def unstore(identification, options = {})
|
288
|
+
parameters = {
|
289
|
+
:billingid => identification,
|
290
|
+
}
|
291
|
+
|
292
|
+
commit('unstore', parameters)
|
293
|
+
end
|
294
|
+
|
295
|
+
private
|
296
|
+
def add_payment_source(params, source)
|
297
|
+
if source.is_a?(String)
|
298
|
+
add_billing_id(params, source)
|
299
|
+
else
|
300
|
+
add_creditcard(params, source)
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
def add_creditcard(params, creditcard)
|
305
|
+
params[:media] = "cc"
|
306
|
+
params[:name] = creditcard.name
|
307
|
+
params[:cc] = creditcard.number
|
308
|
+
params[:exp] = expdate(creditcard)
|
309
|
+
params[:cvv] = creditcard.verification_value if creditcard.verification_value?
|
310
|
+
end
|
311
|
+
|
312
|
+
def add_order_id(params, options)
|
313
|
+
params[:ticket] = options[:order_id] unless options[:order_id].blank?
|
314
|
+
end
|
315
|
+
|
316
|
+
def add_billing_id(params, billingid)
|
317
|
+
params[:billingid] = billingid
|
318
|
+
end
|
319
|
+
|
320
|
+
def add_customer_data(params, options)
|
321
|
+
params[:email] = options[:email] unless options[:email].blank?
|
322
|
+
params[:ip] = options[:ip] unless options[:ip].blank?
|
323
|
+
end
|
324
|
+
|
325
|
+
def add_addresses(params, options)
|
326
|
+
address = options[:billing_address] || options[:address]
|
327
|
+
|
328
|
+
if address
|
329
|
+
params[:address1] = address[:address1] unless address[:address1].blank?
|
330
|
+
params[:address2] = address[:address2] unless address[:address2].blank?
|
331
|
+
params[:city] = address[:city] unless address[:city].blank?
|
332
|
+
params[:state] = address[:state] unless address[:state].blank?
|
333
|
+
params[:zip] = address[:zip] unless address[:zip].blank?
|
334
|
+
params[:country] = address[:country] unless address[:country].blank?
|
335
|
+
params[:avs] = 'n'
|
336
|
+
end
|
337
|
+
|
338
|
+
if shipping_address = options[:shipping_address]
|
339
|
+
params[:shipto_name] = shipping_address[:name] unless shipping_address[:name].blank?
|
340
|
+
params[:shipto_address1] = shipping_address[:address1] unless shipping_address[:address1].blank?
|
341
|
+
params[:shipto_address2] = shipping_address[:address2] unless shipping_address[:address2].blank?
|
342
|
+
params[:shipto_city] = shipping_address[:city] unless shipping_address[:city].blank?
|
343
|
+
params[:shipto_state] = shipping_address[:state] unless shipping_address[:state].blank?
|
344
|
+
params[:shipto_zip] = shipping_address[:zip] unless shipping_address[:zip].blank?
|
345
|
+
params[:shipto_country] = shipping_address[:country] unless shipping_address[:country].blank?
|
346
|
+
end
|
347
|
+
end
|
348
|
+
|
349
|
+
def clean_and_stringify_params(parameters)
|
350
|
+
# TCLink wants us to send a hash with string keys, and activemerchant pushes everything around with
|
351
|
+
# symbol keys. Before sending our input to TCLink, we convert all our keys to strings and dump the symbol keys.
|
352
|
+
# We also remove any pairs with nil values, as these confuse TCLink.
|
353
|
+
parameters.keys.reverse.each do |key|
|
354
|
+
if parameters[key]
|
355
|
+
parameters[key.to_s] = parameters[key]
|
356
|
+
end
|
357
|
+
parameters.delete(key)
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
361
|
+
def post_data(parameters)
|
362
|
+
parameters.collect { |key, value| "#{key}=#{ CGI.escape(value.to_s)}" }.join("&")
|
363
|
+
end
|
364
|
+
|
365
|
+
def commit(action, parameters)
|
366
|
+
parameters[:custid] = @options[:login]
|
367
|
+
parameters[:password] = @options[:password]
|
368
|
+
parameters[:demo] = test? ? 'y' : 'n'
|
369
|
+
parameters[:action] = action
|
370
|
+
|
371
|
+
clean_and_stringify_params(parameters)
|
372
|
+
|
373
|
+
data = if tclink?
|
374
|
+
TCLink.send(parameters)
|
375
|
+
else
|
376
|
+
parse( ssl_post(self.live_url, post_data(parameters)) )
|
377
|
+
end
|
378
|
+
|
379
|
+
# to be considered successful, transaction status must be either "approved" or "accepted"
|
380
|
+
success = SUCCESS_TYPES.include?(data["status"])
|
381
|
+
message = message_from(data)
|
382
|
+
Response.new(success, message, data,
|
383
|
+
:test => test?,
|
384
|
+
:authorization => data["transid"],
|
385
|
+
:cvv_result => data["cvv"],
|
386
|
+
:avs_result => { :code => data["avs"] }
|
387
|
+
)
|
388
|
+
end
|
389
|
+
|
390
|
+
def parse(body)
|
391
|
+
results = {}
|
392
|
+
|
393
|
+
body.split(/\n/).each do |pair|
|
394
|
+
key,val = pair.split(/=/)
|
395
|
+
results[key] = val
|
396
|
+
end
|
397
|
+
|
398
|
+
results
|
399
|
+
end
|
400
|
+
|
401
|
+
def message_from(data)
|
402
|
+
case data["status"]
|
403
|
+
when "decline"
|
404
|
+
return DECLINE_CODES[data["declinetype"]]
|
405
|
+
when "baddata"
|
406
|
+
return BADDATA_CODES[data["error"]]
|
407
|
+
when "error"
|
408
|
+
return ERROR_CODES[data["errortype"]]
|
409
|
+
else
|
410
|
+
return "The transaction was successful"
|
411
|
+
end
|
412
|
+
end
|
413
|
+
|
414
|
+
end
|
415
|
+
end
|
416
|
+
end
|