activemerchant 1.125.0 → 1.129.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +316 -0
  3. data/lib/active_merchant/billing/check.rb +40 -8
  4. data/lib/active_merchant/billing/credit_card.rb +28 -1
  5. data/lib/active_merchant/billing/credit_card_methods.rb +91 -23
  6. data/lib/active_merchant/billing/gateway.rb +2 -1
  7. data/lib/active_merchant/billing/gateways/adyen.rb +74 -12
  8. data/lib/active_merchant/billing/gateways/airwallex.rb +370 -0
  9. data/lib/active_merchant/billing/gateways/alelo.rb +256 -0
  10. data/lib/active_merchant/billing/gateways/authorize_net.rb +21 -4
  11. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +2 -1
  12. data/lib/active_merchant/billing/gateways/beanstream.rb +18 -0
  13. data/lib/active_merchant/billing/gateways/blue_pay.rb +1 -1
  14. data/lib/active_merchant/billing/gateways/blue_snap.rb +53 -22
  15. data/lib/active_merchant/billing/gateways/bogus.rb +4 -0
  16. data/lib/active_merchant/billing/gateways/borgun.rb +56 -16
  17. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +6 -1
  18. data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
  19. data/lib/active_merchant/billing/gateways/braintree_blue.rb +151 -32
  20. data/lib/active_merchant/billing/gateways/card_connect.rb +28 -10
  21. data/lib/active_merchant/billing/gateways/card_stream.rb +23 -0
  22. data/lib/active_merchant/billing/gateways/checkout_v2.rb +228 -57
  23. data/lib/active_merchant/billing/gateways/commerce_hub.rb +361 -0
  24. data/lib/active_merchant/billing/gateways/credorax.rb +56 -26
  25. data/lib/active_merchant/billing/gateways/cyber_source/cyber_source_common.rb +36 -0
  26. data/lib/active_merchant/billing/gateways/cyber_source.rb +112 -58
  27. data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +456 -0
  28. data/lib/active_merchant/billing/gateways/d_local.rb +93 -5
  29. data/lib/active_merchant/billing/gateways/decidir.rb +32 -5
  30. data/lib/active_merchant/billing/gateways/decidir_plus.rb +185 -14
  31. data/lib/active_merchant/billing/gateways/ebanx.rb +39 -26
  32. data/lib/active_merchant/billing/gateways/element.rb +21 -1
  33. data/lib/active_merchant/billing/gateways/global_collect.rb +98 -37
  34. data/lib/active_merchant/billing/gateways/ipg.rb +14 -10
  35. data/lib/active_merchant/billing/gateways/iveri.rb +39 -3
  36. data/lib/active_merchant/billing/gateways/kushki.rb +21 -1
  37. data/lib/active_merchant/billing/gateways/litle.rb +118 -6
  38. data/lib/active_merchant/billing/gateways/mastercard.rb +1 -8
  39. data/lib/active_merchant/billing/gateways/mercado_pago.rb +17 -0
  40. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +44 -10
  41. data/lib/active_merchant/billing/gateways/monei.rb +2 -0
  42. data/lib/active_merchant/billing/gateways/moneris.rb +55 -13
  43. data/lib/active_merchant/billing/gateways/mundipagg.rb +3 -0
  44. data/lib/active_merchant/billing/gateways/nmi.rb +12 -7
  45. data/lib/active_merchant/billing/gateways/ogone.rb +35 -7
  46. data/lib/active_merchant/billing/gateways/openpay.rb +20 -3
  47. data/lib/active_merchant/billing/gateways/orbital.rb +378 -335
  48. data/lib/active_merchant/billing/gateways/pay_trace.rb +64 -18
  49. data/lib/active_merchant/billing/gateways/payeezy.rb +59 -4
  50. data/lib/active_merchant/billing/gateways/payflow.rb +62 -0
  51. data/lib/active_merchant/billing/gateways/paymentez.rb +44 -13
  52. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +4 -0
  53. data/lib/active_merchant/billing/gateways/paysafe.rb +37 -29
  54. data/lib/active_merchant/billing/gateways/payu_latam.rb +28 -15
  55. data/lib/active_merchant/billing/gateways/plexo.rb +308 -0
  56. data/lib/active_merchant/billing/gateways/priority.rb +185 -140
  57. data/lib/active_merchant/billing/gateways/rapyd.rb +319 -0
  58. data/lib/active_merchant/billing/gateways/reach.rb +277 -0
  59. data/lib/active_merchant/billing/gateways/redsys.rb +9 -5
  60. data/lib/active_merchant/billing/gateways/safe_charge.rb +1 -4
  61. data/lib/active_merchant/billing/gateways/sage_pay.rb +1 -1
  62. data/lib/active_merchant/billing/gateways/securion_pay.rb +40 -0
  63. data/lib/active_merchant/billing/gateways/shift4.rb +342 -0
  64. data/lib/active_merchant/billing/gateways/simetrik.rb +368 -0
  65. data/lib/active_merchant/billing/gateways/stripe.rb +25 -3
  66. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +155 -70
  67. data/lib/active_merchant/billing/gateways/tns.rb +2 -5
  68. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +1 -1
  69. data/lib/active_merchant/billing/gateways/trust_commerce.rb +14 -3
  70. data/lib/active_merchant/billing/gateways/vanco.rb +12 -3
  71. data/lib/active_merchant/billing/gateways/visanet_peru.rb +6 -2
  72. data/lib/active_merchant/billing/gateways/vpos.rb +7 -4
  73. data/lib/active_merchant/billing/gateways/wompi.rb +8 -4
  74. data/lib/active_merchant/billing/gateways/worldpay.rb +117 -9
  75. data/lib/active_merchant/billing/response.rb +15 -1
  76. data/lib/active_merchant/connection.rb +0 -2
  77. data/lib/active_merchant/country.rb +1 -0
  78. data/lib/active_merchant/errors.rb +4 -1
  79. data/lib/active_merchant/version.rb +1 -1
  80. metadata +28 -3
