activemerchant 1.133.0 → 1.137.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +240 -0
  3. data/lib/active_merchant/billing/check.rb +2 -2
  4. data/lib/active_merchant/billing/compatibility.rb +4 -4
  5. data/lib/active_merchant/billing/credit_card.rb +11 -8
  6. data/lib/active_merchant/billing/credit_card_formatting.rb +4 -0
  7. data/lib/active_merchant/billing/credit_card_methods.rb +59 -6
  8. data/lib/active_merchant/billing/gateway.rb +9 -0
  9. data/lib/active_merchant/billing/gateways/adyen.rb +162 -43
  10. data/lib/active_merchant/billing/gateways/airwallex.rb +26 -12
  11. data/lib/active_merchant/billing/gateways/alelo.rb +23 -5
  12. data/lib/active_merchant/billing/gateways/authorize_net.rb +43 -35
  13. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +10 -6
  14. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +1 -3
  15. data/lib/active_merchant/billing/gateways/axcessms.rb +6 -2
  16. data/lib/active_merchant/billing/gateways/banwire.rb +4 -2
  17. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +7 -3
  18. data/lib/active_merchant/billing/gateways/blue_pay.rb +13 -5
  19. data/lib/active_merchant/billing/gateways/blue_snap.rb +5 -5
  20. data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +65 -20
  21. data/lib/active_merchant/billing/gateways/braintree_blue.rb +226 -73
  22. data/lib/active_merchant/billing/gateways/braintree_orange.rb +1 -1
  23. data/lib/active_merchant/billing/gateways/card_connect.rb +5 -2
  24. data/lib/active_merchant/billing/gateways/card_stream.rb +4 -6
  25. data/lib/active_merchant/billing/gateways/cashnet.rb +1 -1
  26. data/lib/active_merchant/billing/gateways/cecabank/cecabank_common.rb +36 -0
  27. data/lib/active_merchant/billing/gateways/cecabank/cecabank_json.rb +316 -0
  28. data/lib/active_merchant/billing/gateways/cecabank/cecabank_xml.rb +220 -0
  29. data/lib/active_merchant/billing/gateways/cecabank.rb +7 -240
  30. data/lib/active_merchant/billing/gateways/checkout_v2.rb +238 -34
  31. data/lib/active_merchant/billing/gateways/commerce_hub.rb +63 -6
  32. data/lib/active_merchant/billing/gateways/credorax.rb +3 -5
  33. data/lib/active_merchant/billing/gateways/cyber_source.rb +185 -47
  34. data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +102 -58
  35. data/lib/active_merchant/billing/gateways/d_local.rb +26 -15
  36. data/lib/active_merchant/billing/gateways/data_cash.rb +21 -17
  37. data/lib/active_merchant/billing/gateways/datatrans.rb +279 -0
  38. data/lib/active_merchant/billing/gateways/decidir.rb +53 -18
  39. data/lib/active_merchant/billing/gateways/decidir_plus.rb +4 -1
  40. data/lib/active_merchant/billing/gateways/deepstack.rb +382 -0
  41. data/lib/active_merchant/billing/gateways/ebanx.rb +40 -36
  42. data/lib/active_merchant/billing/gateways/efsnet.rb +6 -2
  43. data/lib/active_merchant/billing/gateways/elavon.rb +99 -33
  44. data/lib/active_merchant/billing/gateways/element.rb +36 -7
  45. data/lib/active_merchant/billing/gateways/epay.rb +6 -2
  46. data/lib/active_merchant/billing/gateways/evo_ca.rb +6 -2
  47. data/lib/active_merchant/billing/gateways/eway.rb +4 -2
  48. data/lib/active_merchant/billing/gateways/eway_managed.rb +6 -2
  49. data/lib/active_merchant/billing/gateways/exact.rb +6 -2
  50. data/lib/active_merchant/billing/gateways/fat_zebra.rb +31 -3
  51. data/lib/active_merchant/billing/gateways/federated_canada.rb +6 -2
  52. data/lib/active_merchant/billing/gateways/first_pay/first_pay_common.rb +15 -0
  53. data/lib/active_merchant/billing/gateways/first_pay/first_pay_json.rb +190 -0
  54. data/lib/active_merchant/billing/gateways/first_pay/first_pay_xml.rb +183 -0
  55. data/lib/active_merchant/billing/gateways/first_pay.rb +6 -172
  56. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +6 -2
  57. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +7 -3
  58. data/lib/active_merchant/billing/gateways/flex_charge.rb +347 -0
  59. data/lib/active_merchant/billing/gateways/garanti.rb +4 -2
  60. data/lib/active_merchant/billing/gateways/global_collect.rb +45 -37
  61. data/lib/active_merchant/billing/gateways/hi_pay.rb +286 -0
  62. data/lib/active_merchant/billing/gateways/hps.rb +1 -1
  63. data/lib/active_merchant/billing/gateways/iats_payments.rb +7 -2
  64. data/lib/active_merchant/billing/gateways/inspire.rb +6 -4
  65. data/lib/active_merchant/billing/gateways/instapay.rb +7 -4
  66. data/lib/active_merchant/billing/gateways/ipg.rb +9 -5
  67. data/lib/active_merchant/billing/gateways/iridium.rb +15 -5
  68. data/lib/active_merchant/billing/gateways/itransact.rb +6 -2
  69. data/lib/active_merchant/billing/gateways/iveri.rb +3 -3
  70. data/lib/active_merchant/billing/gateways/ixopay.rb +2 -2
  71. data/lib/active_merchant/billing/gateways/jetpay.rb +4 -2
  72. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +4 -2
  73. data/lib/active_merchant/billing/gateways/kushki.rb +72 -12
  74. data/lib/active_merchant/billing/gateways/linkpoint.rb +6 -2
  75. data/lib/active_merchant/billing/gateways/litle.rb +33 -50
  76. data/lib/active_merchant/billing/gateways/mastercard.rb +4 -4
  77. data/lib/active_merchant/billing/gateways/maxipago.rb +2 -2
  78. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +8 -5
  79. data/lib/active_merchant/billing/gateways/merchant_ware.rb +11 -4
  80. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +11 -4
  81. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +19 -3
  82. data/lib/active_merchant/billing/gateways/mercury.rb +6 -2
  83. data/lib/active_merchant/billing/gateways/metrics_global.rb +8 -6
  84. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +1 -0
  85. data/lib/active_merchant/billing/gateways/migs.rb +6 -2
  86. data/lib/active_merchant/billing/gateways/mit.rb +8 -3
  87. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +18 -10
  88. data/lib/active_merchant/billing/gateways/monei.rb +1 -1
  89. data/lib/active_merchant/billing/gateways/moneris.rb +9 -3
  90. data/lib/active_merchant/billing/gateways/money_movers.rb +6 -2
  91. data/lib/active_merchant/billing/gateways/nab_transact.rb +12 -4
  92. data/lib/active_merchant/billing/gateways/net_registry.rb +6 -2
  93. data/lib/active_merchant/billing/gateways/netbanx.rb +1 -3
  94. data/lib/active_merchant/billing/gateways/netbilling.rb +6 -2
  95. data/lib/active_merchant/billing/gateways/network_merchants.rb +6 -2
  96. data/lib/active_merchant/billing/gateways/nmi.rb +18 -6
  97. data/lib/active_merchant/billing/gateways/ogone.rb +6 -2
  98. data/lib/active_merchant/billing/gateways/openpay.rb +4 -2
  99. data/lib/active_merchant/billing/gateways/opp.rb +1 -2
  100. data/lib/active_merchant/billing/gateways/optimal_payment.rb +6 -2
  101. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +1 -3
  102. data/lib/active_merchant/billing/gateways/orbital.rb +83 -24
  103. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +7 -4
  104. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +6 -2
  105. data/lib/active_merchant/billing/gateways/pay_hub.rb +4 -2
  106. data/lib/active_merchant/billing/gateways/pay_junction.rb +6 -2
  107. data/lib/active_merchant/billing/gateways/pay_secure.rb +6 -2
  108. data/lib/active_merchant/billing/gateways/pay_trace.rb +31 -18
  109. data/lib/active_merchant/billing/gateways/payeezy.rb +19 -8
  110. data/lib/active_merchant/billing/gateways/payex.rb +4 -2
  111. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -1
  112. data/lib/active_merchant/billing/gateways/payflow.rb +1 -3
  113. data/lib/active_merchant/billing/gateways/payment_express.rb +8 -4
  114. data/lib/active_merchant/billing/gateways/paymentez.rb +23 -11
  115. data/lib/active_merchant/billing/gateways/paysafe.rb +12 -11
  116. data/lib/active_merchant/billing/gateways/payscout.rb +7 -4
  117. data/lib/active_merchant/billing/gateways/paystation.rb +7 -3
  118. data/lib/active_merchant/billing/gateways/payway.rb +6 -2
  119. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +2 -2
  120. data/lib/active_merchant/billing/gateways/pin.rb +22 -4
  121. data/lib/active_merchant/billing/gateways/plexo.rb +49 -10
  122. data/lib/active_merchant/billing/gateways/plugnpay.rb +6 -2
  123. data/lib/active_merchant/billing/gateways/priority.rb +6 -5
  124. data/lib/active_merchant/billing/gateways/psigate.rb +6 -2
  125. data/lib/active_merchant/billing/gateways/psl_card.rb +6 -2
  126. data/lib/active_merchant/billing/gateways/qbms.rb +6 -2
  127. data/lib/active_merchant/billing/gateways/quantum.rb +6 -2
  128. data/lib/active_merchant/billing/gateways/quickbooks.rb +6 -5
  129. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +7 -4
  130. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +6 -2
  131. data/lib/active_merchant/billing/gateways/rapyd.rb +148 -46
  132. data/lib/active_merchant/billing/gateways/reach.rb +11 -4
  133. data/lib/active_merchant/billing/gateways/redsys.rb +2 -10
  134. data/lib/active_merchant/billing/gateways/redsys_rest.rb +507 -0
  135. data/lib/active_merchant/billing/gateways/s5.rb +3 -3
  136. data/lib/active_merchant/billing/gateways/safe_charge.rb +36 -16
  137. data/lib/active_merchant/billing/gateways/sage.rb +12 -4
  138. data/lib/active_merchant/billing/gateways/sage_pay.rb +79 -5
  139. data/lib/active_merchant/billing/gateways/sallie_mae.rb +6 -2
  140. data/lib/active_merchant/billing/gateways/secure_net.rb +6 -2
  141. data/lib/active_merchant/billing/gateways/secure_pay.rb +8 -6
  142. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +12 -4
  143. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +6 -2
  144. data/lib/active_merchant/billing/gateways/securion_pay.rb +24 -10
  145. data/lib/active_merchant/billing/gateways/shift4.rb +17 -20
  146. data/lib/active_merchant/billing/gateways/shift4_v2.rb +117 -0
  147. data/lib/active_merchant/billing/gateways/simetrik.rb +17 -11
  148. data/lib/active_merchant/billing/gateways/skip_jack.rb +6 -2
  149. data/lib/active_merchant/billing/gateways/smart_ps.rb +7 -4
  150. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +4 -2
  151. data/lib/active_merchant/billing/gateways/spreedly_core.rb +2 -4
  152. data/lib/active_merchant/billing/gateways/stripe.rb +53 -21
  153. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +199 -50
  154. data/lib/active_merchant/billing/gateways/sum_up.rb +223 -0
  155. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +4 -2
  156. data/lib/active_merchant/billing/gateways/telr.rb +3 -4
  157. data/lib/active_merchant/billing/gateways/trans_first.rb +1 -2
  158. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +8 -16
  159. data/lib/active_merchant/billing/gateways/transact_pro.rb +1 -1
  160. data/lib/active_merchant/billing/gateways/trust_commerce.rb +6 -2
  161. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +9 -8
  162. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +6 -2
  163. data/lib/active_merchant/billing/gateways/vanco.rb +2 -4
  164. data/lib/active_merchant/billing/gateways/vantiv_express.rb +587 -0
  165. data/lib/active_merchant/billing/gateways/verifi.rb +6 -2
  166. data/lib/active_merchant/billing/gateways/viaklix.rb +6 -2
  167. data/lib/active_merchant/billing/gateways/visanet_peru.rb +2 -2
  168. data/lib/active_merchant/billing/gateways/vpos.rb +3 -3
  169. data/lib/active_merchant/billing/gateways/wirecard.rb +7 -3
  170. data/lib/active_merchant/billing/gateways/wompi.rb +5 -0
  171. data/lib/active_merchant/billing/gateways/worldpay.rb +140 -73
  172. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +13 -10
  173. data/lib/active_merchant/billing/gateways/xpay.rb +242 -0
  174. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +1 -1
  175. data/lib/active_merchant/billing/response.rb +2 -2
  176. data/lib/active_merchant/connection.rb +3 -17
  177. data/lib/active_merchant/country.rb +1 -0
  178. data/lib/active_merchant/errors.rb +10 -0
  179. data/lib/active_merchant/version.rb +1 -1
  180. data/lib/support/gateway_support.rb +2 -2
  181. data/lib/support/ssl_verify.rb +4 -4
  182. data/lib/support/ssl_version.rb +6 -6
  183. metadata +30 -9
