activemerchant 1.77.0 → 1.78.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +49 -0
  3. data/lib/active_merchant/billing/gateways/adyen.rb +75 -29
  4. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +1 -1
  5. data/lib/active_merchant/billing/gateways/blue_snap.rb +3 -8
  6. data/lib/active_merchant/billing/gateways/card_stream.rb +22 -1
  7. data/lib/active_merchant/billing/gateways/cenpos.rb +1 -1
  8. data/lib/active_merchant/billing/gateways/checkout_v2.rb +8 -1
  9. data/lib/active_merchant/billing/gateways/citrus_pay.rb +0 -1
  10. data/lib/active_merchant/billing/gateways/dibs.rb +0 -1
  11. data/lib/active_merchant/billing/gateways/first_pay.rb +0 -1
  12. data/lib/active_merchant/billing/gateways/global_collect.rb +11 -5
  13. data/lib/active_merchant/billing/gateways/global_transport.rb +0 -1
  14. data/lib/active_merchant/billing/gateways/litle.rb +93 -17
  15. data/lib/active_merchant/billing/gateways/mercado_pago.rb +2 -2
  16. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +4 -4
  17. data/lib/active_merchant/billing/gateways/migs.rb +12 -0
  18. data/lib/active_merchant/billing/gateways/netbilling.rb +0 -1
  19. data/lib/active_merchant/billing/gateways/ogone.rb +0 -1
  20. data/lib/active_merchant/billing/gateways/optimal_payment.rb +11 -0
  21. data/lib/active_merchant/billing/gateways/orbital.rb +5 -3
  22. data/lib/active_merchant/billing/gateways/payeezy.rb +14 -24
  23. data/lib/active_merchant/billing/gateways/payflow.rb +15 -1
  24. data/lib/active_merchant/billing/gateways/paymentez.rb +21 -11
  25. data/lib/active_merchant/billing/gateways/paystation.rb +4 -1
  26. data/lib/active_merchant/billing/gateways/payu_latam.rb +7 -7
  27. data/lib/active_merchant/billing/gateways/psigate.rb +1 -1
  28. data/lib/active_merchant/billing/gateways/redsys.rb +5 -0
  29. data/lib/active_merchant/billing/gateways/secure_net.rb +11 -1
  30. data/lib/active_merchant/billing/gateways/spreedly_core.rb +12 -1
  31. data/lib/active_merchant/billing/gateways/stripe.rb +17 -6
  32. data/lib/active_merchant/billing/gateways/tns.rb +0 -1
  33. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +39 -21
  34. data/lib/active_merchant/billing/gateways/worldpay.rb +1 -1
  35. data/lib/active_merchant/billing/gateways/worldpay_us.rb +12 -0
  36. data/lib/active_merchant/version.rb +1 -1
  37. data/lib/certs/cacert.pem +25 -0
  38. metadata +2 -2
@@ -9,7 +9,6 @@ module ActiveMerchant #:nodoc:
9
9
  self.supported_countries = %w(CA PR US)
10
10
  self.default_currency = 'USD'
11
11
  self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb]
12
- self.ssl_version = :TLSv1
13
12
 
14
13
  self.homepage_url = 'https://www.globalpaymentsinc.com'
15
14
  self.display_name = 'Global Transport'
@@ -23,23 +23,33 @@ module ActiveMerchant #:nodoc:
23
23
  def purchase(money, payment_method, options={})
24
24
  request = build_xml_request do |doc|
25
25
  add_authentication(doc)
26
- doc.sale(transaction_attributes(options)) do
27
- add_auth_purchase_params(doc, money, payment_method, options)
26
+ if check?(payment_method)
27
+ doc.echeckSale(transaction_attributes(options)) do
28
+ add_echeck_purchase_params(doc, money, payment_method, options)
29
+ end
30
+ else
31
+ doc.sale(transaction_attributes(options)) do
32
+ add_auth_purchase_params(doc, money, payment_method, options)
33
+ end
28
34
  end
29
35
  end
30
-
31
- commit(:sale, request, money)
36
+ check?(payment_method) ? commit(:echeckSales, request, money) : commit(:sale, request, money)
32
37
  end
33
38
 
34
39
  def authorize(money, payment_method, options={})
35
40
  request = build_xml_request do |doc|
36
41
  add_authentication(doc)
