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.
Files changed (117) hide show
  1. data/CHANGELOG +41 -0
  2. data/CONTRIBUTORS +12 -0
  3. data/README.md +6 -0
  4. data/lib/active_merchant/billing/gateway.rb +2 -1
  5. data/lib/active_merchant/billing/gateways/authorize_net.rb +3 -2
  6. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +77 -78
  7. data/lib/active_merchant/billing/gateways/balanced.rb +0 -1
  8. data/lib/active_merchant/billing/gateways/banwire.rb +1 -2
  9. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +19 -20
  10. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +35 -36
  11. data/lib/active_merchant/billing/gateways/blue_pay.rb +135 -140
  12. data/lib/active_merchant/billing/gateways/braintree_blue.rb +12 -4
  13. data/lib/active_merchant/billing/gateways/card_stream.rb +54 -59
  14. data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -1
  15. data/lib/active_merchant/billing/gateways/cyber_source.rb +19 -14
  16. data/lib/active_merchant/billing/gateways/data_cash.rb +106 -112
  17. data/lib/active_merchant/billing/gateways/efsnet.rb +29 -34
  18. data/lib/active_merchant/billing/gateways/elavon.rb +7 -1
  19. data/lib/active_merchant/billing/gateways/epay.rb +0 -1
  20. data/lib/active_merchant/billing/gateways/eway.rb +88 -93
  21. data/lib/active_merchant/billing/gateways/eway_managed.rb +47 -51
  22. data/lib/active_merchant/billing/gateways/eway_rapid.rb +300 -0
  23. data/lib/active_merchant/billing/gateways/exact.rb +45 -54
  24. data/lib/active_merchant/billing/gateways/federated_canada.rb +3 -4
  25. data/lib/active_merchant/billing/gateways/first_pay.rb +37 -38
  26. data/lib/active_merchant/billing/gateways/garanti.rb +1 -2
  27. data/lib/active_merchant/billing/gateways/hdfc.rb +207 -0
  28. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +5 -8
  29. data/lib/active_merchant/billing/gateways/inspire.rb +52 -52
  30. data/lib/active_merchant/billing/gateways/instapay.rb +10 -11
  31. data/lib/active_merchant/billing/gateways/iridium.rb +38 -39
  32. data/lib/active_merchant/billing/gateways/itransact.rb +7 -9
  33. data/lib/active_merchant/billing/gateways/jetpay.rb +45 -46
  34. data/lib/active_merchant/billing/gateways/linkpoint.rb +104 -108
  35. data/lib/active_merchant/billing/gateways/litle.rb +1 -5
  36. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +153 -155
  37. data/lib/active_merchant/billing/gateways/merchant_ware.rb +49 -50
  38. data/lib/active_merchant/billing/gateways/mercury.rb +272 -0
  39. data/lib/active_merchant/billing/gateways/metrics_global.rb +9 -10
  40. data/lib/active_merchant/billing/gateways/migs.rb +5 -3
  41. data/lib/active_merchant/billing/gateways/modern_payments.rb +6 -7
  42. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +40 -41
  43. data/lib/active_merchant/billing/gateways/moneris.rb +46 -50
  44. data/lib/active_merchant/billing/gateways/moneris_us.rb +52 -55
  45. data/lib/active_merchant/billing/gateways/nab_transact.rb +0 -5
  46. data/lib/active_merchant/billing/gateways/net_registry.rb +20 -21
  47. data/lib/active_merchant/billing/gateways/netaxept.rb +30 -36
  48. data/lib/active_merchant/billing/gateways/netbilling.rb +2 -2
  49. data/lib/active_merchant/billing/gateways/ogone.rb +0 -5
  50. data/lib/active_merchant/billing/gateways/optimal_payment.rb +1 -6
  51. data/lib/active_merchant/billing/gateways/orbital/avs_result.rb +93 -0
  52. data/lib/active_merchant/billing/gateways/orbital.rb +25 -21
  53. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +1 -6
  54. data/lib/active_merchant/billing/gateways/pay_junction.rb +62 -63
  55. data/lib/active_merchant/billing/gateways/pay_secure.rb +29 -30
  56. data/lib/active_merchant/billing/gateways/paybox_direct.rb +0 -5
  57. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +33 -38
  58. data/lib/active_merchant/billing/gateways/payment_express.rb +48 -51
  59. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +7 -11
  60. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +7 -0
  61. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +3 -0
  62. data/lib/active_merchant/billing/gateways/paystation.rb +62 -64
  63. data/lib/active_merchant/billing/gateways/payway.rb +2 -9
  64. data/lib/active_merchant/billing/gateways/plugnpay.rb +0 -1
  65. data/lib/active_merchant/billing/gateways/psigate.rb +102 -94
  66. data/lib/active_merchant/billing/gateways/psl_card.rb +66 -67
  67. data/lib/active_merchant/billing/gateways/qbms.rb +0 -6
  68. data/lib/active_merchant/billing/gateways/quantum.rb +2 -8
  69. data/lib/active_merchant/billing/gateways/quickpay.rb +2 -3
  70. data/lib/active_merchant/billing/gateways/realex.rb +6 -16
  71. data/lib/active_merchant/billing/gateways/redsys.rb +394 -0
  72. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +25 -26
  73. data/lib/active_merchant/billing/gateways/sage.rb +15 -16
  74. data/lib/active_merchant/billing/gateways/sage_pay.rb +51 -56
  75. data/lib/active_merchant/billing/gateways/sallie_mae.rb +1 -2
  76. data/lib/active_merchant/billing/gateways/samurai.rb +1 -4
  77. data/lib/active_merchant/billing/gateways/secure_net.rb +0 -1
  78. data/lib/active_merchant/billing/gateways/secure_pay.rb +5 -8
  79. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +0 -5
  80. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +17 -18
  81. data/lib/active_merchant/billing/gateways/skip_jack.rb +29 -34
  82. data/lib/active_merchant/billing/gateways/smart_ps.rb +55 -56
  83. data/lib/active_merchant/billing/gateways/stripe.rb +8 -3
  84. data/lib/active_merchant/billing/gateways/trans_first.rb +28 -29
  85. data/lib/active_merchant/billing/gateways/trust_commerce.rb +85 -87
  86. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +27 -28
  87. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +0 -5
  88. data/lib/active_merchant/billing/gateways/verifi.rb +86 -87
  89. data/lib/active_merchant/billing/gateways/viaklix.rb +42 -47
  90. data/lib/active_merchant/billing/gateways/vindicia.rb +30 -28
  91. data/lib/active_merchant/billing/gateways/webpay.rb +45 -0
  92. data/lib/active_merchant/billing/gateways/wirecard.rb +0 -6
  93. data/lib/active_merchant/billing/gateways/worldpay.rb +4 -9
  94. data/lib/active_merchant/billing/gateways.rb +6 -7
  95. data/lib/active_merchant/billing/integrations/a1agregator/helper.rb +31 -0
  96. data/lib/active_merchant/billing/integrations/a1agregator/notification.rb +186 -0
  97. data/lib/active_merchant/billing/integrations/a1agregator/status.rb +38 -0
  98. data/lib/active_merchant/billing/integrations/a1agregator.rb +26 -0
  99. data/lib/active_merchant/billing/integrations/liqpay/helper.rb +43 -0
  100. data/lib/active_merchant/billing/integrations/liqpay/notification.rb +89 -0
  101. data/lib/active_merchant/billing/integrations/liqpay/return.rb +83 -0
  102. data/lib/active_merchant/billing/integrations/liqpay.rb +30 -0
  103. data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +17 -1
  104. data/lib/active_merchant/billing/integrations/notification.rb +4 -0
  105. data/lib/active_merchant/billing/integrations/pay_fast/common.rb +42 -0
  106. data/lib/active_merchant/billing/integrations/pay_fast/helper.rb +50 -0
  107. data/lib/active_merchant/billing/integrations/pay_fast/notification.rb +134 -0
  108. data/lib/active_merchant/billing/integrations/pay_fast/return.rb +10 -0
  109. data/lib/active_merchant/billing/integrations/pay_fast.rb +70 -0
  110. data/lib/active_merchant/billing/integrations/paypal/notification.rb +64 -0
  111. data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +10 -7
  112. data/lib/active_merchant/billing/integrations/webmoney/notification.rb +12 -0
  113. data/lib/active_merchant/billing/response.rb +17 -4
  114. data/lib/active_merchant/version.rb +1 -1
  115. data.tar.gz.sig +0 -0
  116. metadata +46 -27
  117. metadata.gz.sig +0 -0