@@ -34,6 +34,7 @@ module ActiveMerchant #:nodoc:
34
34
  public_key: public_key
35
35
  }
36
36
  add_invoice(post, money, options)
37
+ add_tip_in_cents(post, options)
37
38
  add_card(post, payment, options)
38
39
 
39
40
  commit('sale', post, '/transactions_sync')
@@ -141,6 +142,10 @@ module ActiveMerchant #:nodoc:
141
142
  post[:cvc] = cvc if cvc && !cvc.empty?
142
143
  end
143
144
 
145
+ def add_tip_in_cents(post, options)
146
+ post[:tip_in_cents] = options[:tip_in_cents].to_i if options[:tip_in_cents]
147
+ end
148
+
144
149
  def parse(body)
145
150
  JSON.parse(body)
146
151
  end
@@ -38,14 +38,14 @@ module ActiveMerchant #:nodoc:
38
38
  'G' => 'C', # Address does not match, postcode not checked
39
39
  'H' => 'I', # Address and postcode not provided
40
40
  'I' => 'C', # Address not checked postcode does not match
41
- 'J' => 'C', # Address and postcode does not match
41
+ 'J' => 'C' # Address and postcode does not match
42
42
  }
43
43
 
44
44
  CVC_CODE_MAP = {
45
45
  'A' => 'M', # CVV matches
46
46
  'B' => 'P', # Not provided
47
47
  'C' => 'P', # Not checked
48
- 'D' => 'N', # Does not match
48
+ 'D' => 'N' # Does not match
49
49
  }
