activemerchant 1.28.0 → 1.29.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data.tar.gz.sig +3 -3
  2. data/CHANGELOG +36 -0
  3. data/CONTRIBUTORS +8 -0
  4. data/README.md +5 -0
  5. data/lib/active_merchant/billing/gateway.rb +2 -1
  6. data/lib/active_merchant/billing/gateways.rb +6 -7
  7. data/lib/active_merchant/billing/gateways/authorize_net.rb +3 -2
  8. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +77 -78
  9. data/lib/active_merchant/billing/gateways/balanced.rb +0 -1
  10. data/lib/active_merchant/billing/gateways/banwire.rb +1 -2
  11. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +19 -20
  12. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +35 -36
  13. data/lib/active_merchant/billing/gateways/blue_pay.rb +135 -140
  14. data/lib/active_merchant/billing/gateways/braintree_blue.rb +12 -4
  15. data/lib/active_merchant/billing/gateways/card_stream.rb +54 -59
  16. data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -1
  17. data/lib/active_merchant/billing/gateways/cyber_source.rb +19 -14
  18. data/lib/active_merchant/billing/gateways/data_cash.rb +106 -112
  19. data/lib/active_merchant/billing/gateways/efsnet.rb +29 -34
  20. data/lib/active_merchant/billing/gateways/elavon.rb +7 -1
  21. data/lib/active_merchant/billing/gateways/epay.rb +0 -1
  22. data/lib/active_merchant/billing/gateways/eway.rb +88 -93
  23. data/lib/active_merchant/billing/gateways/eway_managed.rb +47 -51
  24. data/lib/active_merchant/billing/gateways/exact.rb +45 -54
  25. data/lib/active_merchant/billing/gateways/federated_canada.rb +3 -4
  26. data/lib/active_merchant/billing/gateways/first_pay.rb +37 -38
  27. data/lib/active_merchant/billing/gateways/garanti.rb +1 -2
  28. data/lib/active_merchant/billing/gateways/hdfc.rb +207 -0
  29. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +5 -8
  30. data/lib/active_merchant/billing/gateways/inspire.rb +52 -52
  31. data/lib/active_merchant/billing/gateways/instapay.rb +10 -11
  32. data/lib/active_merchant/billing/gateways/iridium.rb +38 -39
  33. data/lib/active_merchant/billing/gateways/itransact.rb +7 -9
  34. data/lib/active_merchant/billing/gateways/jetpay.rb +45 -46
  35. data/lib/active_merchant/billing/gateways/linkpoint.rb +104 -108
  36. data/lib/active_merchant/billing/gateways/litle.rb +1 -5
  37. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +153 -155
  38. data/lib/active_merchant/billing/gateways/merchant_ware.rb +49 -50
  39. data/lib/active_merchant/billing/gateways/mercury.rb +272 -0
  40. data/lib/active_merchant/billing/gateways/metrics_global.rb +9 -10
  41. data/lib/active_merchant/billing/gateways/migs.rb +5 -3
  42. data/lib/active_merchant/billing/gateways/modern_payments.rb +6 -7
  43. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +40 -41
  44. data/lib/active_merchant/billing/gateways/moneris.rb +46 -50
  45. data/lib/active_merchant/billing/gateways/moneris_us.rb +52 -55
  46. data/lib/active_merchant/billing/gateways/nab_transact.rb +0 -5
  47. data/lib/active_merchant/billing/gateways/net_registry.rb +20 -21
  48. data/lib/active_merchant/billing/gateways/netaxept.rb +30 -36
  49. data/lib/active_merchant/billing/gateways/netbilling.rb +2 -2
  50. data/lib/active_merchant/billing/gateways/ogone.rb +0 -5
  51. data/lib/active_merchant/billing/gateways/optimal_payment.rb +1 -6
  52. data/lib/active_merchant/billing/gateways/orbital.rb +25 -21
  53. data/lib/active_merchant/billing/gateways/orbital/avs_result.rb +93 -0
  54. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +1 -6
  55. data/lib/active_merchant/billing/gateways/pay_junction.rb +62 -63
  56. data/lib/active_merchant/billing/gateways/pay_secure.rb +29 -30
  57. data/lib/active_merchant/billing/gateways/paybox_direct.rb +0 -5
  58. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +33 -38
  59. data/lib/active_merchant/billing/gateways/payment_express.rb +48 -51
  60. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +7 -11
  61. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +7 -0
  62. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +3 -0
  63. data/lib/active_merchant/billing/gateways/paystation.rb +62 -64
  64. data/lib/active_merchant/billing/gateways/payway.rb +2 -9
  65. data/lib/active_merchant/billing/gateways/plugnpay.rb +0 -1
  66. data/lib/active_merchant/billing/gateways/psigate.rb +102 -94
  67. data/lib/active_merchant/billing/gateways/psl_card.rb +66 -67
  68. data/lib/active_merchant/billing/gateways/qbms.rb +0 -6
  69. data/lib/active_merchant/billing/gateways/quantum.rb +2 -8
  70. data/lib/active_merchant/billing/gateways/quickpay.rb +2 -3
  71. data/lib/active_merchant/billing/gateways/realex.rb +6 -16
  72. data/lib/active_merchant/billing/gateways/redsys.rb +394 -0
  73. data/lib/active_merchant/billing/gateways/sage.rb +15 -16
  74. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +25 -26
  75. data/lib/active_merchant/billing/gateways/sage_pay.rb +51 -56
  76. data/lib/active_merchant/billing/gateways/sallie_mae.rb +1 -2
  77. data/lib/active_merchant/billing/gateways/samurai.rb +1 -4
  78. data/lib/active_merchant/billing/gateways/secure_net.rb +0 -1
  79. data/lib/active_merchant/billing/gateways/secure_pay.rb +5 -8
  80. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +0 -5
  81. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +17 -18
  82. data/lib/active_merchant/billing/gateways/skip_jack.rb +29 -34
  83. data/lib/active_merchant/billing/gateways/smart_ps.rb +55 -56
  84. data/lib/active_merchant/billing/gateways/stripe.rb +8 -3
  85. data/lib/active_merchant/billing/gateways/trans_first.rb +28 -29
  86. data/lib/active_merchant/billing/gateways/trust_commerce.rb +85 -87
  87. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +27 -28
  88. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +0 -5
  89. data/lib/active_merchant/billing/gateways/verifi.rb +86 -87
  90. data/lib/active_merchant/billing/gateways/viaklix.rb +42 -47
  91. data/lib/active_merchant/billing/gateways/vindicia.rb +30 -28
  92. data/lib/active_merchant/billing/gateways/webpay.rb +45 -0
  93. data/lib/active_merchant/billing/gateways/wirecard.rb +0 -6
  94. data/lib/active_merchant/billing/gateways/worldpay.rb +4 -9
  95. data/lib/active_merchant/billing/integrations/a1agregator.rb +26 -0
  96. data/lib/active_merchant/billing/integrations/a1agregator/helper.rb +31 -0
  97. data/lib/active_merchant/billing/integrations/a1agregator/notification.rb +186 -0
  98. data/lib/active_merchant/billing/integrations/a1agregator/status.rb +38 -0
  99. data/lib/active_merchant/billing/integrations/liqpay.rb +30 -0
  100. data/lib/active_merchant/billing/integrations/liqpay/helper.rb +43 -0
  101. data/lib/active_merchant/billing/integrations/liqpay/notification.rb +89 -0
  102. data/lib/active_merchant/billing/integrations/liqpay/return.rb +83 -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.rb +70 -0
  106. data/lib/active_merchant/billing/integrations/pay_fast/common.rb +42 -0
  107. data/lib/active_merchant/billing/integrations/pay_fast/helper.rb +50 -0
  108. data/lib/active_merchant/billing/integrations/pay_fast/notification.rb +134 -0
  109. data/lib/active_merchant/billing/integrations/pay_fast/return.rb +10 -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 +19 -4
  114. data/lib/active_merchant/version.rb +1 -1
  115. metadata +45 -27
  116. metadata.gz.sig +0 -0