@@ -8,7 +8,7 @@ module ActiveMerchant #:nodoc:
8
8
  module Billing #:nodoc:
9
9
  # TO USE:
10
10
  # First, make sure you have everything setup correctly and all of your dependencies in place with:
11
- #
11
+ #
12
12
  # require 'rubygems'
13
13
  # require 'active_merchant'
14
14
  #
@@ -63,12 +63,12 @@ module ActiveMerchant #:nodoc:
63
63
  #
64
64
  # This should be enough to get you started with Trust Commerce and active_merchant. For further information, review the methods
65
65
  # below and the rest of active_merchant's documentation, as well as Trust Commerce's user and developer documentation.
66
-
66
+
67
67
  class TrustCommerceGateway < Gateway
68
68
  self.live_url = self.test_url = 'https://vault.trustcommerce.com/trans/'
69
-
69
+
70
70
  SUCCESS_TYPES = ["approved", "accepted"]
71
-
71
+
72
72
  DECLINE_CODES = {
73
73
  "decline" => "The credit card was declined",
74
74
  "avs" => "AVS failed; the address entered does not match the billing address on file at the bank",
@@ -78,13 +78,13 @@ module ActiveMerchant #:nodoc:
78
78
  "carderror" => "Card number is invalid",
79
79
  "authexpired" => "Attempt to postauth an expired (more than 14 days old) preauth",
80
80
  "fraud" => "CrediGuard fraud score was below requested threshold",
81
- "blacklist" => "CrediGuard blacklist value was triggered",
81
+ "blacklist" => "CrediGuard blacklist value was triggered",
82
82
  "velocity" => "CrediGuard velocity control value was triggered",
83
83
  "dailylimit" => "Daily limit in transaction count or amount as been reached",
84
84
  "weeklylimit" => "Weekly limit in transaction count or amount as been reached",
85
85
  "monthlylimit" => "Monthly limit in transaction count or amount as been reached"
86
86
  }