50
50
 
51
51
  def initialize(options = {})
@@ -62,7 +62,7 @@ module ActiveMerchant #:nodoc:
62
62
 
63
63
  def authorize(money, payment_method, options = {})
64
64
  requires!(options, :order_id)
65
- payment_details = payment_details(payment_method)
65
+ payment_details = payment_details(payment_method, options)
66
66
  authorize_request(money, payment_method, payment_details.merge(options))
67
67
  end
68
68
 
@@ -108,9 +108,11 @@ module ActiveMerchant #:nodoc:
108
108
  # and other transactions should be performed on a normal eCom-flagged
109
109
  # merchant ID.
110
110
  def credit(money, payment_method, options = {})
111
- payment_details = payment_details(payment_method)
111
+ payment_details = payment_details(payment_method, options)
112
112
  if options[:fast_fund_credit]
113
113
  fast_fund_credit_request(money, payment_method, payment_details.merge(credit: true, **options))
114
+ elsif options[:account_funding_transaction]
115
+ aft_request(money, payment_method, payment_details.merge(**options))
114
116
  else
115
117
  credit_request(money, payment_method, payment_details.merge(credit: true, **options))
116
118
  end
@@ -148,11 +150,20 @@ module ActiveMerchant #:nodoc:
148
150
  gsub(%r((<cardNumber>)\d+(</cardNumber>)), '\1[FILTERED]\2').