@@ -4,24 +4,21 @@ module ActiveMerchant #:nodoc:
4
4
  module Billing #:nodoc:
5
5
  class SecurePayGateway < AuthorizeNetGateway
6
6
  self.live_url = self.test_url = 'https://www.securepay.com/AuthSpayAdapter/process.aspx'
7
-
7
+
8
8
  self.homepage_url = 'http://www.securepay.com/'
9
9
  self.display_name = 'SecurePay'
10
-
10
+
11
11
  # Limit support to purchase() for the time being
12
12
  # JRuby chokes here
13
13
  # undef_method :authorize, :capture, :void, :credit
14
-
14
+
15
15
  undef_method :authorize
16
16
  undef_method :capture
17
17
  undef_method :void
18
18
  undef_method :credit
19
-
20
- def test?
21
- Base.gateway_mode == :test
22
- end
23
-
19
+
24
20
  private
21
+
25
22
  def split(response)
26
23
  response.split(',')
27
24
  end
@@ -58,14 +58,9 @@ module ActiveMerchant #:nodoc:
58
58
 
59
59
  def initialize(options = {})
60
60
  requires!(options, :login, :password)
61
- @options = options
62
61
  super
63
62
  end
64
63
 
65
- def test?
66
- @options[:test] || super
67
- end
68
-
69
64
  def purchase(money, credit_card_or_stored_id, options = {})
