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
@@ -0,0 +1,394 @@
1
+ # coding: utf-8
2
+ require 'nokogiri'
3
+
4
+ module ActiveMerchant #:nodoc:
5
+ module Billing #:nodoc:
6
+ # = Redsys Merchant Gateway
7
+ #
8
+ # Gateway support for the Spanish "Redsys" payment gateway system. This is
9
+ # used by many banks in Spain and is particularly well supported by
10
+ # Catalunya Caixa's ecommerce department.
11
+ #
12
+ # Standard ActiveMerchant methods are supported, with one notable exception:
13
+ # :order_id must be provided and must conform to a very specific format.
14
+ #
15
+ # == Example use:
16
+ #
17
+ # gateway = ActiveMerchant::Billing::RedsysGateway.new(
18
+ # :login => "091358382",
19
+ # :secret_key => "qwertyasdf0123456789"
20
+ # )
21
+ #
22
+ # # Run a purchase for 10 euros
23
+ # response = gateway.purchase(1000, creditcard, :order_id => "123456")
24
+ # puts reponse.success? # => true
25
+ #
26
+ # # Partially refund the purchase
27
+ # response = gateway.refund(500, response.authorization)
28
+ #
29
+ # Redsys requires an order_id be provided with each transaction of a
30
+ # specific format. The rules are as follows:
31
+ #
32
+ # * Minimum length: 4
33
+ # * Maximum length: 12
34
+ # * First 4 digits must be numerical
35
+ # * Remaining 8 digits may be alphanumeric
36
+ #
37
+ # Much of the code for this library is based on the active_merchant_sermepa
38
+ # integration gateway which uses essentially the same API but with the
39
+ # banks own payment screen.
40
+ #
41
+ # Written by Samuel Lown for Cabify. For implementation questions, or
42
+ # test access details please get in touch: sam@cabify.com.
43
+ class RedsysGateway < Gateway
44
+ self.live_url = "https://sis.sermepa.es/sis/operaciones"
45
+ self.test_url = "https://sis-t.sermepa.es:25443/sis/operaciones"
46
+
47
+ # Sensible region specific defaults.
48
+ self.supported_countries = ['ES']
49
+ self.default_currency = 'EUR'
50
+ self.money_format = :cents
51
+
52
+ # Not all card types may be actived by the bank!
53
+ self.supported_cardtypes = [:visa, :master, :american_express, :jcb, :diners_club]
54
+
55
+ # Homepage URL of the gateway for reference
56
+ self.homepage_url = "http://www.redsys.es/"
57
+
58
+ # What to call this gateway
59
+ self.display_name = "Redsys"
60
+
61
+ CURRENCY_CODES = {
62
+ "ARS" => '032',
63
+ "AUD" => '036',
64
+ "BRL" => '986',
65
+ "BOB" => '068',
66
+ "CAD" => '124',
67
+ "CHF" => '756',
68
+ "CLP" => '152',
69
+ "COP" => '170',
70
+ "EUR" => '978',
71
+ "GBP" => '826',
72
+ "GTQ" => '320',
73
+ "JPY" => '392',
74
+ "MXN" => '484',
75
+ "NZD" => '554',
76
+ "PEN" => '604',
77
+ "RUB" => '643',
78
+ "USD" => '840',
79
+ "UYU" => '858'
80
+ }
81
+
82
+ # The set of supported transactions for this gateway.
83
+ # More operations are supported by the gateway itself, but
84
+ # are not supported in this library.
85
+ SUPPORTED_TRANSACTIONS = {
86
+ :purchase => 'A',
87
+ :authorize => '1',
88
+ :capture => '2',
89
+ :refund => '3',
90
+ :cancel => '9'
91
+ }
92
+
93
+ # These are the text meanings sent back by the acquirer when
94
+ # a card has been rejected. Syntax or general request errors
95
+ # are not covered here.
96
+ RESPONSE_TEXTS = {
97
+ # Accepted Codes
98
+ 0 => "Transaction Approved",
99
+ 400 => "Cancellation Accepted",
100
+ 481 => "Cancellation Accepted",
101
+ 500 => "Reconciliation Accepted",
102
+ 900 => "Refund / Confirmation approved",
103
+
104
+ # Declined error codes
105
+ 101 => "Card expired",
106
+ 102 => "Card blocked temporarily or under susciption of fraud",
107
+ 104 => "Transaction not permitted",
108
+ 107 => "Contact the card issuer",
109
+ 109 => "Invalid identification by merchant or POS terminal",
110
+ 110 => "Invalid amount",
111
+ 114 => "Card cannot be used to the requested transaction",
112
+ 116 => "Insufficient credit",
113
+ 118 => "Non-registered card",
114
+ 125 => "Card not effective",
115
+ 129 => "CVV2/CVC2 Error",
116
+ 167 => "Contact the card issuer: suspected fraud",
117
+ 180 => "Card out of service",
118
+ 181 => "Card with credit or debit restrictions",
119
+ 182 => "Card with credit or debit restrictions",
120
+ 184 => "Authentication error",
121
+ 190 => "Refusal with no specific reason",
122
+ 191 => "Expiry date incorrect",
123
+
124
+ # Declined, and suspected of fraud
125
+ 201 => "Card expired",
126
+ 202 => "Card blocked temporarily or under suscipition of fraud",
127
+ 204 => "Transaction not permitted",
128
+ 207 => "Contact the card issuer",
129
+ 208 => "Lost or stolen card",
130
+ 209 => "Lost or stolen card",
131
+ 280 => "CVV2/CVC2 Error",
132
+ 290 => "Declined with no specific reason",
133
+
134
+ # More general codes for specific types of transaction
135
+ 480 => "Original transaction not located, or time-out exceeded",
136
+ 501 => "Original transaction not located, or time-out exceeded",
137
+ 502 => "Original transaction not located, or time-out exceeded",
138
+ 503 => "Original transaction not located, or time-out exceeded",
139
+
140
+ # Declined transactions by the bank
141
+ 904 => "Merchant not registered at FUC",
142
+ 909 => "System error",
143
+ 912 => "Issuer not available",
144
+ 913 => "Duplicate transmission",
145
+ 916 => "Amount too low",
146
+ 928 => "Time-out exceeded",
147
+ 940 => "Transaction cancelled previously",
148
+ 941 => "Authorization operation already cancelled",
149
+ 942 => "Original authorization declined",
150
+ 943 => "Different details from origin transaction",
151
+ 944 => "Session error",
152
+ 945 => "Duplicate transmission",
153
+ 946 => "Cancellation of transaction while in progress",
154
+ 947 => "Duplicate tranmission while in progress",
155
+ 949 => "POS Inoperative",
156
+ 950 => "Refund not possible",
157
+ 9064 => "Card number incorrect",
158
+ 9078 => "No payment method available",
159
+ 9093 => "Non-existent card",
160
+ 9218 => "Recursive transaction in bad gateway",
161
+ 9253 => "Check-digit incorrect",
162
+ 9256 => "Preauth not allowed for merchant",
163
+ 9257 => "Preauth not allowed for card",
164
+ 9261 => "Operating limit exceeded",
165
+ 9912 => "Issuer not available",
166
+ 9913 => "Confirmation error",
167
+ 9914 => "KO Confirmation"
168
+ }
169
+
170
+ # Creates a new instance
171
+ #
172
+ # Redsys requires a login and secret_key, and optionally also accepts a
173
+ # non-default terminal.
174
+ #
175
+ # ==== Options
176
+ #
177
+ # * <tt>:login</tt> -- The Redsys Merchant ID (REQUIRED)
178
+ # * <tt>:secret_key</tt> -- The Redsys Secret Key. (REQUIRED)
179
+ # * <tt>:terminal</tt> -- The Redsys Terminal. Defaults to 1. (OPTIONAL)
180
+ # * <tt>:test</tt> -- +true+ or +false+. Defaults to +false+. (OPTIONAL)
181
+ def initialize(options = {})
182
+ requires!(options, :login, :secret_key)
183
+ options[:terminal] ||= 1
184
+ super
185
+ end
186
+
187
+ def purchase(money, creditcard, options = {})
188
+ requires!(options, :order_id)
189
+
190
+ data = {}
191
+ add_action(data, :purchase)
192
+ add_amount(data, money, options)
193
+ add_order(data, options[:order_id])
194
+ add_creditcard(data, creditcard)
195
+
196
+ commit data
197
+ end
198
+
199
+ def authorize(money, creditcard, options = {})
200
+ requires!(options, :order_id)
201
+
202
+ data = {}
203
+ add_action(data, :authorize)
204
+ add_amount(data, money, options)
205
+ add_order(data, options[:order_id])
206
+ add_creditcard(data, creditcard)
207
+
208
+ commit data
209
+ end
210
+
211
+ def capture(money, authorization, options = {})
212
+ data = {}
213
+ add_action(data, :capture)
214
+ add_amount(data, money, options)
215
+ order_id, _, _ = split_authorization(authorization)
216
+ add_order(data, order_id)
217
+
218
+ commit data
219
+ end
220
+
221
+ def void(authorization, options = {})
222
+ data = {}
223
+ add_action(data, :cancel)
224
+ order_id, amount, currency = split_authorization(authorization)
225
+ add_amount(data, amount, :currency => currency)
226
+ add_order(data, order_id)
227
+
228
+ commit data
229
+ end
230
+
231
+ def refund(money, authorization, options = {})
232
+ data = {}
233
+ add_action(data, :refund)
234
+ add_amount(data, money, options)
235
+ order_id, _, _ = split_authorization(authorization)
236
+ add_order(data, order_id)
237
+
238
+ commit data
239
+ end
240
+
241
+ private
242
+
243
+ def add_action(data, action)
244
+ data[:action] = transaction_code(action)
245
+ end
246
+
247
+ def add_amount(data, money, options)
248
+ data[:amount] = amount(money).to_s
249
+ data[:currency] = currency_code(options[:currency] || currency(money))
250
+ end
251
+
252
+ def add_order(data, order_id)
253
+ raise ArgumentError.new("Invalid order_id format") unless(/^\d{4}[\da-zA-Z]{0,8}$/ =~ order_id)
254
+ data[:order_id] = order_id
255
+ end
256
+
257
+ def url
258
+ test? ? test_url : live_url
259
+ end
260
+
261
+ def add_creditcard(data, card)
262
+ name = [card.first_name, card.last_name].join(' ').slice(0, 60)
263
+ year = sprintf("%.4i", card.year)
264
+ month = sprintf("%.2i", card.month)
265
+ data[:card] = {
266
+ :name => name,
267
+ :pan => card.number,
268
+ :date => "#{year[2..3]}#{month}",
269
+ :cvv => card.verification_value
270
+ }
271
+ end
272
+
273
+ def commit(data)
274
+ headers = {
275
+ 'Content-Type' => 'application/x-www-form-urlencoded'
276
+ }
277
+ xml = build_xml_request(data)
278
+ parse(ssl_post(url, "entrada=#{CGI.escape(xml)}", headers))
279
+ end
280
+
281
+ def build_signature(data)
282
+ str = data[:amount] +
283
+ data[:order_id].to_s +
284
+ @options[:login].to_s +
285
+ data[:currency]
286
+
287
+ if card = data[:card]
288
+ str << card[:pan]
289
+ str << card[:cvv] if card[:cvv]
290
+ end
291
+
292
+ str << data[:action]
293
+ str << @options[:secret_key]
294
+
295
+ Digest::SHA1.hexdigest(str)
296
+ end
297
+
298
+ def build_xml_request(data)
299
+ xml = Builder::XmlMarkup.new :indent => 2
300
+ xml.DATOSENTRADA do
301
+ # Basic elements
302
+ xml.DS_Version 0.1
303
+ xml.DS_MERCHANT_CURRENCY data[:currency]
304
+ xml.DS_MERCHANT_AMOUNT data[:amount]
305
+ xml.DS_MERCHANT_ORDER data[:order_id]
306
+ xml.DS_MERCHANT_TRANSACTIONTYPE data[:action]
307
+ xml.DS_MERCHANT_TERMINAL @options[:terminal]
308
+ xml.DS_MERCHANT_MERCHANTCODE @options[:login]
309
+ xml.DS_MERCHANT_MERCHANTSIGNATURE build_signature(data)
310
+
311
+ # Only when card is present
312
+ if data[:card]
313
+ xml.DS_MERCHANT_TITULAR data[:card][:name]
314
+ xml.DS_MERCHANT_PAN data[:card][:pan]
315
+ xml.DS_MERCHANT_EXPIRYDATE data[:card][:date]
316
+ xml.DS_MERCHANT_CVV2 data[:card][:cvv]
317
+ end
318
+ end
319
+ xml.target!
320
+ end
321
+
322
+ def parse(data)
323
+ params = {}
324
+ success = false
325
+ message = ""
326
+ options = @options.merge(:test => test?)
327
+ xml = Nokogiri::XML(data)
328
+ code = xml.xpath("//RETORNOXML/CODIGO").text
329
+ if code == "0"
330
+ op = xml.xpath("//RETORNOXML/OPERACION")
331
+ op.children.each do |element|
332
+ params[element.name.downcase.to_sym] = element.text
333
+ end
334
+
335
+ if validate_signature(params)
336
+ message = response_text(params[:ds_response])
337
+ options[:authorization] = build_authorization(params)
338
+ success = is_success_response?(params[:ds_response])
339
+ else
340
+ message = "Response failed validation check"
341
+ end
342
+ else
343
+ # Some kind of programmer error with the request!
344
+ message = "#{code} ERROR"
345
+ end
346
+
347
+ Response.new(success, message, params, options)
348
+ end
349
+
350
+ def validate_signature(data)
351
+ str = data[:ds_amount] +
352
+ data[:ds_order].to_s +
353
+ data[:ds_merchantcode] +
354
+ data[:ds_currency] +
355
+ data[:ds_response] +
356
+ data[:ds_cardnumber].to_s +
357
+ data[:ds_transactiontype].to_s +
358
+ data[:ds_securepayment].to_s +
359
+ @options[:secret_key]
360
+
361
+ sig = Digest::SHA1.hexdigest(str)
362
+ data[:ds_signature].to_s.downcase == sig
363
+ end
364
+
365
+ def build_authorization(params)
366
+ [params[:ds_order], params[:ds_amount], params[:ds_currency]].join("|")
367
+ end
368
+
369
+ def split_authorization(authorization)
370
+ order_id, amount, currency = authorization.split("|")
371
+ [order_id, amount.to_i, currency]
372
+ end
373
+
374
+ def currency_code(currency)
375
+ return currency if currency =~ /^\d+$/
376
+ CURRENCY_CODES[currency]
377
+ end
378
+
379
+ def transaction_code(type)
380
+ SUPPORTED_TRANSACTIONS[type]
381
+ end
382
+
383
+ def response_text(code)
384
+ code = code.to_i
385
+ code = 0 if code < 100
386
+ RESPONSE_TEXTS[code] || "Unkown code, please check in manual"
387
+ end
388
+
389
+ def is_success_response?(code)
390
+ (code.to_i < 100) || [400, 481, 500, 900].include?(code.to_i)
391
+ end
392
+ end
393
+ end
394
+ end
@@ -10,22 +10,21 @@ module ActiveMerchant #:nodoc:
10
10
  self.abstract_class = true