149
151
  gsub(%r((<cvc>)[^<]+(</cvc>)), '\1[FILTERED]\2').
150
152
  gsub(%r((<tokenNumber>)\d+(</tokenNumber>)), '\1[FILTERED]\2').
151
- gsub(%r((<cryptogram>)[^<]+(</cryptogram>)), '\1[FILTERED]\2')
153
+ gsub(%r((<cryptogram>)[^<]+(</cryptogram>)), '\1[FILTERED]\2').
154
+ gsub(%r((<accountReference accountType="\w+">)\d+(<\/accountReference>)), '\1[FILTERED]\2')
152
155
  end
153
156
 
154
157
  private
155
158
 
159
+ def eci_value(payment_method, options)
160
+ eci = payment_method.respond_to?(:eci) ? format(payment_method.eci, :two_digits) : ''
161
+
162
+ return eci unless eci.empty?
163
+
164
+ options[:use_default_eci] ? '07' : eci
165
+ end
166
+
156
167
  def authorize_request(money, payment_method, options)
157
168
  commit('authorize', build_authorization_request(money, payment_method, options), 'AUTHORISED', 'CAPTURED', options)
158
169
  end
@@ -181,6 +192,10 @@ module ActiveMerchant #:nodoc:
181
192
  commit('fast_credit', build_fast_fund_credit_request(money, payment_method, options), :ok, 'PUSH_APPROVED', options)
182
193
  end
183
194
 
195
+ def aft_request(money, payment_method, options)
196
+ commit('funding_transfer_transaction', build_aft_request(money, payment_method, options), :ok, 'AUTHORISED', options)
197
+ end
198
+
184
199
  def store_request(credit_card, options)
185
200
  commit('store', build_store_request(credit_card, options), options)
186
201
  end
@@ -252,9 +267,8 @@ module ActiveMerchant #:nodoc:
252
267
  xml.invoiceReferenceNumber data[:invoice_reference_number] if data.include?(:invoice_reference_number)