70
65
  if credit_card_or_stored_id.respond_to?(:number)
71
66
  requires!(options, :order_id)
@@ -18,7 +18,7 @@ module ActiveMerchant #:nodoc:
18
18
  8 => "Bad or malformed request",
19
19
  9 => "Invalid card number"
20
20
  }
21
-
21
+
22
22
  self.default_currency = 'NZD'
23
23
  self.supported_countries = ['NZ']
24
24
  self.supported_cardtypes = [:visa, :master, :american_express, :diners_club]
@@ -27,33 +27,32 @@ module ActiveMerchant #:nodoc:
27
27
 
28
28
  def initialize(options = {})
29
29
  requires!(options, :login, :password)
30
- @options = options
31
30
  super
32
- end
33
-
31
+ end
32
+
34
33
  def purchase(money, creditcard, options = {})
35
34
  post = SecurePayTechPostData.new
36
35
 
37
36
  add_invoice(post, money, options)
38
- add_creditcard(post, creditcard)
39
-
37
+ add_creditcard(post, creditcard)
38
+
40
39
  commit(:purchase, post)
41
- end
42
-
43
- private
44
-
40
+ end
41
+
42
+ private
43
+
45
44
  def add_invoice(post, money, options)
46
45
  post[:Amount] = amount(money)
47
46
  post[:Currency] = options[:currency] || currency(money)
48
47
 
49
48
  post[:OrderReference] = options[:order_id]
50
49
  end
51
-
50
+
52
51
  def add_creditcard(post, creditcard)
53
52
  post[:CardNumber] = creditcard.number
54
53
  post[:CardExpiry] = expdate(creditcard)
55
54
  post[:CardHolderName] = creditcard.name
56
-
55
+
57
56
  if creditcard.verification_value?
58
57
  post[:EnableCSC] = true
59
58
  post[:CSC] = creditcard.verification_value
@@ -62,7 +61,7 @@ module ActiveMerchant #:nodoc:
62
61
  # SPT will autodetect this
63
62
  post[:CardType] = 0
64
63
  end
65
-
64
+
66
65
  def parse(body)
67
66
  response = CGI.unescape(body).split(',')
68
67
 
@@ -80,13 +79,13 @@ module ActiveMerchant #:nodoc:
80
79
  end
81
80
 
82
81
  result
83
- end
84
-
82
+ end
83
+
85
84
  def commit(action, post)
86
85
  response = parse( ssl_post(self.live_url, post_data(action, post) ) )
87
86
 