37
- doc.authorization(transaction_attributes(options)) do
38
- add_auth_purchase_params(doc, money, payment_method, options)
42
+ if check?(payment_method)
43
+ doc.echeckVerification(transaction_attributes(options)) do
44
+ add_echeck_purchase_params(doc, money, payment_method, options)
45
+ end
46
+ else
47
+ doc.authorization(transaction_attributes(options)) do
48
+ add_auth_purchase_params(doc, money, payment_method, options)
49
+ end
39
50
  end
40
51
  end
41
-
42
- commit(:authorization, request, money)
52
+ check?(payment_method) ? commit(:echeckVerification, request, money) : commit(:authorization, request, money)
43
53
  end
44
54
 
45
55
  def capture(money, authorization, options={})
@@ -62,19 +72,24 @@ module ActiveMerchant #:nodoc:
62
72
  refund(money, authorization, options)
63
73
  end
64
74
 
65
- def refund(money, authorization, options={})
66
- transaction_id, _, _ = split_authorization(authorization)
67
-
75
+ def refund(money, payment, options={})
68
76
  request = build_xml_request do |doc|
69
77
  add_authentication(doc)
70
78
  add_descriptor(doc, options)
71
- doc.credit(transaction_attributes(options)) do
72
- doc.litleTxnId(transaction_id)
73
- doc.amount(money) if money
79
+ doc.send(refund_type(payment), transaction_attributes(options)) do
80
+ if payment.is_a?(String)
81
+ transaction_id, kind, _ = split_authorization(payment)
82
+ doc.litleTxnId(transaction_id)
83
+ doc.amount(money) if money
84
+ elsif check?(payment)
85
+ add_echeck_purchase_params(doc, money, payment, options)
86
+ else
87
+ add_auth_purchase_params(doc, money, payment, options)
88
+ end
74
89
  end
75
90
  end
76
91
 
77
- commit(:credit, request)
92
+ commit(refund_type(payment), request)
78
93
  end
79
94
 
80
95
  def verify(creditcard, options = {})
@@ -105,6 +120,11 @@ module ActiveMerchant #:nodoc:
105
120
  doc.orderId(truncate(options[:order_id], 24))
106
121
  if payment_method.is_a?(String)
107
122
  doc.paypageRegistrationId(payment_method)
123
+ elsif check?(payment_method)
124
+ doc.echeckForToken do
125
+ doc.accNum(payment_method.account_number)
126
+ doc.routingNum(payment_method.routing_number)
127
+ end
108
128
  else
109
129
  doc.accountNumber(payment_method.number)
110
130
  doc.cardValidationNum(payment_method.verification_value) if payment_method.verification_value
@@ -124,6 +144,8 @@ module ActiveMerchant #:nodoc:
124
144
  gsub(%r((<user>).+(</user>)), '\1[FILTERED]\2').
125
145
  gsub(%r((<password>).+(</password>)), '\1[FILTERED]\2').
126
146
  gsub(%r((<number>).+(</number>)), '\1[FILTERED]\2').
147
+ gsub(%r((<accNum>).+(</accNum>)), '\1[FILTERED]\2').
148
+ gsub(%r((<routingNum>).+(</routingNum>)), '\1[FILTERED]\2').
127
149
  gsub(%r((<cardValidationNum>).+(</cardValidationNum>)), '\1[FILTERED]\2').
128
150
  gsub(%r((<accountNumber>).+(</accountNumber>)), '\1[FILTERED]\2').
129
151
  gsub(%r((<paypageRegistrationId>).+(</paypageRegistrationId>)), '\1[FILTERED]\2').
@@ -131,6 +153,7 @@ module ActiveMerchant #:nodoc:
131
153
  end
132
154
 
133
155
  private
156
+
134
157
  CARD_TYPE = {
135
158
  'visa' => 'VI',
136
159
  'master' => 'MC',
@@ -159,7 +182,27 @@ module ActiveMerchant #:nodoc:
159
182
  }
160
183
 
161
184
  def void_type(kind)
162
- (kind == 'authorization') ? :authReversal : :void
185
+ if kind == 'authorization'
186
+ :authReversal
187
+ elsif kind == 'echeckSales'
188
+ :echeckVoid
189
+ else
190
+ :void
191
+ end
192
+ end
193
+
194
+ def refund_type(payment)
195
+ transaction_id, kind, _ = split_authorization(payment)
196
+ if check?(payment) || kind == 'echeckSales'
197
+ :echeckCredit
198
+ else
199
+ :credit
200
+ end
201
+ end
202
+
203
+ def check?(payment_method)
204
+ return false if payment_method.is_a?(String)
205
+ card_brand(payment_method) == 'check'
163
206
  end
164
207
 