253
268
  xml.customerReference data[:customer_reference] if data.include?(:customer_reference)
254
269
  xml.cardAcceptorTaxId data[:card_acceptor_tax_id] if data.include?(:card_acceptor_tax_id)
255
-
256
270
  {
257
- sales_tax: 'salesTax',
271
+ tax_amount: 'salesTax',
258
272
  discount_amount: 'discountAmount',
259
273
  shipping_amount: 'shippingAmount',
260
274
  duty_amount: 'dutyAmount'
@@ -262,53 +276,37 @@ module ActiveMerchant #:nodoc:
262
276
  next unless data.include?(key)
263
277
 
264
278
  xml.tag! tag do
265
- data_amount = data[key].symbolize_keys
266
- add_amount(xml, data_amount[:amount].to_i, data_amount)
279
+ add_amount(xml, data[key].to_i, data)
267
280
  end
268
281
  end
269
282
 
270
- xml.discountName data[:discount_name] if data.include?(:discount_name)
271
- xml.discountCode data[:discount_code] if data.include?(:discount_code)
272
-
273
- add_date_element(xml, 'shippingDate', data[:shipping_date]) if data.include?(:shipping_date)
274
-
275
- if data.include?(:shipping_courier)
276
- xml.shippingCourier(
277
- data[:shipping_courier][:priority],
278
- data[:shipping_courier][:tracking_number],
279
- data[:shipping_courier][:name]
280
- )
281
- end
282
-
283
283
  add_optional_data_level_two_and_three(xml, data)
284
284
 
285
- if data.include?(:item) && data[:item].kind_of?(Array)
286
- data[:item].each { |item| add_items_into_level_three_data(xml, item.symbolize_keys) }
287
- elsif data.include?(:item)
288
- add_items_into_level_three_data(xml, data[:item].symbolize_keys)
289
- end
285
+ data[:line_items].each { |item| add_line_items_into_level_three_data(xml, item.symbolize_keys, data) } if data.include?(:line_items)
290
286
  end
291
287
 
292
- def add_items_into_level_three_data(xml, item)
288
+ def add_line_items_into_level_three_data(xml, item, data)
293
289
  xml.item do
294
290
  xml.description item[:description] if item[:description]
295
291
  xml.productCode item[:product_code] if item[:product_code]
296
292
  xml.commodityCode item[:commodity_code] if item[:commodity_code]
297
293
  xml.quantity item[:quantity] if item[:quantity]
298
-
299
- {
300
- unit_cost: 'unitCost',
301
- item_total: 'itemTotal',
302
- item_total_with_tax: 'itemTotalWithTax',
303
- item_discount_amount: 'itemDiscountAmount',
304
- tax_amount: 'taxAmount'
305
- }.each do |key, tag|
306
- next unless item.include?(key)
307
-
308
- xml.tag! tag do
309
- data_amount = item[key].symbolize_keys
310
- add_amount(xml, data_amount[:amount].to_i, data_amount)
311
- end
294
+ xml.unitCost do
295
+ add_amount(xml, item[:unit_cost], data)
296
+ end
297
+ xml.unitOfMeasure item[:unit_of_measure] || 'each'
298
+ xml.itemTotal do
299
+ sub_total_amount = item[:quantity].to_i * (item[:unit_cost].to_i - item[:discount_amount].to_i)
300
+ add_amount(xml, sub_total_amount, data)
301
+ end
302
+ xml.itemTotalWithTax do
303
+ add_amount(xml, item[:total_amount], data)
304
+ end
305
+ xml.itemDiscountAmount do
306
+ add_amount(xml, item[:discount_amount], data)
307
+ end
308
+ xml.taxAmount do
309
+ add_amount(xml, item[:tax_amount], data)
312
310
  end
313
311
  end
314
312
  end
@@ -318,7 +316,7 @@ module ActiveMerchant #:nodoc:
318
316
  xml.destinationPostalCode data[:destination_postal_code] if data.include?(:destination_postal_code)
319
317
  xml.destinationCountryCode data[:destination_country_code] if data.include?(:destination_country_code)
320
318
  add_date_element(xml, 'orderDate', data[:order_date].symbolize_keys) if data.include?(:order_date)
321
- xml.taxExempt data[:tax_exempt] if data.include?(:tax_exempt)
319
+ xml.taxExempt data[:tax_amount].to_i > 0 ? 'false' : 'true'
322
320
  end
323
321
 
324
322
  def order_tag_attributes(options)
@@ -409,6 +407,66 @@ module ActiveMerchant #:nodoc:
409
407
  end
410
408
  end
411
409
 
410
+ def build_aft_request(money, payment_method, options)
411
+ build_request do |xml|
412
+ xml.submit do
413
+ xml.order order_tag_attributes(options) do
414
+ xml.description(options[:description].blank? ? 'Account Funding Transaction' : options[:description])
415
+ add_amount(xml, money, options)
416
+ add_order_content(xml, options)
417
+ add_payment_method(xml, money, payment_method, options)
418
+ add_shopper(xml, options)
419
+ add_sub_merchant_data(xml, options[:sub_merchant_data]) if options[:sub_merchant_data]
420
+ add_aft_data(xml, payment_method, options)
421
+ end
422
+ end
423
+ end
424
+ end
425
+
426
+ def add_aft_data(xml, payment_method, options)
427
+ xml.fundingTransfer 'type' => options[:aft_type], 'category' => 'PULL_FROM_CARD' do
428
+ xml.paymentPurpose options[:aft_payment_purpose] # Must be included for the recipient for following countries, otherwise optional: Argentina, Bangladesh, Chile, Columbia, Jordan, Mexico, Thailand, UAE, India cross-border
429
+ xml.fundingParty 'type' => 'sender' do
430
+ xml.accountReference options[:aft_sender_account_reference], 'accountType' => options[:aft_sender_account_type]
431
+ xml.fullName do
432
+ xml.first options.dig(:aft_sender_full_name, :first)
433
+ xml.middle options.dig(:aft_sender_full_name, :middle)
434
+ xml.last options.dig(:aft_sender_full_name, :last)
435
+ end
436
+ xml.fundingAddress do
437
+ xml.address1 options.dig(:aft_sender_funding_address, :address1)
438
+ xml.address2 options.dig(:aft_sender_funding_address, :address2)
439
+ xml.postalCode options.dig(:aft_sender_funding_address, :postal_code)
440
+ xml.city options.dig(:aft_sender_funding_address, :city)
441
+ xml.state options.dig(:aft_sender_funding_address, :state)
442
+ xml.countryCode options.dig(:aft_sender_funding_address, :country_code)
443
+ end
444
+ end
445
+ xml.fundingParty 'type' => 'recipient' do
446
+ xml.accountReference options[:aft_recipient_account_reference], 'accountType' => options[:aft_recipient_account_type]
447
+ xml.fullName do
448
+ xml.first options.dig(:aft_recipient_full_name, :first)
449
+ xml.middle options.dig(:aft_recipient_full_name, :middle)
450
+ xml.last options.dig(:aft_recipient_full_name, :last)
451
+ end
452
+ xml.fundingAddress do
453
+ xml.address1 options.dig(:aft_recipient_funding_address, :address1)
454
+ xml.address2 options.dig(:aft_recipient_funding_address, :address2)
455
+ xml.postalCode options.dig(:aft_recipient_funding_address, :postal_code)
456
+ xml.city options.dig(:aft_recipient_funding_address, :city)
457
+ xml.state options.dig(:aft_recipient_funding_address, :state)
458
+ xml.countryCode options.dig(:aft_recipient_funding_address, :country_code)
459
+ end
460
+ if options[:aft_recipient_funding_data]
461
+ xml.fundingData do
462
+ add_date_element(xml, 'birthDate', options[:aft_recipient_funding_data][:birth_date])
463
+ xml.telephoneNumber options.dig(:aft_recipient_funding_data, :telephone_number)
464
+ end
465
+ end
466
+ end
467
+ end
468
+ end
469
+
412
470
  def add_payment_details_for_ff_credit(xml, payment_method, options)
413
471
  xml.paymentDetails do
414
472
  xml.tag! 'FF_DISBURSE-SSL' do
@@ -443,7 +501,7 @@ module ActiveMerchant #:nodoc:
443
501
  end
444
502
 
445
503
  def add_additional_3ds_data(xml, options)
446
- additional_data = { 'dfReferenceId' => options[:session_id] }
504
+ additional_data = { 'dfReferenceId' => options[:df_reference_id] }
447
505
  additional_data['challengeWindowSize'] = options[:browser_size] if options[:browser_size]
448
506
 
449
507
  xml.additional3DSData additional_data
@@ -554,10 +612,10 @@ module ActiveMerchant #:nodoc:
554
612
  end
555
613
 
556
614
  def add_amount(xml, money, options)
557
- currency = options[:currency] || currency(money)
615
+ currency = options[:currency] || currency(money.to_i)
558
616
 
559
617
  amount_hash = {
560
- :value => localized_amount(money, currency),
618
+ :value => localized_amount(money.to_i, currency),
561
619
  'currencyCode' => currency,
562
620
  'exponent' => currency_exponent(currency)
563
621
  }
@@ -572,7 +630,7 @@ module ActiveMerchant #:nodoc:
572
630
  when :pay_as_order
573
631
  add_amount_for_pay_as_order(xml, amount, payment_method, options)
574
632
  when :network_token
575
- add_network_tokenization_card(xml, payment_method)
633
+ add_network_tokenization_card(xml, payment_method, options)
576
634
  else
577
635
  add_card_or_token(xml, payment_method, options)
578
636
  end
@@ -590,8 +648,9 @@ module ActiveMerchant #:nodoc:
590
648
  end
591
649
  end
592
650
 
593
- def add_network_tokenization_card(xml, payment_method)
594
- token_type = NETWORK_TOKEN_TYPE.fetch(payment_method.source, 'NETWORKTOKEN')
651
+ def add_network_tokenization_card(xml, payment_method, options)
652
+ source = payment_method.respond_to?(:source) ? payment_method.source : options[:wallet_type]
653
+ token_type = NETWORK_TOKEN_TYPE.fetch(source, 'NETWORKTOKEN')
595
654
 
596
655
  xml.paymentDetails do
597
656
  xml.tag! 'EMVCO_TOKEN-SSL', 'type' => token_type do
@@ -603,11 +662,12 @@ module ActiveMerchant #:nodoc:
603
662
  )
