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,221 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'check.rb')
|
2
|
+
module ActiveMerchant #:nodoc:
|
3
|
+
module Billing #:nodoc:
|
4
|
+
class InspireGateway < Gateway
|
5
|
+
URL = 'https://secure.inspiregateway.net/api/transact.php'
|
6
|
+
|
7
|
+
self.supported_countries = ['US']
|
8
|
+
self.supported_cardtypes = [:visa, :master, :american_express]
|
9
|
+
self.homepage_url = 'http://www.inspiregateway.com'
|
10
|
+
self.display_name = 'Inspire Commerce'
|
11
|
+
# Creates a new InspireGateway
|
12
|
+
#
|
13
|
+
# The gateway requires that a valid login and password be passed
|
14
|
+
# in the +options+ hash.
|
15
|
+
#
|
16
|
+
# ==== Options
|
17
|
+
#
|
18
|
+
# * <tt>:login</tt> -- The Inspire Username.
|
19
|
+
# * <tt>:password</tt> -- The Inspire Passowrd.
|
20
|
+
# See the Inspire Integration Guide for details. (default: +false+)
|
21
|
+
def initialize(options = {})
|
22
|
+
requires!(options, :login, :password)
|
23
|
+
@options = options
|
24
|
+
super
|
25
|
+
end
|
26
|
+
|
27
|
+
# Pass :store => true in the options to store the
|
28
|
+
# payment info at Inspire Gateway and get a generated
|
29
|
+
# customer_vault_id in the response.
|
30
|
+
# Pass :store => some_number_or_string to specify the
|
31
|
+
# customer_vault_id InspireGateway should use (make sure it's
|
32
|
+
# unique).
|
33
|
+
def authorize(money, creditcard, options = {})
|
34
|
+
post = {}
|
35
|
+
add_invoice(post, options)
|
36
|
+
add_payment_source(post, creditcard,options)
|
37
|
+
add_address(post, creditcard, options)
|
38
|
+
add_customer_data(post, options)
|
39
|
+
|
40
|
+
commit('auth', money, post)
|
41
|
+
end
|
42
|
+
|
43
|
+
def purchase(money, payment_source, options = {})
|
44
|
+
post = {}
|
45
|
+
add_invoice(post, options)
|
46
|
+
add_payment_source(post, payment_source, options)
|
47
|
+
add_address(post, payment_source, options)
|
48
|
+
add_customer_data(post, options)
|
49
|
+
|
50
|
+
commit('sale', money, post)
|
51
|
+
end
|
52
|
+
|
53
|
+
def capture(money, authorization, options = {})
|
54
|
+
post ={}
|
55
|
+
post[:transactionid] = authorization
|
56
|
+
commit('capture', money, post)
|
57
|
+
end
|
58
|
+
|
59
|
+
def void(authorization, options = {})
|
60
|
+
post ={}
|
61
|
+
post[:transactionid] = authorization
|
62
|
+
commit('void', nil, post)
|
63
|
+
end
|
64
|
+
|
65
|
+
# Update the values (such as CC expiration) stored at
|
66
|
+
# InspireGateway. The CC number must be supplied in the
|
67
|
+
# CreditCard object.
|
68
|
+
def update(vault_id, creditcard, options = {})
|
69
|
+
post = {}
|
70
|
+
post[:customer_vault] = "update_customer"
|
71
|
+
add_customer_vault_id(post, vault_id)
|
72
|
+
add_creditcard(post, creditcard, options)
|
73
|
+
add_address(post, creditcard, options)
|
74
|
+
add_customer_data(post, options)
|
75
|
+
|
76
|
+
commit(nil, nil, post)
|
77
|
+
end
|
78
|
+
|
79
|
+
def delete(vault_id)
|
80
|
+
post = {}
|
81
|
+
post[:customer_vault] = "delete_customer"
|
82
|
+
add_customer_vault_id(post, vault_id)
|
83
|
+
commit(nil, nil, post)
|
84
|
+
end
|
85
|
+
|
86
|
+
# To match the other stored-value gateways, like TrustCommerce,
|
87
|
+
# store and unstore need to be defined
|
88
|
+
def store(creditcard, options = {})
|
89
|
+
billing_id = options.delete(:billing_id).to_s || true
|
90
|
+
authorize(100, creditcard, options.merge(:store => billing_id))
|
91
|
+
end
|
92
|
+
|
93
|
+
alias_method :unstore, :delete
|
94
|
+
|
95
|
+
private
|
96
|
+
def add_customer_data(post, options)
|
97
|
+
if options.has_key? :email
|
98
|
+
post[:email] = options[:email]
|
99
|
+
end
|
100
|
+
|
101
|
+
if options.has_key? :ip
|
102
|
+
post[:ipaddress] = options[:ip]
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def add_address(post, creditcard, options)
|
107
|
+
if address = options[:billing_address] || options[:address]
|
108
|
+
post[:address1] = address[:address1].to_s
|
109
|
+
post[:address2] = address[:address2].to_s unless address[:address2].blank?
|
110
|
+
post[:company] = address[:company].to_s
|
111
|
+
post[:phone] = address[:phone].to_s
|
112
|
+
post[:zip] = address[:zip].to_s
|
113
|
+
post[:city] = address[:city].to_s
|
114
|
+
post[:country] = address[:country].to_s
|
115
|
+
post[:state] = address[:state].blank? ? 'n/a' : address[:state]
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def add_invoice(post, options)
|
120
|
+
post[:orderid] = options[:order_id].to_s.gsub(/[^\w.]/, '')
|
121
|
+
post[:orderdescription] = options[:description]
|
122
|
+
end
|
123
|
+
|
124
|
+
def add_payment_source(params, source, options={})
|
125
|
+
case determine_funding_source(source)
|
126
|
+
when :vault then add_customer_vault_id(params, source)
|
127
|
+
when :credit_card then add_creditcard(params, source, options)
|
128
|
+
when :check then add_check(params, source)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def add_customer_vault_id(params,vault_id)
|
133
|
+
params[:customer_vault_id] = vault_id
|
134
|
+
end
|
135
|
+
|
136
|
+
def add_creditcard(post, creditcard,options)
|
137
|
+
if options[:store]
|
138
|
+
post[:customer_vault] = "add_customer"
|
139
|
+
post[:customer_vault_id] = options[:store] unless options[:store] == true
|
140
|
+
end
|
141
|
+
post[:ccnumber] = creditcard.number
|
142
|
+
post[:cvv] = creditcard.verification_value if creditcard.verification_value?
|
143
|
+
post[:ccexp] = expdate(creditcard)
|
144
|
+
post[:firstname] = creditcard.first_name
|
145
|
+
post[:lastname] = creditcard.last_name
|
146
|
+
end
|
147
|
+
|
148
|
+
def add_check(post, check)
|
149
|
+
post[:payment] = 'check' # Set transaction to ACH
|
150
|
+
post[:checkname] = check.name # The name on the customer's Checking Account
|
151
|
+
post[:checkaba] = check.routing_number # The customer's bank routing number
|
152
|
+
post[:checkaccount] = check.account_number # The customer's account number
|
153
|
+
post[:account_holder_type] = check.account_holder_type # The customer's type of ACH account
|
154
|
+
post[:account_type] = check.account_type # The customer's type of ACH account
|
155
|
+
end
|
156
|
+
|
157
|
+
def parse(body)
|
158
|
+
results = {}
|
159
|
+
body.split(/&/).each do |pair|
|
160
|
+
key,val = pair.split(/=/)
|
161
|
+
results[key] = val
|
162
|
+
end
|
163
|
+
|
164
|
+
results
|
165
|
+
end
|
166
|
+
|
167
|
+
def commit(action, money, parameters)
|
168
|
+
parameters[:amount] = amount(money) if money
|
169
|
+
|
170
|
+
response = parse( ssl_post(URL, post_data(action,parameters)) )
|
171
|
+
|
172
|
+
Response.new(response["response"] == "1", message_from(response), response,
|
173
|
+
:authorization => response["transactionid"],
|
174
|
+
:test => test?,
|
175
|
+
:cvv_result => response["cvvresponse"],
|
176
|
+
:avs_result => { :code => response["avsresponse"] }
|
177
|
+
)
|
178
|
+
|
179
|
+
end
|
180
|
+
|
181
|
+
def expdate(creditcard)
|
182
|
+
year = sprintf("%.4i", creditcard.year)
|
183
|
+
month = sprintf("%.2i", creditcard.month)
|
184
|
+
|
185
|
+
"#{month}#{year[-2..-1]}"
|
186
|
+
end
|
187
|
+
|
188
|
+
|
189
|
+
def message_from(response)
|
190
|
+
case response["responsetext"]
|
191
|
+
when "SUCCESS","Approved"
|
192
|
+
"This transaction has been approved"
|
193
|
+
when "DECLINE"
|
194
|
+
"This transaction has been declined"
|
195
|
+
else
|
196
|
+
response["responsetext"]
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
def post_data(action, parameters = {})
|
201
|
+
post = {}
|
202
|
+
post[:username] = @options[:login]
|
203
|
+
post[:password] = @options[:password]
|
204
|
+
post[:type] = action if action
|
205
|
+
|
206
|
+
request = post.merge(parameters).map {|key,value| "#{key}=#{CGI.escape(value.to_s)}"}.join("&")
|
207
|
+
request
|
208
|
+
end
|
209
|
+
|
210
|
+
def determine_funding_source(source)
|
211
|
+
case
|
212
|
+
when source.is_a?(String) then :vault
|
213
|
+
when CreditCard.card_companies.keys.include?(card_brand(source)) then :credit_card
|
214
|
+
when card_brand(source) == 'check' then :check
|
215
|
+
else raise ArgumentError, "Unsupported funding source provided"
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
@@ -0,0 +1,164 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class InstapayGateway < Gateway
|
4
|
+
GATEWAY_URL = 'https://trans.instapaygateway.com/cgi-bin/process.cgi'
|
5
|
+
|
6
|
+
# The countries the gateway supports merchants from as 2 digit ISO country codes
|
7
|
+
self.supported_countries = ['US']
|
8
|
+
self.money_format = :dollars
|
9
|
+
self.default_currency = 'USD'
|
10
|
+
# The card types supported by the payment gateway
|
11
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
12
|
+
|
13
|
+
# The homepage URL of the gateway
|
14
|
+
self.homepage_url = 'http://www.instapayllc.com'
|
15
|
+
|
16
|
+
# The name of the gateway
|
17
|
+
self.display_name = 'InstaPay'
|
18
|
+
|
19
|
+
SUCCESS = "Accepted"
|
20
|
+
SUCCESS_MESSAGE = "The transaction has been approved"
|
21
|
+
|
22
|
+
def initialize(options = {})
|
23
|
+
requires!(options, :login)
|
24
|
+
@options = options
|
25
|
+
super
|
26
|
+
end
|
27
|
+
|
28
|
+
def authorize(money, creditcard, options = {})
|
29
|
+
post = {}
|
30
|
+
post[:authonly] = 1
|
31
|
+
add_amount(post, money)
|
32
|
+
add_invoice(post, options)
|
33
|
+
add_creditcard(post, creditcard)
|
34
|
+
add_address(post, options)
|
35
|
+
add_customer_data(post, options)
|
36
|
+
|
37
|
+
commit('ns_quicksale_cc', post)
|
38
|
+
end
|
39
|
+
|
40
|
+
def purchase(money, creditcard, options = {})
|
41
|
+
post = {}
|
42
|
+
add_amount(post, money)
|
43
|
+
add_invoice(post, options)
|
44
|
+
add_creditcard(post, creditcard)
|
45
|
+
add_address(post, options)
|
46
|
+
add_customer_data(post, options)
|
47
|
+
|
48
|
+
commit('ns_quicksale_cc', post)
|
49
|
+
end
|
50
|
+
|
51
|
+
def capture(money, authorization, options = {})
|
52
|
+
post = {}
|
53
|
+
add_amount(post, money)
|
54
|
+
add_reference(post, authorization)
|
55
|
+
commit('ns_quicksale_cc', post)
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def add_amount(post, money)
|
61
|
+
post[:amount] = amount(money)
|
62
|
+
end
|
63
|
+
|
64
|
+
def add_reference(post, reference)
|
65
|
+
post[:postonly] = reference
|
66
|
+
end
|
67
|
+
|
68
|
+
def add_customer_data(post, options)
|
69
|
+
post[:ci_email] = options[:email]
|
70
|
+
post["ci_IP Address"] = options[:ip]
|
71
|
+
end
|
72
|
+
|
73
|
+
def add_address(post, options)
|
74
|
+
if address = options[:billing_address] || options[:address]
|
75
|
+
post[:ci_billaddr1] = address[:address1]
|
76
|
+
post[:ci_billaddr2] = address[:address2]
|
77
|
+
post[:ci_billcity] = address[:city]
|
78
|
+
post[:ci_billstate] = address[:state]
|
79
|
+
post[:ci_billzip] = address[:zip]
|
80
|
+
post[:ci_billcountry] = address[:country]
|
81
|
+
post[:ci_phone] = address[:phone]
|
82
|
+
end
|
83
|
+
|
84
|
+
if address = options[:shipping_address]
|
85
|
+
post[:ci_shipaddr1] = address[:address1]
|
86
|
+
post[:ci_shipaddr2] = address[:address2]
|
87
|
+
post[:ci_shipcity] = address[:city]
|
88
|
+
post[:ci_shipstate] = address[:state]
|
89
|
+
post[:ci_shipzip] = address[:zip]
|
90
|
+
post[:ci_shipcountry] = address[:country]
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def add_invoice(post, options)
|
95
|
+
post[:merchantordernumber] = options[:order_id]
|
96
|
+
post[:ci_memo] = options[:description]
|
97
|
+
post[:pocustomerrefid] = options[:invoice]
|
98
|
+
end
|
99
|
+
|
100
|
+
def add_creditcard(post, creditcard)
|
101
|
+
post[:ccnum] = creditcard.number
|
102
|
+
post[:expmon] = format(creditcard.month, :two_digits)
|
103
|
+
post[:cvv2] = creditcard.verification_value if creditcard.verification_value?
|
104
|
+
post[:expyear] = creditcard.year
|
105
|
+
post[:ccname] = creditcard.name
|
106
|
+
end
|
107
|
+
|
108
|
+
def parse(body)
|
109
|
+
results = {}
|
110
|
+
fields = body.split("\r\n")
|
111
|
+
|
112
|
+
response = fields[1].split('=')
|
113
|
+
response_data = response[1].split(':')
|
114
|
+
|
115
|
+
if response[0] == SUCCESS
|
116
|
+
results[:success] = true
|
117
|
+
results[:message] = SUCCESS_MESSAGE
|
118
|
+
results[:transaction_type] = response_data[0]
|
119
|
+
results[:authorization_code] = response_data[1]
|
120
|
+
results[:reference_number] = response_data[2]
|
121
|
+
results[:batch_number] = response_data[3]
|
122
|
+
results[:transaction_id] = response_data[4]
|
123
|
+
results[:avs_result] = response_data[5]
|
124
|
+
results[:authorize_net] = response_data[6]
|
125
|
+
results[:cvv_result] = response_data[7]
|
126
|
+
else
|
127
|
+
results[:success] = false
|
128
|
+
results[:result] = response_data[0]
|
129
|
+
results[:response_code] = response_data[1]
|
130
|
+
results[:message] = response_data[2]
|
131
|
+
end
|
132
|
+
|
133
|
+
fields[1..-1].each do |pair|
|
134
|
+
key, value = pair.split('=')
|
135
|
+
results[key] = value
|
136
|
+
end
|
137
|
+
results
|
138
|
+
end
|
139
|
+
|
140
|
+
def commit(action, parameters)
|
141
|
+
data = ssl_post GATEWAY_URL , post_data(action, parameters)
|
142
|
+
response = parse(data)
|
143
|
+
|
144
|
+
Response.new(response[:success] , response[:message], response,
|
145
|
+
:authorization => response[:transaction_id],
|
146
|
+
:avs_result => { :code => response[:avs_result] },
|
147
|
+
:cvv_result => response[:cvv_result]
|
148
|
+
)
|
149
|
+
end
|
150
|
+
|
151
|
+
def post_data(action, parameters = {})
|
152
|
+
post = {}
|
153
|
+
post[:acctid] = @options[:login]
|
154
|
+
if(@options[:password])
|
155
|
+
post[:merchantpin] = @options[:password]
|
156
|
+
end
|
157
|
+
post[:action] = action
|
158
|
+
request = post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
|
159
|
+
request
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
@@ -0,0 +1,258 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
# For more information on the Iridium Gateway please download the
|
4
|
+
# documentation from their Merchant Management System.
|
5
|
+
#
|
6
|
+
# The login and password are not the username and password you use to
|
7
|
+
# login to the Iridium Merchant Management System. Instead, you will
|
8
|
+
# use the API username and password you were issued separately.
|
9
|
+
class IridiumGateway < Gateway
|
10
|
+
TEST_URL = 'https://gw1.iridiumcorp.net/'
|
11
|
+
LIVE_URL = 'https://gw1.iridiumcorp.net/'
|
12
|
+
|
13
|
+
# The countries the gateway supports merchants from as 2 digit ISO country codes
|
14
|
+
self.supported_countries = ['GB', 'ES']
|
15
|
+
self.default_currency = 'EUR'
|
16
|
+
self.money_format = :cents
|
17
|
+
|
18
|
+
# The card types supported by the payment gateway
|
19
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
20
|
+
|
21
|
+
# The homepage URL of the gateway
|
22
|
+
self.homepage_url = 'http://www.iridiumcorp.co.uk/'
|
23
|
+
|
24
|
+
# The name of the gateway
|
25
|
+
self.display_name = 'Iridium'
|
26
|
+
|
27
|
+
CURRENCY_CODES = {
|
28
|
+
"AUD" => '036',
|
29
|
+
"CAD" => '124',
|
30
|
+
"EUR" => '978',
|
31
|
+
"GBP" => '826',
|
32
|
+
"MXN" => '484',
|
33
|
+
"NZD" => '554',
|
34
|
+
"USD" => '840',
|
35
|
+
}
|
36
|
+
|
37
|
+
def initialize(options = {})
|
38
|
+
requires!(options, :login, :password)
|
39
|
+
@options = options
|
40
|
+
super
|
41
|
+
end
|
42
|
+
|
43
|
+
def authorize(money, creditcard, options = {})
|
44
|
+
commit(build_purchase_request('PREAUTH', money, creditcard, options), options)
|
45
|
+
end
|
46
|
+
|
47
|
+
def purchase(money, payment_source, options = {})
|
48
|
+
setup_address_hash(options)
|
49
|
+
|
50
|
+
if payment_source.respond_to?(:number)
|
51
|
+
commit(build_purchase_request('SALE', money, payment_source, options), options)
|
52
|
+
else
|
53
|
+
commit(build_reference_request('SALE', money, payment_source, options), options)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def capture(money, authorization, options = {})
|
58
|
+
commit(build_reference_request('COLLECTION', money, authorization, options), options)
|
59
|
+
end
|
60
|
+
|
61
|
+
def credit(money, authorization, options={})
|
62
|
+
deprecated CREDIT_DEPRECATION_MESSAGE
|
63
|
+
refund(money, authorization, options)
|
64
|
+
end
|
65
|
+
|
66
|
+
def refund(money, authorization, options={})
|
67
|
+
commit(build_reference_request('REFUND', money, authorization, options), options)
|
68
|
+
end
|
69
|
+
|
70
|
+
def void(authorization, options={})
|
71
|
+
commit(build_reference_request('VOID', nil, authorization, options), options)
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def build_purchase_request(type, money, creditcard, options)
|
77
|
+
options.merge!(:action => 'CardDetailsTransaction')
|
78
|
+
build_request(options) do |xml|
|
79
|
+
add_purchase_data(xml, type, money, options)
|
80
|
+
add_creditcard(xml, creditcard)
|
81
|
+
add_customerdetails(xml, creditcard, options[:billing_address], options)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def build_reference_request(type, money, authorization, options)
|
86
|
+
options.merge!(:action => 'CrossReferenceTransaction')
|
87
|
+
order_id, cross_reference, auth_id = authorization.split(";")
|
88
|
+
build_request(options) do |xml|
|
89
|
+
if money
|
90
|
+
details = {'CurrencyCode' => currency_code(options[:currency] || default_currency), 'Amount' => amount(money)}
|
91
|
+
else
|
92
|
+
details = {'CurrencyCode' => currency_code(default_currency), 'Amount' => '0'}
|
93
|
+
end
|
94
|
+
xml.tag! 'TransactionDetails', details do
|
95
|
+
xml.tag! 'MessageDetails', {'TransactionType' => type, 'CrossReference' => cross_reference}
|
96
|
+
xml.tag! 'OrderID', (options[:order_id] || order_id)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def build_request(options)
|
102
|
+
requires!(options, :action)
|
103
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
104
|
+
xml.instruct!(:xml, :version => '1.0', :encoding => 'utf-8')
|
105
|
+
xml.tag! 'soap:Envelope', { 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/',
|
106
|
+
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
|
107
|
+
'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema'} do
|
108
|
+
xml.tag! 'soap:Body' do
|
109
|
+
xml.tag! options[:action], {'xmlns' => "https://www.thepaymentgateway.net/"} do
|
110
|
+
xml.tag! 'PaymentMessage' do
|
111
|
+
add_merchant_data(xml, options)
|
112
|
+
yield(xml)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
xml.target!
|
118
|
+
end
|
119
|
+
|
120
|
+
def setup_address_hash(options)
|
121
|
+
options[:billing_address] = options[:billing_address] || options[:address] || {}
|
122
|
+
options[:shipping_address] = options[:shipping_address] || {}
|
123
|
+
end
|
124
|
+
|
125
|
+
def add_purchase_data(xml, type, money, options)
|
126
|
+
requires!(options, :order_id)
|
127
|
+
xml.tag! 'TransactionDetails', {'Amount' => amount(money), 'CurrencyCode' => currency_code(options[:currency] || currency(money))} do
|
128
|
+
xml.tag! 'MessageDetails', {'TransactionType' => type}
|
129
|
+
xml.tag! 'OrderID', options[:order_id]
|
130
|
+
xml.tag! 'TransactionControl' do
|
131
|
+
xml.tag! 'ThreeDSecureOverridePolicy', 'FALSE'
|
132
|
+
xml.tag! 'EchoAVSCheckResult', 'TRUE'
|
133
|
+
xml.tag! 'EchoCV2CheckResult', 'TRUE'
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def add_customerdetails(xml, creditcard, address, options, shipTo = false)
|
139
|
+
xml.tag! 'CustomerDetails' do
|
140
|
+
if address
|
141
|
+
unless address[:country].blank?
|
142
|
+
country_code = Country.find(address[:country]).code(:numeric)
|
143
|
+
end
|
144
|
+
xml.tag! 'BillingAddress' do
|
145
|
+
xml.tag! 'Address1', address[:address1]
|
146
|
+
xml.tag! 'Address2', address[:address2]
|
147
|
+
xml.tag! 'City', address[:city]
|
148
|
+
xml.tag! 'State', address[:state]
|
149
|
+
xml.tag! 'PostCode', address[:zip]
|
150
|
+
xml.tag! 'CountryCode', country_code if country_code
|
151
|
+
end
|
152
|
+
xml.tag! 'PhoneNumber', address[:phone]
|
153
|
+
end
|
154
|
+
|
155
|
+
xml.tag! 'EmailAddress', options[:email]
|
156
|
+
xml.tag! 'CustomerIPAddress', options[:ip] || "127.0.0.1"
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def add_creditcard(xml, creditcard)
|
161
|
+
xml.tag! 'CardDetails' do
|
162
|
+
xml.tag! 'CardName', creditcard.name
|
163
|
+
xml.tag! 'CV2', creditcard.verification_value if creditcard.verification_value
|
164
|
+
xml.tag! 'CardNumber', creditcard.number
|
165
|
+
xml.tag! 'ExpiryDate', { 'Month' => creditcard.month.to_s.rjust(2, "0"), 'Year' => creditcard.year.to_s[/\d\d$/] }
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
def add_merchant_data(xml, options)
|
170
|
+
xml.tag! 'MerchantAuthentication', {"MerchantID" => @options[:login], "Password" => @options[:password]}
|
171
|
+
end
|
172
|
+
|
173
|
+
def commit(request, options)
|
174
|
+
requires!(options, :action)
|
175
|
+
response = parse(ssl_post(test? ? TEST_URL : LIVE_URL, request,
|
176
|
+
{"SOAPAction" => "https://www.thepaymentgateway.net/#{options[:action]}",
|
177
|
+
"Content-Type" => "text/xml; charset=utf-8" }))
|
178
|
+
|
179
|
+
success = response[:transaction_result][:status_code] == "0"
|
180
|
+
message = response[:transaction_result][:message]
|
181
|
+
authorization = success ? [ options[:order_id], response[:transaction_output_data][:cross_reference], response[:transaction_output_data][:auth_code] ].compact.join(";") : nil
|
182
|
+
|
183
|
+
Response.new(success, message, response,
|
184
|
+
:test => test?,
|
185
|
+
:authorization => authorization)
|
186
|
+
end
|
187
|
+
|
188
|
+
def parse(xml)
|
189
|
+
reply = {}
|
190
|
+
xml = REXML::Document.new(xml)
|
191
|
+
if (root = REXML::XPath.first(xml, "//CardDetailsTransactionResponse")) or
|
192
|
+
(root = REXML::XPath.first(xml, "//CrossReferenceTransactionResponse"))
|
193
|
+
root.elements.to_a.each do |node|
|
194
|
+
case node.name
|
195
|
+
when 'Message'
|
196
|
+
reply[:message] = reply(node.text)
|
197
|
+
else
|
198
|
+
parse_element(reply, node)
|
199
|
+
end
|
200
|
+
end
|
201
|
+
elsif root = REXML::XPath.first(xml, "//soap:Fault")
|
202
|
+
parse_element(reply, root)
|
203
|
+
reply[:message] = "#{reply[:faultcode]}: #{reply[:faultstring]}"
|
204
|
+
end
|
205
|
+
reply
|
206
|
+
end
|
207
|
+
|
208
|
+
def parse_element(reply, node)
|
209
|
+
case node.name
|
210
|
+
when "CrossReferenceTransactionResult"
|
211
|
+
reply[:transaction_result] = {}
|
212
|
+
node.attributes.each do |a,b|
|
213
|
+
reply[:transaction_result][a.underscore.to_sym] = b
|
214
|
+
end
|
215
|
+
node.elements.each{|e| parse_element(reply[:transaction_result], e) } if node.has_elements?
|
216
|
+
|
217
|
+
when "CardDetailsTransactionResult"
|
218
|
+
reply[:transaction_result] = {}
|
219
|
+
node.attributes.each do |a,b|
|
220
|
+
reply[:transaction_result][a.underscore.to_sym] = b
|
221
|
+
end
|
222
|
+
node.elements.each{|e| parse_element(reply[:transaction_result], e) } if node.has_elements?
|
223
|
+
|
224
|
+
when "TransactionOutputData"
|
225
|
+
reply[:transaction_output_data] = {}
|
226
|
+
node.attributes.each{|a,b| reply[:transaction_output_data][a.underscore.to_sym] = b }
|
227
|
+
node.elements.each{|e| parse_element(reply[:transaction_output_data], e) } if node.has_elements?
|
228
|
+
when "CustomVariables"
|
229
|
+
reply[:custom_variables] = {}
|
230
|
+
node.attributes.each{|a,b| reply[:custom_variables][a.underscore.to_sym] = b }
|
231
|
+
node.elements.each{|e| parse_element(reply[:custom_variables], e) } if node.has_elements?
|
232
|
+
when "GatewayEntryPoints"
|
233
|
+
reply[:gateway_entry_points] = {}
|
234
|
+
node.attributes.each{|a,b| reply[:gateway_entry_points][a.underscore.to_sym] = b }
|
235
|
+
node.elements.each{|e| parse_element(reply[:gateway_entry_points], e) } if node.has_elements?
|
236
|
+
else
|
237
|
+
k = node.name.underscore.to_sym
|
238
|
+
if node.has_elements?
|
239
|
+
reply[k] = {}
|
240
|
+
node.elements.each{|e| parse_element(reply[k], e) }
|
241
|
+
else
|
242
|
+
if node.has_attributes?
|
243
|
+
reply[k] = {}
|
244
|
+
node.attributes.each{|a,b| reply[k][a.underscore.to_sym] = b }
|
245
|
+
else
|
246
|
+
reply[k] = node.text
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
250
|
+
reply
|
251
|
+
end
|
252
|
+
|
253
|
+
def currency_code(currency)
|
254
|
+
CURRENCY_CODES[currency]
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|