87
-
87
+
88
88
  BADDATA_CODES = {
89
89
  "missingfields" => "One or more parameters required for this transaction type were not sent",
90
90
  "extrafields" => "Parameters not allowed for this transaction type were sent",
@@ -93,32 +93,32 @@ module ActiveMerchant #:nodoc:
93
93
  "merchantcantaccept" => "The merchant can't accept data passed in this field",
94
94
  "mismatch" => "Data in one of the offending fields did not cross-check with the other offending field"
95
95
  }
96
-
96
+
97
97
  ERROR_CODES = {
98
98
  "cantconnect" => "Couldn't connect to the TrustCommerce gateway",
99
99
  "dnsfailure" => "The TCLink software was unable to resolve DNS hostnames",
100
100
  "linkfailure" => "The connection was established, but was severed before the transaction could complete",
101
101
  "failtoprocess" => "The bank servers are offline and unable to authorize transactions"
102
102
  }
103
-
103
+
104
104
  TEST_LOGIN = 'TestMerchant'
105
105
  TEST_PASSWORD = 'password'
106
-
106
+
107
107
  self.money_format = :cents
108
108
  self.supported_cardtypes = [:visa, :master, :discover, :american_express, :diners_club, :jcb]
109
109
  self.supported_countries = ['US']
110
110
  self.homepage_url = 'http://www.trustcommerce.com/'
111
111
  self.display_name = 'TrustCommerce'
112
-
112
+
113
113
  def self.tclink?
114
114
  defined?(TCLink)
115
115
  end
116
-
116
+
117
117
  # Creates a new TrustCommerceGateway
118
- #
118
+ #
119
119
  # The gateway requires that a valid login and password be passed
120
120
  # in the +options+ hash.
121
- #
121
+ #
122
122
  # ==== Options
123
123
  #
124
124
  # * <tt>:login</tt> -- The TrustCommerce account login.
@@ -130,44 +130,42 @@ module ActiveMerchant #:nodoc:
130
130
  # * <tt>:password</tt> -- password
131
131
  def initialize(options = {})
132
132
  requires!(options, :login, :password)
133
-
134
- @options = options
133
+
135
134
  super
136
135
  end
137
-
136
+
138
137
  def tclink?
139
138
  self.class.tclink?
140
139
  end
141
-
140
+
142
141
  def test?
143
- @options[:login] == TEST_LOGIN &&
144
- @options[:password] == TEST_PASSWORD || @options[:test] || super
142
+ ((@options[:login] == TEST_LOGIN && @options[:password] == TEST_PASSWORD) || super)
145
143
  end
146
-
144
+
147
145
  # authorize() is the first half of the preauth(authorize)/postauth(capture) model. The TC API docs call this
148
146
  # preauth, we preserve active_merchant's nomenclature of authorize() for consistency with the rest of the library. This
149
147
  # method simply checks to make sure funds are available for a transaction, and returns a transid that can be used later to
150
148
  # postauthorize (capture) the funds.
