activemerchant 1.28.0 → 1.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +41 -0
- data/CONTRIBUTORS +12 -0
- data/README.md +6 -0
- data/lib/active_merchant/billing/gateway.rb +2 -1
- 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/eway_rapid.rb +300 -0
- 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/avs_result.rb +93 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +25 -21
- 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/sage_core.rb +25 -26
- data/lib/active_merchant/billing/gateways/sage.rb +15 -16
- 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/gateways.rb +6 -7
- 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/a1agregator.rb +26 -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/liqpay.rb +30 -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/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/pay_fast.rb +70 -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 +17 -4
- data/lib/active_merchant/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +46 -27
- metadata.gz.sig +0 -0
|
@@ -7,9 +7,9 @@ module ActiveMerchant #:nodoc:
|
|
|
7
7
|
|
|
8
8
|
self.live_url = 'https://secure.bluepay.com/interfaces/bp20post'
|
|
9
9
|
self.rebilling_url = 'https://secure.bluepay.com/interfaces/bp20rebadmin'
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
self.ignore_http_status = true
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
RESPONSE_CODE, RESPONSE_REASON_CODE, RESPONSE_REASON_TEXT = 0, 2, 3
|
|
14
14
|
AVS_RESULT_CODE, TRANSACTION_ID, CARD_CODE_RESPONSE_CODE = 5, 6, 38
|
|
15
15
|
|
|
@@ -35,10 +35,9 @@ module ActiveMerchant #:nodoc:
|
|
|
35
35
|
#
|
|
36
36
|
# * <tt>:account_id</tt> -- The BluePay gateway Account ID (REQUIRED)
|
|
37
37
|
# * <tt>:secret_key</tt> -- The BluePay gateway Secret Key (REQUIRED)
|
|
38
|
-
# * <tt>:test</tt> -- set to true for TEST mode or false for LIVE mode
|
|
38
|
+
# * <tt>:test</tt> -- set to true for TEST mode or false for LIVE mode
|
|
39
39
|
def initialize(options = {})
|
|
40
40
|
requires!(options, :login, :password)
|
|
41
|
-
@options = options
|
|
42
41
|
super
|
|
43
42
|
end
|
|
44
43
|
|
|
@@ -54,30 +53,30 @@ module ActiveMerchant #:nodoc:
|
|
|
54
53
|
# or a token. The token is called the Master ID. This is a unique transaction ID returned from a previous transaction. This token associates all the stored information for a previous transaction.
|
|
55
54
|
# * <tt>options</tt> -- A hash of optional parameters.
|
|
56
55
|
def authorize(money, payment_object, options = {})
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
post = {}
|
|
57
|
+
post[:MASTER_ID] = ''
|
|
58
|
+
if payment_object != nil && payment_object.class() != String
|
|
59
|
+
payment_object.class() == ActiveMerchant::Billing::Check ?
|
|
61
60
|
add_check(post, payment_object) :
|
|
62
61
|
add_creditcard(post, payment_object)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
else
|
|
63
|
+
post[:MASTER_ID] = payment_object
|
|
64
|
+
end
|
|
65
|
+
add_invoice(post, options)
|
|
67
66
|
add_address(post, options)
|
|
68
67
|
add_customer_data(post, options)
|
|
69
|
-
|
|
68
|
+
if options[:rebill] != nil
|
|
70
69
|
post[:DO_REBILL] = '1'
|
|
71
70
|
post[:REB_AMOUNT] = amount(options[:rebill_amount])
|
|
72
71
|
post[:REB_FIRST_DATE] = options[:rebill_start_date]
|
|
73
72
|
post[:REB_EXPR] = options[:rebill_expression]
|
|
74
73
|
post[:REB_CYCLES] = options[:rebill_cycles]
|
|
75
74
|
end
|
|
76
|
-
|
|
75
|
+
post[:TRANS_TYPE] = 'AUTH'
|
|
77
76
|
commit('AUTH_ONLY', money, post)
|
|
78
77
|
end
|
|
79
78
|
|
|
80
|
-
# Perform a purchase, which is essentially an authorization and capture in a single operation.
|
|
79
|
+
# Perform a purchase, which is essentially an authorization and capture in a single operation.
|
|
81
80
|
# This is referred to a SALE transaction in BluePay
|
|
82
81
|
#
|
|
83
82
|
# ==== Parameters
|
|
@@ -89,26 +88,26 @@ module ActiveMerchant #:nodoc:
|
|
|
89
88
|
# or a token. The token is called the Master ID. This is a unique transaction ID returned from a previous transaction. This token associates all the stored information for a previous transaction.
|
|
90
89
|
# * <tt>options</tt> -- A hash of optional parameters.,
|
|
91
90
|
def purchase(money, payment_object, options = {})
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
91
|
+
post = {}
|
|
92
|
+
post[:MASTER_ID] = ''
|
|
93
|
+
if payment_object != nil && payment_object.class() != String
|
|
94
|
+
payment_object.class() == ActiveMerchant::Billing::Check ?
|
|
95
|
+
add_check(post, payment_object) :
|
|
96
|
+
add_creditcard(post, payment_object)
|
|
97
|
+
else
|
|
98
|
+
post[:MASTER_ID] = payment_object
|
|
99
|
+
end
|
|
100
|
+
add_invoice(post, options)
|
|
102
101
|
add_address(post, options)
|
|
103
102
|
add_customer_data(post, options)
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
if options[:rebill] != nil
|
|
104
|
+
post[:DO_REBILL] = '1'
|
|
105
|
+
post[:REB_AMOUNT] = amount(options[:rebill_amount])
|
|
107
106
|
post[:REB_FIRST_DATE] = options[:rebill_start_date]
|
|
108
107
|
post[:REB_EXPR] = options[:rebill_expression]
|
|
109
108
|
post[:REB_CYCLES] = options[:rebill_cycles]
|
|
110
109
|
end
|
|
111
|
-
|
|
110
|
+
post[:TRANS_TYPE] = 'SALE'
|
|
112
111
|
commit('AUTH_CAPTURE', money, post)
|
|
113
112
|
end
|
|
114
113
|
|
|
@@ -120,11 +119,11 @@ module ActiveMerchant #:nodoc:
|
|
|
120
119
|
# * <tt>money</tt> -- The amount to be captured as an Integer value in cents.
|
|
121
120
|
# * <tt>identification</tt> -- The Master ID, or token, returned from the previous authorize transaction.
|
|
122
121
|
def capture(money, identification, options = {})
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
post = {}
|
|
123
|
+
add_address(post, options)
|
|
124
|
+
add_customer_data(post, options)
|
|
126
125
|
post[:MASTER_ID] = identification
|
|
127
|
-
|
|
126
|
+
post[:TRANS_TYPE] = 'CAPTURE'
|
|
128
127
|
commit('PRIOR_AUTH_CAPTURE', money, post)
|
|
129
128
|
end
|
|
130
129
|
|
|
@@ -135,9 +134,9 @@ module ActiveMerchant #:nodoc:
|
|
|
135
134
|
#
|
|
136
135
|
# * <tt>identification</tt> - The Master ID, or token, returned from a previous authorize transaction.
|
|
137
136
|
def void(identification, options = {})
|
|
138
|
-
|
|
137
|
+
post = {}
|
|
139
138
|
post[:MASTER_ID] = identification
|
|
140
|
-
|
|
139
|
+
post[:TRANS_TYPE] = 'VOID'
|
|
141
140
|
commit('VOID', nil, post)
|
|
142
141
|
end
|
|
143
142
|
|
|
@@ -156,20 +155,20 @@ module ActiveMerchant #:nodoc:
|
|
|
156
155
|
# If the payment_object is either a CreditCard or Check object, then the transaction type will be an unmatched credit placing funds in the specified account. This is referred to a CREDIT transaction in BluePay.
|
|
157
156
|
# * <tt>options</tt> -- A hash of parameters.
|
|
158
157
|
def refund(money, payment_object, options = {})
|
|
159
|
-
|
|
160
|
-
|
|
158
|
+
post = {}
|
|
159
|
+
post[:PAYMENT_ACCOUNT] = ''
|
|
161
160
|
if payment_object != nil && payment_object.class() != String
|
|
162
161
|
payment_object.class() == ActiveMerchant::Billing::Check ?
|
|
163
162
|
add_check(post, payment_object) :
|
|
164
163
|
add_creditcard(post, payment_object)
|
|
165
|
-
|
|
164
|
+
post[:TRANS_TYPE] = 'CREDIT'
|
|
166
165
|
else
|
|
167
166
|
post[:MASTER_ID] = payment_object
|
|
168
|
-
|
|
167
|
+
post[:TRANS_TYPE] = 'REFUND'
|
|
169
168
|
end
|
|
170
169
|
|
|
171
170
|
options[:first_name] ? post[:NAME1] = options[:first_name] : post[:NAME1] = ''
|
|
172
|
-
post[:NAME2] = options[:last_name] if options[:last_name]
|
|
171
|
+
post[:NAME2] = options[:last_name] if options[:last_name]
|
|
173
172
|
post[:ZIP] = options[:zip] if options[:zip]
|
|
174
173
|
add_invoice(post, options)
|
|
175
174
|
add_address(post, options)
|
|
@@ -195,7 +194,7 @@ module ActiveMerchant #:nodoc:
|
|
|
195
194
|
|
|
196
195
|
# ==== Options
|
|
197
196
|
#
|
|
198
|
-
# * <tt>:rebill_start_date</tt> is a string that tells the gateway when to start the rebill. (REQUIRED)
|
|
197
|
+
# * <tt>:rebill_start_date</tt> is a string that tells the gateway when to start the rebill. (REQUIRED)
|
|
199
198
|
# Has two valid formats:
|
|
200
199
|
# "YYYY-MM-DD HH:MM:SS" Hours, minutes, and seconds are optional.
|
|
201
200
|
# "XX UNITS" Relative date as explained below. Marked from the time of the
|
|
@@ -206,16 +205,16 @@ module ActiveMerchant #:nodoc:
|
|
|
206
205
|
# * <tt>rebill_cycles</tt>: Number of times to rebill. Don't send or set to nil for infinite rebillings (or
|
|
207
206
|
# until canceled).
|
|
208
207
|
# * <tt>rebill_amount</tt>: Amount to rebill. Defaults to amount of transaction for rebillings.
|
|
209
|
-
#
|
|
208
|
+
#
|
|
210
209
|
# For example, to charge the customer $19.95 now and then charge $39.95 in 60 days every 3 months for 5 times, the options hash would be as follows:
|
|
211
210
|
# :rebill_start_date => '60 DAYS',
|
|
212
211
|
# :rebill_expression => '3 MONTHS',
|
|
213
212
|
# :rebill_cycles => '5',
|
|
214
|
-
# :rebill_amount => '39.95'
|
|
213
|
+
# :rebill_amount => '39.95'
|
|
215
214
|
# A money object of 1995 cents would be passed into the 'money' parameter.
|
|
216
215
|
def recurring(money, payment_object, options = {})
|
|
217
216
|
requires!(options, :rebill_start_date, :rebill_expression)
|
|
218
|
-
|
|
217
|
+
options[:rebill] = '1'
|
|
219
218
|
money == nil ? authorize(money, payment_object, options) :
|
|
220
219
|
purchase(money, payment_object, options)
|
|
221
220
|
end
|
|
@@ -228,7 +227,7 @@ module ActiveMerchant #:nodoc:
|
|
|
228
227
|
#
|
|
229
228
|
# * <tt>rebill_id</tt> -- A string containing the rebill_id of the recurring billing that is already active (REQUIRED)
|
|
230
229
|
def status_recurring(rebill_id)
|
|
231
|
-
|
|
230
|
+
post = {}
|
|
232
231
|
requires!(rebill_id)
|
|
233
232
|
post[:REBILL_ID] = rebill_id
|
|
234
233
|
post[:TRANS_TYPE] = 'GET'
|
|
@@ -241,7 +240,7 @@ module ActiveMerchant #:nodoc:
|
|
|
241
240
|
#
|
|
242
241
|
# ==== Options
|
|
243
242
|
#
|
|
244
|
-
# * <tt>:rebill_id</tt> -- The 12 digit rebill ID used to update a particular rebilling cycle. (REQUIRED)
|
|
243
|
+
# * <tt>:rebill_id</tt> -- The 12 digit rebill ID used to update a particular rebilling cycle. (REQUIRED)
|
|
245
244
|
# * <tt>:rebill_amount</tt> -- A string containing the new rebilling amount.
|
|
246
245
|
# * <tt>:rebill_next_date</tt> -- A string containing the new rebilling next date.
|
|
247
246
|
# * <tt>:rebill_expression</tt> -- A string containing the new rebilling expression.
|
|
@@ -249,16 +248,16 @@ module ActiveMerchant #:nodoc:
|
|
|
249
248
|
# * <tt>:rebill_next_amount</tt> -- A string containing the next rebilling amount to charge the customer. This ONLY affects the next scheduled charge; all other rebillings will continue at the regular (rebill_amount) amount.
|
|
250
249
|
# Take a look above at the recurring_payment method for similar examples on how to use.
|
|
251
250
|
def update_recurring(options = {})
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
251
|
+
post = {}
|
|
252
|
+
requires!(options, :rebill_id)
|
|
253
|
+
post[:REBILL_ID] = options[:rebill_id]
|
|
254
|
+
post[:TRANS_TYPE] = 'SET'
|
|
256
255
|
post[:REB_AMOUNT] = amount(options[:rebill_amount]) if !options[:rebill_amount].nil?
|
|
257
256
|
post[:NEXT_DATE] = options[:rebill_next_date] if !options[:rebill_next_date].nil?
|
|
258
257
|
post[:REB_EXPR] = options[:rebill_expression] if !options[:rebill_expression].nil?
|
|
259
|
-
post[:REB_CYCLES]
|
|
260
|
-
|
|
261
|
-
|
|
258
|
+
post[:REB_CYCLES] = options[:rebill_cycles] if !options[:rebill_cycles].nil?
|
|
259
|
+
post[:NEXT_AMOUNT] = options[:rebill_next_amount] if !options[:rebill_next_amount].nil?
|
|
260
|
+
commit('rebill', 'nil', post)
|
|
262
261
|
end
|
|
263
262
|
|
|
264
263
|
# Cancel a recurring payment.
|
|
@@ -269,93 +268,91 @@ module ActiveMerchant #:nodoc:
|
|
|
269
268
|
#
|
|
270
269
|
# * <tt>rebill_id</tt> -- A string containing the rebill_id of the recurring billing that you wish to cancel/stop (REQUIRED)
|
|
271
270
|
def cancel_recurring(rebill_id)
|
|
272
|
-
|
|
271
|
+
post = {}
|
|
273
272
|
requires!(rebill_id)
|
|
274
273
|
post[:REBILL_ID] = rebill_id
|
|
275
274
|
post[:TRANS_TYPE] = 'SET'
|
|
276
|
-
|
|
275
|
+
post[:STATUS] = 'stopped'
|
|
277
276
|
commit('rebill', 'nil', post)
|
|
278
277
|
end
|
|
279
278
|
|
|
280
279
|
private
|
|
281
|
-
|
|
280
|
+
|
|
282
281
|
def commit(action, money, fields)
|
|
283
282
|
fields[:AMOUNT] = amount(money) unless (fields[:TRANS_TYPE] == 'VOID' or action == 'rebill')
|
|
284
|
-
|
|
285
|
-
|
|
283
|
+
test? == true || @options[:test] == true ? fields[:MODE] = 'TEST' : fields[:MODE] = 'LIVE'
|
|
284
|
+
action == 'rebill' ? begin url = rebilling_url; fields[:TAMPER_PROOF_SEAL] = calc_rebill_tps(fields) end : begin url = live_url; fields[:TAMPER_PROOF_SEAL] = calc_tps(amount(money), fields) end
|
|
286
285
|
fields[:ACCOUNT_ID] = @options[:login]
|
|
287
286
|
data = ssl_post url, post_data(action, fields)
|
|
288
287
|
response = parse(data)
|
|
289
288
|
message = message_from(response)
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
response.has_key?('CVV2') ? cvv2 = response['CVV2'] : cvv2 = ''
|
|
301
|
-
response[CARD_CODE_RESPONSE_CODE] != '' ? cvv2 = response[CARD_CODE_RESPONSE_CODE] : cvv2 = ''
|
|
289
|
+
test_mode = test? || fields[:MODE] == 'TEST'
|
|
290
|
+
if (response.has_key?('TRANS_ID'))
|
|
291
|
+
response_id = response['TRANS_ID'].to_s()
|
|
292
|
+
elsif (response.has_key?('rebill_id'))
|
|
293
|
+
response_id = response['rebill_id'][0]
|
|
294
|
+
else
|
|
295
|
+
response_id = response[TRANSACTION_ID]
|
|
296
|
+
end
|
|
297
|
+
avs = (response[AVS_RESULT_CODE] != '' ? response[AVS_RESULT_CODE] : '')
|
|
298
|
+
cvv2 = (!response[CARD_CODE_RESPONSE_CODE].empty? ? response[CARD_CODE_RESPONSE_CODE] : '')
|
|
302
299
|
Response.new(success?(response), message, response,
|
|
303
300
|
:test => test_mode,
|
|
304
301
|
:authorization => response_id,
|
|
305
|
-
|
|
302
|
+
:fraud_review => fraud_review?(response),
|
|
306
303
|
:avs_result => { :code => avs },
|
|
307
304
|
:cvv_result => cvv2
|
|
308
305
|
)
|
|
309
306
|
end
|
|
310
307
|
|
|
311
308
|
def success?(response)
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
309
|
+
if (response['STATUS'] == '1' || message_from(response) =~ /approved/ || response.has_key?('rebill_id') || response[RESPONSE_REASON_TEXT] =~ /approved/)
|
|
310
|
+
return true
|
|
311
|
+
else
|
|
312
|
+
return false
|
|
313
|
+
end
|
|
317
314
|
end
|
|
318
315
|
|
|
319
316
|
def fraud_review?(response)
|
|
320
|
-
|
|
317
|
+
response['STATUS'] == 'E' || response['STATUS'] == '0' || response[RESPONSE_REASON_TEXT] =~ /being reviewed/
|
|
321
318
|
end
|
|
322
319
|
|
|
323
320
|
def get_rebill_id(response)
|
|
324
|
-
|
|
321
|
+
response['REBID'] if response_has.key?('REBID')
|
|
325
322
|
end
|
|
326
|
-
|
|
323
|
+
|
|
327
324
|
def parse(body)
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
325
|
+
fields = CGI::parse(body)
|
|
326
|
+
if fields.has_key?('MESSAGE') or fields.has_key?('rebill_id')
|
|
327
|
+
if fields.has_key?('MESSAGE')
|
|
328
|
+
fields['MESSAGE'][0] == "Missing ACCOUNT_ID" ? message = "The merchant login ID or password is invalid" : message = fields['MESSAGE']
|
|
329
|
+
fields['MESSAGE'][0] =~ /Approved/ ? message = "This transaction has been approved" : message = fields['MESSAGE'] if message == fields['MESSAGE']
|
|
330
|
+
fields['MESSAGE'][0] =~ /Expired/ ? message = "The credit card has expired" : message = fields['MESSAGE'] if message == fields['MESSAGE']
|
|
331
|
+
fields.delete('MESSAGE')
|
|
332
|
+
end
|
|
333
|
+
fields.has_key?('STATUS') ? begin status = fields['STATUS']; fields.delete('STATUS') end : status = ''
|
|
334
|
+
fields.has_key?('AVS') ? begin avs = fields['AVS']; fields.delete('AVS') end : avs = ''
|
|
335
|
+
fields.has_key?('CVV2') ? begin cvv2 = fields['CVV2']; fields.delete('CVV2') end : cvv2 = ''
|
|
336
|
+
fields.has_key?('MASTER_ID') ? begin trans_id = fields['MASTER_ID']; fields.delete('MASTER_ID') end : trans_id = ''
|
|
337
|
+
fields[:avs_result_code] = avs
|
|
338
|
+
fields[:card_code] = cvv2
|
|
339
|
+
fields[:response_code] = status
|
|
340
|
+
fields[:response_reason_code] = ''
|
|
341
|
+
fields[:response_reason_text] = message
|
|
342
|
+
fields[:transaction_id] = trans_id
|
|
343
|
+
return fields
|
|
344
|
+
end
|
|
345
|
+
# parse response if using other old API
|
|
346
|
+
hash = Hash.new
|
|
350
347
|
fields = fields.first[0].split(",")
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
348
|
+
fields.each_index do |x|
|
|
349
|
+
hash[x] = fields[x].tr('$','')
|
|
350
|
+
end
|
|
351
|
+
hash
|
|
355
352
|
end
|
|
356
353
|
|
|
357
354
|
def add_invoice(post, options)
|
|
358
|
-
|
|
355
|
+
post[:ORDER_ID] = options[:order_id] if options.has_key? :order_id
|
|
359
356
|
post[:INVOICE_ID] = options[:invoice] if options.has_key? :invoice
|
|
360
357
|
post[:invoice_num] = options[:order_id] if options.has_key? :order_id
|
|
361
358
|
post[:MEMO] = options[:description] if options.has_key? :description
|
|
@@ -363,9 +360,9 @@ module ActiveMerchant #:nodoc:
|
|
|
363
360
|
end
|
|
364
361
|
|
|
365
362
|
def add_creditcard(post, creditcard)
|
|
366
|
-
|
|
363
|
+
post[:PAYMENT_TYPE] = 'CREDIT'
|
|
367
364
|
post[:PAYMENT_ACCOUNT] = creditcard.number
|
|
368
|
-
post[:CARD_CVV2] = creditcard.verification_value if
|
|
365
|
+
post[:CARD_CVV2] = creditcard.verification_value if
|
|
369
366
|
creditcard.verification_value?
|
|
370
367
|
post[:CARD_EXPIRE] = expdate(creditcard)
|
|
371
368
|
post[:NAME1] = creditcard.first_name
|
|
@@ -373,34 +370,34 @@ module ActiveMerchant #:nodoc:
|
|
|
373
370
|
end
|
|
374
371
|
|
|
375
372
|
def add_check(post, check)
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
373
|
+
post[:PAYMENT_TYPE] = 'ACH'
|
|
374
|
+
post[:PAYMENT_ACCOUNT] = check.account_type + ":" + check.routing_number + ":" + check.account_number
|
|
375
|
+
post[:NAME1] = check.first_name
|
|
376
|
+
post[:NAME2] = check.last_name
|
|
380
377
|
end
|
|
381
378
|
|
|
382
379
|
def add_customer_data(post, options)
|
|
383
380
|
post[:EMAIL] = options[:email] if options.has_key? :email
|
|
384
|
-
|
|
381
|
+
post[:CUSTOM_ID] = options[:customer] if options.has_key? :customer
|
|
385
382
|
end
|
|
386
383
|
|
|
387
384
|
def add_duplicate_window(post)
|
|
388
385
|
unless duplicate_window.nil?
|
|
389
386
|
post[:duplicate_window] = duplicate_window
|
|
390
|
-
|
|
387
|
+
post[:DUPLICATE_OVERRIDE] = duplicate_window
|
|
391
388
|
end
|
|
392
389
|
end
|
|
393
390
|
|
|
394
391
|
def add_address(post, options)
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
392
|
+
if address = options[:billing_address] || options[:address]
|
|
393
|
+
post[:NAME1] = address[:first_name]
|
|
394
|
+
post[:NAME2] = address[:last_name]
|
|
398
395
|
post[:ADDR1] = address[:address1]
|
|
399
|
-
|
|
396
|
+
post[:ADDR2] = address[:address2]
|
|
400
397
|
post[:COMPANY_NAME] = address[:company]
|
|
401
398
|
post[:PHONE] = address[:phone]
|
|
402
399
|
post[:CITY] = address[:city]
|
|
403
|
-
|
|
400
|
+
post[:STATE] = address[:state].blank? ? 'n/a' : address[:state]
|
|
404
401
|
post[:ZIP] = address[:zip]
|
|
405
402
|
post[:COUNTRY] = address[:country]
|
|
406
403
|
end
|
|
@@ -408,13 +405,13 @@ module ActiveMerchant #:nodoc:
|
|
|
408
405
|
post[:NAME1] = address[:first_name]
|
|
409
406
|
post[:NAME2] = address[:last_name]
|
|
410
407
|
post[:ADDR1] = address[:address1]
|
|
411
|
-
|
|
408
|
+
post[:ADDR1] = address[:address1]
|
|
412
409
|
post[:COMPANY_NAME] = address[:company]
|
|
413
410
|
post[:PHONE] = address[:phone]
|
|
414
411
|
post[:ZIP] = address[:zip]
|
|
415
412
|
post[:CITY] = address[:city]
|
|
416
413
|
post[:COUNTRY] = address[:country]
|
|
417
|
-
post[:STATE] = address[:state].blank? ? 'n/a' : address[:state]
|
|
414
|
+
post[:STATE] = address[:state].blank? ? 'n/a' : address[:state]
|
|
418
415
|
end
|
|
419
416
|
end
|
|
420
417
|
|
|
@@ -428,8 +425,8 @@ module ActiveMerchant #:nodoc:
|
|
|
428
425
|
post[:delim_data] = "TRUE"
|
|
429
426
|
post[:delim_char] = ","
|
|
430
427
|
post[:encap_char] = "$"
|
|
431
|
-
|
|
432
|
-
|
|
428
|
+
post[:card_num] = '4111111111111111'
|
|
429
|
+
post[:exp_date] = '1212'
|
|
433
430
|
post[:solution_ID] = application_id if application_id.present? && application_id != "ActiveMerchant"
|
|
434
431
|
request = post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
|
|
435
432
|
request
|
|
@@ -441,15 +438,15 @@ module ActiveMerchant #:nodoc:
|
|
|
441
438
|
if AVS_REASON_CODES.include?(results[:response_reason_code]) && AVS_ERRORS.include?(results[:avs_result_code])
|
|
442
439
|
return AVSResult.messages[ results[:avs_result_code] ]
|
|
443
440
|
end
|
|
444
|
-
|
|
441
|
+
return (results[:response_reason_text] ? results[:response_reason_text].chomp('.') : '')
|
|
442
|
+
end
|
|
443
|
+
if results.has_key?(:response_reason_text)
|
|
444
|
+
return results[:response_reason_text].to_s()
|
|
445
|
+
end
|
|
446
|
+
if !results.has_key?('STATUS')
|
|
447
|
+
return results[RESPONSE_REASON_TEXT] ? results[RESPONSE_REASON_TEXT].chomp('.') : ''
|
|
445
448
|
end
|
|
446
|
-
|
|
447
|
-
return results[:response_reason_text].to_s()
|
|
448
|
-
end
|
|
449
|
-
if !results.has_key?('STATUS')
|
|
450
|
-
return results[RESPONSE_REASON_TEXT] ? results[RESPONSE_REASON_TEXT].chomp('.') : ''
|
|
451
|
-
end
|
|
452
|
-
end
|
|
449
|
+
end
|
|
453
450
|
|
|
454
451
|
def expdate(creditcard)
|
|
455
452
|
year = sprintf("%.4i", creditcard.year)
|
|
@@ -459,21 +456,20 @@ module ActiveMerchant #:nodoc:
|
|
|
459
456
|
end
|
|
460
457
|
|
|
461
458
|
def calc_tps(amount, post)
|
|
462
|
-
|
|
463
|
-
digest = Digest::MD5.hexdigest(@options[:password] +
|
|
464
|
-
@options[:login] + post[:TRANS_TYPE] +
|
|
465
|
-
amount.to_s() + post[:MASTER_ID].to_s() +
|
|
459
|
+
post[:NAME1] = '' if post[:NAME1].nil?
|
|
460
|
+
digest = Digest::MD5.hexdigest(@options[:password] +
|
|
461
|
+
@options[:login] + post[:TRANS_TYPE] +
|
|
462
|
+
amount.to_s() + post[:MASTER_ID].to_s() +
|
|
466
463
|
post[:NAME1].to_s() + post[:PAYMENT_ACCOUNT].to_s())
|
|
467
|
-
|
|
464
|
+
return digest
|
|
468
465
|
end
|
|
469
466
|
|
|
470
|
-
|
|
471
467
|
def calc_rebill_tps(post)
|
|
472
|
-
digest = Digest::MD5.hexdigest(@options[:password] +
|
|
468
|
+
digest = Digest::MD5.hexdigest(@options[:password] +
|
|
473
469
|
@options[:login] + post[:TRANS_TYPE] + post[:REBILL_ID][0].to_s())
|
|
474
470
|
return digest
|
|
475
471
|
end
|
|
476
|
-
|
|
472
|
+
|
|
477
473
|
def handle_response(response)
|
|
478
474
|
if ignore_http_status then
|
|
479
475
|
return response.body
|
|
@@ -486,7 +482,6 @@ module ActiveMerchant #:nodoc:
|
|
|
486
482
|
end
|
|
487
483
|
end
|
|
488
484
|
end
|
|
489
|
-
|
|
490
485
|
end
|
|
491
486
|
end
|
|
492
487
|
end
|
|
@@ -57,18 +57,20 @@ module ActiveMerchant #:nodoc:
|
|
|
57
57
|
|
|
58
58
|
def initialize(options = {})
|
|
59
59
|
requires!(options, :merchant_id, :public_key, :private_key)
|
|
60
|
-
@options = options
|
|
61
60
|
@merchant_account_id = options[:merchant_account_id]
|
|
61
|
+
|
|
62
|
+
super
|
|
63
|
+
|
|
62
64
|
Braintree::Configuration.merchant_id = options[:merchant_id]
|
|
63
65
|
Braintree::Configuration.public_key = options[:public_key]
|
|
64
66
|
Braintree::Configuration.private_key = options[:private_key]
|
|
65
67
|
Braintree::Configuration.environment = (options[:environment] || (test? ? :sandbox : :production)).to_sym
|
|
66
68
|
Braintree::Configuration.custom_user_agent = "ActiveMerchant #{ActiveMerchant::VERSION}"
|
|
69
|
+
|
|
67
70
|
if wiredump_device
|
|
68
71
|
Braintree::Configuration.logger = wiredump_device
|
|
69
72
|
Braintree::Configuration.logger.level = Logger::DEBUG
|
|
70
73
|
end
|
|
71
|
-
super
|
|
72
74
|
end
|
|
73
75
|
|
|
74
76
|
def authorize(money, credit_card_or_vault_id, options = {})
|
|
@@ -93,7 +95,7 @@ module ActiveMerchant #:nodoc:
|
|
|
93
95
|
def refund(*args)
|
|
94
96
|
# legacy signature: #refund(transaction_id, options = {})
|
|
95
97
|
# new signature: #refund(money, transaction_id, options = {})
|
|
96
|
-
money, transaction_id,
|
|
98
|
+
money, transaction_id, _ = extract_refund_args(args)
|
|
97
99
|
money = amount(money).to_s if money
|
|
98
100
|
|
|
99
101
|
commit do
|
|
@@ -140,7 +142,7 @@ module ActiveMerchant #:nodoc:
|
|
|
140
142
|
|
|
141
143
|
def update(vault_id, creditcard, options = {})
|
|
142
144
|
braintree_credit_card = nil
|
|
143
|
-
|
|
145
|
+
commit do
|
|
144
146
|
braintree_credit_card = Braintree::Customer.find(vault_id).credit_cards.detect { |cc| cc.default? }
|
|
145
147
|
return Response.new(false, 'Braintree::NotFoundError') if braintree_credit_card.nil?
|
|
146
148
|
|
|
@@ -362,9 +364,15 @@ module ActiveMerchant #:nodoc:
|
|
|
362
364
|
:submit_for_settlement => options[:submit_for_settlement]
|
|
363
365
|
}
|
|
364
366
|
}
|
|
367
|
+
|
|
365
368
|
if merchant_account_id = (options[:merchant_account_id] || @merchant_account_id)
|
|
366
369
|
parameters[:merchant_account_id] = merchant_account_id
|
|
367
370
|
end
|
|
371
|
+
|
|
372
|
+
if options[:recurring]
|
|
373
|
+
parameters[:recurring] = true
|
|
374
|
+
end
|
|
375
|
+
|
|
368
376
|
if credit_card_or_vault_id.is_a?(String) || credit_card_or_vault_id.is_a?(Integer)
|
|
369
377
|
parameters[:customer_id] = credit_card_or_vault_id
|
|
370
378
|
else
|