88
- Response.new(response[:result_code] == 1, message_from(response), response,
89
- :test => test?,
87
+ Response.new(response[:result_code] == 1, message_from(response), response,
88
+ :test => test?,
90
89
  :authorization => response[:merchant_transaction_reference]
91
90
  )
92
91
  end
@@ -94,7 +93,7 @@ module ActiveMerchant #:nodoc:
94
93
  def message_from(result)
95
94
  PAYMENT_GATEWAY_RESPONSES[result[:result_code]]
96
95
  end
97
-
96
+
98
97
  def post_data(action, post)
99
98
  post[:MerchantID] = @options[:login]
100
99
  post[:MerchantKey] = @options[:password]
@@ -5,21 +5,21 @@ module ActiveMerchant #:nodoc:
5
5
  module Billing #:nodoc:
6
6
  class SkipJackGateway < Gateway
7
7
  API_VERSION = '?.?'
8
-
9
- self.live_url = "https://www.skipjackic.com"
8
+
9
+ self.live_url = "https://www.skipjackic.com"
10
10
  self.test_url = "https://developer.skipjackic.com"
11
-
11
+
12
12
  BASIC_PATH = "/scripts/evolvcc.dll"
13
13
  ADVANCED_PATH = "/evolvcc/evolvcc.aspx"
14
-
14
+
15
15
  ACTIONS = {
16
16
  :authorization => 'AuthorizeAPI',
17
17
  :change_status => 'SJAPI_TransactionChangeStatusRequest',
18
18
  :get_status => 'SJAPI_TransactionStatusRequest'
19
19
  }
20
-
20
+
21
21
  SUCCESS_MESSAGE = 'The transaction was successful.'
22
-
22
+
23
23
  MONETARY_CHANGE_STATUSES = ['SETTLE', 'AUTHORIZE', 'AUTHORIZE ADDITIONAL', 'CREDIT', 'SPLITSETTLE']
24
24
 
25
25
  CARD_CODE_ERRORS = %w( N S "" )
@@ -87,7 +87,7 @@ module ActiveMerchant #:nodoc:
87
87
  '4' => 'Pending Manual Settlement',
88
88
  '5' => 'Pending Recurring'
89
89
  }
90
-
90
+
91
91
  RETURN_CODE_MESSAGES = {
92
92
  '-1' => 'Data was not by received intact by Skipjack Transaction Network.',
93
93
  '0' => 'Communication Failure. Error in Request and Response at IP level.',
@@ -161,17 +161,17 @@ module ActiveMerchant #:nodoc:
161
161
  '-116' => 'POS Check Invalid Lane Number POS Check lane or cash register number is invalid. Use a valid lane or cash register number that has been configured in the Skipjack Merchant Account.',
162
162
  '-117' => 'POS Check Invalid Cashier Number'
163
163
  }
164
-
164
+
165
165
  self.supported_countries = ['US', 'CA']
166
166
  self.supported_cardtypes = [:visa, :master, :american_express, :jcb, :discover, :diners_club]
167
167
  self.homepage_url = 'http://www.skipjack.com/'
168
168
  self.display_name = 'SkipJack'
169
169
 
170
170
  # Creates a new SkipJackGateway
171
- #
171
+ #
172
172
  # The gateway requires that a valid login and password be passed
173
173
  # in the +options+ hash.
174
- #
174
+ #
175
175
  # ==== Options
176
176
  #
177
177
  # * <tt>:login</tt> -- The SkipJack Merchant Serial Number.
@@ -181,14 +181,9 @@ module ActiveMerchant #:nodoc:
181
181
  # See the SkipJack Integration Guide for details. (default: +false+)
182
182
  def initialize(options = {})
183
183
  requires!(options, :login, :password)
184
- @options = options
185
184
  super
186
185
  end
187
-
188
- def test?
189
- @options[:test] || super
190
- end
191
-
186
+
192
187
  def authorize(money, creditcard, options = {})
193
188
  requires!(options, :order_id, :email)
194
189
  post = {}
@@ -210,13 +205,13 @@ module ActiveMerchant #:nodoc:
210
205
  end
211
206
 
212
207
  # Captures the funds from an authorized transaction.
213
- #
208
+ #
214
209
  # ==== Parameters
215
210
  #
216
211
  # * <tt>money</tt> -- The amount to be capture as an Integer in cents.
217
212
  # * <tt>authorization</tt> -- The authorization returned from the previous authorize request.