165
208
  def add_authentication(doc)
@@ -178,9 +221,29 @@ module ActiveMerchant #:nodoc:
178
221
  add_payment_method(doc, payment_method, options)
179
222
  add_pos(doc, payment_method)
180
223
  add_descriptor(doc, options)
224
+ add_merchant_data(doc, options)
181
225
  add_debt_repayment(doc, options)
182
226
  end
183
227
 
228
+ def add_merchant_data(doc, options={})
229
+ if options[:affiliate] || options[:campaign] || options[:merchant_grouping_id]
230
+ doc.merchantData do
231
+ doc.affiliate(options[:affiliate]) if options[:affiliate]
232
+ doc.campaign(options[:campaign]) if options[:campaign]
233
+ doc.merchantGroupingId(options[:merchant_grouping_id]) if options[:merchant_grouping_id]
234
+ end
235
+ end
236
+ end
237
+
238
+ def add_echeck_purchase_params(doc, money, payment_method, options)
239
+ doc.orderId(truncate(options[:order_id], 24))
240
+ doc.amount(money)
241
+ add_order_source(doc, payment_method, options)
242
+ add_billing_address(doc, payment_method, options)
243
+ add_payment_method(doc, payment_method, options)
244
+ add_descriptor(doc, options)
245
+ end
246
+
184
247
  def add_descriptor(doc, options)
185
248
  if options[:descriptor_name] || options[:descriptor_phone]
186
249
  doc.customBilling do
@@ -203,6 +266,13 @@ module ActiveMerchant #:nodoc:
203
266
  doc.card do
204
267
  doc.track(payment_method.track_data)
205
268
  end
269
+ elsif check?(payment_method)
270
+ doc.echeck do
271
+ doc.accType(payment_method.account_type)
272
+ doc.accNum(payment_method.account_number)
273
+ doc.routingNum(payment_method.routing_number)
274
+ doc.checkNum(payment_method.number)
275
+ end
206
276
  else
207
277
  doc.card do
208
278
  doc.type_(CARD_TYPE[payment_method.brand])
@@ -227,7 +297,13 @@ module ActiveMerchant #:nodoc:
227
297
  return if payment_method.is_a?(String)
228
298
 
229
299
  doc.billToAddress do
230
- doc.name(payment_method.name)
300
+ if check?(payment_method)
301
+ doc.name(payment_method.name)
302
+ doc.firstName(payment_method.first_name)
303
+ doc.lastName(payment_method.last_name)
304
+ else
305
+ doc.name(payment_method.name)
306
+ end
231
307
  doc.email(options[:email]) if options[:email]
232
308
 
233
309
  add_address(doc, options[:billing_address])
@@ -102,7 +102,7 @@ module ActiveMerchant #:nodoc:
102
102
  add_additional_data(post, options)
103
103
  add_customer_data(post, payment, options)
104
104
  add_address(post, options)
105
- post[:binary_mode] = true
105
+ post[:binary_mode] = (options[:binary_mode].nil? ? true : options[:binary_mode])
106
106
  post
107
107
  end
108
108
 
@@ -210,7 +210,7 @@ module ActiveMerchant #:nodoc:
210
210
  if action == "refund"
211
211
  response["error"].nil?
212
212
  else
213
- ["active", "approved", "authorized", "cancelled"].include?(response["status"])
213
+ ["active", "approved", "authorized", "cancelled", "in_process"].include?(response["status"])
214
214
  end
215
215
  end
216
216
 
@@ -79,13 +79,13 @@ module ActiveMerchant #:nodoc:
79
79
 
80
80
  post['customerName'] = scrub_name(address[:name])
81
81
  post['customerCountry'] = address[:country]
82
- post['customerState'] = address[:state]
82
+ post['customerState'] = address[:state] || 'N/A'
83
83
  post['customerCity'] = address[:city]
84
84
  post['customerAddress'] = address[:address1]
85
85
  post['customerPostCode'] = address[:zip]
86
- post['customerIP'] = address[:ip]
87
- post['customerPhone'] = address[:phone]
88
- post['customerEmail'] = address[:email]
86
+ post['customerIP'] = address[:ip]
87
+ post['customerPhone'] = address[:phone]
88
+ post['customerEmail'] = address[:email]
89
89
  end
90
90
 
91
91
  def add_order_id(post, options)
@@ -206,6 +206,18 @@ module ActiveMerchant #:nodoc:
206
206
  @options[:login].start_with?('TEST')
207
207
  end
208
208
 