151
-
149
+
152
150
  def authorize(money, creditcard_or_billing_id, options = {})
153
151
  parameters = {
154
152
  :amount => amount(money),
155
- }
156
-
153
+ }
154
+
157
155
  add_order_id(parameters, options)
158
156
  add_customer_data(parameters, options)
159
157
  add_payment_source(parameters, creditcard_or_billing_id)
160
158
  add_addresses(parameters, options)
161
159
  commit('preauth', parameters)
162
160
  end
163
-
161
+
164
162
  # purchase() is a simple sale. This is one of the most common types of transactions, and is extremely simple. All that you need
165
163
  # to process a purchase are an amount in cents or a money object and a creditcard object or billingid string.
166
- def purchase(money, creditcard_or_billing_id, options = {})
164
+ def purchase(money, creditcard_or_billing_id, options = {})
167
165
  parameters = {
168
166
  :amount => amount(money),
169
- }
170
-
167
+ }
168
+
171
169
  add_order_id(parameters, options)
172
170
  add_customer_data(parameters, options)
173
171
  add_payment_source(parameters, creditcard_or_billing_id)
@@ -183,62 +181,62 @@ module ActiveMerchant #:nodoc:
183
181
  :amount => amount(money),
184
182
  :transid => authorization,
185
183
  }
186
-
184
+
187
185
  commit('postauth', parameters)
188
186
  end
189
-
187
+
190
188
  # refund() allows you to return money to a card that was previously billed. You need to supply the amount, in cents or a money object,
191
189
  # that you want to refund, and a TC transid for the transaction that you are refunding.
192
- def refund(money, identification, options = {})
190
+ def refund(money, identification, options = {})
193
191
  parameters = {
194
192
  :amount => amount(money),
195
193
  :transid => identification
196
194
  }
197
-
195
+
198
196
  commit('credit', parameters)
199
197
  end
200
198
 
201
- def credit(money, identification, options = {})
199
+ def credit(money, identification, options = {})
202
200
  deprecated CREDIT_DEPRECATION_MESSAGE
203
201
  refund(money, identification, options)
204
202
  end
205
-
203
+
206
204
  # void() clears an existing authorization and releases the reserved fund
207
- # s back to the cardholder. The TC API refers to this transaction as a
208
- # reversal. After voiding, you will no longer be able to capture funds
209
- # from this authorization. TrustCommerce seems to always return a status
210
- # of "accepted" even if the transid you are trying to deauthorize has
211
- # already been captured. Note: Your account needs to be configured by
212
- # TrustCommerce to allow for reversal transactions before you can use this
213
- # method.
214
- #
215
- # NOTE: AMEX preauth's cannot be reversed. If you want to clear it more
216
- # quickly than the automatic expiration (7-10 days), you will have to
217
- # capture it and then immediately issue a credit for the same amount
205
+ # s back to the cardholder. The TC API refers to this transaction as a
206
+ # reversal. After voiding, you will no longer be able to capture funds
207
+ # from this authorization. TrustCommerce seems to always return a status
208
+ # of "accepted" even if the transid you are trying to deauthorize has
209
+ # already been captured. Note: Your account needs to be configured by
210
+ # TrustCommerce to allow for reversal transactions before you can use this
211
+ # method.
212
+ #
213
+ # NOTE: AMEX preauth's cannot be reversed. If you want to clear it more
214
+ # quickly than the automatic expiration (7-10 days), you will have to
215
+ # capture it and then immediately issue a credit for the same amount
218
216
  # which should clear the customers credit card with 48 hours according to
219
217
  # TC.
220
218
  def void(authorization, options = {})
221
219
  parameters = {
222
220
  :transid => authorization,
223
221
  }
224
-
222
+
225
223
  commit('reversal', parameters)
226
224
  end
227
-
225
+
228
226
  # recurring() a TrustCommerce account that is activated for Citatdel, TrustCommerce's
229
227
  # hosted customer billing info database.
230
228
  #
231
229
  # Recurring billing uses the same TC action as a plain-vanilla 'store', but we have a separate method for clarity. It can be called
232
230
  # like store, with the addition of a required 'periodicity' parameter:
233
- #
231
+ #
234
232
  # The parameter :periodicity should be specified as either :bimonthly, :monthly, :biweekly, :weekly, :yearly or :daily
235
233
  #
236
234
  # gateway.recurring(tendollar, creditcard, :periodicity => :weekly)
237
235
  #
238
236
  # You can optionally specify how long you want payments to continue using 'payments'
239
- def recurring(money, creditcard, options = {})
237
+ def recurring(money, creditcard, options = {})
240
238
  requires!(options, [:periodicity, :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily] )