218
213
  # * <tt>options</tt> -- A hash of optional parameters.
219
- #
214
+ #
220
215
  # ==== Options
221
216
  #
222
217
  # * <tt>:force_settlement</tt> -- Force the settlement to occur as soon as possible. This option is not supported by other gateways. See the SkipJack API reference for more details
@@ -252,24 +247,24 @@ module ActiveMerchant #:nodoc:
252
247
  def status(order_id)
253
248
  commit(:get_status, nil, :szOrderNumber => order_id)
254
249
  end
255
-
250
+
256
251
  private
257
-
252
+
258
253
  def advanced?
259
254
  @options[:advanced]
260
255
  end
261
-
256
+
262
257
  def add_forced_settlement(post, options)
263
258
  post[:szForceSettlement] = options[:force_settlment] ? 1 : 0
264
259
  end
265
-
260
+
266
261
  def add_status_action(post, action)
267
262
  post[:szDesiredStatus] = action
268
263
  end
269
-
264
+
270
265
  def commit(action, money, parameters)
271
266
  response = parse( ssl_post( url_for(action), post_data(action, money, parameters) ), action )
272
-
267
+
273
268
  # Pass along the original transaction id in the case an update transaction
274
269
  Response.new(response[:success], message_from(response, action), response,
275
270
  :test => test?,
@@ -278,13 +273,13 @@ module ActiveMerchant #:nodoc:
278
273
  :cvv_result => response[:szCVV2ResponseCode]
279
274
  )
280
275
  end
281
-
276
+
282
277
  def url_for(action)
283
278
  result = test? ? self.test_url : self.live_url
284
279
  result += advanced? && action == :authorization ? ADVANCED_PATH : BASIC_PATH
285
280
  result += "?#{ACTIONS[action]}"
286
281
  end
287
-
282
+
288
283
  def add_credentials(params, action)
289
284
  if action == :authorization
290
285
  params[:SerialNumber] = @options[:login]
@@ -294,7 +289,7 @@ module ActiveMerchant #:nodoc:
294
289
  params[:szDeveloperSerialNumber] = @options[:password]
295
290
  end
296
291
  end
297
-
292
+
298
293
  def add_amount(params, action, money)
299
294
  if action == :authorization
300
295
  params[:TransactionAmount] = amount(money)
@@ -313,7 +308,7 @@ module ActiveMerchant #:nodoc:
313
308
  parse_status_response(body, [ :SerialNumber, :TransactionAmount, :DesiredStatus, :StatusResponse, :StatusResponseMessage, :OrderNumber, :AuditID ])
314
309
  end
315
310
  end
316
-
311
+
317
312
  def split_lines(body)
318
313
  body.split(/[\r\n]+/)
319
314
  end
@@ -321,13 +316,13 @@ module ActiveMerchant #:nodoc:
321
316
  def split_line(line)
322
317
  line.split(/","/).collect { |key| key.sub(/"*([^"]*)"*/, '\1').strip; }
323
318
  end
324
-
319
+
325
320
  def authorize_response_map(body)
326
321
  lines = split_lines(body)
327
322
  keys, values = split_line(lines[0]), split_line(lines[1])
328
323
  Hash[*(keys.zip(values).flatten)].symbolize_keys
329
324
  end
330
-
325
+
331
326
  def parse_authorization_response(body)
332
327
  result = authorize_response_map(body)
333
328
  result[:success] = (result[:szIsApproved] == '1')
@@ -374,7 +369,7 @@ module ActiveMerchant #:nodoc:
374
369
  post[:CustomerCode] = options[:customer].to_s.slice(0, 17)
375
370
  post[:InvoiceNumber] = options[:invoice]
376
371
  post[:OrderDescription] = options[:description]
377
-
372
+
378
373
  if order_items = options[:items]
379
374
  post[:OrderString] = order_items.collect { |item| "#{item[:sku]}~#{item[:description].tr('~','-')}~#{item[:declared_value]}~#{item[:quantity]}~#{item[:taxable]}~~~~~~~~#{item[:tax_rate]}~||"}.join