209
+ def supports_scrubbing?
210
+ true
211
+ end
212
+
213
+ def scrub(transcript)
214
+ transcript.
215
+ gsub(%r((&?CardNum=)\d*(&?)), '\1[FILTERED]\2').
216
+ gsub(%r((&?CardSecurityCode=)\d*(&?)), '\1[FILTERED]\2').
217
+ gsub(%r((&?AccessCode=)[^&]*(&?)), '\1[FILTERED]\2').
218
+ gsub(%r((&?Password=)[^&]*(&?)), '\1[FILTERED]\2')
219
+ end
220
+
209
221
  private
210
222
 
211
223
  def add_amount(post, money, options)
@@ -31,7 +31,6 @@ module ActiveMerchant #:nodoc:
31
31
  self.display_name = 'NETbilling'
32
32
  self.homepage_url = 'http://www.netbilling.com'
33
33
  self.supported_countries = ['US']
34
- self.ssl_version = :TLSv1
35
34
  self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club]
36
35
 
37
36
  def initialize(options = {})
@@ -141,7 +141,6 @@ module ActiveMerchant #:nodoc:
141
141
  self.display_name = 'Ogone'
142
142
  self.default_currency = 'EUR'
143
143
  self.money_format = :cents
144
- self.ssl_version = :TLSv1
145
144
 
146
145
  def initialize(options = {})
147
146
  requires!(options, :login, :user, :password)
@@ -59,6 +59,17 @@ module ActiveMerchant #:nodoc:
59
59
  commit('ccSettlement', money, options)
60
60
  end
61
61
 
62
+ def supports_scrubbing?
63
+ true
64
+ end
65
+
66
+ def scrub(transcript)
67
+ transcript.
68
+ gsub(%r((%3CstorePwd%3E).*(%3C(%2F|/)storePwd%3E))i, '\1[FILTERED]\2').
69
+ gsub(%r((%3CcardNum%3E)\d*(%3C(%2F|/)cardNum%3E))i, '\1[FILTERED]\2').
70
+ gsub(%r((%3Ccvd%3E)\d*(%3C(%2F|/)cvd%3E))i, '\1[FILTERED]\2')
71
+ end
72
+
62
73
  private
63
74
 
64
75
  def parse_card_or_auth(card_or_auth, options)
@@ -306,8 +306,10 @@ module ActiveMerchant #:nodoc:
306
306
  gsub(%r((<OrbitalConnectionUsername>).+(</OrbitalConnectionUsername>)), '\1[FILTERED]\2').
307
307
  gsub(%r((<OrbitalConnectionPassword>).+(</OrbitalConnectionPassword>)), '\1[FILTERED]\2').
308
308
  gsub(%r((<AccountNum>).+(</AccountNum>)), '\1[FILTERED]\2').
309
+ gsub(%r((<CCAccountNum>).+(</CCAccountNum>)), '\1[FILTERED]\2').
309
310
  gsub(%r((<CardSecVal>).+(</CardSecVal>)), '\1[FILTERED]\2').
310
- gsub(%r((<MerchantID>).+(</MerchantID>)), '\1[FILTERED]\2')
311
+ gsub(%r((<MerchantID>).+(</MerchantID>)), '\1[FILTERED]\2').
312
+ gsub(%r((<CustomerMerchantID>).+(</CustomerMerchantID>)), '\1[FILTERED]\2')
311
313
  end
312
314
 
313
315
  private
@@ -356,8 +358,8 @@ module ActiveMerchant #:nodoc:
356
358
 
357
359
  def add_level_2_tax(xml, options={})
358
360
  if (level_2 = options[:level_2_data])
359
- xml.tag! :TaxInd, level_2[:tax_indicator] if [TAX_NOT_PROVIDED, TAX_INCLUDED, NON_TAXABLE_TRANSACTION].include?(level_2[:tax_indicator])
360
- xml.tag! :Tax, amount(level_2[:tax]) if level_2[:tax]
361
+ xml.tag! :TaxInd, level_2[:tax_indicator] if [TAX_NOT_PROVIDED, TAX_INCLUDED, NON_TAXABLE_TRANSACTION].include?(level_2[:tax_indicator].to_i)
362
+ xml.tag! :Tax, level_2[:tax].to_i if level_2[:tax]
361
363
  end
362
364
  end
363
365
 
@@ -74,7 +74,7 @@ module ActiveMerchant
74
74
  end
75
75
 
76
76
  def store(payment_method, options = {})
77
- params = {}
77
+ params = {transaction_type: 'store'}
78
78
 
