bitfluent-activemerchant 1.5.1.1 → 1.15.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +168 -0
- data/CONTRIBUTORS +96 -1
- data/README.rdoc +33 -5
- data/lib/active_merchant.rb +12 -0
- data/lib/active_merchant/billing/credit_card.rb +59 -46
- data/lib/active_merchant/billing/credit_card_methods.rb +3 -3
- data/lib/active_merchant/billing/gateway.rb +16 -9
- data/lib/active_merchant/billing/gateways/authorize_net.rb +19 -9
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +134 -12
- data/lib/active_merchant/billing/gateways/barclays_epdq.rb +309 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +39 -2
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +64 -26
- data/lib/active_merchant/billing/gateways/blue_pay.rb +11 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +33 -3
- data/lib/active_merchant/billing/gateways/braintree.rb +11 -11
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -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/cyber_source.rb +5 -1
- data/lib/active_merchant/billing/gateways/data_cash.rb +6 -2
- data/lib/active_merchant/billing/gateways/efsnet.rb +8 -2
- data/lib/active_merchant/billing/gateways/epay.rb +268 -0
- data/lib/active_merchant/billing/gateways/eway_managed.rb +231 -0
- data/lib/active_merchant/billing/gateways/federated_canada.rb +168 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +8 -3
- data/lib/active_merchant/billing/gateways/garanti.rb +132 -92
- 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/iridium.rb +258 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +12 -6
- data/lib/active_merchant/billing/gateways/linkpoint.rb +6 -1
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +10 -8
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +7 -1
- data/lib/active_merchant/billing/gateways/moneris.rb +6 -2
- data/lib/active_merchant/billing/gateways/netaxept.rb +239 -0
- data/lib/active_merchant/billing/gateways/nmi.rb +13 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +16 -3
- data/lib/active_merchant/billing/gateways/orbital.rb +317 -0
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +46 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +9 -9
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +207 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +26 -9
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +11 -11
- data/lib/active_merchant/billing/gateways/payflow_express.rb +122 -38
- data/lib/active_merchant/billing/gateways/payment_express.rb +7 -2
- data/lib/active_merchant/billing/gateways/paypal.rb +5 -5
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +33 -8
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +26 -15
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +1 -1
- data/lib/active_merchant/billing/gateways/paypal_express.rb +55 -13
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +8 -3
- data/lib/active_merchant/billing/gateways/plugnpay.rb +9 -3
- data/lib/active_merchant/billing/gateways/psigate.rb +5 -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 +7 -2
- data/lib/active_merchant/billing/gateways/realex.rb +187 -76
- data/lib/active_merchant/billing/gateways/sage_pay.rb +16 -5
- data/lib/active_merchant/billing/gateways/secure_net.rb +330 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +39 -3
- data/lib/active_merchant/billing/gateways/smart_ps.rb +9 -3
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +7 -2
- data/lib/active_merchant/billing/gateways/usa_epay.rb +1 -1
- data/lib/active_merchant/billing/gateways/verifi.rb +6 -1
- data/lib/active_merchant/billing/gateways/viaklix.rb +1 -1
- data/lib/active_merchant/billing/gateways/worldpay.rb +280 -0
- data/lib/active_merchant/billing/integrations.rb +0 -12
- data/lib/active_merchant/billing/integrations/action_view_helper.rb +13 -24
- data/lib/active_merchant/billing/integrations/bogus.rb +2 -2
- data/lib/active_merchant/billing/integrations/chronopay.rb +2 -2
- data/lib/active_merchant/billing/integrations/direc_pay.rb +41 -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/directebanking.rb +47 -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/gestpay.rb +2 -2
- data/lib/active_merchant/billing/integrations/helper.rb +14 -11
- data/lib/active_merchant/billing/integrations/hi_trust.rb +2 -2
- data/lib/active_merchant/billing/integrations/ipay88.rb +4 -4
- data/lib/active_merchant/billing/integrations/moneybookers.rb +26 -0
- data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +59 -0
- data/lib/active_merchant/billing/integrations/moneybookers/notification.rb +129 -0
- data/lib/active_merchant/billing/integrations/nochex.rb +2 -2
- data/lib/active_merchant/billing/integrations/notification.rb +1 -1
- data/lib/active_merchant/billing/integrations/paypal.rb +2 -2
- data/lib/active_merchant/billing/integrations/quickpay.rb +6 -2
- data/lib/active_merchant/billing/integrations/quickpay/helper.rb +1 -1
- data/lib/active_merchant/billing/integrations/quickpay/notification.rb +2 -2
- data/lib/active_merchant/billing/integrations/return.rb +10 -3
- data/lib/active_merchant/billing/integrations/sage_pay_form.rb +37 -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/two_checkout.rb +2 -2
- data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +5 -5
- data/lib/active_merchant/billing/integrations/valitor.rb +33 -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/world_pay.rb +27 -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/common.rb +1 -1
- data/lib/active_merchant/common/connection.rb +13 -8
- data/lib/active_merchant/common/country.rb +15 -6
- data/lib/active_merchant/common/post_data.rb +1 -1
- data/lib/active_merchant/common/posts_data.rb +21 -5
- data/lib/active_merchant/common/utils.rb +4 -0
- data/lib/active_merchant/common/validateable.rb +20 -15
- data/lib/active_merchant/version.rb +3 -0
- data/lib/support/gateway_support.rb +1 -1
- metadata +65 -27
@@ -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
|
@@ -58,7 +58,8 @@ module ActiveMerchant #:nodoc:
|
|
58
58
|
"025" => "Transaction Not Found.",
|
59
59
|
"981" => "AVS Error.",
|
60
60
|
"913" => "Invalid Card Type.",
|
61
|
-
"996" => "Terminal ID Not Found."
|
61
|
+
"996" => "Terminal ID Not Found.",
|
62
|
+
nil => "No response returned (missing credentials?)."
|
62
63
|
}
|
63
64
|
|
64
65
|
def initialize(options = {})
|
@@ -85,17 +86,20 @@ module ActiveMerchant #:nodoc:
|
|
85
86
|
end
|
86
87
|
|
87
88
|
def credit(money, transaction_id_or_card, options = {})
|
88
|
-
|
89
89
|
if transaction_id_or_card.is_a?(String)
|
90
|
-
|
91
|
-
|
90
|
+
deprecated CREDIT_DEPRECATION_MESSAGE
|
91
|
+
refund(money, transaction_id_or_card, options)
|
92
92
|
else
|
93
|
-
|
94
|
-
credit_card = transaction_id_or_card
|
93
|
+
commit(money, build_credit_request('CREDIT', money, nil, transaction_id_or_card))
|
95
94
|
end
|
95
|
+
end
|
96
96
|
|
97
|
+
def refund(money, reference, options = {})
|
98
|
+
transaction_id = reference.split(";").first
|
99
|
+
credit_card = options[:credit_card]
|
97
100
|
commit(money, build_credit_request('CREDIT', money, transaction_id, credit_card))
|
98
101
|
end
|
102
|
+
|
99
103
|
|
100
104
|
private
|
101
105
|
|
@@ -177,6 +181,8 @@ module ActiveMerchant #:nodoc:
|
|
177
181
|
end
|
178
182
|
|
179
183
|
def parse(body)
|
184
|
+
return {} if body.blank?
|
185
|
+
|
180
186
|
xml = REXML::Document.new(body)
|
181
187
|
|
182
188
|
response = {}
|
@@ -233,13 +233,18 @@ module ActiveMerchant #:nodoc:
|
|
233
233
|
#
|
234
234
|
# identification must be a valid order id previously submitted by SALE
|
235
235
|
#
|
236
|
-
def
|
236
|
+
def refund(money, identification, options = {})
|
237
237
|
options.update(
|
238
238
|
:ordertype => "CREDIT",
|
239
239
|
:order_id => identification
|
240
240
|
)
|
241
241
|
commit(money, nil, options)
|
242
242
|
end
|
243
|
+
|
244
|
+
def credit(money, identification, options = {})
|
245
|
+
deprecated CREDIT_DEPRECATION_MESSAGE
|
246
|
+
refund(money, identification, options)
|
247
|
+
end
|
243
248
|
|
244
249
|
def test?
|
245
250
|
@options[:test] || super
|
@@ -56,20 +56,22 @@ module ActiveMerchant #:nodoc:
|
|
56
56
|
post[:card_id] = card_id
|
57
57
|
commit('X', nil, post)
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
|
+
def refund(money, identification, options = {})
|
61
|
+
commit('U', money, options.merge(:transaction_id => identification))
|
62
|
+
end
|
63
|
+
|
60
64
|
def credit(money, creditcard_or_card_id, options = {})
|
61
|
-
post ={}
|
65
|
+
post = {}
|
62
66
|
add_payment_source(post, creditcard_or_card_id, options)
|
63
67
|
commit('C', money, post)
|
64
68
|
end
|
65
69
|
|
66
|
-
def void(transaction_id)
|
67
|
-
|
68
|
-
post[:transaction_id] = transaction_id
|
69
|
-
commit('V', nil, post)
|
70
|
+
def void(transaction_id, options = {})
|
71
|
+
commit('V', nil, options.merge(:transaction_id => transaction_id))
|
70
72
|
end
|
71
|
-
|
72
|
-
private
|
73
|
+
|
74
|
+
private
|
73
75
|
|
74
76
|
def add_address(post, options)
|
75
77
|
if address = options[:billing_address] || options[:address]
|
@@ -98,11 +98,17 @@ module ActiveMerchant #:nodoc:
|
|
98
98
|
# * <tt>:order_id</tt> - A unique reference for this order (required when performing a non-referenced credit)
|
99
99
|
def credit(money, identification, options = {})
|
100
100
|
if identification.is_a?(String)
|
101
|
-
|
101
|
+
deprecated CREDIT_DEPRECATION_MESSAGE
|
102
|
+
refund(money, identification, options)
|
102
103
|
else
|
103
104
|
perform_credit(money, identification, options)
|
104
105
|
end
|
105
106
|
end
|
107
|
+
|
108
|
+
def refund(money, reference, options = {})
|
109
|
+
perform_reference_credit(money, reference, options)
|
110
|
+
end
|
111
|
+
|
106
112
|
|
107
113
|
private
|
108
114
|
|
@@ -14,7 +14,7 @@ module ActiveMerchant #:nodoc:
|
|
14
14
|
LIVE_URL = 'https://www3.moneris.com/gateway2/servlet/MpgRequest'
|
15
15
|
|
16
16
|
self.supported_countries = ['CA']
|
17
|
-
self.supported_cardtypes = [:visa, :master, :american_express]
|
17
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :discover]
|
18
18
|
self.homepage_url = 'http://www.moneris.com/'
|
19
19
|
self.display_name = 'Moneris'
|
20
20
|
|
@@ -71,9 +71,13 @@ module ActiveMerchant #:nodoc:
|
|
71
71
|
# Moneris interface consistent with other gateways. (See +capture+ for
|
72
72
|
# details.)
|
73
73
|
def credit(money, authorization, options = {})
|
74
|
-
|
74
|
+
deprecated CREDIT_DEPRECATION_MESSAGE
|
75
|
+
refund(money, authorization, options)
|
75
76
|
end
|
76
77
|
|
78
|
+
def refund(money, authorization, options = {})
|
79
|
+
commit 'refund', crediting_params(authorization, :amount => amount(money))
|
80
|
+
end
|
77
81
|
private # :nodoc: all
|
78
82
|
|
79
83
|
def expdate(creditcard)
|
@@ -0,0 +1,239 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
class NetaxeptGateway < Gateway
|
6
|
+
TEST_URL = 'https://epayment-test.bbs.no/'
|
7
|
+
LIVE_URL = 'https://epayment.bbs.no/'
|
8
|
+
|
9
|
+
# The countries the gateway supports merchants from as 2 digit ISO country codes
|
10
|
+
self.supported_countries = ['NO', 'DK', 'SE', 'FI']
|
11
|
+
|
12
|
+
# The card types supported by the payment gateway
|
13
|
+
self.supported_cardtypes = [:visa, :master, :american_express]
|
14
|
+
|
15
|
+
# The homepage URL of the gateway
|
16
|
+
self.homepage_url = 'http://www.betalingsterminal.no/Netthandel-forside/'
|
17
|
+
|
18
|
+
# The name of the gateway
|
19
|
+
self.display_name = 'BBS Netaxept'
|
20
|
+
|
21
|
+
self.money_format = :cents
|
22
|
+
|
23
|
+
self.default_currency = 'NOK'
|
24
|
+
|
25
|
+
def initialize(options = {})
|
26
|
+
requires!(options, :login, :password)
|
27
|
+
@options = options
|
28
|
+
super
|
29
|
+
end
|
30
|
+
|
31
|
+
def purchase(money, creditcard, options = {})
|
32
|
+
requires!(options, :order_id)
|
33
|
+
|
34
|
+
post = {}
|
35
|
+
add_credentials(post, options)
|
36
|
+
add_transaction(post, options)
|
37
|
+
add_order(post, money, options)
|
38
|
+
add_creditcard(post, creditcard)
|
39
|
+
commit('Sale', post)
|
40
|
+
end
|
41
|
+
|
42
|
+
def authorize(money, creditcard, options = {})
|
43
|
+
requires!(options, :order_id)
|
44
|
+
|
45
|
+
post = {}
|
46
|
+
add_credentials(post, options)
|
47
|
+
add_transaction(post, options)
|
48
|
+
add_order(post, money, options)
|
49
|
+
add_creditcard(post, creditcard)
|
50
|
+
commit('Auth', post)
|
51
|
+
end
|
52
|
+
|
53
|
+
def capture(money, authorization, options = {})
|
54
|
+
post = {}
|
55
|
+
add_credentials(post, options)
|
56
|
+
add_authorization(post, authorization, money)
|
57
|
+
commit('Capture', post, false)
|
58
|
+
end
|
59
|
+
|
60
|
+
def refund(money, authorization, options = {})
|
61
|
+
post = {}
|
62
|
+
add_credentials(post, options)
|
63
|
+
add_authorization(post, authorization, money)
|
64
|
+
commit('Credit', post, false)
|
65
|
+
end
|
66
|
+
|
67
|
+
def credit(money, authorization, options = {})
|
68
|
+
deprecated CREDIT_DEPRECATION_MESSAGE
|
69
|
+
refund(money, authorization, options)
|
70
|
+
end
|
71
|
+
|
72
|
+
def void(authorization, options = {})
|
73
|
+
post = {}
|
74
|
+
add_credentials(post, options)
|
75
|
+
add_authorization(post, authorization)
|
76
|
+
commit('Annul', post, false)
|
77
|
+
end
|
78
|
+
|
79
|
+
def test?
|
80
|
+
@options[:test] || Base.gateway_mode == :test
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
private
|
85
|
+
|
86
|
+
def add_credentials(post, options)
|
87
|
+
post[:merchantId] = @options[:login]
|
88
|
+
post[:token] = @options[:password]
|
89
|
+
end
|
90
|
+
|
91
|
+
def add_authorization(post, authorization, money=nil)
|
92
|
+
post[:transactionId] = authorization
|
93
|
+
post[:transactionAmount] = amount(money) if money
|
94
|
+
end
|
95
|
+
|
96
|
+
def add_transaction(post, options)
|
97
|
+
post[:transactionId] = generate_transaction_id(options)
|
98
|
+
post[:serviceType] = 'M'
|
99
|
+
post[:redirectUrl] = 'http://example.com'
|
100
|
+
end
|
101
|
+
|
102
|
+
def add_order(post, money, options)
|
103
|
+
post[:orderNumber] = options[:order_id]
|
104
|
+
post[:amount] = amount(money)
|
105
|
+
post[:currencyCode] = (options[:currency] || currency(money))
|
106
|
+
end
|
107
|
+
|
108
|
+
CARD_TYPE_PREFIXES = {
|
109
|
+
'visa' => 'v',
|
110
|
+
'master' => 'm',
|
111
|
+
'american_express' => 'a',
|
112
|
+
}
|
113
|
+
def add_creditcard(post, creditcard)
|
114
|
+
brand = Gateway.card_brand(creditcard)
|
115
|
+
prefix = CARD_TYPE_PREFIXES[brand]
|
116
|
+
unless prefix
|
117
|
+
raise ArgumentError.new("Card type #{brand} not supported.")
|
118
|
+
end
|
119
|
+
|
120
|
+
post[:creditcard] = {}
|
121
|
+
post[:creditcard][:"#{prefix}a"] = creditcard.number
|
122
|
+
post[:creditcard][:"#{prefix}m"] = format(creditcard.month, :two_digits)
|
123
|
+
post[:creditcard][:"#{prefix}y"] = format(creditcard.year, :two_digits)
|
124
|
+
post[:creditcard][:"#{prefix}c"] = creditcard.verification_value
|
125
|
+
end
|
126
|
+
|
127
|
+
def commit(action, parameters, setup=true)
|
128
|
+
parameters[:action] = action
|
129
|
+
|
130
|
+
response = {:success => false}
|
131
|
+
|
132
|
+
catch(:exception) do
|
133
|
+
if setup
|
134
|
+
commit_transaction_setup(response, parameters)
|
135
|
+
commit_payment_details(response, parameters)
|
136
|
+
commit_process_setup(response, parameters)
|
137
|
+
end
|
138
|
+
commit_transaction(response, parameters)
|
139
|
+
response[:success] = true
|
140
|
+
end
|
141
|
+
|
142
|
+
Response.new(response[:success], response[:message], response, :test => test?, :authorization => response[:authorization])
|
143
|
+
end
|
144
|
+
|
145
|
+
def commit_transaction_setup(response, parameters)
|
146
|
+
response[:setup] = parse(ssl_get(build_url("REST/Setup.aspx", pick(parameters, :merchantId, :token, :serviceType, :amount, :currencyCode, :redirectUrl, :orderNumber, :transactionId))))
|
147
|
+
process(response, :setup)
|
148
|
+
end
|
149
|
+
|
150
|
+
def commit_payment_details(response, parameters)
|
151
|
+
data = encode(parameters[:creditcard].merge(:BBSePay_transaction => response[:setup]['SetupString']))
|
152
|
+
response[:paymentDetails] = parse(ssl_post(build_url("terminal/default.aspx"), data), false)
|
153
|
+
process(response, :paymentDetails)
|
154
|
+
end
|
155
|
+
|
156
|
+
def commit_process_setup(response, parameters)
|
157
|
+
result = ssl_get(build_url("REST/ProcessSetup.aspx", pick(parameters, :merchantId, :token, :transactionId).merge(:transactionString => response[:paymentDetails][:result])))
|
158
|
+
response[:processSetup] = parse(result)
|
159
|
+
process(response, :processSetup)
|
160
|
+
end
|
161
|
+
|
162
|
+
def commit_transaction(response, parameters)
|
163
|
+
result = ssl_get(build_url("REST/#{parameters[:action]}.aspx", pick(parameters, :merchantId, :token, :transactionId, :transactionAmount)))
|
164
|
+
response[:action] = parse(result)
|
165
|
+
process(response, :action)
|
166
|
+
end
|
167
|
+
|
168
|
+
def process(response, step)
|
169
|
+
if response[step][:container] =~ /Exception|Error/
|
170
|
+
response[:message] = response[step]['Message']
|
171
|
+
throw :exception
|
172
|
+
else
|
173
|
+
message = (response[step]['ResponseText'] || response[step]['ResponseCode'])
|
174
|
+
response[:message] = (message || response[:message])
|
175
|
+
|
176
|
+
response[:authorization] = response[step]['TransactionId']
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
def parse(result, expects_xml=true)
|
181
|
+
if expects_xml || /^</ =~ result
|
182
|
+
doc = REXML::Document.new(result)
|
183
|
+
extract_xml(doc.root).merge(:container => doc.root.name)
|
184
|
+
else
|
185
|
+
{:result => result}
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
def extract_xml(element)
|
190
|
+
if element.has_elements?
|
191
|
+
hash = {}
|
192
|
+
element.elements.each do |e|
|
193
|
+
hash[e.name] = extract_xml(e)
|
194
|
+
end
|
195
|
+
hash
|
196
|
+
else
|
197
|
+
element.text
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def url
|
202
|
+
(test? ? TEST_URL : LIVE_URL)
|
203
|
+
end
|
204
|
+
|
205
|
+
def generate_transaction_id(options)
|
206
|
+
Digest::MD5.hexdigest("#{options.inspect}+#{Time.now}+#{rand}")
|
207
|
+
end
|
208
|
+
|
209
|
+
def pick(hash, *keys)
|
210
|
+
keys.inject({}){|h,key| h[key] = hash[key] if hash[key]; h}
|
211
|
+
end
|
212
|
+
|
213
|
+
def build_url(base, parameters=nil)
|
214
|
+
url = "#{test? ? TEST_URL : LIVE_URL}"
|
215
|
+
url << base
|
216
|
+
if parameters
|
217
|
+
url << '?'
|
218
|
+
url << encode(parameters)
|
219
|
+
end
|
220
|
+
url
|
221
|
+
end
|
222
|
+
|
223
|
+
def encode(hash)
|
224
|
+
hash.collect{|(k,v)| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"}.join('&')
|
225
|
+
end
|
226
|
+
|
227
|
+
class Response < Billing::Response
|
228
|
+
attr_reader :error_detail
|
229
|
+
def initialize(success, message, raw, options)
|
230
|
+
super
|
231
|
+
unless success
|
232
|
+
@error_detail = raw[:processSetup]['Result']['ResponseText'] if raw[:processSetup] && raw[:processSetup]['Result']
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|