380
375
  else
@@ -405,7 +400,7 @@ module ActiveMerchant #:nodoc:
405
400
  post[:Phone] = address[:phone]
406
401
  post[:Fax] = address[:fax]
407
402
  end
408
-
403
+
409
404
  if address = options[:shipping_address]
410
405
  post[:ShipToName] = address[:name]
411
406
  post[:ShipToStreetAddress] = address[:address1]
@@ -417,7 +412,7 @@ module ActiveMerchant #:nodoc:
417
412
  post[:ShipToPhone] = address[:phone]
418
413
  post[:ShipToFax] = address[:fax]
419
414
  end
420
-
415
+
421
416
  # The phone number for the shipping address is required
422
417
  # Use the billing address phone number if a shipping address
423
418
  # phone number wasn't provided
@@ -449,7 +444,7 @@ module ActiveMerchant #:nodoc:
449
444
  def message_from_status(response)
450
445
  response[:success] ? SUCCESS_MESSAGE : response[:szErrorMessage]
451
446
  end
452
-
447
+
453
448
  def sanitize_order_id(value)
454
449
  value.to_s.gsub(/[^\w.]/, '')
455
450
  end
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), '..', 'check.rb')
3
3
  module ActiveMerchant #:nodoc:
4
4
  module Billing #:nodoc:
5
5
  class SmartPs < Gateway #:nodoc:
6
-
6
+
7
7
  ##
8
8
  # This is the base gateway for processors who use the smartPS processing system
9
9
 
@@ -11,13 +11,12 @@ module ActiveMerchant #:nodoc:
11
11
 
12
12
  def initialize(options = {})
13
13
  requires!(options, :login, :password)
14
- @options = options
15
14
  super
16
- end
17
-
18
- # Pass :store => true in the options to store the
19
- # payment info at the gateway and get a generated
20
- # customer_vault_id in the response.
15
+ end
16
+
17
+ # Pass :store => true in the options to store the
18
+ # payment info at the gateway and get a generated
19
+ # customer_vault_id in the response.
21
20
  # Pass :store => some_number_or_string to specify the
22
21
  # customer_vault_id the gateway should use (make sure it's
23
22
  # unique).
@@ -33,7 +32,7 @@ module ActiveMerchant #:nodoc:
33
32
  add_processor(post, options)
34
33
  commit('auth', money, post)
35
34
  end
36
-
35
+
37
36
  def purchase(money, payment_source, options = {})
38
37
  post = {}
39
38
  add_invoice(post, options)
@@ -43,26 +42,26 @@ module ActiveMerchant #:nodoc:
43
42
  add_customer_data(post, options)
44
43
  add_currency(post, money, options)
45
44
  add_taxes(post, options)
46
- add_processor(post, options)
45
+ add_processor(post, options)
47
46
  commit('sale', money, post)
48
- end
49
-
47
+ end
48
+
50
49
  def capture(money, authorization, options = {})
51
50
  post ={}
52
51
  post[:transactionid] = authorization
53
52
  commit('capture', money, post)
54
53
  end
55
-
54
+
56
55
  def void(authorization, options = {})
57
56
  post ={}
58
57
  post[:transactionid] = authorization
59
58
  commit('void', nil, post)
60
59
  end
61
-
60
+
62
61
  def credit(money, payment_source, options = {})
63
62
  post = {}
64
63
  add_invoice(post, options)
65
- add_payment_source(post, payment_source, options)
64
+ add_payment_source(post, payment_source, options)
66
65
  add_address(post, options[:billing_address] || options[:address])
67
66
  add_customer_data(post, options)
68
67
  add_sku(post,options)
@@ -70,14 +69,14 @@ module ActiveMerchant #:nodoc:
70
69
  add_processor(post, options)
71
70
  commit('credit', money, post)
72
71
  end
73
-
72
+
74
73
  def refund(money, auth, options = {})
75
74
  post = {}
76
75
  add_transaction(post, auth)
77
76
  commit('refund', money, post)
78
77
  end
79
-
80
-
78
+
79
+
81
80
  # Update the values (such as CC expiration) stored at
