activemerchant-kiddy 1.15.0.kiddy
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +688 -0
- data/CONTRIBUTORS +233 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +164 -0
- data/gem-public_cert.pem +20 -0
- data/lib/active_merchant/billing/avs_result.rb +98 -0
- data/lib/active_merchant/billing/base.rb +57 -0
- data/lib/active_merchant/billing/check.rb +68 -0
- data/lib/active_merchant/billing/credit_card.rb +172 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +21 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +125 -0
- data/lib/active_merchant/billing/cvv_result.rb +38 -0
- data/lib/active_merchant/billing/expiry_date.rb +34 -0
- data/lib/active_merchant/billing/gateway.rb +170 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +671 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +858 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq.rb +309 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +282 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +139 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
- data/lib/active_merchant/billing/gateways/blue_pay.rb +11 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +132 -0
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +17 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +293 -0
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +17 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +230 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +410 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +597 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +235 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +134 -0
- data/lib/active_merchant/billing/gateways/epay.rb +268 -0
- data/lib/active_merchant/billing/gateways/eway.rb +277 -0
- data/lib/active_merchant/billing/gateways/eway_managed.rb +231 -0
- data/lib/active_merchant/billing/gateways/exact.rb +222 -0
- data/lib/active_merchant/billing/gateways/federated_canada.rb +168 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +177 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +262 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +250 -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 +55 -0
- data/lib/active_merchant/billing/gateways/inspire.rb +221 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +164 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +258 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +276 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +454 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +156 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +289 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +36 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +220 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +209 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +189 -0
- data/lib/active_merchant/billing/gateways/netaxept.rb +239 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +168 -0
- data/lib/active_merchant/billing/gateways/nmi.rb +13 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +292 -0
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +46 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +317 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +392 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +120 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +207 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +207 -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.rb +253 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +222 -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 +235 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +351 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +49 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +121 -0
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +177 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +25 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +298 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +219 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +304 -0
- data/lib/active_merchant/billing/gateways/qbms.rb +295 -0
- data/lib/active_merchant/billing/gateways/quantum.rb +282 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +218 -0
- data/lib/active_merchant/billing/gateways/realex.rb +311 -0
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +88 -0
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +116 -0
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
- data/lib/active_merchant/billing/gateways/sage.rb +146 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +320 -0
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +144 -0
- data/lib/active_merchant/billing/gateways/secure_net.rb +330 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +31 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +193 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +113 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +453 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +271 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +127 -0
- data/lib/active_merchant/billing/gateways/transax.rb +25 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +423 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +194 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +233 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +189 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +318 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +280 -0
- data/lib/active_merchant/billing/gateways.rb +18 -0
- data/lib/active_merchant/billing/integrations/action_view_helper.rb +68 -0
- data/lib/active_merchant/billing/integrations/bogus/helper.rb +17 -0
- data/lib/active_merchant/billing/integrations/bogus/notification.rb +11 -0
- data/lib/active_merchant/billing/integrations/bogus/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/bogus.rb +23 -0
- data/lib/active_merchant/billing/integrations/chronopay/helper.rb +120 -0
- data/lib/active_merchant/billing/integrations/chronopay/notification.rb +158 -0
- data/lib/active_merchant/billing/integrations/chronopay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/chronopay.rb +23 -0
- data/lib/active_merchant/billing/integrations/direc_pay/helper.rb +200 -0
- data/lib/active_merchant/billing/integrations/direc_pay/notification.rb +76 -0
- data/lib/active_merchant/billing/integrations/direc_pay/return.rb +32 -0
- data/lib/active_merchant/billing/integrations/direc_pay/status.rb +37 -0
- data/lib/active_merchant/billing/integrations/direc_pay.rb +41 -0
- data/lib/active_merchant/billing/integrations/directebanking/helper.rb +90 -0
- data/lib/active_merchant/billing/integrations/directebanking/notification.rb +120 -0
- data/lib/active_merchant/billing/integrations/directebanking/return.rb +11 -0
- data/lib/active_merchant/billing/integrations/directebanking.rb +47 -0
- data/lib/active_merchant/billing/integrations/gestpay/common.rb +42 -0
- data/lib/active_merchant/billing/integrations/gestpay/helper.rb +70 -0
- data/lib/active_merchant/billing/integrations/gestpay/notification.rb +85 -0
- data/lib/active_merchant/billing/integrations/gestpay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/gestpay.rb +25 -0
- data/lib/active_merchant/billing/integrations/helper.rb +96 -0
- data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +58 -0
- data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +59 -0
- data/lib/active_merchant/billing/integrations/hi_trust/return.rb +67 -0
- data/lib/active_merchant/billing/integrations/hi_trust.rb +27 -0
- data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +48 -0
- data/lib/active_merchant/billing/integrations/moneybookers/notification.rb +129 -0
- data/lib/active_merchant/billing/integrations/moneybookers.rb +26 -0
- data/lib/active_merchant/billing/integrations/nochex/helper.rb +68 -0
- data/lib/active_merchant/billing/integrations/nochex/notification.rb +94 -0
- data/lib/active_merchant/billing/integrations/nochex/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/nochex.rb +88 -0
- data/lib/active_merchant/billing/integrations/notification.rb +62 -0
- data/lib/active_merchant/billing/integrations/paypal/helper.rb +119 -0
- data/lib/active_merchant/billing/integrations/paypal/notification.rb +154 -0
- data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/paypal.rb +39 -0
- data/lib/active_merchant/billing/integrations/quickpay/helper.rb +72 -0
- data/lib/active_merchant/billing/integrations/quickpay/notification.rb +74 -0
- data/lib/active_merchant/billing/integrations/quickpay.rb +21 -0
- data/lib/active_merchant/billing/integrations/return.rb +42 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb +33 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +111 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/notification.rb +210 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/return.rb +31 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form.rb +37 -0
- data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +59 -0
- data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +114 -0
- data/lib/active_merchant/billing/integrations/two_checkout/return.rb +17 -0
- data/lib/active_merchant/billing/integrations/two_checkout.rb +23 -0
- data/lib/active_merchant/billing/integrations/valitor/helper.rb +86 -0
- data/lib/active_merchant/billing/integrations/valitor/notification.rb +13 -0
- data/lib/active_merchant/billing/integrations/valitor/response_fields.rb +88 -0
- data/lib/active_merchant/billing/integrations/valitor/return.rb +13 -0
- data/lib/active_merchant/billing/integrations/valitor.rb +33 -0
- data/lib/active_merchant/billing/integrations/world_pay/helper.rb +100 -0
- data/lib/active_merchant/billing/integrations/world_pay/notification.rb +160 -0
- data/lib/active_merchant/billing/integrations/world_pay.rb +38 -0
- data/lib/active_merchant/billing/integrations.rb +17 -0
- data/lib/active_merchant/billing/response.rb +32 -0
- data/lib/active_merchant/billing.rb +9 -0
- data/lib/active_merchant/common/connection.rb +177 -0
- data/lib/active_merchant/common/country.rb +328 -0
- data/lib/active_merchant/common/error.rb +26 -0
- data/lib/active_merchant/common/post_data.rb +24 -0
- data/lib/active_merchant/common/posts_data.rb +63 -0
- data/lib/active_merchant/common/requires_parameters.rb +16 -0
- data/lib/active_merchant/common/utils.rb +22 -0
- data/lib/active_merchant/common/validateable.rb +81 -0
- data/lib/active_merchant/common.rb +14 -0
- data/lib/active_merchant/version.rb +3 -0
- data/lib/active_merchant.rb +50 -0
- data/lib/activemerchant.rb +1 -0
- data/lib/certs/cacert.pem +7815 -0
- data/lib/support/gateway_support.rb +58 -0
- data/lib/support/outbound_hosts.rb +25 -0
- metadata +273 -0
@@ -0,0 +1,423 @@
|
|
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
|
+
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
|
+
@options = options
|
135
|
+
super
|
136
|
+
end
|
137
|
+
|
138
|
+
def tclink?
|
139
|
+
self.class.tclink?
|
140
|
+
end
|
141
|
+
|
142
|
+
def test?
|
143
|
+
@options[:login] == TEST_LOGIN &&
|
144
|
+
@options[:password] == TEST_PASSWORD || @options[:test] || super
|
145
|
+
end
|
146
|
+
|
147
|
+
# authorize() is the first half of the preauth(authorize)/postauth(capture) model. The TC API docs call this
|
148
|
+
# preauth, we preserve active_merchant's nomenclature of authorize() for consistency with the rest of the library. This
|
149
|
+
# method simply checks to make sure funds are available for a transaction, and returns a transid that can be used later to
|
150
|
+
# postauthorize (capture) the funds.
|
151
|
+
|
152
|
+
def authorize(money, creditcard_or_billing_id, options = {})
|
153
|
+
parameters = {
|
154
|
+
:amount => amount(money),
|
155
|
+
}
|
156
|
+
|
157
|
+
add_order_id(parameters, options)
|
158
|
+
add_customer_data(parameters, options)
|
159
|
+
add_payment_source(parameters, creditcard_or_billing_id)
|
160
|
+
add_addresses(parameters, options)
|
161
|
+
commit('preauth', parameters)
|
162
|
+
end
|
163
|
+
|
164
|
+
# purchase() is a simple sale. This is one of the most common types of transactions, and is extremely simple. All that you need
|
165
|
+
# to process a purchase are an amount in cents or a money object and a creditcard object or billingid string.
|
166
|
+
def purchase(money, creditcard_or_billing_id, options = {})
|
167
|
+
parameters = {
|
168
|
+
:amount => amount(money),
|
169
|
+
}
|
170
|
+
|
171
|
+
add_order_id(parameters, options)
|
172
|
+
add_customer_data(parameters, options)
|
173
|
+
add_payment_source(parameters, creditcard_or_billing_id)
|
174
|
+
add_addresses(parameters, options)
|
175
|
+
commit('sale', parameters)
|
176
|
+
end
|
177
|
+
|
178
|
+
# capture() is the second half of the preauth(authorize)/postauth(capture) model. The TC API docs call this
|
179
|
+
# postauth, we preserve active_merchant's nomenclature of capture() for consistency with the rest of the library. To process
|
180
|
+
# a postauthorization with TC, you need an amount in cents or a money object, and a TC transid.
|
181
|
+
def capture(money, authorization, options = {})
|
182
|
+
parameters = {
|
183
|
+
:amount => amount(money),
|
184
|
+
:transid => authorization,
|
185
|
+
}
|
186
|
+
|
187
|
+
commit('postauth', parameters)
|
188
|
+
end
|
189
|
+
|
190
|
+
# 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,
|
191
|
+
# that you want to refund, and a TC transid for the transaction that you are refunding.
|
192
|
+
def refund(money, identification, options = {})
|
193
|
+
parameters = {
|
194
|
+
:amount => amount(money),
|
195
|
+
:transid => identification
|
196
|
+
}
|
197
|
+
|
198
|
+
commit('credit', parameters)
|
199
|
+
end
|
200
|
+
|
201
|
+
def credit(money, identification, options = {})
|
202
|
+
deprecated CREDIT_DEPRECATION_MESSAGE
|
203
|
+
refund(money, identification, options)
|
204
|
+
end
|
205
|
+
|
206
|
+
# void() clears an existing authorization and releases the reserved fund
|
207
|
+
# s back to the cardholder. The TC API refers to this transaction as a
|
208
|
+
# reversal. After voiding, you will no longer be able to capture funds
|
209
|
+
# from this authorization. TrustCommerce seems to always return a status
|
210
|
+
# of "accepted" even if the transid you are trying to deauthorize has
|
211
|
+
# already been captured. Note: Your account needs to be configured by
|
212
|
+
# TrustCommerce to allow for reversal transactions before you can use this
|
213
|
+
# method.
|
214
|
+
#
|
215
|
+
# NOTE: AMEX preauth's cannot be reversed. If you want to clear it more
|
216
|
+
# quickly than the automatic expiration (7-10 days), you will have to
|
217
|
+
# capture it and then immediately issue a credit for the same amount
|
218
|
+
# which should clear the customers credit card with 48 hours according to
|
219
|
+
# TC.
|
220
|
+
def void(authorization, options = {})
|
221
|
+
parameters = {
|
222
|
+
:transid => authorization,
|
223
|
+
}
|
224
|
+
|
225
|
+
commit('reversal', parameters)
|
226
|
+
end
|
227
|
+
|
228
|
+
# recurring() a TrustCommerce account that is activated for Citatdel, TrustCommerce's
|
229
|
+
# hosted customer billing info database.
|
230
|
+
#
|
231
|
+
# Recurring billing uses the same TC action as a plain-vanilla 'store', but we have a separate method for clarity. It can be called
|
232
|
+
# like store, with the addition of a required 'periodicity' parameter:
|
233
|
+
#
|
234
|
+
# The parameter :periodicity should be specified as either :bimonthly, :monthly, :biweekly, :weekly, :yearly or :daily
|
235
|
+
#
|
236
|
+
# gateway.recurring(tendollar, creditcard, :periodicity => :weekly)
|
237
|
+
#
|
238
|
+
# You can optionally specify how long you want payments to continue using 'payments'
|
239
|
+
def recurring(money, creditcard, options = {})
|
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 expdate(creditcard)
|
305
|
+
year = sprintf("%.4i", creditcard.year)
|
306
|
+
month = sprintf("%.2i", creditcard.month)
|
307
|
+
|
308
|
+
"#{month}#{year[-2..-1]}"
|
309
|
+
end
|
310
|
+
|
311
|
+
def add_creditcard(params, creditcard)
|
312
|
+
params[:media] = "cc"
|
313
|
+
params[:name] = creditcard.name
|
314
|
+
params[:cc] = creditcard.number
|
315
|
+
params[:exp] = expdate(creditcard)
|
316
|
+
params[:cvv] = creditcard.verification_value if creditcard.verification_value?
|
317
|
+
end
|
318
|
+
|
319
|
+
def add_order_id(params, options)
|
320
|
+
params[:ticket] = options[:order_id] unless options[:order_id].blank?
|
321
|
+
end
|
322
|
+
|
323
|
+
def add_billing_id(params, billingid)
|
324
|
+
params[:billingid] = billingid
|
325
|
+
end
|
326
|
+
|
327
|
+
def add_customer_data(params, options)
|
328
|
+
params[:email] = options[:email] unless options[:email].blank?
|
329
|
+
params[:ip] = options[:ip] unless options[:ip].blank?
|
330
|
+
end
|
331
|
+
|
332
|
+
def add_addresses(params, options)
|
333
|
+
address = options[:billing_address] || options[:address]
|
334
|
+
|
335
|
+
if address
|
336
|
+
params[:address1] = address[:address1] unless address[:address1].blank?
|
337
|
+
params[:address2] = address[:address2] unless address[:address2].blank?
|
338
|
+
params[:city] = address[:city] unless address[:city].blank?
|
339
|
+
params[:state] = address[:state] unless address[:state].blank?
|
340
|
+
params[:zip] = address[:zip] unless address[:zip].blank?
|
341
|
+
params[:country] = address[:country] unless address[:country].blank?
|
342
|
+
params[:avs] = 'n'
|
343
|
+
end
|
344
|
+
|
345
|
+
if shipping_address = options[:shipping_address]
|
346
|
+
params[:shipto_name] = shipping_address[:name] unless shipping_address[:name].blank?
|
347
|
+
params[:shipto_address1] = shipping_address[:address1] unless shipping_address[:address1].blank?
|
348
|
+
params[:shipto_address2] = shipping_address[:address2] unless shipping_address[:address2].blank?
|
349
|
+
params[:shipto_city] = shipping_address[:city] unless shipping_address[:city].blank?
|
350
|
+
params[:shipto_state] = shipping_address[:state] unless shipping_address[:state].blank?
|
351
|
+
params[:shipto_zip] = shipping_address[:zip] unless shipping_address[:zip].blank?
|
352
|
+
params[:shipto_country] = shipping_address[:country] unless shipping_address[:country].blank?
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
356
|
+
def clean_and_stringify_params(parameters)
|
357
|
+
# TCLink wants us to send a hash with string keys, and activemerchant pushes everything around with
|
358
|
+
# symbol keys. Before sending our input to TCLink, we convert all our keys to strings and dump the symbol keys.
|
359
|
+
# We also remove any pairs with nil values, as these confuse TCLink.
|
360
|
+
parameters.keys.reverse.each do |key|
|
361
|
+
if parameters[key]
|
362
|
+
parameters[key.to_s] = parameters[key]
|
363
|
+
end
|
364
|
+
parameters.delete(key)
|
365
|
+
end
|
366
|
+
end
|
367
|
+
|
368
|
+
def post_data(parameters)
|
369
|
+
parameters.collect { |key, value| "#{key}=#{ CGI.escape(value.to_s)}" }.join("&")
|
370
|
+
end
|
371
|
+
|
372
|
+
def commit(action, parameters)
|
373
|
+
parameters[:custid] = @options[:login]
|
374
|
+
parameters[:password] = @options[:password]
|
375
|
+
parameters[:demo] = test? ? 'y' : 'n'
|
376
|
+
parameters[:action] = action
|
377
|
+
|
378
|
+
clean_and_stringify_params(parameters)
|
379
|
+
|
380
|
+
data = if tclink?
|
381
|
+
TCLink.send(parameters)
|
382
|
+
else
|
383
|
+
parse( ssl_post(URL, post_data(parameters)) )
|
384
|
+
end
|
385
|
+
|
386
|
+
# to be considered successful, transaction status must be either "approved" or "accepted"
|
387
|
+
success = SUCCESS_TYPES.include?(data["status"])
|
388
|
+
message = message_from(data)
|
389
|
+
Response.new(success, message, data,
|
390
|
+
:test => test?,
|
391
|
+
:authorization => data["transid"],
|
392
|
+
:cvv_result => data["cvv"],
|
393
|
+
:avs_result => { :code => data["avs"] }
|
394
|
+
)
|
395
|
+
end
|
396
|
+
|
397
|
+
def parse(body)
|
398
|
+
results = {}
|
399
|
+
|
400
|
+
body.split(/\n/).each do |pair|
|
401
|
+
key,val = pair.split(/=/)
|
402
|
+
results[key] = val
|
403
|
+
end
|
404
|
+
|
405
|
+
results
|
406
|
+
end
|
407
|
+
|
408
|
+
def message_from(data)
|
409
|
+
status = case data["status"]
|
410
|
+
when "decline"
|
411
|
+
return DECLINE_CODES[data["declinetype"]]
|
412
|
+
when "baddata"
|
413
|
+
return BADDATA_CODES[data["error"]]
|
414
|
+
when "error"
|
415
|
+
return ERROR_CODES[data["errortype"]]
|
416
|
+
else
|
417
|
+
return "The transaction was successful"
|
418
|
+
end
|
419
|
+
end
|
420
|
+
|
421
|
+
end
|
422
|
+
end
|
423
|
+
end
|
@@ -0,0 +1,194 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
|
4
|
+
class UsaEpayGateway < Gateway
|
5
|
+
URL = 'https://www.usaepay.com/gate.php'
|
6
|
+
|
7
|
+
self.supported_cardtypes = [:visa, :master, :american_express]
|
8
|
+
self.supported_countries = ['US']
|
9
|
+
self.homepage_url = 'http://www.usaepay.com/'
|
10
|
+
self.display_name = 'USA ePay'
|
11
|
+
|
12
|
+
TRANSACTIONS = {
|
13
|
+
:authorization => 'authonly',
|
14
|
+
:purchase => 'sale',
|
15
|
+
:capture => 'capture'
|
16
|
+
}
|
17
|
+
|
18
|
+
def initialize(options = {})
|
19
|
+
requires!(options, :login)
|
20
|
+
@options = options
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
def authorize(money, credit_card, options = {})
|
25
|
+
post = {}
|
26
|
+
|
27
|
+
add_amount(post, money)
|
28
|
+
add_invoice(post, options)
|
29
|
+
add_credit_card(post, credit_card)
|
30
|
+
add_address(post, credit_card, options)
|
31
|
+
add_customer_data(post, options)
|
32
|
+
|
33
|
+
commit(:authorization, post)
|
34
|
+
end
|
35
|
+
|
36
|
+
def purchase(money, credit_card, options = {})
|
37
|
+
post = {}
|
38
|
+
|
39
|
+
add_amount(post, money)
|
40
|
+
add_invoice(post, options)
|
41
|
+
add_credit_card(post, credit_card)
|
42
|
+
add_address(post, credit_card, options)
|
43
|
+
add_customer_data(post, options)
|
44
|
+
|
45
|
+
commit(:purchase, post)
|
46
|
+
end
|
47
|
+
|
48
|
+
def capture(money, authorization, options = {})
|
49
|
+
post = {
|
50
|
+
:refNum => authorization
|
51
|
+
}
|
52
|
+
|
53
|
+
add_amount(post, money)
|
54
|
+
commit(:capture, post)
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def add_amount(post, money)
|
60
|
+
post[:amount] = amount(money)
|
61
|
+
end
|
62
|
+
|
63
|
+
def expdate(credit_card)
|
64
|
+
year = format(credit_card.year, :two_digits)
|
65
|
+
month = format(credit_card.month, :two_digits)
|
66
|
+
|
67
|
+
"#{month}#{year}"
|
68
|
+
end
|
69
|
+
|
70
|
+
def add_customer_data(post, options)
|
71
|
+
address = options[:billing_address] || options[:address] || {}
|
72
|
+
post[:street] = address[:address1]
|
73
|
+
post[:zip] = address[:zip]
|
74
|
+
|
75
|
+
if options.has_key? :email
|
76
|
+
post[:custemail] = options[:email]
|
77
|
+
post[:custreceipt] = 'No'
|
78
|
+
end
|
79
|
+
|
80
|
+
if options.has_key? :customer
|
81
|
+
post[:custid] = options[:customer]
|
82
|
+
end
|
83
|
+
|
84
|
+
if options.has_key? :ip
|
85
|
+
post[:ip] = options[:ip]
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def add_address(post, credit_card, options)
|
90
|
+
billing_address = options[:billing_address] || options[:address]
|
91
|
+
|
92
|
+
add_address_for_type(:billing, post, credit_card, billing_address) if billing_address
|
93
|
+
add_address_for_type(:shipping, post, credit_card, options[:shipping_address]) if options[:shipping_address]
|
94
|
+
end
|
95
|
+
|
96
|
+
def add_address_for_type(type, post, credit_card, address)
|
97
|
+
prefix = address_key_prefix(type)
|
98
|
+
|
99
|
+
post[address_key(prefix, 'fname')] = credit_card.first_name
|
100
|
+
post[address_key(prefix, 'lname')] = credit_card.last_name
|
101
|
+
post[address_key(prefix, 'company')] = address[:company] unless address[:company].blank?
|
102
|
+
post[address_key(prefix, 'street')] = address[:address1] unless address[:address1].blank?
|
103
|
+
post[address_key(prefix, 'street2')] = address[:address2] unless address[:address2].blank?
|
104
|
+
post[address_key(prefix, 'city')] = address[:city] unless address[:city].blank?
|
105
|
+
post[address_key(prefix, 'state')] = address[:state] unless address[:state].blank?
|
106
|
+
post[address_key(prefix, 'zip')] = address[:zip] unless address[:zip].blank?
|
107
|
+
post[address_key(prefix, 'country')] = address[:country] unless address[:country].blank?
|
108
|
+
post[address_key(prefix, 'phone')] = address[:phone] unless address[:phone].blank?
|
109
|
+
end
|
110
|
+
|
111
|
+
def address_key_prefix(type)
|
112
|
+
case type
|
113
|
+
when :shipping then 'ship'
|
114
|
+
when :billing then 'bill'
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def address_key(prefix, key)
|
119
|
+
"#{prefix}#{key}".to_sym
|
120
|
+
end
|
121
|
+
|
122
|
+
def add_invoice(post, options)
|
123
|
+
post[:invoice] = options[:order_id]
|
124
|
+
end
|
125
|
+
|
126
|
+
def add_credit_card(post, credit_card)
|
127
|
+
post[:card] = credit_card.number
|
128
|
+
post[:cvv2] = credit_card.verification_value if credit_card.verification_value?
|
129
|
+
post[:expir] = expdate(credit_card)
|
130
|
+
post[:name] = credit_card.name
|
131
|
+
end
|
132
|
+
|
133
|
+
def parse(body)
|
134
|
+
fields = {}
|
135
|
+
for line in body.split('&')
|
136
|
+
key, value = *line.scan( %r{^(\w+)\=(.*)$} ).flatten
|
137
|
+
fields[key] = CGI.unescape(value.to_s)
|
138
|
+
end
|
139
|
+
|
140
|
+
{
|
141
|
+
:status => fields['UMstatus'],
|
142
|
+
:auth_code => fields['UMauthCode'],
|
143
|
+
:ref_num => fields['UMrefNum'],
|
144
|
+
:batch => fields['UMbatch'],
|
145
|
+
:avs_result => fields['UMavsResult'],
|
146
|
+
:avs_result_code => fields['UMavsResultCode'],
|
147
|
+
:cvv2_result => fields['UMcvv2Result'],
|
148
|
+
:cvv2_result_code => fields['UMcvv2ResultCode'],
|
149
|
+
:vpas_result_code => fields['UMvpasResultCode'],
|
150
|
+
:result => fields['UMresult'],
|
151
|
+
:error => fields['UMerror'],
|
152
|
+
:error_code => fields['UMerrorcode'],
|
153
|
+
:acs_url => fields['UMacsurl'],
|
154
|
+
:payload => fields['UMpayload']
|
155
|
+
}.delete_if{|k, v| v.nil?}
|
156
|
+
end
|
157
|
+
|
158
|
+
|
159
|
+
def commit(action, parameters)
|
160
|
+
response = parse( ssl_post(URL, post_data(action, parameters)) )
|
161
|
+
|
162
|
+
Response.new(response[:status] == 'Approved', message_from(response), response,
|
163
|
+
:test => @options[:test] || test?,
|
164
|
+
:authorization => response[:ref_num],
|
165
|
+
:cvv_result => response[:cvv2_result_code],
|
166
|
+
:avs_result => {
|
167
|
+
:street_match => response[:avs_result_code].to_s[0,1],
|
168
|
+
:postal_match => response[:avs_result_code].to_s[1,1],
|
169
|
+
:code => response[:avs_result_code].to_s[2,1]
|
170
|
+
}
|
171
|
+
)
|
172
|
+
end
|
173
|
+
|
174
|
+
def message_from(response)
|
175
|
+
if response[:status] == "Approved"
|
176
|
+
return 'Success'
|
177
|
+
else
|
178
|
+
return 'Unspecified error' if response[:error].blank?
|
179
|
+
return response[:error]
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def post_data(action, parameters = {})
|
184
|
+
parameters[:command] = TRANSACTIONS[action]
|
185
|
+
parameters[:key] = @options[:login]
|
186
|
+
parameters[:software] = 'Active Merchant'
|
187
|
+
parameters[:testmode] = @options[:test] ? 1 : 0
|
188
|
+
|
189
|
+
parameters.collect { |key, value| "UM#{key}=#{CGI.escape(value.to_s)}" }.join("&")
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|