11
11
 
12
12
  # Creates a new SageGateway
13
- #
13
+ #
14
14
  # The gateway requires that a valid login and password be passed
15
15
  # in the +options+ hash.
16
- #
16
+ #
17
17
  # ==== Options
18
18
  #
19
19
  # * <tt>:login</tt> - The Sage Payment Solutions Merchant ID Number.
20
20
  # * <tt>:password</tt> - The Sage Payment Solutions Merchant Key Number.
21
21
  def initialize(options = {})
22
22
  requires!(options, :login, :password)
23
- @options = options
24
23
  super
25
24
  end
26
-
25
+
27
26
  # Performs an authorization transaction
28
- #
27
+ #
29
28
  # ==== Parameters
30
29
  # * <tt>money</tt> - The amount to be authorized as an integer value in cents.
31
30
  # * <tt>credit_card</tt> - The CreditCard object to be used as the funding source for the transaction.
@@ -42,20 +41,20 @@ module ActiveMerchant #:nodoc:
42
41
  # * <tt>:phone</tt> - The billing address phone number
43
42
  # * <tt>:fax</tt> - The billing address fax number
44
43
  # * <tt>:shipping_address</tt> - The customer's shipping address as a hash of address information.
45
- # * <tt>:name</tt> - The name at the shipping address
44
+ # * <tt>:name</tt> - The name at the shipping address
46
45
  # * <tt>:address1</tt> - The shipping address street