82
81
  # the gateway. The CC number must be supplied in the
83
82
  # CreditCard object.
@@ -85,13 +84,13 @@ module ActiveMerchant #:nodoc:
85
84
  post = {}
86
85
  post[:customer_vault] = "update_customer"
87
86
  add_customer_vault_id(post, vault_id)
88
- add_creditcard(post, creditcard, options)
87
+ add_creditcard(post, creditcard, options)
89
88
  add_address(post, options[:billing_address] || options[:address])
90
89
  add_customer_data(post, options)
91
-
90
+
92
91
  commit(nil, nil, post)
93
92
  end
94
-
93
+
95
94
  # Amend an existing transaction
96
95
  def amend(auth, options = {})
97
96
  post = {}
@@ -99,15 +98,15 @@ module ActiveMerchant #:nodoc:
99
98
  add_transaction(post, auth)
100
99
  commit('update', nil, post)
101
100
  end
102
-
103
-
101
+
102
+
104
103
  def delete(vault_id)
105
104
  post = {}
106
105
  post[:customer_vault] = "delete_customer"
107
- add_customer_vault_id(post, vault_id)
106
+ add_customer_vault_id(post, vault_id)
108
107
  commit(nil, nil, post)
109
108
  end
110
-
109
+
111
110
  # To match the other stored-value gateways, like TrustCommerce,
112
111
  # store and unstore need to be defined
113
112
  def store(payment_source, options = {})
@@ -118,10 +117,10 @@ module ActiveMerchant #:nodoc:
118
117
  add_customer_data(post, options)
119
118
  commit(nil, nil, post)
120
119
  end
121
-
120
+
122
121
  alias_method :unstore, :delete
123
122
 
124
- private
123
+ private
125
124
  def add_customer_data(post, options)
126
125
  if options.has_key? :email
127
126
  post[:email] = options[:email]
@@ -129,23 +128,23 @@ module ActiveMerchant #:nodoc:
129
128
 
130
129
  if options.has_key? :ip
131
130
  post[:ipaddress] = options[:ip]
132
- end
131
+ end
133
132
  end
134
133
 
135
- def add_address(post, address,prefix="")
136
- prefix +="_" unless prefix.blank?
134
+ def add_address(post, address,prefix="")
135
+ prefix +="_" unless prefix.blank?
137
136
  unless address.blank? or address.values.blank?
138
137
  post[prefix+"address1"] = address[:address1].to_s
139
138
  post[prefix+"address2"] = address[:address2].to_s unless address[:address2].blank?
140
139
  post[prefix+"company"] = address[:company].to_s
141
140
  post[prefix+"phone"] = address[:phone].to_s
142
- post[prefix+"zip"] = address[:zip].to_s
141
+ post[prefix+"zip"] = address[:zip].to_s
143
142
  post[prefix+"city"] = address[:city].to_s
144
143
  post[prefix+"country"] = address[:country].to_s
145
144
  post[prefix+"state"] = address[:state].blank? ? 'n/a' : address[:state]
146
- end
145
+ end
147
146
  end
148
-
147
+
149
148
  def add_currency(post, money, options)
150
149
  post[:currency] = options[:currency] || currency(money)
151
150
  end
@@ -157,11 +156,11 @@ module ActiveMerchant #:nodoc:
157
156
  def add_processor(post, options)
158
157
  post[:processor] = options[:processor] unless options[:processor].nil?
159
158
  end
160
-
159
+
161
160
  def add_invoice(post, options)
162
161
  post[:orderid] = options[:order_id].to_s.gsub(/[^\w.]/, '')
163
162
  end
164
-
163
+
165
164
  def add_payment_source(params, source, options={})
166
165
  case determine_funding_source(source)
167
166
  when :vault then add_customer_vault_id(params, source)
@@ -169,13 +168,13 @@ module ActiveMerchant #:nodoc:
169
168
  when :check then add_check(params, source, options)
170
169
  end
171
170
  end
172
-
171
+
173
172
  def add_customer_vault_id(params, vault_id)
174
173
  params[:customer_vault_id] = vault_id
175
174
  end