241
-
239
+
242
240
  cycle = case options[:periodicity]
243
241
  when :monthly
244
242
  '1m'
@@ -253,7 +251,7 @@ module ActiveMerchant #:nodoc:
253
251
  when :daily
254
252
  '1d'
255
253
  end
256
-
254
+
257
255
  parameters = {
258
256
  :amount => amount(money),
259
257
  :cycle => cycle,
@@ -261,37 +259,37 @@ module ActiveMerchant #:nodoc:
261
259
  :billingid => options[:billingid] || nil,
262
260
  :payments => options[:payments] || nil,
263
261
  }
264
-
262
+
265
263
  add_creditcard(parameters, creditcard)
266
-
264
+
267
265
  commit('store', parameters)
268
- end
269
-
266
+ end
267
+
270
268
  # store() requires a TrustCommerce account that is activated for Citatdel. You can call it with a credit card and a billing ID
271
269
  # you would like to use to reference the stored credit card info for future captures. Use 'verify' to specify whether you want
272
270
  # to simply store the card in the DB, or you want TC to verify the data first.
273
-
274
- def store(creditcard, options = {})
271
+
272
+ def store(creditcard, options = {})
275
273
  parameters = {
276
274
  :verify => options[:verify] || 'y',
277
275
  :billingid => options[:billingid] || options[:billing_id] || nil,
278
276
  }
279
-
277
+
280
278
  add_creditcard(parameters, creditcard)
281
- add_addresses(parameters, options)
279
+ add_addresses(parameters, options)
282
280
  commit('store', parameters)
283
281
  end
284
-
282
+
285
283
  # To unstore a creditcard stored in Citadel using store() or recurring(), all that is required is the billing id. When you run
286
284
  # unstore() the information will be removed and a Response object will be returned indicating the success of the action.
287
285
  def unstore(identification, options = {})
288
286
  parameters = {
289
287
  :billingid => identification,
290
288
  }
291
-
289
+
292
290
  commit('unstore', parameters)
293
- end
294
-
291
+ end
292
+
295
293
  private
296
294
  def add_payment_source(params, source)
297
295
  if source.is_a?(String)
@@ -300,39 +298,39 @@ module ActiveMerchant #:nodoc:
300
298
  add_creditcard(params, source)
301
299
  end
302
300
  end
303
-
301
+
304
302
  def expdate(creditcard)
305
303
  year = sprintf("%.4i", creditcard.year)
306
304
  month = sprintf("%.2i", creditcard.month)
307
305
 
308
306
  "#{month}#{year[-2..-1]}"
309
307
  end
310
-
308
+
311
309
  def add_creditcard(params, creditcard)
312
310
  params[:media] = "cc"
313
311
  params[:name] = creditcard.name
314
- params[:cc] = creditcard.number
312
+ params[:cc] = creditcard.number
315
313
  params[:exp] = expdate(creditcard)
316
314
  params[:cvv] = creditcard.verification_value if creditcard.verification_value?
317
315
  end
318
-
316
+
319
317
  def add_order_id(params, options)
320
318
  params[:ticket] = options[:order_id] unless options[:order_id].blank?
321
319
  end
322
-
320
+
323
321
  def add_billing_id(params, billingid)
324
322
  params[:billingid] = billingid
325
323
  end
326
-
324
+
327
325
  def add_customer_data(params, options)
328
326
  params[:email] = options[:email] unless options[:email].blank?
329
327
  params[:ip] = options[:ip] unless options[:ip].blank?
330
328
  end
331
-
329
+
332
330
  def add_addresses(params, options)
333
331
  address = options[:billing_address] || options[:address]
334
-
335
- if address
332
+
333
+ if address
336
334
  params[:address1] = address[:address1] unless address[:address1].blank?
337
335
  params[:address2] = address[:address2] unless address[:address2].blank?
338
336
  params[:city] = address[:city] unless address[:city].blank?
@@ -341,7 +339,7 @@ module ActiveMerchant #:nodoc:
341
339
  params[:country] = address[:country] unless address[:country].blank?
342
340
  params[:avs] = 'n'
343
341
  end
344
-
342
+
345
343
  if shipping_address = options[:shipping_address]
346
344
  params[:shipto_name] = shipping_address[:name] unless shipping_address[:name].blank?
347
345
  params[:shipto_address1] = shipping_address[:address1] unless shipping_address[:address1].blank?