79
79
  add_creditcard_for_tokenization(params, payment_method, options)
80
80
 
@@ -131,25 +131,19 @@ module ActiveMerchant
131
131
  transaction_id, transaction_tag, method, _ = authorization.split('|')
132
132
  params[:transaction_id] = transaction_id
133
133
  params[:transaction_tag] = transaction_tag
134
- params[:method] = method
134
+ params[:method] = (method == 'token') ? 'credit_card' : method
135
135
  end
136
136
 
137
137
  def add_creditcard_for_tokenization(params, payment_method, options)
138
138
  params[:apikey] = @options[:apikey]
139
- params[:js_security_key] = options[:js_security_key]
140
139
  params[:ta_token] = options[:ta_token]
141
- params[:callback] = 'Payeezy.callback'
142
140
  params[:type] = 'FDToken'
143
- card = add_card_data(payment_method)
144
- params['credit_card.type'] = card[:type]
145
- params['credit_card.cardholder_name'] = card[:cardholder_name]
146
- params['credit_card.card_number'] = card[:card_number]
147
- params['credit_card.exp_date'] = card[:exp_date]
148
- params['credit_card.cvv'] = card[:cvv]
141
+ params[:credit_card] = add_card_data(payment_method)
142
+ params[:auth] = 'false'
149
143
  end
150
144
 
151
145
  def is_store_action?(params)
152
- params[:ta_token].present?
146
+ params[:transaction_type] == 'store'
153
147
  end
154
148
 
155
149
  def add_payment_method(params, payment_method, options)
@@ -277,18 +271,12 @@ module ActiveMerchant
277
271
  end
278
272
 
279
273
  def endpoint(params)
280
- is_store_action?(params) ? '/securitytokens' : '/transactions'
274
+ is_store_action?(params) ? '/transactions/tokens' : '/transactions'
281
275
  end
282
276
 
283
277
  def api_request(url, params)
284
- if is_store_action?(params)
285
- callback = ssl_request(:get, "#{url}?#{post_data(params)}", nil, {})
286
- payload = callback[/{(?:\n|.)*}/]
287
- parse(payload)
288
- else
289
- body = params.to_json
290
- parse(ssl_post(url, body, headers(body)))
291
- end
278
+ body = params.to_json
279
+ parse(ssl_post(url, body, headers(body)))
292
280
  end
293
281
 
294
282
  def post_data(params)
@@ -331,6 +319,8 @@ module ActiveMerchant
331
319
  response['transaction_status'] == 'approved'
332
320
  elsif response['results']
333
321
  response['results']['status'] == 'success'
322
+ elsif response['status']
323
+ response['status'] == 'success'
334
324
  else
335
325
  false
336
326
  end
@@ -360,10 +350,10 @@ module ActiveMerchant
360
350
  if is_store_action?(params)
361
351
  if success_from(response)
362
352
  [
363
- response['results']['token']['type'],
364
- response['results']['token']['cardholder_name'],
365
- response['results']['token']['exp_date'],
366
- response['results']['token']['value']
353
+ response['token']['type'],
354
+ response['token']['cardholder_name'],
355
+ response['token']['exp_date'],
356
+ response['token']['value']
367
357
  ].join('|')
368
358
  else
369
359
  nil
@@ -100,8 +100,20 @@ module ActiveMerchant #:nodoc:
100
100
  @express ||= PayflowExpressGateway.new(@options)
101
101
  end
102
102
 
103
+ def supports_scrubbing?
104
+ true
105
+ end
106
+
107
+ def scrub(transcript)
108
+ transcript.
109
+ gsub(%r((<CardNum>)[^<]*(</CardNum>)), '\1[FILTERED]\2').
110
+ gsub(%r((<CVNum>)[^<]*(</CVNum>)), '\1[FILTERED]\2').
111
+ gsub(%r((<AcctNum>)[^<]*(</AcctNum>)), '\1[FILTERED]\2').
112
+ gsub(%r((<Password>)[^<]*(</Password>)), '\1[FILTERED]\2')
113
+ end
103
114
 
104
115
  private
116
+
105
117
  def build_sale_or_authorization_request(action, money, funding_source, options)
106
118
  if funding_source.is_a?(String)
107
119
  build_reference_sale_or_authorization_request(action, money, funding_source, options)
@@ -121,6 +133,7 @@ module ActiveMerchant #:nodoc:
121
133
  xml.tag! 'CustIP', options[:ip] unless options[:ip].blank?