604
663
  end
605
664
  name = card_holder_name(payment_method, options)
606
- eci = format(payment_method.eci, :two_digits)
607
665
  xml.cardHolderName name if name.present?
608
- xml.cryptogram payment_method.payment_cryptogram
609
- xml.eciIndicator eci.empty? ? '07' : eci
666
+ xml.cryptogram payment_method.payment_cryptogram unless options[:wallet_type] == :google_pay
667
+ eci = eci_value(payment_method, options)
668
+ xml.eciIndicator eci if eci.present?
610
669
  end
670
+ add_stored_credential_options(xml, options)
611
671
  end
612
672
  end
613
673
 
@@ -684,30 +744,27 @@ module ActiveMerchant #:nodoc:
684
744
  end
685
745
 
686
746
  def add_stored_credential_using_normalized_fields(xml, options)
687
- if options[:stored_credential][:initial_transaction]
688
- xml.storedCredentials 'usage' => 'FIRST'
689
- else
690
- reason = case options[:stored_credential][:reason_type]
691
- when 'installment' then 'INSTALMENT'
692
- when 'recurring' then 'RECURRING'
693
- when 'unscheduled' then 'UNSCHEDULED'
694
- end
695
-
696
- xml.storedCredentials 'usage' => 'USED', 'merchantInitiatedReason' => reason do
697
- xml.schemeTransactionIdentifier options[:stored_credential][:network_transaction_id] if options[:stored_credential][:network_transaction_id]
698
- end
747
+ reason = case options[:stored_credential][:reason_type]
748
+ when 'installment' then 'INSTALMENT'
749
+ when 'recurring' then 'RECURRING'
750
+ when 'unscheduled' then 'UNSCHEDULED'
751
+ end
752
+ is_initial_transaction = options[:stored_credential][:initial_transaction]
753
+ stored_credential_params = generate_stored_credential_params(is_initial_transaction, reason)
754
+
755
+ xml.storedCredentials stored_credential_params do
756
+ xml.schemeTransactionIdentifier network_transaction_id(options) if network_transaction_id(options) && !is_initial_transaction
699
757
  end