47
46
  # * <tt>:city</tt> - The shipping address city
48
47
  # * <tt>:state</tt> - The shipping address state code
49
48
  # * <tt>:country</tt> - The 2 digit ISO shipping address country code
50
49
  # * <tt>:zip</tt> - The shipping address zip code
51
50
  # * <tt>:tax</tt> - The tax amount for the transaction as an Integer value in cents. Maps to Sage <tt>T_tax</tt>.
52
- # * <tt>:shipping</tt> - The shipping amount for the transaction as an Integer value in cents. Maps to Sage <tt>T_shipping</tt>.
51
+ # * <tt>:shipping</tt> - The shipping amount for the transaction as an Integer value in cents. Maps to Sage <tt>T_shipping</tt>.
53
52
  def authorize(money, credit_card, options = {})
54
53
  bankcard.authorize(money, credit_card, options)
55
54
  end
56
-
55
+
57
56
  # Performs a purchase, which is essentially an authorization and capture in a single operation.
58
- #
57
+ #
59
58
  # ==== Parameters
60
59
  #
61
60
  # * <tt>money</tt> - The amount to be authorized as an integer value in cents.
@@ -73,7 +72,7 @@ module ActiveMerchant #:nodoc:
73
72
  # * <tt>:phone</tt> - The billing address phone number