@@ -27,12 +27,12 @@ module ActiveMerchant #:nodoc:
27
27
  self.display_name = 'Priority'
28
28
 
29
29
  def initialize(options = {})
30
- requires!(options, :merchant_id, :key, :secret)
30
+ requires!(options, :merchant_id, :api_key, :secret)
31
31
  super
32
32
  end
33
33
 
34
34
  def basic_auth
35
- Base64.strict_encode64("#{@options[:key]}:#{@options[:secret]}")
35
+ Base64.strict_encode64("#{@options[:api_key]}:#{@options[:secret]}")
36
36
  end
37
37
 
38
38
  def request_headers
@@ -50,69 +50,87 @@ module ActiveMerchant #:nodoc:
50
50
 
51
51
  def purchase(amount, credit_card, options = {})
52
52
  params = {}
53
- params['amount'] = localized_amount(amount.to_f, options[:currency])
54
53
  params['authOnly'] = false
54
+ params['isSettleFunds'] = true
55
55
 
56
- add_credit_card(params, credit_card, 'purchase', options)
57
- add_type_merchant_purchase(params, @options[:merchant_id], true, options)
58
- commit('purchase', params: params, jwt: options)
56
+ add_merchant_id(params)
57
+ add_amount(params, amount, options)
58
+ add_auth_purchase_params(params, credit_card, options)
59
+
60
+ commit('purchase', params: params)
59
61
  end
60
62
 
61
63
  def authorize(amount, credit_card, options = {})
62
64
  params = {}
63
- params['amount'] = localized_amount(amount.to_f, options[:currency])
64
65
  params['authOnly'] = true
66
+ params['isSettleFunds'] = false
65
67
 
66
- add_credit_card(params, credit_card, 'purchase', options)
67
- add_type_merchant_purchase(params, @options[:merchant_id], false, options)
68
- commit('purchase', params: params, jwt: options)
68
+ add_merchant_id(params)
69
+ add_amount(params, amount, options)
70
+ add_auth_purchase_params(params, credit_card, options)
71
+
72
+ commit('purchase', params: params)
73
+ end
74
+
75
+ def credit(amount, credit_card, options = {})
76
+ params = {}
77
+ params['authOnly'] = false
78
+ params['isSettleFunds'] = true
79
+ amount = -amount
80
+
81
+ add_merchant_id(params)
82
+ add_amount(params, amount, options)
83
+ add_credit_params(params, credit_card, options)
84
+ commit('credit', params: params)
69
85
  end
70
86
 
71
87
  def refund(amount, authorization, options = {})
72
88
  params = {}