700
758
  end
701
759
 
702
760
  def add_stored_credential_using_gateway_specific_fields(xml, options)
703
761
  return unless options[:stored_credential_usage]
704
762
 
705
- if options[:stored_credential_initiated_reason]
706
- xml.storedCredentials 'usage' => options[:stored_credential_usage], 'merchantInitiatedReason' => options[:stored_credential_initiated_reason] do
707
- xml.schemeTransactionIdentifier options[:stored_credential_transaction_id] if options[:stored_credential_transaction_id]
708
- end
709
- else
710
- xml.storedCredentials 'usage' => options[:stored_credential_usage]
763
+ is_initial_transaction = options[:stored_credential_usage] == 'FIRST'
764
+ stored_credential_params = generate_stored_credential_params(is_initial_transaction, options[:stored_credential_initiated_reason])
765
+
766
+ xml.storedCredentials stored_credential_params do
767
+ xml.schemeTransactionIdentifier options[:stored_credential_transaction_id] if options[:stored_credential_transaction_id] && !is_initial_transaction
711
768
  end
712
769
  end
713
770
 
@@ -832,7 +889,8 @@ module ActiveMerchant #:nodoc:
832
889
 
833
890
  # ensure cookie included on follow-up '3ds' and 'capture_request' calls, using the cookie saved from the preceding response