176
-
175
+
177
176
  def add_creditcard(post, creditcard, options)
178
- if options[:store]
177
+ if options[:store]
179
178
  post[:customer_vault] = "add_customer"
180
179
  post[:customer_vault_id] = options[:store] unless options[:store] == true
181
180
  end
@@ -183,15 +182,15 @@ module ActiveMerchant #:nodoc:
183
182
  post[:cvv] = creditcard.verification_value if creditcard.verification_value?
184
183
  post[:ccexp] = expdate(creditcard)
185
184
  post[:firstname] = creditcard.first_name
186
- post[:lastname] = creditcard.last_name
185
+ post[:lastname] = creditcard.last_name
187
186
  end
188
-
187
+
189
188
  def add_check(post, check, options)
190
- if options[:store]
189
+ if options[:store]
191
190
  post[:customer_vault] = "add_customer"
192
191
  post[:customer_vault_id] = options[:store] unless options[:store] == true
193
192
  end
194
-
193
+
195
194
  post[:payment] = 'check' # Set transaction to ACH
196
195
  post[:checkname] = check.name # The name on the customer's Checking Account
197
196
  post[:checkaba] = check.routing_number # The customer's bank routing number
@@ -199,44 +198,44 @@ module ActiveMerchant #:nodoc:
199
198
  post[:account_holder_type] = check.account_holder_type # The customer's type of ACH account
200
199
  post[:account_type] = check.account_type # The customer's type of ACH account
201
200
  end
202
-
201
+
203
202
  def add_sku(post,options)
204
203
  post["product_sku_#"] = options[:sku] || options["product_sku_#"]
205
204
  end
206
-
205
+
207
206
  def add_transaction(post, auth)
208
207
  post[:transactionid] = auth
209
208
  end
210
-
209
+
211
210
  def parse(body)
212
211
  results = {}
213
212
  body.split(/&/).each do |pair|
214
213
  key,val = pair.split(/=/)
215
214
  results[key] = val
216
215
  end
217
-
216
+
218
217
  results
219
- end
220
-
218
+ end
219
+
221
220
  def commit(action, money, parameters)
222
221
  parameters[:amount] = amount(money) if money
223
222
  response = parse( ssl_post(self.live_url, post_data(action,parameters)) )
224
- Response.new(response["response"] == "1", message_from(response), response,
223
+ Response.new(response["response"] == "1", message_from(response), response,
225
224
  :authorization => response["transactionid"],
226
225
  :test => test?,
227
226
  :cvv_result => response["cvvresponse"],
228
227
  :avs_result => { :code => response["avsresponse"] }
229
228
  )
230
-
229
+
231
230
  end
232
-
231
+
233
232
  def expdate(creditcard)
234
233
  year = sprintf("%.04i", creditcard.year.to_i)
235
234
  month = sprintf("%.02i", creditcard.month.to_i)
236
235
 
237
236
  "#{month}#{year[-2..-1]}"
238
237
  end
239
-
238
+
240
239
 
241
240
  def message_from(response)
242
241
  case response["responsetext"]
@@ -248,7 +247,7 @@ module ActiveMerchant #:nodoc:
248
247
  response["responsetext"]
249
248
  end
250
249
  end
251
-
250
+
252
251
  def post_data(action, parameters = {})
253
252
  post = {}
254
253
  post[:username] = @options[:login]
@@ -256,18 +255,18 @@ module ActiveMerchant #:nodoc:
256
255
  post[:type] = action if action
257
256
 
258
257
  request = post.merge(parameters).map {|key,value| "#{key}=#{CGI.escape(value.to_s)}"}.join("&")
259
- request
258
+ request
260
259
  end
261
-
260
+
262
261
  def determine_funding_source(source)
263
- case
262
+ case
264
263
  when source.is_a?(String) then :vault
265
264
  when CreditCard.card_companies.keys.include?(card_brand(source)) then :credit_card
266
265
  when card_brand(source) == 'check' then :check
267
266
  else raise ArgumentError, "Unsupported funding source provided"
268
267
  end
269
268
  end
270
- end
269
+ end
271
270
  end
272
271
  end
273
272