73
- params['merchantId'] = @options[:merchant_id]
74
- params['paymentToken'] = get_hash(authorization)['payment_token'] || options[:payment_token]
89
+ add_merchant_id(params)
90
+ params['paymentToken'] = payment_token(authorization) || options[:payment_token]
91
+
75
92
  # refund amounts must be negative
76
93
  params['amount'] = ('-' + localized_amount(amount.to_f, options[:currency])).to_f
77
- commit('refund', params: params, jwt: options)
94
+
95
+ commit('refund', params: params)
78
96
  end
79
97
 
80
98
  def capture(amount, authorization, options = {})
81
99
  params = {}
82
- params['amount'] = localized_amount(amount.to_f, options[:currency])
83
- params['authCode'] = options[:authCode]
84
- params['merchantId'] = @options[:merchant_id]
85
- params['paymentToken'] = get_hash(authorization)['payment_token']
86
- params['shouldGetCreditCardLevel'] = true
87
- params['source'] = options[:source]
88
- params['tenderType'] = 'Card'
100
+ add_merchant_id(params)
101
+ add_amount(params, amount, options)
102
+ params['paymentToken'] = payment_token(authorization) || options[:payment_token]
103
+ params['tenderType'] = options[:tender_type].present? ? options[:tender_type] : 'Card'
89
104
 
90
- commit('capture', params: params, jwt: options)
105
+ commit('capture', params: params)
91
106
  end
92
107
 
93
108
  def void(authorization, options = {})
94
- commit('void', iid: get_hash(authorization)['id'], jwt: options)
109
+ params = {}
110
+
111
+ commit('void', params: params, iid: payment_id(authorization))
95
112
  end
96
113
 
97
- def verify(credit_card, options)
98
- jwt = options[:jwt_token]
114
+ def verify(credit_card, _options = {})
115
+ jwt = create_jwt.params['jwtToken']
116
+
99
117
  commit('verify', card_number: credit_card.number, jwt: jwt)
100
118
  end
101
119
 
102
- def supports_scrubbing?
103
- true
120
+ def get_payment_status(batch_id)
121
+ commit('get_payment_status', params: batch_id)
104
122
  end
105
123
 
106
- def get_payment_status(batch_id, options)
107
- commit('get_payment_status', params: batch_id, jwt: options)
124
+ def close_batch(batch_id)
125
+ commit('close_batch', params: batch_id)
108
126
  end
109
127
 
110
- def close_batch(batch_id, options)
111
- commit('close_batch', params: batch_id, jwt: options)
128
+ def create_jwt
129
+ commit('create_jwt', params: @options[:merchant_id])
112
130
  end
113
131
 
114
- def create_jwt(options)
115
- commit('create_jwt', params: @options[:merchant_id], jwt: options)
132
+ def supports_scrubbing?
133
+ true
116
134
  end
117
135
 
118
136
  def scrub(transcript)