74
73
  # * <tt>:fax</tt> - The billing address fax number
75
74
  # * <tt>:shipping_address</tt> - The customer's shipping address as a hash of address information.
76
- # * <tt>:name</tt> - The name at the shipping address
75
+ # * <tt>:name</tt> - The name at the shipping address
77
76
  # * <tt>:address1</tt> - The shipping address street
78
77
  # * <tt>:city</tt> - The shipping address city
79
78
  # * <tt>:state</tt> - The shipping address state code
@@ -95,8 +94,8 @@ module ActiveMerchant #:nodoc:
95
94
  else
96
95
  bankcard.purchase(money, source, options)
97
96
  end
98
- end
99
-
97
+ end
98
+
100
99
  # Captures authorized funds.
101
100
  #
102
101
  # ==== Parameters
@@ -106,7 +105,7 @@ module ActiveMerchant #:nodoc:
106
105
  def capture(money, reference, options = {})
107
106
  bankcard.capture(money, reference, options)
108
107
  end
109
-
108
+
110
109
  # Voids a prior transaction. Works for both CreditCard and Check transactions.
111
110
  #
112
111
  # ==== Parameters
@@ -133,15 +132,15 @@ module ActiveMerchant #:nodoc:
133
132
  bankcard.credit(money, source, options)
134
133
  end
135
134
  end
136
-
135
+
137
136
  private
138
137
  def bankcard
139
138
  @bankcard ||= SageBankcardGateway.new(@options)
140
139
  end
141
-
140
+
142
141
  def virtual_check
143
142
  @virtual_check ||= SageVirtualCheckGateway.new(@options)
144
- end
143
+ end
145
144
  end
146
145
  end
147
146
  end