834
891
  # cookie should be present in options on the 3ds and capture calls, but also still saved in the instance var in case
835
- cookie = options[:cookie] || @cookie || nil
892
+ cookie = defined?(@cookie) ? @cookie : nil
893
+ cookie = options[:cookie] || cookie
836
894
  headers['Cookie'] = cookie if cookie
837
895
 
838
896
  headers['Idempotency-Key'] = idempotency_key if idempotency_key
@@ -977,12 +1035,12 @@ module ActiveMerchant #:nodoc:
977
1035
  token_details
978
1036
  end
979
1037
 
980
- def payment_details(payment_method)
1038
+ def payment_details(payment_method, options = {})
981
1039
  case payment_method
982
1040
  when String
983
1041
  token_type_and_details(payment_method)
984
1042
  else
985
- type = network_token?(payment_method) ? :network_token : :credit
1043
+ type = network_token?(payment_method) || options[:wallet_type] == :google_pay ? :network_token : :credit
986
1044
 
987
1045
  { payment_type: type }
988
1046
  end
@@ -1026,6 +1084,15 @@ module ActiveMerchant #:nodoc:
1026
1084
  def card_holder_name(payment_method, options)
1027
1085
  test? && options[:execute_threed] && !options[:three_ds_version]&.start_with?('2') ? '3D' : payment_method.name
1028
1086
  end
1087
+
1088
+ def generate_stored_credential_params(is_initial_transaction, reason = nil)
1089
+ customer_or_merchant = reason == 'RECURRING' && is_initial_transaction ? 'customerInitiatedReason' : 'merchantInitiatedReason'
1090
+
1091
+ stored_credential_params = {}
1092
+ stored_credential_params['usage'] = is_initial_transaction ? 'FIRST' : 'USED'
1093
+ stored_credential_params[customer_or_merchant] = reason if reason
1094
+ stored_credential_params
1095
+ end
1029
1096
  end
1030
1097
  end
1031
1098
  end
@@ -34,14 +34,16 @@ module ActiveMerchant #:nodoc:
34
34
  if authorization
35
35
  commit(:post, "orders/#{CGI.escape(authorization)}/capture", { 'captureAmount' => money }, options, 'capture')
36
36
  else
37
- Response.new(false,
37
+ Response.new(
38
+ false,
38
39
  'FAILED',
39
40
  'FAILED',
40
41
  test: test?,
41
42
  authorization: false,
42
43
  avs_result: {},
43
44
  cvv_result: {},
44
- error_code: false)
45
+ error_code: false
46
+ )
45
47
  end
46
48
  end
47
49
 
@@ -84,8 +86,7 @@ module ActiveMerchant #:nodoc:
84
86
  },
85
87
  'clientKey' => @client_key
86
88
  }
87
- token_response = commit(:post, 'tokens', obj, { 'Authorization' => @service_key }, 'token')
88
- token_response
89
+ commit(:post, 'tokens', obj, { 'Authorization' => @service_key }, 'token')
89
90
  end
90
91
 
91
92
  def create_post_for_auth_or_purchase(token, money, options)
@@ -134,7 +135,10 @@ module ActiveMerchant #:nodoc:
134
135
 
135
136
  raw_response = ssl_request(method, self.live_url + url, json, headers(options))
136
137
 
137
- if raw_response != ''
138
+ if raw_response == ''
139
+ success = true
140
+ response = {}
141
+ else
138
142
  response = parse(raw_response)
139
143
  if type == 'token'
140
144
  success = response.key?('token')
@@ -151,9 +155,6 @@ module ActiveMerchant #:nodoc:
151
155
  end
152
156
  end
153
157
  end
154
- else
155
- success = true
156
- response = {}
157
158
  end
158
159
  rescue ResponseError => e
159
160
  raw_response = e.response.body
@@ -170,14 +171,16 @@ module ActiveMerchant #:nodoc:
170
171
  authorization = response['message']
171
172
  end
172
173
 
173
- Response.new(success,
174
+ Response.new(
175
+ success,
174
176
  success ? 'SUCCESS' : response['message'],
175
177
  response,
176
178
  test: test?,
177
179
  authorization: authorization,
178
180
  avs_result: {},
179
181
  cvv_result: {},
180
- error_code: success ? nil : response['customCode'])
182
+ error_code: success ? nil : response['customCode']
183
+ )
181
184
  end
182
185
 
183
186
  def test?