@@ -122,35 +140,47 @@ module ActiveMerchant #:nodoc:
122
140
  gsub(%r((cvv\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]')
123
141
  end
124
142
 
143
+ private
144
+
145
+ def add_amount(params, amount, options)
146
+ params['amount'] = localized_amount(amount.to_f, options[:currency])
147
+ end
148
+
149
+ def add_merchant_id(params)
150
+ params['merchantId'] = @options[:merchant_id]
151
+ end
152
+
153
+ def add_auth_purchase_params(params, credit_card, options)
154
+ add_replay_id(params, options)
155
+ add_credit_card(params, credit_card, 'purchase', options)
156
+ add_purchases_data(params, options)
157
+ add_shipping_data(params, options)
158
+ add_pos_data(params, options)
159
+ add_additional_data(params, options)
160
+ end
161
+
162
+ def add_credit_params(params, credit_card, options)
163
+ add_replay_id(params, options)
164
+ add_credit_card(params, credit_card, 'purchase', options)
165
+ add_additional_data(params, options)
166
+ end
167
+
168
+ def add_replay_id(params, options)
169
+ params['replayId'] = options[:replay_id] if options[:replay_id]
170
+ end
171
+
125
172
  def add_credit_card(params, credit_card, action, options)
126
173
  return unless credit_card&.is_a?(CreditCard)
127
174
 
128
175
  card_details = {}
129
-
130
176
  card_details['expiryMonth'] = format(credit_card.month, :two_digits).to_s
131
177
  card_details['expiryYear'] = format(credit_card.year, :two_digits).to_s
132
- card_details['expiryDate'] = exp_date(credit_card)
133
178
  card_details['cardType'] = credit_card.brand
134
179
  card_details['last4'] = credit_card.last_digits
135
- card_details['cvv'] = credit_card.verification_value
180
+ card_details['cvv'] = credit_card.verification_value unless credit_card.verification_value.nil?
136
181
  card_details['number'] = credit_card.number
137
-
138
- card_details['entryMode'] = options['entryMode'].blank? ? 'Keyed' : options['entryMode']
139
-
140
- case action
141
- when 'purchase'
142
- card_details['avsStreet'] = options[:billing_address][:address1] if options[:billing_address]
143
- card_details['avsZip'] = options[:billing_address][:zip] if options[:billing_address]
144
- when 'refund'
145
- card_details['cardId'] = options[:card_id]
146
- card_details['cardPresent'] = options[:card_present]
147
- card_details['hasContract'] = options[:has_contract]
148
- card_details['isCorp'] = options[:is_corp]
149
- card_details['isDebit'] = options[:is_debit]
150
- card_details['token'] = options[:token]
151
- else
152
- card_details
153
- end
182
+ card_details['avsStreet'] = options[:billing_address][:address1] if options[:billing_address]
183
+ card_details['avsZip'] = options[:billing_address][:zip] if !options[:billing_address].nil? && !options[:billing_address][:zip].nil?
154
184
 
155
185
  params['cardAccount'] = card_details
156
186
  end
@@ -159,29 +189,92 @@ module ActiveMerchant #:nodoc:
159
189
  "#{format(credit_card.month, :two_digits)}/#{format(credit_card.year, :two_digits)}"
160
190
  end
161
191
 
162
- def purchases
163
- [{ taxRate: '0.0000', additionalTaxRate: nil, discountRate: nil }]
192
+ def add_additional_data(params, options)
193
+ params['isAuth'] = options[:is_auth].present? ? options[:is_auth] : 'true'
194
+ params['paymentType'] = options[:payment_type].present? ? options[:payment_type] : 'Sale'
195
+ params['tenderType'] = options[:tender_type].present? ? options[:tender_type] : 'Card'
196
+ params['taxExempt'] = options[:tax_exempt].present? ? options[:tax_exempt] : 'false'
197
+ params['taxAmount'] = options[:tax_amount] if options[:tax_amount]
198
+ params['shouldGetCreditCardLevel'] = options[:should_get_credit_card_level] if options[:should_get_credit_card_level]
199
+ params['source'] = options[:source] if options[:source]
200
+ params['invoice'] = options[:invoice] if options[:invoice]
201
+ params['isTicket'] = options[:is_ticket] if options[:is_ticket]
202
+ params['shouldVaultCard'] = options[:should_vault_card] if options[:should_vault_card]
203
+ params['sourceZip'] = options[:source_zip] if options[:source_zip]
204
+ params['authCode'] = options[:auth_code] if options[:auth_code]
205
+ params['achIndicator'] = options[:ach_indicator] if options[:ach_indicator]
206
+ params['bankAccount'] = options[:bank_account] if options[:bank_account]
207
+ params['meta'] = options[:meta] if options[:meta]
208
+ end
209
+
210
+ def add_pos_data(params, options)
211
+ pos_data = {}
212
+ pos_data['cardholderPresence'] = options.dig(:pos_data, :cardholder_presence) || 'Ecom'
213
+ pos_data['deviceAttendance'] = options.dig(:pos_data, :device_attendance) || 'HomePc'
214
+ pos_data['deviceInputCapability'] = options.dig(:pos_data, :device_input_capability) || 'Unknown'
215
+ pos_data['deviceLocation'] = options.dig(:pos_data, :device_location) || 'HomePc'
216
+ pos_data['panCaptureMethod'] = options.dig(:pos_data, :pan_capture_method) || 'Manual'
217
+ pos_data['partialApprovalSupport'] = options.dig(:pos_data, :partial_approval_support) || 'NotSupported'
218
+ pos_data['pinCaptureCapability'] = options.dig(:pos_data, :pin_capture_capability) || 'Incapable'
219
+
220
+ params['posData'] = pos_data
221
+ end
222
+
223
+ def add_purchases_data(params, options)
224
+ return unless options[:purchases]
225
+
226
+ params['purchases'] = []
227
+
228
+ options[:purchases].each do |purchase|
229
+ purchase_object = {}
230
+
231
+ purchase_object['name'] = purchase[:name] if purchase[:name]
232
+ purchase_object['description'] = purchase[:description] if purchase[:description]
233
+ purchase_object['code'] = purchase[:code] if purchase[:code]
234
+ purchase_object['unitOfMeasure'] = purchase[:unit_of_measure] if purchase[:unit_of_measure]
235
+ purchase_object['unitPrice'] = purchase[:unit_price] if purchase[:unit_price]
236
+ purchase_object['quantity'] = purchase[:quantity] if purchase[:quantity]
237
+ purchase_object['taxRate'] = purchase[:tax_rate] if purchase[:tax_rate]
238
+ purchase_object['taxAmount'] = purchase[:tax_amount] if purchase[:tax_amount]
239
+ purchase_object['discountRate'] = purchase[:discount_rate] if purchase[:discount_rate]
240
+ purchase_object['discountAmount'] = purchase[:discount_amount] if purchase[:discount_amount]
241
+ purchase_object['extendedAmount'] = purchase[:extended_amount] if purchase[:extended_amount]
242
+ purchase_object['lineItemId'] = purchase[:line_item_id] if purchase[:line_item_id]
243
+
244
+ params['purchases'].append(purchase_object)
245
+ end
164
246
  end
165
247
 
166
- def add_type_merchant_purchase(params, merchant, is_settle_funds, options)
167
- params['cardPresent'] = false
168
- params['cardPresentType'] = 'CardNotPresent'
169
- params['isAuth'] = true
170
- params['isSettleFunds'] = is_settle_funds
171
- params['isTicket'] = false
248
+ def add_shipping_data(params, options)
249
+ params['shipAmount'] = options[:ship_amount] if options[:ship_amount]
172
250
 
173
- params['merchantId'] = merchant
174
- params['mxAdvantageEnabled'] = false
175
- params['paymentType'] = 'Sale'
251
+ shipping_country = shipping_country_from(options)
252
+ params['shipToCountry'] = shipping_country if shipping_country
176
253
 
177
- params['purchases'] = purchases
254
+ shipping_zip = shipping_zip_from(options)
255
+ params['shipToZip'] = shipping_zip if shipping_zip
256
+ end
257
+
258
+ def shipping_country_from(options)
259
+ options[:ship_to_country] || options.dig(:shipping_address, :country) || options.dig(:billing_address, :country)
260
+ end
178
261
 
179
- params['shouldGetCreditCardLevel'] = true
180
- params['shouldVaultCard'] = true
181
- params['source'] = options[:source]
182
- params['sourceZip'] = options[:billing_address][:zip] if options[:billing_address]
183
- params['taxExempt'] = false
184
- params['tenderType'] = 'Card'
262
+ def shipping_zip_from(options)
263
+ options[:ship_to_zip] || options.dig(:shipping_addres, :zip) || options.dig(:billing_address, :zip)
264
+ end
265
+
266
+ def payment_token(authorization)
267
+ return unless authorization
268
+ return authorization unless authorization.include?('|')
269
+
270
+ authorization.split('|').last
271
+ end
272
+
273
+ def payment_id(authorization)
274
+ return unless authorization
275
+ return authorization unless authorization.include?('|')
276
+
277
+ authorization.split('|').first
185
278
  end
186
279
 
187
280
  def commit(action, params: '', iid: '', card_number: nil, jwt: '')
@@ -200,10 +293,12 @@ module ActiveMerchant #:nodoc:
200
293
  parse(ssl_post(url(action, params), post_data(params), request_headers))
201
294
  end
202
295
  rescue ResponseError => e
203
- parse(e.response.body)
296
+ # currently Priority returns a 404 with no body on certain calls. In those cases we will substitute the response status from response.message
297
+ gateway_response = e.response.body.presence || e.response.message
298
+ parse(gateway_response)
204
299
  end
300
+
205
301
  success = success_from(response, action)
206
- response = { 'code' => '204' } if response == ''
207
302
  Response.new(
208
303
  success,
209
304
  message_from(response),
@@ -214,16 +309,6 @@ module ActiveMerchant #:nodoc:
214
309
  )
215
310
  end
216
311
 
217
- def handle_response(response)
218
- if response.code != '204' && (200...300).cover?(response.code.to_i)
219
- response.body
220
- elsif response.code == '204' || response == ''
221
- response.body = { 'code' => '204' }
222
- else
223
- raise ResponseError.new(response)
224
- end
225
- end
226
-
227
312
  def url(action, params, ref_number: '', credit_card_number: nil)
228
313
  case action
229
314
  when 'void'
@@ -255,10 +340,22 @@ module ActiveMerchant #:nodoc:
255
340
  test? ? self.test_url_batch : self.live_url_batch
256
341
  end
257
342
 
343
+ def handle_response(response)
344
+ case response.code.to_i
345
+ when 204
346
+ { status: 'Success' }.to_json
347
+ when 200...300
348
+ response.body
349
+ else
350
+ raise ResponseError.new(response)
351
+ end
352
+ end
353
+
258
354
  def parse(body)
259
- return body if body['code'] == '204'
355
+ return {} if body.blank?
260
356
 
261
- JSON.parse(body)
357
+ parsed_response = JSON.parse(body)
358
+ parsed_response.is_a?(String) ? { 'message' => parsed_response } : parsed_response
262
359
  rescue JSON::ParserError
263
360
  message = 'Invalid JSON response received from Priority Gateway. Please contact Priority Gateway if you continue to receive this message.'
264
361
  message += " (The raw response returned by the API was #{body.inspect})"
@@ -268,10 +365,9 @@ module ActiveMerchant #:nodoc:
268
365
  end
269
366
 
270
367
  def success_from(response, action)
271
- success = response['status'] == 'Approved' || response['status'] == 'Open' if response['status']
272
- success = response['code'] == '204' if action == 'void'
273
- success = !response['bank'].empty? if action == 'verify' && response['bank']
274
- success
368
+ return !response['bank'].empty? if action == 'verify' && response['bank']
369
+
370
+ %w[Approved Open Success Settled Voided].include?(response['status'])
275
371
  end
276
372
 
277
373
  def message_from(response)
@@ -281,10 +377,7 @@ module ActiveMerchant #:nodoc:
281
377
  end
282
378
 
283
379
  def authorization_from(response)
284
- {
285
- 'payment_token' => response['paymentToken'],
286
- 'id' => response['id']
287
- }
380
+ [response['id'], response['paymentToken']].join('|')
288
381
  end
289
382
 
290
383
  def error_from(response)
@@ -294,54 +387,6 @@ module ActiveMerchant #:nodoc:
294
387
  def post_data(params)
295
388
  params.to_json
296
389
  end
297
-
298
- def add_pos_data(options)
299
- pos_options = {}
300
- pos_options['panCaptureMethod'] = options[:pan_capture_method]
301
-
302
- pos_options
303
- end
304
-
305
- def add_purchases_data(options)
306
- purchases = {}
307
-
308
- purchases['dateCreated'] = options[:date_created]
309
- purchases['iId'] = options[:i_id]
310
- purchases['transactionIId'] = options[:transaction_i_id]
311
- purchases['transactionId'] = options[:transaction_id]
312
- purchases['name'] = options[:name]
313
- purchases['description'] = options[:description]
314
- purchases['code'] = options[:code]
315
- purchases['unitOfMeasure'] = options[:unit_of_measure]
316
- purchases['unitPrice'] = options[:unit_price]
317
- purchases['quantity'] = options[:quantity]
318
- purchases['taxRate'] = options[:tax_rate]
319
- purchases['taxAmount'] = options[:tax_amount]
320
- purchases['discountRate'] = options[:discount_rate]
321
- purchases['discountAmount'] = options[:discount_amt]
322
- purchases['extendedAmount'] = options[:extended_amt]
323
- purchases['lineItemId'] = options[:line_item_id]
324
-
325
- purchase_arr = []
326
- purchase_arr[0] = purchases
327
- purchase_arr
328
- end
329
-
330
- def add_risk_data(options)
331
- risk = {}
332
- risk['cvvResponseCode'] = options[:cvv_response_code]
333
- risk['cvvResponse'] = options[:cvv_response]
334
- risk['cvvMatch'] = options[:cvv_match]
335
- risk['avsResponse'] = options[:avs_response]
336
- risk['avsAddressMatch'] = options[:avs_address_match]
337
- risk['avsZipMatch'] = options[:avs_zip_match]
338
-
339
- risk
340
- end
341
-
342
- def get_hash(string)
343
- JSON.parse(string.gsub('=>', ':'))
344
- end
345
390
  end
346
391
  end
347
392
  end