projectdx_activemerchant 1.7.1.20100817.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +530 -0
- data/CONTRIBUTORS +142 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +136 -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 +159 -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 +163 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +654 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +736 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +244 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +102 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +102 -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 +210 -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/convenience_pay.rb +191 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +406 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +593 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +229 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +134 -0
- data/lib/active_merchant/billing/gateways/eway.rb +277 -0
- data/lib/active_merchant/billing/gateways/exact.rb +222 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +172 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +222 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +164 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +270 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +449 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +154 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +283 -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 +205 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +189 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +168 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +279 -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/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 +236 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +138 -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 +230 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +326 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +38 -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 +135 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +20 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +292 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +214 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +304 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +213 -0
- data/lib/active_merchant/billing/gateways/realex.rb +200 -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 +309 -0
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +144 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +31 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +157 -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 +265 -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 +418 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +194 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +228 -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.rb +18 -0
- data/lib/active_merchant/billing/integrations/action_view_helper.rb +79 -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/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 +93 -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/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 +17 -0
- data/lib/active_merchant/billing/integrations/return.rb +35 -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.rb +29 -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 +172 -0
- data/lib/active_merchant/common/country.rb +319 -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 +47 -0
- data/lib/active_merchant/common/requires_parameters.rb +16 -0
- data/lib/active_merchant/common/utils.rb +18 -0
- data/lib/active_merchant/common/validateable.rb +76 -0
- data/lib/active_merchant/common.rb +14 -0
- data/lib/active_merchant/version.rb +3 -0
- data/lib/active_merchant.rb +47 -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 +254 -0
@@ -0,0 +1,265 @@
|
|
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
|
+
def initialize(options = {})
|
11
|
+
requires!(options, :login, :password)
|
12
|
+
@options = options
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
# Pass :store => true in the options to store the
|
17
|
+
# payment info at the gateway and get a generated
|
18
|
+
# customer_vault_id in the response.
|
19
|
+
# Pass :store => some_number_or_string to specify the
|
20
|
+
# customer_vault_id the gateway should use (make sure it's
|
21
|
+
# unique).
|
22
|
+
def authorize(money, creditcard, options = {})
|
23
|
+
post = {}
|
24
|
+
add_invoice(post, options)
|
25
|
+
add_payment_source(post, creditcard,options)
|
26
|
+
add_address(post, options[:billing_address] || options[:address])
|
27
|
+
add_address(post, options[:shipping_address], "shipping")
|
28
|
+
add_customer_data(post, options)
|
29
|
+
add_currency(post, money, options)
|
30
|
+
add_processor(post, options)
|
31
|
+
commit('auth', money, post)
|
32
|
+
end
|
33
|
+
|
34
|
+
def purchase(money, payment_source, options = {})
|
35
|
+
post = {}
|
36
|
+
add_invoice(post, options)
|
37
|
+
add_payment_source(post, payment_source, options)
|
38
|
+
add_address(post, options[:billing_address] || options[:address])
|
39
|
+
add_address(post, options[:shipping_address], "shipping")
|
40
|
+
add_customer_data(post, options)
|
41
|
+
add_currency(post, money, options)
|
42
|
+
add_processor(post, options)
|
43
|
+
commit('sale', money, post)
|
44
|
+
end
|
45
|
+
|
46
|
+
def capture(money, authorization, options = {})
|
47
|
+
post ={}
|
48
|
+
post[:transactionid] = authorization
|
49
|
+
commit('capture', money, post)
|
50
|
+
end
|
51
|
+
|
52
|
+
def void(authorization, options = {})
|
53
|
+
post ={}
|
54
|
+
post[:transactionid] = authorization
|
55
|
+
commit('void', nil, post)
|
56
|
+
end
|
57
|
+
|
58
|
+
def credit(money, payment_source, options = {})
|
59
|
+
post = {}
|
60
|
+
add_invoice(post, options)
|
61
|
+
add_payment_source(post, payment_source, options)
|
62
|
+
add_address(post, options[:billing_address] || options[:address])
|
63
|
+
add_customer_data(post, options)
|
64
|
+
add_sku(post,options)
|
65
|
+
add_currency(post, money, options)
|
66
|
+
add_processor(post, options)
|
67
|
+
commit('credit', money, post)
|
68
|
+
end
|
69
|
+
|
70
|
+
def refund(auth, options = {})
|
71
|
+
post = {}
|
72
|
+
add_transaction(post, auth)
|
73
|
+
commit('refund', options.delete(:amount), post)
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
# Update the values (such as CC expiration) stored at
|
78
|
+
# the gateway. The CC number must be supplied in the
|
79
|
+
# CreditCard object.
|
80
|
+
def update(vault_id, creditcard, options = {})
|
81
|
+
post = {}
|
82
|
+
post[:customer_vault] = "update_customer"
|
83
|
+
add_customer_vault_id(post, vault_id)
|
84
|
+
add_creditcard(post, creditcard, options)
|
85
|
+
add_address(post, options[:billing_address] || options[:address])
|
86
|
+
add_customer_data(post, options)
|
87
|
+
|
88
|
+
commit(nil, nil, post)
|
89
|
+
end
|
90
|
+
|
91
|
+
# Amend an existing transaction
|
92
|
+
def amend(auth, options = {})
|
93
|
+
post = {}
|
94
|
+
add_invoice(post, options)
|
95
|
+
add_transaction(post, auth)
|
96
|
+
commit('update', nil, post)
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
def delete(vault_id)
|
101
|
+
post = {}
|
102
|
+
post[:customer_vault] = "delete_customer"
|
103
|
+
add_customer_vault_id(post, vault_id)
|
104
|
+
commit(nil, nil, post)
|
105
|
+
end
|
106
|
+
|
107
|
+
# To match the other stored-value gateways, like TrustCommerce,
|
108
|
+
# store and unstore need to be defined
|
109
|
+
def store(payment_source, options = {})
|
110
|
+
post = {}
|
111
|
+
billing_id = options.delete(:billing_id).to_s || true
|
112
|
+
add_payment_source(post, payment_source, :store => billing_id)
|
113
|
+
add_address(post, options[:billing_address] || options[:address])
|
114
|
+
add_customer_data(post, options)
|
115
|
+
commit(nil, nil, post)
|
116
|
+
end
|
117
|
+
|
118
|
+
alias_method :unstore, :delete
|
119
|
+
|
120
|
+
private
|
121
|
+
def add_customer_data(post, options)
|
122
|
+
if options.has_key? :email
|
123
|
+
post[:email] = options[:email]
|
124
|
+
end
|
125
|
+
|
126
|
+
if options.has_key? :ip
|
127
|
+
post[:ipaddress] = options[:ip]
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def add_address(post, address,prefix="")
|
132
|
+
prefix +="_" unless prefix.blank?
|
133
|
+
unless address.blank? or address.values.blank?
|
134
|
+
post[prefix+"address1"] = address[:address1].to_s
|
135
|
+
post[prefix+"address2"] = address[:address2].to_s unless address[:address2].blank?
|
136
|
+
post[prefix+"company"] = address[:company].to_s
|
137
|
+
post[prefix+"phone"] = address[:phone].to_s
|
138
|
+
post[prefix+"zip"] = address[:zip].to_s
|
139
|
+
post[prefix+"city"] = address[:city].to_s
|
140
|
+
post[prefix+"country"] = address[:country].to_s
|
141
|
+
post[prefix+"state"] = address[:state].blank? ? 'n/a' : address[:state]
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def add_currency(post, money, options)
|
146
|
+
post[:currency] = options[:currency] || currency(money)
|
147
|
+
end
|
148
|
+
|
149
|
+
def add_processor(post, options)
|
150
|
+
post[:processor] = options[:processor] unless options[:processor].nil?
|
151
|
+
end
|
152
|
+
|
153
|
+
def add_invoice(post, options)
|
154
|
+
post[:orderid] = options[:order_id].to_s.gsub(/[^\w.]/, '')
|
155
|
+
end
|
156
|
+
|
157
|
+
def add_payment_source(params, source, options={})
|
158
|
+
case determine_funding_source(source)
|
159
|
+
when :vault then add_customer_vault_id(params, source)
|
160
|
+
when :credit_card then add_creditcard(params, source, options)
|
161
|
+
when :check then add_check(params, source, options)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
def add_customer_vault_id(params, vault_id)
|
166
|
+
params[:customer_vault_id] = vault_id
|
167
|
+
end
|
168
|
+
|
169
|
+
def add_creditcard(post, creditcard, options)
|
170
|
+
if options[:store]
|
171
|
+
post[:customer_vault] = "add_customer"
|
172
|
+
post[:customer_vault_id] = options[:store] unless options[:store] == true
|
173
|
+
end
|
174
|
+
post[:ccnumber] = creditcard.number
|
175
|
+
post[:cvv] = creditcard.verification_value if creditcard.verification_value?
|
176
|
+
post[:ccexp] = expdate(creditcard)
|
177
|
+
post[:firstname] = creditcard.first_name
|
178
|
+
post[:lastname] = creditcard.last_name
|
179
|
+
end
|
180
|
+
|
181
|
+
def add_check(post, check, options)
|
182
|
+
if options[:store]
|
183
|
+
post[:customer_vault] = "add_customer"
|
184
|
+
post[:customer_vault_id] = options[:store] unless options[:store] == true
|
185
|
+
end
|
186
|
+
|
187
|
+
post[:payment] = 'check' # Set transaction to ACH
|
188
|
+
post[:checkname] = check.name # The name on the customer's Checking Account
|
189
|
+
post[:checkaba] = check.routing_number # The customer's bank routing number
|
190
|
+
post[:checkaccount] = check.account_number # The customer's account number
|
191
|
+
post[:account_holder_type] = check.account_holder_type # The customer's type of ACH account
|
192
|
+
post[:account_type] = check.account_type # The customer's type of ACH account
|
193
|
+
end
|
194
|
+
|
195
|
+
def add_sku(post,options)
|
196
|
+
post["product_sku_#"] = options[:sku] || options["product_sku_#"]
|
197
|
+
end
|
198
|
+
|
199
|
+
def add_transaction(post, auth)
|
200
|
+
post[:transactionid] = auth
|
201
|
+
end
|
202
|
+
|
203
|
+
def parse(body)
|
204
|
+
results = {}
|
205
|
+
body.split(/&/).each do |pair|
|
206
|
+
key,val = pair.split(/=/)
|
207
|
+
results[key] = val
|
208
|
+
end
|
209
|
+
|
210
|
+
results
|
211
|
+
end
|
212
|
+
|
213
|
+
def commit(action, money, parameters)
|
214
|
+
parameters[:amount] = amount(money) if money
|
215
|
+
response = parse( ssl_post(api_url, post_data(action,parameters)) )
|
216
|
+
Response.new(response["response"] == "1", message_from(response), response,
|
217
|
+
:authorization => response["transactionid"],
|
218
|
+
:test => test?,
|
219
|
+
:cvv_result => response["cvvresponse"],
|
220
|
+
:avs_result => { :code => response["avsresponse"] }
|
221
|
+
)
|
222
|
+
|
223
|
+
end
|
224
|
+
|
225
|
+
def expdate(creditcard)
|
226
|
+
year = sprintf("%.04i", creditcard.year.to_i)
|
227
|
+
month = sprintf("%.02i", creditcard.month.to_i)
|
228
|
+
|
229
|
+
"#{month}#{year[-2..-1]}"
|
230
|
+
end
|
231
|
+
|
232
|
+
|
233
|
+
def message_from(response)
|
234
|
+
case response["responsetext"]
|
235
|
+
when "SUCCESS", "Approved", nil # This is dubious, but responses from UPDATE are nil.
|
236
|
+
"This transaction has been approved"
|
237
|
+
when "DECLINE"
|
238
|
+
"This transaction has been declined"
|
239
|
+
else
|
240
|
+
response["responsetext"]
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
def post_data(action, parameters = {})
|
245
|
+
post = {}
|
246
|
+
post[:username] = @options[:login]
|
247
|
+
post[:password] = @options[:password]
|
248
|
+
post[:type] = action if action
|
249
|
+
|
250
|
+
request = post.merge(parameters).map {|key,value| "#{key}=#{CGI.escape(value.to_s)}"}.join("&")
|
251
|
+
request
|
252
|
+
end
|
253
|
+
|
254
|
+
def determine_funding_source(source)
|
255
|
+
case
|
256
|
+
when source.is_a?(String) then :vault
|
257
|
+
when CreditCard.card_companies.keys.include?(card_brand(source)) then :credit_card
|
258
|
+
when card_brand(source) == 'check' then :check
|
259
|
+
else raise ArgumentError, "Unsupported funding source provided"
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
@@ -0,0 +1,127 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class TransFirstGateway < Gateway
|
4
|
+
URL = 'https://webservices.primerchants.com/creditcard.asmx/CCSale'
|
5
|
+
|
6
|
+
self.supported_countries = ['US']
|
7
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
8
|
+
self.homepage_url = 'http://www.transfirst.com/'
|
9
|
+
self.display_name = 'TransFirst'
|
10
|
+
|
11
|
+
UNUSED_FIELDS = %w(ECIValue UserId CAVVData TrackData POSInd EComInd MerchZIP MerchCustPNum MCC InstallmentNum InstallmentOf POSEntryMode POSConditionCode AuthCharInd CardCertData)
|
12
|
+
|
13
|
+
DECLINED = 'The transaction was declined'
|
14
|
+
|
15
|
+
def initialize(options = {})
|
16
|
+
requires!(options, :login, :password)
|
17
|
+
@options = options
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def purchase(money, credit_card, options = {})
|
22
|
+
post = {}
|
23
|
+
|
24
|
+
add_amount(post, money)
|
25
|
+
add_invoice(post, options)
|
26
|
+
add_credit_card(post, credit_card)
|
27
|
+
add_address(post, options)
|
28
|
+
|
29
|
+
commit(post)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
def add_amount(post, money)
|
34
|
+
add_pair(post, :Amount, amount(money), :required => true)
|
35
|
+
end
|
36
|
+
|
37
|
+
def add_address(post, options)
|
38
|
+
address = options[:billing_address] || options[:address]
|
39
|
+
|
40
|
+
if address
|
41
|
+
add_pair(post, :Address, address[:address1])
|
42
|
+
add_pair(post, :ZipCode, address[:zip])
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def add_invoice(post, options)
|
47
|
+
add_pair(post, :RefID, options[:order_id], :required => true)
|
48
|
+
add_pair(post, :PONumber, options[:invoice], :required => true)
|
49
|
+
add_pair(post, :SaleTaxAmount, amount(options[:tax] || 0))
|
50
|
+
add_pair(post, :PaymentDesc, options[:description], :required => true)
|
51
|
+
add_pair(post, :TaxIndicator, 0)
|
52
|
+
end
|
53
|
+
|
54
|
+
def add_credit_card(post, credit_card)
|
55
|
+
add_pair(post, :CardHolderName, credit_card.name, :required => true)
|
56
|
+
add_pair(post, :CardNumber, credit_card.number, :required => true)
|
57
|
+
|
58
|
+
add_pair(post, :Expiration, expdate(credit_card), :required => true)
|
59
|
+
add_pair(post, :CVV2, credit_card.verification_value)
|
60
|
+
end
|
61
|
+
|
62
|
+
def add_unused_fields(post)
|
63
|
+
UNUSED_FIELDS.each do |f|
|
64
|
+
post[f] = ""
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def expdate(credit_card)
|
69
|
+
year = format(credit_card.year, :two_digits)
|
70
|
+
month = format(credit_card.month, :two_digits)
|
71
|
+
|
72
|
+
"#{month}#{year}"
|
73
|
+
end
|
74
|
+
|
75
|
+
def parse(data)
|
76
|
+
response = {}
|
77
|
+
|
78
|
+
xml = REXML::Document.new(data)
|
79
|
+
root = REXML::XPath.first(xml, "//CCSaleDebitResponse")
|
80
|
+
|
81
|
+
if root.nil?
|
82
|
+
response[:message] = data.to_s.strip
|
83
|
+
else
|
84
|
+
root.elements.to_a.each do |node|
|
85
|
+
response[node.name.underscore.to_sym] = node.text
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
response
|
90
|
+
end
|
91
|
+
|
92
|
+
def commit(params)
|
93
|
+
response = parse( ssl_post(URL, post_data(params)) )
|
94
|
+
|
95
|
+
Response.new(response[:status] == "Authorized", message_from(response), response,
|
96
|
+
:test => test?,
|
97
|
+
:authorization => response[:trans_id],
|
98
|
+
:avs_result => { :code => response[:avs_code] },
|
99
|
+
:cvv_result => response[:cvv2_code]
|
100
|
+
)
|
101
|
+
end
|
102
|
+
|
103
|
+
def message_from(response)
|
104
|
+
case response[:message]
|
105
|
+
when 'Call Voice Center'
|
106
|
+
DECLINED
|
107
|
+
else
|
108
|
+
response[:message]
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def post_data(params = {})
|
113
|
+
add_unused_fields(params)
|
114
|
+
params[:MerchantID] = @options[:login]
|
115
|
+
params[:RegKey] = @options[:password]
|
116
|
+
|
117
|
+
request = params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
|
118
|
+
request
|
119
|
+
end
|
120
|
+
|
121
|
+
def add_pair(post, key, value, options = {})
|
122
|
+
post[key] = value if !value.blank? || options[:required]
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__),'smart_ps.rb')
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
class TransaxGateway < SmartPs
|
6
|
+
def api_url
|
7
|
+
'https://secure.nelixtransax.net/api/transact.php'
|
8
|
+
end
|
9
|
+
|
10
|
+
# The countries the gateway supports merchants from as 2 digit ISO country codes
|
11
|
+
self.supported_countries = ['US']
|
12
|
+
|
13
|
+
# The card types supported by the payment gateway
|
14
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
15
|
+
|
16
|
+
# The homepage URL of the gateway
|
17
|
+
self.homepage_url = 'https://www.nelixtransax.com/'
|
18
|
+
|
19
|
+
# The name of the gateway
|
20
|
+
self.display_name = 'NELiX TransaX'
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|