122
134
  xml.tag! 'InvNum', options[:order_id].to_s.gsub(/[^\w.]/, '') unless options[:order_id].blank?
123
135
  xml.tag! 'Description', options[:description] unless options[:description].blank?
136
+ xml.tag! 'OrderDesc', options[:order_desc] unless options[:order_desc].blank?
124
137
  xml.tag! 'Comment', options[:comment] unless options[:comment].blank?
125
138
  xml.tag!('ExtData', 'Name'=> 'COMMENT2', 'Value'=> options[:comment2]) unless options[:comment2].blank?
126
139
  xml.tag! 'TaxAmt', options[:taxamt] unless options[:taxamt].blank?
@@ -152,6 +165,7 @@ module ActiveMerchant #:nodoc:
152
165
  xml.tag! 'CustIP', options[:ip] unless options[:ip].blank?
153
166
  xml.tag! 'InvNum', options[:order_id].to_s.gsub(/[^\w.]/, '') unless options[:order_id].blank?
154
167
  xml.tag! 'Description', options[:description] unless options[:description].blank?
168
+ xml.tag! 'OrderDesc', options[:order_desc] unless options[:order_desc].blank?
155
169
  # Comment and Comment2 will show up in manager.paypal.com as Comment1 and Comment2
156
170
  xml.tag! 'Comment', options[:comment] unless options[:comment].blank?
157
171
  xml.tag!('ExtData', 'Name'=> 'COMMENT2', 'Value'=> options[:comment2]) unless options[:comment2].blank?
@@ -184,6 +198,7 @@ module ActiveMerchant #:nodoc:
184
198
  xml.tag! 'CustIP', options[:ip] unless options[:ip].blank?
185
199
  xml.tag! 'InvNum', options[:order_id].to_s.gsub(/[^\w.]/, '') unless options[:order_id].blank?
186
200
  xml.tag! 'Description', options[:description] unless options[:description].blank?
201
+ xml.tag! 'OrderDesc', options[:order_desc] unless options[:order_desc].blank?
187
202
  xml.tag! 'BillTo' do
188
203
  xml.tag! 'Name', check.name
189
204
  end
@@ -332,4 +347,3 @@ module ActiveMerchant #:nodoc:
332
347
  end
333
348
  end
334
349
  end
335
-
@@ -52,8 +52,9 @@ module ActiveMerchant #:nodoc:
52
52
  add_invoice(post, money, options)
53
53
  add_payment(post, payment)
54
54
  add_customer_data(post, options)
55
+ action = payment.is_a?(String) ? 'debit' : 'debit_cc'
55
56
 
56
- commit_transaction('debit_cc', post)
57
+ commit_transaction(action, post)
57
58
  end
58
59
 
59
60
  def authorize(money, payment, options = {})
@@ -62,10 +63,15 @@ module ActiveMerchant #:nodoc:
62
63
  add_invoice(post, money, options)
63
64
  add_customer_data(post, options)
64
65
 
65
- MultiResponse.run do |r|
66
- r.process { store(payment, options) }
67
- post[:card] = { token: r.authorization }
68
- r.process { commit_transaction('authorize', post) }
66
+ if payment.is_a?(String)
67
+ post[:card] = { token: payment }
68
+ commit_transaction('authorize', post)
69
+ else
70
+ MultiResponse.run do |r|
71
+ r.process { store(payment, options) }
72
+ post[:card] = { token: r.authorization }
73
+ r.process { commit_transaction('authorize', post) }
74
+ end
69
75
  end
70
76
  end
71
77
 
@@ -148,12 +154,16 @@ module ActiveMerchant #:nodoc:
148
154
 
149
155
  def add_payment(post, payment)
150
156
  post[:card] ||= {}
151
- post[:card][:number] = payment.number
152
- post[:card][:holder_name] = payment.name
153
- post[:card][:expiry_month] = payment.month
154
- post[:card][:expiry_year] = payment.year
155
- post[:card][:cvc] = payment.verification_value
156
- post[:card][:type] = CARD_MAPPING[payment.brand]
157
+ if payment.is_a?(String)
158
+ post[:card][:token] = payment
159
+ else
160
+ post[:card][:number] = payment.number
161
+ post[:card][:holder_name] = payment.name
162
+ post[:card][:expiry_month] = payment.month
163
+ post[:card][:expiry_year] = payment.year
164
+ post[:card][:cvc] = payment.verification_value
165
+ post[:card][:type] = CARD_MAPPING[payment.brand]
166
+ end
157
167
  end
158
168
 
159
169
  def parse(body)