activemerchant 1.28.0 → 1.29.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +3 -3
- data/CHANGELOG +36 -0
- data/CONTRIBUTORS +8 -0
- data/README.md +5 -0
- data/lib/active_merchant/billing/gateway.rb +2 -1
- data/lib/active_merchant/billing/gateways.rb +6 -7
- data/lib/active_merchant/billing/gateways/authorize_net.rb +3 -2
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +77 -78
- data/lib/active_merchant/billing/gateways/balanced.rb +0 -1
- data/lib/active_merchant/billing/gateways/banwire.rb +1 -2
- data/lib/active_merchant/billing/gateways/barclays_epdq.rb +19 -20
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +35 -36
- data/lib/active_merchant/billing/gateways/blue_pay.rb +135 -140
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +12 -4
- data/lib/active_merchant/billing/gateways/card_stream.rb +54 -59
- data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -1
- data/lib/active_merchant/billing/gateways/cyber_source.rb +19 -14
- data/lib/active_merchant/billing/gateways/data_cash.rb +106 -112
- data/lib/active_merchant/billing/gateways/efsnet.rb +29 -34
- data/lib/active_merchant/billing/gateways/elavon.rb +7 -1
- data/lib/active_merchant/billing/gateways/epay.rb +0 -1
- data/lib/active_merchant/billing/gateways/eway.rb +88 -93
- data/lib/active_merchant/billing/gateways/eway_managed.rb +47 -51
- data/lib/active_merchant/billing/gateways/exact.rb +45 -54
- data/lib/active_merchant/billing/gateways/federated_canada.rb +3 -4
- data/lib/active_merchant/billing/gateways/first_pay.rb +37 -38
- data/lib/active_merchant/billing/gateways/garanti.rb +1 -2
- data/lib/active_merchant/billing/gateways/hdfc.rb +207 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +5 -8
- data/lib/active_merchant/billing/gateways/inspire.rb +52 -52
- data/lib/active_merchant/billing/gateways/instapay.rb +10 -11
- data/lib/active_merchant/billing/gateways/iridium.rb +38 -39
- data/lib/active_merchant/billing/gateways/itransact.rb +7 -9
- data/lib/active_merchant/billing/gateways/jetpay.rb +45 -46
- data/lib/active_merchant/billing/gateways/linkpoint.rb +104 -108
- data/lib/active_merchant/billing/gateways/litle.rb +1 -5
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +153 -155
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +49 -50
- data/lib/active_merchant/billing/gateways/mercury.rb +272 -0
- data/lib/active_merchant/billing/gateways/metrics_global.rb +9 -10
- data/lib/active_merchant/billing/gateways/migs.rb +5 -3
- data/lib/active_merchant/billing/gateways/modern_payments.rb +6 -7
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +40 -41
- data/lib/active_merchant/billing/gateways/moneris.rb +46 -50
- data/lib/active_merchant/billing/gateways/moneris_us.rb +52 -55
- data/lib/active_merchant/billing/gateways/nab_transact.rb +0 -5
- data/lib/active_merchant/billing/gateways/net_registry.rb +20 -21
- data/lib/active_merchant/billing/gateways/netaxept.rb +30 -36
- data/lib/active_merchant/billing/gateways/netbilling.rb +2 -2
- data/lib/active_merchant/billing/gateways/ogone.rb +0 -5
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +1 -6
- data/lib/active_merchant/billing/gateways/orbital.rb +25 -21
- data/lib/active_merchant/billing/gateways/orbital/avs_result.rb +93 -0
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +1 -6
- data/lib/active_merchant/billing/gateways/pay_junction.rb +62 -63
- data/lib/active_merchant/billing/gateways/pay_secure.rb +29 -30
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +0 -5
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +33 -38
- data/lib/active_merchant/billing/gateways/payment_express.rb +48 -51
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +7 -11
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +7 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +3 -0
- data/lib/active_merchant/billing/gateways/paystation.rb +62 -64
- data/lib/active_merchant/billing/gateways/payway.rb +2 -9
- data/lib/active_merchant/billing/gateways/plugnpay.rb +0 -1
- data/lib/active_merchant/billing/gateways/psigate.rb +102 -94
- data/lib/active_merchant/billing/gateways/psl_card.rb +66 -67
- data/lib/active_merchant/billing/gateways/qbms.rb +0 -6
- data/lib/active_merchant/billing/gateways/quantum.rb +2 -8
- data/lib/active_merchant/billing/gateways/quickpay.rb +2 -3
- data/lib/active_merchant/billing/gateways/realex.rb +6 -16
- data/lib/active_merchant/billing/gateways/redsys.rb +394 -0
- data/lib/active_merchant/billing/gateways/sage.rb +15 -16
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +25 -26
- data/lib/active_merchant/billing/gateways/sage_pay.rb +51 -56
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +1 -2
- data/lib/active_merchant/billing/gateways/samurai.rb +1 -4
- data/lib/active_merchant/billing/gateways/secure_net.rb +0 -1
- data/lib/active_merchant/billing/gateways/secure_pay.rb +5 -8
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +0 -5
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +17 -18
- data/lib/active_merchant/billing/gateways/skip_jack.rb +29 -34
- data/lib/active_merchant/billing/gateways/smart_ps.rb +55 -56
- data/lib/active_merchant/billing/gateways/stripe.rb +8 -3
- data/lib/active_merchant/billing/gateways/trans_first.rb +28 -29
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +85 -87
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +27 -28
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +0 -5
- data/lib/active_merchant/billing/gateways/verifi.rb +86 -87
- data/lib/active_merchant/billing/gateways/viaklix.rb +42 -47
- data/lib/active_merchant/billing/gateways/vindicia.rb +30 -28
- data/lib/active_merchant/billing/gateways/webpay.rb +45 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +0 -6
- data/lib/active_merchant/billing/gateways/worldpay.rb +4 -9
- data/lib/active_merchant/billing/integrations/a1agregator.rb +26 -0
- data/lib/active_merchant/billing/integrations/a1agregator/helper.rb +31 -0
- data/lib/active_merchant/billing/integrations/a1agregator/notification.rb +186 -0
- data/lib/active_merchant/billing/integrations/a1agregator/status.rb +38 -0
- data/lib/active_merchant/billing/integrations/liqpay.rb +30 -0
- data/lib/active_merchant/billing/integrations/liqpay/helper.rb +43 -0
- data/lib/active_merchant/billing/integrations/liqpay/notification.rb +89 -0
- data/lib/active_merchant/billing/integrations/liqpay/return.rb +83 -0
- data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +17 -1
- data/lib/active_merchant/billing/integrations/notification.rb +4 -0
- data/lib/active_merchant/billing/integrations/pay_fast.rb +70 -0
- data/lib/active_merchant/billing/integrations/pay_fast/common.rb +42 -0
- data/lib/active_merchant/billing/integrations/pay_fast/helper.rb +50 -0
- data/lib/active_merchant/billing/integrations/pay_fast/notification.rb +134 -0
- data/lib/active_merchant/billing/integrations/pay_fast/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/paypal/notification.rb +64 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +10 -7
- data/lib/active_merchant/billing/integrations/webmoney/notification.rb +12 -0
- data/lib/active_merchant/billing/response.rb +19 -4
- data/lib/active_merchant/version.rb +1 -1
- metadata +45 -27
- metadata.gz.sig +0 -0
@@ -3,33 +3,33 @@ require 'rexml/document'
|
|
3
3
|
module ActiveMerchant #:nodoc:
|
4
4
|
module Billing #:nodoc:
|
5
5
|
|
6
|
-
# To learn more about the Moneris gateway, please contact
|
7
|
-
# eselectplus@moneris.com for a copy of their integration guide. For
|
8
|
-
# information on remote testing, please see "Test Environment Penny Value
|
9
|
-
# Response Table", and "Test Environment eFraud (AVS and CVD) Penny
|
10
|
-
# Response Values", available at Moneris' {eSelect Plus Documentation
|
6
|
+
# To learn more about the Moneris gateway, please contact
|
7
|
+
# eselectplus@moneris.com for a copy of their integration guide. For
|
8
|
+
# information on remote testing, please see "Test Environment Penny Value
|
9
|
+
# Response Table", and "Test Environment eFraud (AVS and CVD) Penny
|
10
|
+
# Response Values", available at Moneris' {eSelect Plus Documentation
|
11
11
|
# Centre}[https://www3.moneris.com/connect/en/documents/index.html].
|
12
12
|
class MonerisGateway < Gateway
|
13
13
|
self.test_url = 'https://esqa.moneris.com/gateway2/servlet/MpgRequest'
|
14
14
|
self.live_url = 'https://www3.moneris.com/gateway2/servlet/MpgRequest'
|
15
|
-
|
15
|
+
|
16
16
|
self.supported_countries = ['CA']
|
17
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
|
+
|
21
21
|
# login is your Store ID
|
22
22
|
# password is your API Token
|
23
23
|
def initialize(options = {})
|
24
24
|
requires!(options, :login, :password)
|
25
25
|
@options = { :crypt_type => 7 }.update(options)
|
26
|
-
super
|
27
|
-
end
|
28
|
-
|
29
|
-
# Referred to as "PreAuth" in the Moneris integration guide, this action
|
30
|
-
# verifies and locks funds on a customer's card, which then must be
|
26
|
+
super
|
27
|
+
end
|
28
|
+
|
29
|
+
# Referred to as "PreAuth" in the Moneris integration guide, this action
|
30
|
+
# verifies and locks funds on a customer's card, which then must be
|
31
31
|
# captured at a later date.
|
32
|
-
#
|
32
|
+
#
|
33
33
|
# Pass in +order_id+ and optionally a +customer+ parameter.
|
34
34
|
def authorize(money, creditcard_or_datakey, options = {})
|
35
35
|
requires!(options, :order_id)
|
@@ -42,10 +42,10 @@ module ActiveMerchant #:nodoc:
|
|
42
42
|
action = (post[:data_key].blank?) ? 'preauth' : 'res_preauth_cc'
|
43
43
|
commit(action, post)
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
# This action verifies funding on a customer's card and readies them for
|
47
47
|
# deposit in a merchant's account.
|
48
|
-
#
|
48
|
+
#
|
49
49
|
# Pass in <tt>order_id</tt> and optionally a <tt>customer</tt> parameter
|
50
50
|
def purchase(money, creditcard_or_datakey, options = {})
|
51
51
|
requires!(options, :order_id)
|
@@ -59,9 +59,9 @@ module ActiveMerchant #:nodoc:
|
|
59
59
|
commit(action, post)
|
60
60
|
end
|
61
61
|
|
62
|
-
# This method retrieves locked funds from a customer's account (from a
|
62
|
+
# This method retrieves locked funds from a customer's account (from a
|
63
63
|
# PreAuth) and prepares them for deposit in a merchant's account.
|
64
|
-
#
|
64
|
+
#
|
65
65
|
# Note: Moneris requires both the order_id and the transaction number of
|
66
66
|
# the original authorization. To maintain the same interface as the other
|
67
67
|
# gateways the two numbers are concatenated together with a ; separator as
|
@@ -70,27 +70,27 @@ module ActiveMerchant #:nodoc:
|
|
70
70
|
commit 'completion', crediting_params(authorization, :comp_amount => amount(money))
|
71
71
|
end
|
72
72
|
|
73
|
-
# Voiding requires the original transaction ID and order ID of some open
|
74
|
-
# transaction. Closed transactions must be refunded. Note that the only
|
73
|
+
# Voiding requires the original transaction ID and order ID of some open
|
74
|
+
# transaction. Closed transactions must be refunded. Note that the only
|
75
75
|
# methods which may be voided are +capture+ and +purchase+.
|
76
|
-
#
|
77
|
-
# Concatenate your transaction number and order_id by using a semicolon
|
78
|
-
# (';'). This is to keep the Moneris interface consistent with other
|
76
|
+
#
|
77
|
+
# Concatenate your transaction number and order_id by using a semicolon
|
78
|
+
# (';'). This is to keep the Moneris interface consistent with other
|
79
79
|
# gateways. (See +capture+ for details.)
|
80
80
|
def void(authorization, options = {})
|
81
81
|
commit 'purchasecorrection', crediting_params(authorization)
|
82
82
|
end
|
83
|
-
|
84
|
-
# Performs a refund. This method requires that the original transaction
|
85
|
-
# number and order number be included. Concatenate your transaction
|
86
|
-
# number and order_id by using a semicolon (';'). This is to keep the
|
87
|
-
# Moneris interface consistent with other gateways. (See +capture+ for
|
83
|
+
|
84
|
+
# Performs a refund. This method requires that the original transaction
|
85
|
+
# number and order number be included. Concatenate your transaction
|
86
|
+
# number and order_id by using a semicolon (';'). This is to keep the
|
87
|
+
# Moneris interface consistent with other gateways. (See +capture+ for
|
88
88
|
# details.)
|
89
89
|
def credit(money, authorization, options = {})
|
90
90
|
deprecated CREDIT_DEPRECATION_MESSAGE
|
91
91
|
refund(money, authorization, options)
|
92
92
|
end
|
93
|
-
|
93
|
+
|
94
94
|
def refund(money, authorization, options = {})
|
95
95
|
commit 'refund', crediting_params(authorization, :amount => amount(money))
|
96
96
|
end
|
@@ -118,12 +118,8 @@ module ActiveMerchant #:nodoc:
|
|
118
118
|
commit('res_update_cc', post)
|
119
119
|
end
|
120
120
|
|
121
|
-
|
122
|
-
@options[:test] || super
|
123
|
-
end
|
121
|
+
private # :nodoc: all
|
124
122
|
|
125
|
-
private # :nodoc: all
|
126
|
-
|
127
123
|
def expdate(creditcard)
|
128
124
|
sprintf("%.4i", creditcard.year)[-2..-1] + sprintf("%.2i", creditcard.month)
|
129
125
|
end
|
@@ -136,26 +132,26 @@ module ActiveMerchant #:nodoc:
|
|
136
132
|
post[:expdate] = expdate(source)
|
137
133
|
end
|
138
134
|
end
|
139
|
-
|
135
|
+
|
140
136
|
# Common params used amongst the +credit+, +void+ and +capture+ methods
|
141
137
|
def crediting_params(authorization, options = {})
|
142
138
|
{
|
143
|
-
:txn_number => split_authorization(authorization).first,
|
144
|
-
:order_id => split_authorization(authorization).last,
|
139
|
+
:txn_number => split_authorization(authorization).first,
|
140
|
+
:order_id => split_authorization(authorization).last,
|
145
141
|
:crypt_type => options[:crypt_type] || @options[:crypt_type]
|
146
142
|
}.merge(options)
|
147
143
|
end
|
148
|
-
|
149
|
-
# Splits an +authorization+ param and retrives the order id and
|
144
|
+
|
145
|
+
# Splits an +authorization+ param and retrives the order id and
|
150
146
|
# transaction number in that order.
|
151
147
|
def split_authorization(authorization)
|
152
148
|
if authorization.nil? || authorization.empty? || authorization !~ /;/
|
153
|
-
raise ArgumentError, 'You must include a valid authorization code (e.g. "1234;567")'
|
149
|
+
raise ArgumentError, 'You must include a valid authorization code (e.g. "1234;567")'
|
154
150
|
else
|
155
151
|
authorization.split(';')
|
156
152
|
end
|
157
153
|
end
|
158
|
-
|
154
|
+
|
159
155
|
def commit(action, parameters = {})
|
160
156
|
response = parse(ssl_post(test? ? self.test_url : self.live_url, post_data(action, parameters)))
|
161
157
|
|
@@ -164,27 +160,27 @@ module ActiveMerchant #:nodoc:
|
|
164
160
|
:authorization => authorization_from(response)
|
165
161
|
)
|
166
162
|
end
|
167
|
-
|
163
|
+
|
168
164
|
# Generates a Moneris authorization string of the form 'trans_id;receipt_id'.
|
169
165
|
def authorization_from(response = {})
|
170
166
|
if response[:trans_id] && response[:receipt_id]
|
171
167
|
"#{response[:trans_id]};#{response[:receipt_id]}"
|
172
168
|
end
|
173
169
|
end
|
174
|
-
|
170
|
+
|
175
171
|
# Tests for a successful response from Moneris' servers
|
176
172
|
def successful?(response)
|
177
|
-
response[:response_code] &&
|
178
|
-
response[:complete] &&
|
173
|
+
response[:response_code] &&
|
174
|
+
response[:complete] &&
|
179
175
|
(0..49).include?(response[:response_code].to_i)
|
180
176
|
end
|
181
|
-
|
177
|
+
|
182
178
|
def parse(xml)
|
183
179
|
response = { :message => "Global Error Receipt", :complete => false }
|
184
180
|
hashify_xml!(xml, response)
|
185
181
|
response
|
186
182
|
end
|
187
|
-
|
183
|
+
|
188
184
|
def hashify_xml!(xml, response)
|
189
185
|
xml = REXML::Document.new(xml)
|
190
186
|
return if xml.root.nil?
|
@@ -204,10 +200,10 @@ module ActiveMerchant #:nodoc:
|
|
204
200
|
actions[action].each do |key|
|
205
201
|
transaction.add_element(key.to_s).text = parameters[key] unless parameters[key].blank?
|
206
202
|
end
|
207
|
-
|
203
|
+
|
208
204
|
xml.to_s
|
209
205
|
end
|
210
|
-
|
206
|
+
|
211
207
|
def message_from(message)
|
212
208
|
return 'Unspecified error' if message.blank?
|
213
209
|
message.gsub(/[^\w]/, ' ').split.join(" ").capitalize
|
@@ -220,9 +216,9 @@ module ActiveMerchant #:nodoc:
|
|
220
216
|
when "false" then false
|
221
217
|
when '', "null" then nil
|
222
218
|
else field
|
223
|
-
end
|
219
|
+
end
|
224
220
|
end
|
225
|
-
|
221
|
+
|
226
222
|
def actions
|
227
223
|
{
|
228
224
|
"purchase" => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type],
|
@@ -3,49 +3,49 @@ require 'rexml/document'
|
|
3
3
|
module ActiveMerchant #:nodoc:
|
4
4
|
module Billing #:nodoc:
|
5
5
|
|
6
|
-
# To learn more about the Moneris (US) gateway, please contact
|
7
|
-
# ussales@moneris.com for a copy of their integration guide. For
|
8
|
-
# information on remote testing, please see "Test Environment Penny Value
|
9
|
-
# Response Table", and "Test Environment eFraud (AVS and CVD) Penny
|
10
|
-
# Response Values", available at Moneris' {eSelect Plus Documentation
|
6
|
+
# To learn more about the Moneris (US) gateway, please contact
|
7
|
+
# ussales@moneris.com for a copy of their integration guide. For
|
8
|
+
# information on remote testing, please see "Test Environment Penny Value
|
9
|
+
# Response Table", and "Test Environment eFraud (AVS and CVD) Penny
|
10
|
+
# Response Values", available at Moneris' {eSelect Plus Documentation
|
11
11
|
# Centre}[https://www3.moneris.com/connect/en/documents/index.html].
|
12
12
|
class MonerisUsGateway < Gateway
|
13
13
|
self.test_url = 'https://esplusqa.moneris.com/gateway_us/servlet/MpgRequest'
|
14
14
|
self.live_url = 'https://esplus.moneris.com/gateway_us/servlet/MpgRequest'
|
15
|
-
|
15
|
+
|
16
16
|
self.supported_countries = ['US']
|
17
17
|
self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :discover]
|
18
18
|
self.homepage_url = 'http://www.monerisusa.com/'
|
19
19
|
self.display_name = 'Moneris (US)'
|
20
|
-
|
20
|
+
|
21
21
|
# login is your Store ID
|
22
22
|
# password is your API Token
|
23
23
|
def initialize(options = {})
|
24
24
|
requires!(options, :login, :password)
|
25
25
|
@options = { :crypt_type => 7 }.update(options)
|
26
|
-
super
|
27
|
-
end
|
28
|
-
|
29
|
-
# Referred to as "PreAuth" in the Moneris integration guide, this action
|
30
|
-
# verifies and locks funds on a customer's card, which then must be
|
26
|
+
super
|
27
|
+
end
|
28
|
+
|
29
|
+
# Referred to as "PreAuth" in the Moneris integration guide, this action
|
30
|
+
# verifies and locks funds on a customer's card, which then must be
|
31
31
|
# captured at a later date.
|
32
|
-
#
|
32
|
+
#
|
33
33
|
# Pass in +order_id+ and optionally a +customer+ parameter.
|
34
34
|
def authorize(money, creditcard, options = {})
|
35
|
-
debit_commit 'us_preauth', money, creditcard, options
|
35
|
+
debit_commit 'us_preauth', money, creditcard, options
|
36
36
|
end
|
37
|
-
|
38
|
-
# This action verifies funding on a customer's card, and readies them for
|
37
|
+
|
38
|
+
# This action verifies funding on a customer's card, and readies them for
|
39
39
|
# deposit in a merchant's account.
|
40
|
-
#
|
40
|
+
#
|
41
41
|
# Pass in <tt>order_id</tt> and optionally a <tt>customer</tt> parameter
|
42
42
|
def purchase(money, creditcard, options = {})
|
43
43
|
debit_commit 'us_purchase', money, creditcard, options
|
44
44
|
end
|
45
|
-
|
46
|
-
# This method retrieves locked funds from a customer's account (from a
|
45
|
+
|
46
|
+
# This method retrieves locked funds from a customer's account (from a
|
47
47
|
# PreAuth) and prepares them for deposit in a merchant's account.
|
48
|
-
#
|
48
|
+
#
|
49
49
|
# Note: Moneris requires both the order_id and the transaction number of
|
50
50
|
# the original authorization. To maintain the same interface as the other
|
51
51
|
# gateways the two numbers are concatenated together with a ; separator as
|
@@ -54,45 +54,42 @@ module ActiveMerchant #:nodoc:
|
|
54
54
|
commit 'us_completion', crediting_params(authorization, :comp_amount => amount(money))
|
55
55
|
end
|
56
56
|
|
57
|
-
# Voiding requires the original transaction ID and order ID of some open
|
58
|
-
# transaction. Closed transactions must be refunded. Note that the only
|
57
|
+
# Voiding requires the original transaction ID and order ID of some open
|
58
|
+
# transaction. Closed transactions must be refunded. Note that the only
|
59
59
|
# methods which may be voided are +capture+ and +purchase+.
|
60
|
-
#
|
61
|
-
# Concatenate your transaction number and order_id by using a semicolon
|
62
|
-
# (';'). This is to keep the Moneris interface consistent with other
|
60
|
+
#
|
61
|
+
# Concatenate your transaction number and order_id by using a semicolon
|
62
|
+
# (';'). This is to keep the Moneris interface consistent with other
|
63
63
|
# gateways. (See +capture+ for details.)
|
64
64
|
def void(authorization, options = {})
|
65
65
|
commit 'us_purchasecorrection', crediting_params(authorization)
|
66
66
|
end
|
67
|
-
|
68
|
-
# Performs a refund. This method requires that the original transaction
|
69
|
-
# number and order number be included. Concatenate your transaction
|
70
|
-
# number and order_id by using a semicolon (';'). This is to keep the
|
71
|
-
# Moneris interface consistent with other gateways. (See +capture+ for
|
67
|
+
|
68
|
+
# Performs a refund. This method requires that the original transaction
|
69
|
+
# number and order number be included. Concatenate your transaction
|
70
|
+
# number and order_id by using a semicolon (';'). This is to keep the
|
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
75
|
refund(money, authorization, options)
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
def refund(money, authorization, options = {})
|
79
79
|
commit 'us_refund', crediting_params(authorization, :amount => amount(money))
|
80
80
|
end
|
81
81
|
|
82
|
-
|
83
|
-
|
84
|
-
end
|
85
|
-
private # :nodoc: all
|
86
|
-
|
82
|
+
private # :nodoc: all
|
83
|
+
|
87
84
|
def expdate(creditcard)
|
88
85
|
sprintf("%.4i", creditcard.year)[-2..-1] + sprintf("%.2i", creditcard.month)
|
89
86
|
end
|
90
|
-
|
87
|
+
|
91
88
|
def debit_commit(commit_type, money, creditcard, options)
|
92
89
|
requires!(options, :order_id)
|
93
90
|
commit(commit_type, debit_params(money, creditcard, options))
|
94
91
|
end
|
95
|
-
|
92
|
+
|
96
93
|
# Common params used amongst the +purchase+ and +authorization+ methods
|
97
94
|
def debit_params(money, creditcard, options = {})
|
98
95
|
{
|
@@ -104,26 +101,26 @@ module ActiveMerchant #:nodoc:
|
|
104
101
|
:crypt_type => options[:crypt_type] || @options[:crypt_type]
|
105
102
|
}
|
106
103
|
end
|
107
|
-
|
104
|
+
|
108
105
|
# Common params used amongst the +credit+, +void+ and +capture+ methods
|
109
106
|
def crediting_params(authorization, options = {})
|
110
107
|
{
|
111
|
-
:txn_number => split_authorization(authorization).first,
|
112
|
-
:order_id => split_authorization(authorization).last,
|
108
|
+
:txn_number => split_authorization(authorization).first,
|
109
|
+
:order_id => split_authorization(authorization).last,
|
113
110
|
:crypt_type => options[:crypt_type] || @options[:crypt_type]
|
114
111
|
}.merge(options)
|
115
112
|
end
|
116
|
-
|
117
|
-
# Splits an +authorization+ param and retrives the order id and
|
113
|
+
|
114
|
+
# Splits an +authorization+ param and retrives the order id and
|
118
115
|
# transaction number in that order.
|
119
116
|
def split_authorization(authorization)
|
120
117
|
if authorization.nil? || authorization.empty? || authorization !~ /;/
|
121
|
-
raise ArgumentError, 'You must include a valid authorization code (e.g. "1234;567")'
|
118
|
+
raise ArgumentError, 'You must include a valid authorization code (e.g. "1234;567")'
|
122
119
|
else
|
123
120
|
authorization.split(';')
|
124
121
|
end
|
125
122
|
end
|
126
|
-
|
123
|
+
|
127
124
|
def commit(action, parameters = {})
|
128
125
|
response = parse(ssl_post(test? ? self.test_url : self.live_url, post_data(action, parameters)))
|
129
126
|
|
@@ -132,27 +129,27 @@ module ActiveMerchant #:nodoc:
|
|
132
129
|
:authorization => authorization_from(response)
|
133
130
|
)
|
134
131
|
end
|
135
|
-
|
132
|
+
|
136
133
|
# Generates a Moneris authorization string of the form 'trans_id;receipt_id'.
|
137
134
|
def authorization_from(response = {})
|
138
135
|
if response[:trans_id] && response[:receipt_id]
|
139
136
|
"#{response[:trans_id]};#{response[:receipt_id]}"
|
140
137
|
end
|
141
138
|
end
|
142
|
-
|
139
|
+
|
143
140
|
# Tests for a successful response from Moneris' servers
|
144
141
|
def successful?(response)
|
145
|
-
response[:response_code] &&
|
146
|
-
response[:complete] &&
|
142
|
+
response[:response_code] &&
|
143
|
+
response[:complete] &&
|
147
144
|
(0..49).include?(response[:response_code].to_i)
|
148
145
|
end
|
149
|
-
|
146
|
+
|
150
147
|
def parse(xml)
|
151
148
|
response = { :message => "Global Error Receipt", :complete => false }
|
152
149
|
hashify_xml!(xml, response)
|
153
150
|
response
|
154
151
|
end
|
155
|
-
|
152
|
+
|
156
153
|
def hashify_xml!(xml, response)
|
157
154
|
xml = REXML::Document.new(xml)
|
158
155
|
return if xml.root.nil?
|
@@ -172,10 +169,10 @@ module ActiveMerchant #:nodoc:
|
|
172
169
|
actions[action].each do |key|
|
173
170
|
transaction.add_element(key.to_s).text = parameters[key] unless parameters[key].blank?
|
174
171
|
end
|
175
|
-
|
172
|
+
|
176
173
|
xml.to_s
|
177
174
|
end
|
178
|
-
|
175
|
+
|
179
176
|
def message_from(message)
|
180
177
|
return 'Unspecified error' if message.blank?
|
181
178
|
message.gsub(/[^\w]/, ' ').split.join(" ").capitalize
|
@@ -188,9 +185,9 @@ module ActiveMerchant #:nodoc:
|
|
188
185
|
when "false" then false
|
189
186
|
when '', "null" then nil
|
190
187
|
else field
|
191
|
-
end
|
188
|
+
end
|
192
189
|
end
|
193
|
-
|
190
|
+
|
194
191
|
def actions
|
195
192
|
{
|
196
193
|
"us_purchase" => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type],
|
@@ -52,14 +52,9 @@ module ActiveMerchant #:nodoc:
|
|
52
52
|
|
53
53
|
def initialize(options = {})
|
54
54
|
requires!(options, :login, :password)
|
55
|
-
@options = options
|
56
55
|
super
|
57
56
|
end
|
58
57
|
|
59
|
-
def test?
|
60
|
-
@options[:test] || super
|
61
|
-
end
|
62
|
-
|
63
58
|
def purchase(money, credit_card_or_stored_id, options = {})
|
64
59
|
if credit_card_or_stored_id.respond_to?(:number)
|
65
60
|
#Credit card for instant payment
|