@@ -352,7 +350,7 @@ module ActiveMerchant #:nodoc:
352
350
  params[:shipto_country] = shipping_address[:country] unless shipping_address[:country].blank?
353
351
  end
354
352
  end
355
-
353
+
356
354
  def clean_and_stringify_params(parameters)
357
355
  # TCLink wants us to send a hash with string keys, and activemerchant pushes everything around with
358
356
  # symbol keys. Before sending our input to TCLink, we convert all our keys to strings and dump the symbol keys.
@@ -364,50 +362,50 @@ module ActiveMerchant #:nodoc:
364
362
  parameters.delete(key)
365
363
  end
366
364
  end
367
-
365
+
368
366
  def post_data(parameters)
369
367
  parameters.collect { |key, value| "#{key}=#{ CGI.escape(value.to_s)}" }.join("&")
370
368
  end
371
-
369
+
372
370
  def commit(action, parameters)
373
371
  parameters[:custid] = @options[:login]
374
372
  parameters[:password] = @options[:password]
375
373
  parameters[:demo] = test? ? 'y' : 'n'
376
374
  parameters[:action] = action
377
-
375
+
378
376
  clean_and_stringify_params(parameters)
379
-
377
+
380
378
  data = if tclink?
381
379
  TCLink.send(parameters)
382
380
  else
383
381
  parse( ssl_post(self.live_url, post_data(parameters)) )
384
382
  end
385
-
383
+
386
384
  # to be considered successful, transaction status must be either "approved" or "accepted"
387
385
  success = SUCCESS_TYPES.include?(data["status"])
388
386
  message = message_from(data)
389
- Response.new(success, message, data,
390
- :test => test?,
387
+ Response.new(success, message, data,
388
+ :test => test?,
391
389
  :authorization => data["transid"],
392
390
  :cvv_result => data["cvv"],
393
391
  :avs_result => { :code => data["avs"] }
394
392
  )
395
393
  end
396
-
394
+
397
395
  def parse(body)
398
396
  results = {}
399
-
397
+
400
398
  body.split(/\n/).each do |pair|
401
399
  key,val = pair.split(/=/)
402
400
  results[key] = val
403
401
  end
404
-
402
+
405
403
  results
406
404
  end
407
-
408
- def message_from(data)
405
+
406
+ def message_from(data)
409
407
  status = case data["status"]
410
- when "decline"
408
+ when "decline"
411
409
  return DECLINE_CODES[data["declinetype"]]
412
410
  when "baddata"
413
411
  return BADDATA_CODES[data["error"]]
@@ -417,7 +415,7 @@ module ActiveMerchant #:nodoc:
417
415
  return "The transaction was successful"
418
416
  end
419
417
  end
420
-
418
+
421
419
  end
422
420
  end
423
421
  end
@@ -5,7 +5,7 @@ module ActiveMerchant #:nodoc:
5
5
  module Billing #:nodoc:
6
6
  # ==== USA ePay Advanced SOAP Interface
7
7
  #
8
- # This class encapuslates USA ePay's Advanced SOAP Interface. The Advanced Soap Interface allows
8
+ # This class encapuslates USA ePay's Advanced SOAP Interface. The Advanced Soap Interface allows
9
9
  # standard transactions, storing customer information, and recurring billing. Storing sensitive
10
10
  # information on USA ePay's servers can help with PCI DSS compliance, since customer and card data
11
11
  # do not need to be stored locally.
@@ -63,7 +63,7 @@ module ActiveMerchant #:nodoc:
63
63
  #
64
64
  class UsaEpayAdvancedGateway < Gateway
65
65
  API_VERSION = "1.4"
66
-
66
+
67
67
  TEST_URL_BASE = 'https://sandbox.usaepay.com/soap/gate/' #:nodoc:
68
68
  LIVE_URL_BASE = 'https://www.usaepay.com/soap/gate/' #:nodoc:
69
69
 
@@ -71,7 +71,7 @@ module ActiveMerchant #:nodoc:
71
71
  self.live_url = LIVE_URL_BASE
72
72
 
73
73
  FAILURE_MESSAGE = "Default Failure" #:nodoc:
74
-
74
+
75
75
  self.supported_countries = ['US']
76
76
  self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb]
77
77
  self.homepage_url = 'http://www.usaepay.com/'
@@ -154,7 +154,7 @@ module ActiveMerchant #:nodoc:
154
154
  :currency => [:string, 'Currency'],
155
155
  :non_tax => [:boolean, 'NonTax'],
156
156
  } #:nodoc:
157
-
157
+
158
158
  TRANSACTION_DETAIL_MONEY_OPTIONS = {
159
159
  :amount => [:double, 'Amount'],
160
160
  :tax => [:double, 'Tax'],
@@ -235,15 +235,14 @@ module ActiveMerchant #:nodoc:
235
235
  # * <tt>:soap_response</tt> -- set to +true+ to add :soap_response to the params hash containing the entire soap xml message
236
236
  #
237
237
  def initialize(options = {})
238
- requires! options, :login, :password
239
- @options = options
238
+ requires!(options, :login, :password)
240
239
 
241
- if @options[:software_id]
242
- self.live_url = "#{LIVE_URL_BASE}#{@options[:software_id].to_s}"
243
- self.test_url = "#{TEST_URL_BASE}#{@options[:software_id].to_s}"
240
+ if options[:software_id]
241
+ self.live_url = "#{LIVE_URL_BASE}#{options[:software_id].to_s}"
242
+ self.test_url = "#{TEST_URL_BASE}#{options[:software_id].to_s}"
244
243
  else
245
- self.live_url = @options[:live_url].to_s
246
- self.test_url = @options[:test_url].to_s if @options[:test_url]
244
+ self.live_url = options[:live_url].to_s
245
+ self.test_url = options[:test_url].to_s if options[:test_url]
247
246
  end
248
247
 
249
248
  super
@@ -251,7 +250,7 @@ module ActiveMerchant #:nodoc:
251
250
 
252
251
  # Standard Gateway Methods ======================================
253
252
 
254
- # Make a purchase with a credit card. (Authorize and
253
+ # Make a purchase with a credit card. (Authorize and
255
254
  # capture for settlement.)
256
255
  #
257
256
  # Note: See run_transaction for additional options.
@@ -302,7 +301,7 @@ module ActiveMerchant #:nodoc:
302
301
  # * <tt>:data</tt> -- base64 data about customer
303
302
  # * <tt>:url</tt> -- customer website
304
303
  # * <tt>:billing_address</tt> -- usual options
305
- # * <tt>:payment_methods</tt> -- array of payment method hashes.
304
+ # * <tt>:payment_methods</tt> -- array of payment method hashes.
306
305
  # * <tt>:method</tt> -- credit_card or check
307
306
  # * <tt>:name</tt> -- optional name/label for the method
308
307
  # * <tt>:sort</tt> -- optional integer value specifying the backup sort order, 0 is default
@@ -531,7 +530,7 @@ module ActiveMerchant #:nodoc:
531
530
  # Run a transaction.
532
531
  #
533
532
  # Note: run_sale, run_auth_only, run_credit, run_check_sale, run_check_credit
534
- # methods are also available. Each takes the same options as
533
+ # methods are also available. Each takes the same options as
535
534
  # run_transaction, but the :command option is not required.
536
535
  #
537
536
  # Recurring Note: If recurring options are included USA ePay will create a
@@ -589,7 +588,7 @@ module ActiveMerchant #:nodoc:
589
588
  end
590
589
 
591
590
  TRANSACTION_METHODS = [
592
- :run_sale, :run_auth_only, :run_credit,
591
+ :run_sale, :run_auth_only, :run_credit,
593
592
  :run_check_sale, :run_check_credit
594
593
  ] #:nodoc:
595
594
 
@@ -639,7 +638,7 @@ module ActiveMerchant #:nodoc:
639
638
  request = build_request(__method__, options)
640
639
  commit(__method__, request)
641
640
  end
642
-
641
+
643
642
  # Void a transaction.
644
643
  #
645
644
  # Note: Can only be voided before being settled.
@@ -656,7 +655,7 @@ module ActiveMerchant #:nodoc:
656
655
  request = build_request(__method__, options)
657
656
  commit(__method__, request)
658
657
  end
659
-
658
+
660
659
  # Refund transaction.
661
660
  #
662
661
  # Note: Required after a transaction has been settled. Refunds
@@ -675,7 +674,7 @@ module ActiveMerchant #:nodoc:
675
674
  request = build_request(__method__, options)
676
675
  commit(__method__, request)
677
676
  end
678
-
677
+
679
678
  # Override transaction flagged for mananager approval.
680
679
  #
681
680
  # Note: Checks only!
@@ -812,7 +811,7 @@ module ActiveMerchant #:nodoc:
812
811
  end
813
812
 
814
813
  # Check status of a transaction (custom).
815
- #
814
+ #
816
815
  # ==== Required
817
816
  # * <tt>:reference_number</tt>
818
817
  # * <tt>:fields</tt> -- string array of fields to retrieve
@@ -937,7 +936,7 @@ module ActiveMerchant #:nodoc:
937
936
  end
938
937
 
939
938
  # Builders ======================================================
940
-
939
+
941
940
  private
942
941
 
943
942
  # Build soap header, etc.
@@ -1062,7 +1061,7 @@ module ActiveMerchant #:nodoc:
1062
1061
  end
1063
1062
 
1064
1063
  # Transactions ==================================================
1065
-
1064
+
1066
1065
  def build_run_transaction(soap, options)
1067
1066
  soap.tag! 'ns1:runTransaction' do |soap|
1068
1067
  build_token soap, options
@@ -1213,7 +1212,7 @@ module ActiveMerchant #:nodoc:
1213
1212
  def build_customer_payments(soap, options)
1214
1213
  if options[:payment_methods]
1215
1214
  length = options[:payment_methods].length
1216
- soap.PaymentMethods 'SOAP-ENC:arrayType' => "ns1:PaymentMethod[#{length}]",
1215
+ soap.PaymentMethods 'SOAP-ENC:arrayType' => "ns1:PaymentMethod[#{length}]",
1217
1216
  'xsi:type' =>"ns1:PaymentMethodArray" do |soap|
1218
1217
  build_customer_payment_methods soap, options
1219
1218
  end
@@ -1239,7 +1238,7 @@ module ActiveMerchant #:nodoc:
1239
1238
  case
1240
1239
  when payment_method[:method].kind_of?(ActiveMerchant::Billing::CreditCard)
1241
1240
  build_tag soap, :string, 'CardNumber', payment_method[:method].number
1242
- build_tag soap, :string, 'CardExpiration',
1241
+ build_tag soap, :string, 'CardExpiration',
1243
1242
  "#{"%02d" % payment_method[:method].month}#{payment_method[:method].year}"
1244
1243
  if options[:billing_address]
1245
1244
  build_tag soap, :string, 'AvsStreet', options[:billing_address][:address1]
@@ -1319,7 +1318,7 @@ module ActiveMerchant #:nodoc:
1319
1318
  def build_credit_card_data(soap, options)
1320
1319
  soap.CreditCardData 'xsi:type' => "ns1:CreditCardData" do |soap|
1321
1320
  build_tag soap, :string, 'CardNumber', options[:payment_method].number
1322
- build_tag soap, :string, 'CardExpiration',
1321
+ build_tag soap, :string, 'CardExpiration',
1323
1322
  "#{"%02d" % options[:payment_method].month}#{options[:payment_method].year}"
1324
1323
  if options[:billing_address]
1325
1324
  build_tag soap, :string, 'AvsStreet', options[:billing_address][:address1]
@@ -1397,7 +1396,7 @@ module ActiveMerchant #:nodoc:
1397
1396
 
1398
1397
  def build_line_items(soap, options) # TODO
1399
1398
  end
1400
-
1399
+
1401
1400
  def build_custom_fields(soap, options) # TODO
1402
1401
  end
1403
1402
 
@@ -1444,7 +1443,7 @@ module ActiveMerchant #:nodoc:
1444
1443
  fault = (!response) || (response.length < 1) || response.has_key?('faultcode')
1445
1444
  return [response, success, response['faultstring'], authorization, avs, cvv] if fault
1446
1445
 
1447
- if response.respond_to?(:[]) && p = response["#{action}_return"]
1446
+ if response.respond_to?(:[]) && p = response["#{action}_return"]
1448
1447
  if p.respond_to?(:key?) && p.key?('result_code')
1449
1448
  success = p['result_code'] == 'A' ? true : false
1450
1449
  authorization = p['ref_num']
@@ -1481,8 +1480,8 @@ module ActiveMerchant #:nodoc:
1481
1480
  response[key] = [response[key], value]
1482
1481
  end
1483
1482
  else
1484
- response[key] = parse_element(e)
1485
- end
1483
+ response[key] = parse_element(e)
1484
+ end
1486
1485
  end
1487
1486
  else
1488
1487
  response = node.text
@@ -19,7 +19,6 @@ module ActiveMerchant #:nodoc:
19
19
 
20
20
  def initialize(options = {})
21
21
  requires!(options, :login)
22
- @options = options
23
22
  super
24
23
  end
25
24
 
@@ -66,10 +65,6 @@ module ActiveMerchant #:nodoc:
66
65
  commit(:void, post)
67
66
  end
68
67
 
69
- def test?
70
- @options[:test] || super
71
- end
72
-
73
68
  private
74
69
 
75
70
  def add_amount(post, money)