activemerchant 1.131.0 → 1.137.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +262 -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 +13 -8
  6. data/lib/active_merchant/billing/credit_card_formatting.rb +4 -0
  7. data/lib/active_merchant/billing/credit_card_methods.rb +64 -7
  8. data/lib/active_merchant/billing/gateway.rb +9 -0
  9. data/lib/active_merchant/billing/gateways/adyen.rb +240 -41
  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/borgun.rb +6 -4
  21. data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +65 -20
  22. data/lib/active_merchant/billing/gateways/braintree_blue.rb +226 -73
  23. data/lib/active_merchant/billing/gateways/braintree_orange.rb +1 -1
  24. data/lib/active_merchant/billing/gateways/card_connect.rb +5 -2
  25. data/lib/active_merchant/billing/gateways/card_stream.rb +4 -6
  26. data/lib/active_merchant/billing/gateways/cashnet.rb +1 -1
  27. data/lib/active_merchant/billing/gateways/cecabank/cecabank_common.rb +36 -0
  28. data/lib/active_merchant/billing/gateways/cecabank/cecabank_json.rb +316 -0
  29. data/lib/active_merchant/billing/gateways/cecabank/cecabank_xml.rb +220 -0
  30. data/lib/active_merchant/billing/gateways/cecabank.rb +7 -240
  31. data/lib/active_merchant/billing/gateways/checkout_v2.rb +242 -41
  32. data/lib/active_merchant/billing/gateways/commerce_hub.rb +69 -8
  33. data/lib/active_merchant/billing/gateways/credorax.rb +3 -5
  34. data/lib/active_merchant/billing/gateways/cyber_source.rb +192 -41
  35. data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +102 -58
  36. data/lib/active_merchant/billing/gateways/d_local.rb +26 -15
  37. data/lib/active_merchant/billing/gateways/data_cash.rb +21 -17
  38. data/lib/active_merchant/billing/gateways/datatrans.rb +279 -0
  39. data/lib/active_merchant/billing/gateways/decidir.rb +53 -18
  40. data/lib/active_merchant/billing/gateways/decidir_plus.rb +4 -1
  41. data/lib/active_merchant/billing/gateways/deepstack.rb +382 -0
  42. data/lib/active_merchant/billing/gateways/ebanx.rb +40 -36
  43. data/lib/active_merchant/billing/gateways/efsnet.rb +6 -2
  44. data/lib/active_merchant/billing/gateways/elavon.rb +99 -33
  45. data/lib/active_merchant/billing/gateways/element.rb +36 -7
  46. data/lib/active_merchant/billing/gateways/epay.rb +6 -2
  47. data/lib/active_merchant/billing/gateways/evo_ca.rb +6 -2
  48. data/lib/active_merchant/billing/gateways/eway.rb +4 -2
  49. data/lib/active_merchant/billing/gateways/eway_managed.rb +6 -2
  50. data/lib/active_merchant/billing/gateways/exact.rb +6 -2
  51. data/lib/active_merchant/billing/gateways/fat_zebra.rb +31 -3
  52. data/lib/active_merchant/billing/gateways/federated_canada.rb +6 -2
  53. data/lib/active_merchant/billing/gateways/first_pay/first_pay_common.rb +15 -0
  54. data/lib/active_merchant/billing/gateways/first_pay/first_pay_json.rb +190 -0
  55. data/lib/active_merchant/billing/gateways/first_pay/first_pay_xml.rb +183 -0
  56. data/lib/active_merchant/billing/gateways/first_pay.rb +6 -172
  57. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +6 -2
  58. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +7 -3
  59. data/lib/active_merchant/billing/gateways/flex_charge.rb +347 -0
  60. data/lib/active_merchant/billing/gateways/garanti.rb +4 -2
  61. data/lib/active_merchant/billing/gateways/global_collect.rb +45 -37
  62. data/lib/active_merchant/billing/gateways/hi_pay.rb +286 -0
  63. data/lib/active_merchant/billing/gateways/hps.rb +1 -1
  64. data/lib/active_merchant/billing/gateways/iats_payments.rb +7 -2
  65. data/lib/active_merchant/billing/gateways/inspire.rb +6 -4
  66. data/lib/active_merchant/billing/gateways/instapay.rb +7 -4
  67. data/lib/active_merchant/billing/gateways/ipg.rb +10 -6
  68. data/lib/active_merchant/billing/gateways/iridium.rb +15 -5
  69. data/lib/active_merchant/billing/gateways/itransact.rb +6 -2
  70. data/lib/active_merchant/billing/gateways/iveri.rb +3 -3
  71. data/lib/active_merchant/billing/gateways/ixopay.rb +2 -2
  72. data/lib/active_merchant/billing/gateways/jetpay.rb +4 -2
  73. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +4 -2
  74. data/lib/active_merchant/billing/gateways/kushki.rb +73 -13
  75. data/lib/active_merchant/billing/gateways/linkpoint.rb +6 -2
  76. data/lib/active_merchant/billing/gateways/litle.rb +33 -50
  77. data/lib/active_merchant/billing/gateways/mastercard.rb +4 -4
  78. data/lib/active_merchant/billing/gateways/maxipago.rb +2 -2
  79. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +8 -5
  80. data/lib/active_merchant/billing/gateways/merchant_ware.rb +11 -4
  81. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +11 -4
  82. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +19 -3
  83. data/lib/active_merchant/billing/gateways/mercury.rb +6 -2
  84. data/lib/active_merchant/billing/gateways/metrics_global.rb +8 -6
  85. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +1 -0
  86. data/lib/active_merchant/billing/gateways/migs.rb +6 -2
  87. data/lib/active_merchant/billing/gateways/mit.rb +25 -20
  88. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +18 -10
  89. data/lib/active_merchant/billing/gateways/monei.rb +1 -1
  90. data/lib/active_merchant/billing/gateways/moneris.rb +9 -3
  91. data/lib/active_merchant/billing/gateways/money_movers.rb +6 -2
  92. data/lib/active_merchant/billing/gateways/nab_transact.rb +12 -4
  93. data/lib/active_merchant/billing/gateways/net_registry.rb +6 -2
  94. data/lib/active_merchant/billing/gateways/netbanx.rb +1 -3
  95. data/lib/active_merchant/billing/gateways/netbilling.rb +6 -2
  96. data/lib/active_merchant/billing/gateways/network_merchants.rb +6 -2
  97. data/lib/active_merchant/billing/gateways/nmi.rb +23 -6
  98. data/lib/active_merchant/billing/gateways/ogone.rb +6 -2
  99. data/lib/active_merchant/billing/gateways/openpay.rb +4 -2
  100. data/lib/active_merchant/billing/gateways/opp.rb +1 -2
  101. data/lib/active_merchant/billing/gateways/optimal_payment.rb +6 -2
  102. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +1 -3
  103. data/lib/active_merchant/billing/gateways/orbital.rb +83 -24
  104. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +7 -4
  105. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +6 -2
  106. data/lib/active_merchant/billing/gateways/pay_hub.rb +4 -2
  107. data/lib/active_merchant/billing/gateways/pay_junction.rb +6 -2
  108. data/lib/active_merchant/billing/gateways/pay_secure.rb +6 -2
  109. data/lib/active_merchant/billing/gateways/pay_trace.rb +31 -18
  110. data/lib/active_merchant/billing/gateways/payeezy.rb +19 -8
  111. data/lib/active_merchant/billing/gateways/payex.rb +4 -2
  112. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -1
  113. data/lib/active_merchant/billing/gateways/payflow.rb +1 -3
  114. data/lib/active_merchant/billing/gateways/payment_express.rb +8 -4
  115. data/lib/active_merchant/billing/gateways/paymentez.rb +23 -11
  116. data/lib/active_merchant/billing/gateways/paysafe.rb +12 -11
  117. data/lib/active_merchant/billing/gateways/payscout.rb +7 -4
  118. data/lib/active_merchant/billing/gateways/paystation.rb +7 -3
  119. data/lib/active_merchant/billing/gateways/payway.rb +6 -2
  120. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +3 -3
  121. data/lib/active_merchant/billing/gateways/pin.rb +22 -4
  122. data/lib/active_merchant/billing/gateways/plexo.rb +49 -10
  123. data/lib/active_merchant/billing/gateways/plugnpay.rb +6 -2
  124. data/lib/active_merchant/billing/gateways/priority.rb +6 -5
  125. data/lib/active_merchant/billing/gateways/psigate.rb +6 -2
  126. data/lib/active_merchant/billing/gateways/psl_card.rb +6 -2
  127. data/lib/active_merchant/billing/gateways/qbms.rb +6 -2
  128. data/lib/active_merchant/billing/gateways/quantum.rb +6 -2
  129. data/lib/active_merchant/billing/gateways/quickbooks.rb +6 -5
  130. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +7 -4
  131. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +6 -2
  132. data/lib/active_merchant/billing/gateways/rapyd.rb +148 -46
  133. data/lib/active_merchant/billing/gateways/reach.rb +11 -4
  134. data/lib/active_merchant/billing/gateways/redsys.rb +2 -10
  135. data/lib/active_merchant/billing/gateways/redsys_rest.rb +507 -0
  136. data/lib/active_merchant/billing/gateways/s5.rb +3 -3
  137. data/lib/active_merchant/billing/gateways/safe_charge.rb +38 -17
  138. data/lib/active_merchant/billing/gateways/sage.rb +12 -4
  139. data/lib/active_merchant/billing/gateways/sage_pay.rb +79 -5
  140. data/lib/active_merchant/billing/gateways/sallie_mae.rb +6 -2
  141. data/lib/active_merchant/billing/gateways/secure_net.rb +6 -2
  142. data/lib/active_merchant/billing/gateways/secure_pay.rb +8 -6
  143. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +12 -4
  144. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +6 -2
  145. data/lib/active_merchant/billing/gateways/securion_pay.rb +24 -10
  146. data/lib/active_merchant/billing/gateways/shift4.rb +17 -20
  147. data/lib/active_merchant/billing/gateways/shift4_v2.rb +117 -0
  148. data/lib/active_merchant/billing/gateways/simetrik.rb +17 -11
  149. data/lib/active_merchant/billing/gateways/skip_jack.rb +6 -2
  150. data/lib/active_merchant/billing/gateways/smart_ps.rb +7 -4
  151. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +4 -2
  152. data/lib/active_merchant/billing/gateways/spreedly_core.rb +2 -4
  153. data/lib/active_merchant/billing/gateways/stripe.rb +63 -19
  154. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +280 -88
  155. data/lib/active_merchant/billing/gateways/sum_up.rb +223 -0
  156. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +4 -2
  157. data/lib/active_merchant/billing/gateways/telr.rb +3 -4
  158. data/lib/active_merchant/billing/gateways/trans_first.rb +1 -2
  159. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +8 -16
  160. data/lib/active_merchant/billing/gateways/transact_pro.rb +1 -1
  161. data/lib/active_merchant/billing/gateways/trust_commerce.rb +6 -2
  162. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +9 -8
  163. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +6 -2
  164. data/lib/active_merchant/billing/gateways/vanco.rb +2 -4
  165. data/lib/active_merchant/billing/gateways/vantiv_express.rb +587 -0
  166. data/lib/active_merchant/billing/gateways/verifi.rb +6 -2
  167. data/lib/active_merchant/billing/gateways/viaklix.rb +6 -2
  168. data/lib/active_merchant/billing/gateways/visanet_peru.rb +2 -2
  169. data/lib/active_merchant/billing/gateways/vpos.rb +4 -4
  170. data/lib/active_merchant/billing/gateways/wirecard.rb +7 -3
  171. data/lib/active_merchant/billing/gateways/wompi.rb +5 -0
  172. data/lib/active_merchant/billing/gateways/worldpay.rb +141 -93
  173. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +13 -10
  174. data/lib/active_merchant/billing/gateways/xpay.rb +242 -0
  175. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +1 -1
  176. data/lib/active_merchant/billing/response.rb +2 -2
  177. data/lib/active_merchant/connection.rb +3 -17
  178. data/lib/active_merchant/country.rb +1 -0
  179. data/lib/active_merchant/errors.rb +10 -0
  180. data/lib/active_merchant/version.rb +1 -1
  181. data/lib/support/gateway_support.rb +2 -2
  182. data/lib/support/ssl_verify.rb +4 -4
  183. data/lib/support/ssl_version.rb +6 -6
  184. metadata +30 -9
@@ -30,7 +30,7 @@ module ActiveMerchant #:nodoc:
30
30
  class OrbitalGateway < Gateway
31
31
  include Empty
32
32
 
33
- API_VERSION = '9.0'
33
+ API_VERSION = '9.5'
34
34
 
35
35
  POST_HEADERS = {
36
36
  'MIME-Version' => '1.1',
@@ -193,6 +193,10 @@ module ActiveMerchant #:nodoc:
193
193
  'checking' => 'C'
194
194
  }
195
195
 
196
+ # safetech token flags
197
+ GET_TOKEN = 'GT'
198
+ USE_TOKEN = 'UT'
199
+
196
200
  def initialize(options = {})
197
201
  requires!(options, :merchant_id)
198
202
  requires!(options, :login, :password) unless options[:ip_authentication]
@@ -253,6 +257,11 @@ module ActiveMerchant #:nodoc:
253
257
  commit(order, :refund, options[:retry_logic], options[:trace_number])
254
258
  end
255
259
 
260
+ # Orbital save a payment method if the TokenTxnType is 'GT', that's why we use this as the default value for store
261
+ def store(creditcard, options = {})
262
+ authorize(0, creditcard, options.merge({ token_txn_type: GET_TOKEN }))
263
+ end
264
+
256
265
  def void(authorization, options = {}, deprecated = {})
257
266
  if !options.kind_of?(Hash)
258
267
  ActiveMerchant.deprecated('Calling the void method with an amount parameter is deprecated and will be removed in a future version.')
@@ -487,6 +496,35 @@ module ActiveMerchant #:nodoc:
487
496
  end
488
497
  end
489
498
 
499
+ def add_level2_card_and_more_tax(xml, options = {})
500
+ if (level2 = options[:level_2_data])
501
+ xml.tag! :PCardRequestorName, byte_limit(level2[:requestor_name], 38) if level2[:requestor_name]
502
+ xml.tag! :PCardLocalTaxRate, byte_limit(level2[:local_tax_rate], 5) if level2[:local_tax_rate]
503
+ # Canadian Merchants Only
504
+ xml.tag! :PCardNationalTax, byte_limit(level2[:national_tax], 12) if level2[:national_tax]
505
+ xml.tag! :PCardPstTaxRegNumber, byte_limit(level2[:pst_tax_reg_number], 15) if level2[:pst_tax_reg_number]
506
+ xml.tag! :PCardCustomerVatRegNumber, byte_limit(level2[:customer_vat_reg_number], 13) if level2[:customer_vat_reg_number]
507
+ # Canadian Merchants Only
508
+ xml.tag! :PCardMerchantVatRegNumber, byte_limit(level2[:merchant_vat_reg_number], 20) if level2[:merchant_vat_reg_number]
509
+ xml.tag! :PCardTotalTaxAmount, byte_limit(level2[:total_tax_amount], 12) if level2[:total_tax_amount]
510
+ end
511
+ end
512
+
513
+ def add_card_commodity_code(xml, options = {})
514
+ if (level2 = options[:level_2_data]) && (level2[:commodity_code])
515
+ xml.tag! :PCardCommodityCode, byte_limit(level2[:commodity_code], 4)
516
+ end
517
+ end
518
+
519
+ def add_level3_vat_fields(xml, options = {})
520
+ if (level3 = options[:level_3_data])
521
+ xml.tag! :PC3InvoiceDiscTreatment, byte_limit(level3[:invoice_discount_treatment], 1) if level3[:invoice_discount_treatment]
522
+ xml.tag! :PC3TaxTreatment, byte_limit(level3[:tax_treatment], 1) if level3[:tax_treatment]
523
+ xml.tag! :PC3UniqueVATInvoiceRefNum, byte_limit(level3[:unique_vat_invoice_ref], 15) if level3[:unique_vat_invoice_ref]
524
+ xml.tag! :PC3ShipVATRate, byte_limit(level3[:ship_vat_rate], 4) if level3[:ship_vat_rate]
525
+ end
526
+ end
527
+
490
528
  #=====ADDRESS FIELDS=====
491
529
 
492
530
  def add_address(xml, payment_source, options)
@@ -536,9 +574,9 @@ module ActiveMerchant #:nodoc:
536
574
  end
537
575
 
538
576
  def billing_name(payment_source, options)
539
- if payment_source&.name.present?
577
+ if !payment_source.is_a?(String) && payment_source&.name.present?
540
578
  payment_source.name[0..29]
541
- elsif options[:billing_address][:name].present?
579
+ elsif options[:billing_address] && options[:billing_address][:name].present?
542
580
  options[:billing_address][:name][0..29]
543
581
  end
544
582
  end
@@ -555,10 +593,17 @@ module ActiveMerchant #:nodoc:
555
593
  options[:billing_address] || options[:address]
556
594
  end
557
595
 
596
+ def add_safetech_token_data(xml, payment_source, options)
597
+ payment_source_token = split_authorization(payment_source).values_at(2).first
598
+ xml.tag! :CardBrand, options[:card_brand]
599
+ xml.tag! :AccountNum, payment_source_token
600
+ end
601
+
558
602
  #=====PAYMENT SOURCE FIELDS=====
559
603
 
560
604
  # Payment can be done through either Credit Card or Electronic Check
561
605
  def add_payment_source(xml, payment_source, options = {})
606
+ add_safetech_token_data(xml, payment_source, options) if payment_source.is_a?(String)
562
607
  payment_source.is_a?(Check) ? add_echeck(xml, payment_source, options) : add_credit_card(xml, payment_source, options)
563
608
  end
564
609
 
@@ -576,10 +621,10 @@ module ActiveMerchant #:nodoc:
576
621
  end
577
622
 
578
623
  def add_credit_card(xml, credit_card, options)
579
- xml.tag! :AccountNum, credit_card.number if credit_card
580
- xml.tag! :Exp, expiry_date(credit_card) if credit_card
624
+ xml.tag! :AccountNum, credit_card.number if credit_card.is_a?(CreditCard)
625
+ xml.tag! :Exp, expiry_date(credit_card) if credit_card.is_a?(CreditCard)
581
626
  add_currency_fields(xml, options[:currency])
582
- add_verification_value(xml, credit_card) if credit_card
627
+ add_verification_value(xml, credit_card) if credit_card.is_a?(CreditCard)
583
628
  end
584
629
 
585
630
  def add_verification_value(xml, credit_card)
@@ -679,7 +724,7 @@ module ActiveMerchant #:nodoc:
679
724
  add_mc_sca_recurring(xml, credit_card, parameters, three_d_secure)
680
725
  add_mc_program_protocol(xml, credit_card, three_d_secure)
681
726
  add_mc_directory_trans_id(xml, credit_card, three_d_secure)
682
- add_mc_ucafind(xml, credit_card, three_d_secure)
727
+ add_mc_ucafind(xml, credit_card, three_d_secure, parameters)
683
728
  end
684
729
 
685
730
  def add_mc_sca_merchant_initiated(xml, credit_card, parameters, three_d_secure)
@@ -708,10 +753,16 @@ module ActiveMerchant #:nodoc:
708
753
  xml.tag!(:MCDirectoryTransID, three_d_secure[:ds_transaction_id]) if three_d_secure[:ds_transaction_id]
709
754
  end
710
755
 
711
- def add_mc_ucafind(xml, credit_card, three_d_secure)
756
+ def add_mc_ucafind(xml, credit_card, three_d_secure, options)
712
757
  return unless three_d_secure
713
758
 
714
- xml.tag! :UCAFInd, '4'
759
+ if options[:alternate_ucaf_flow]
760
+ return unless %w(4 6 7).include?(three_d_secure[:eci])
761
+
762
+ xml.tag! :UCAFInd, options[:ucaf_collection_indicator] if options[:ucaf_collection_indicator]
763
+ else
764
+ xml.tag! :UCAFInd, options[:ucaf_collection_indicator] || '4'
765
+ end
715
766
  end
716
767
 
717
768
  #=====SCA (STORED CREDENTIAL) FIELDS=====
@@ -886,13 +937,19 @@ module ActiveMerchant #:nodoc:
886
937
  request.call(remote_url(:secondary))
887
938
  end
888
939
 
889
- Response.new(success?(response, message_type), message_from(response), response,
940
+ authorization = authorization_string(response[:tx_ref_num], response[:order_id], response[:safetech_token], response[:card_brand])
941
+
942
+ Response.new(
943
+ success?(response, message_type),
944
+ message_from(response),
945
+ response,
890
946
  {
891
- authorization: authorization_string(response[:tx_ref_num], response[:order_id]),
947
+ authorization: authorization,
892
948
  test: self.test?,
893
949
  avs_result: OrbitalGateway::AVSResult.new(response[:avs_resp_code]),
894
950
  cvv_result: OrbitalGateway::CVVResult.new(response[:cvv2_resp_code])
895
- })
951
+ }
952
+ )
896
953
  end
897
954
 
898
955
  def remote_url(url = :primary)
@@ -981,35 +1038,34 @@ module ActiveMerchant #:nodoc:
981
1038
  xml.tag! :OrderID, format_order_id(parameters[:order_id])
982
1039
  xml.tag! :Amount, amount(money)
983
1040
  xml.tag! :Comments, parameters[:comments] if parameters[:comments]
984
-
985
1041
  add_level2_tax(xml, parameters)
986
1042
  add_level2_advice_addendum(xml, parameters)
987
-
988
1043
  add_aav(xml, payment_source, three_d_secure)
989
1044
  # CustomerAni, AVSPhoneType and AVSDestPhoneType could be added here.
990
-
991
1045
  add_soft_descriptors(xml, parameters[:soft_descriptors])
992
- add_payment_action_ind(xml, parameters[:payment_action_ind])
993
- add_dpanind(xml, payment_source, parameters[:industry_type])
994
- add_aevv(xml, payment_source, three_d_secure)
995
- add_digital_token_cryptogram(xml, payment_source, three_d_secure)
996
-
997
- xml.tag! :ECPSameDayInd, parameters[:same_day] if parameters[:same_day] && payment_source.is_a?(Check)
998
-
999
1046
  set_recurring_ind(xml, parameters)
1000
1047
 
1001
1048
  # Append Transaction Reference Number at the end for Refund transactions
1002
1049
  add_tx_ref_num(xml, parameters[:authorization]) if action == REFUND && payment_source.nil?
1003
-
1004
1050
  add_level2_purchase(xml, parameters)
1005
1051
  add_level3_purchase(xml, parameters)
1006
1052
  add_level3_tax(xml, parameters)
1007
1053
  add_line_items(xml, parameters) if parameters[:line_items]
1008
- add_ecp_details(xml, payment_source, parameters) if payment_source.is_a?(Check)
1009
1054
  add_card_indicators(xml, parameters)
1055
+ add_payment_action_ind(xml, parameters[:payment_action_ind])
1056
+ add_dpanind(xml, payment_source, parameters[:industry_type])
1057
+ add_aevv(xml, payment_source, three_d_secure)
1058
+ add_level2_card_and_more_tax(xml, parameters)
1059
+ add_digital_token_cryptogram(xml, payment_source, three_d_secure)
1060
+ xml.tag! :ECPSameDayInd, parameters[:same_day] if parameters[:same_day] && payment_source.is_a?(Check)
1061
+ add_ecp_details(xml, payment_source, parameters) if payment_source.is_a?(Check)
1062
+
1010
1063
  add_stored_credentials(xml, parameters)
1011
1064
  add_pymt_brand_program_code(xml, payment_source, three_d_secure)
1065
+ xml.tag! :TokenTxnType, parameters[:token_txn_type] if parameters[:token_txn_type]
1012
1066
  add_mastercard_fields(xml, payment_source, parameters, three_d_secure) if mastercard?(payment_source)
1067
+ add_card_commodity_code(xml, parameters)
1068
+ add_level3_vat_fields(xml, parameters)
1013
1069
  end
1014
1070
  end
1015
1071
  xml.target!
@@ -1031,6 +1087,9 @@ module ActiveMerchant #:nodoc:
1031
1087
  add_level3_purchase(xml, parameters)
1032
1088
  add_level3_tax(xml, parameters)
1033
1089
  add_line_items(xml, parameters) if parameters[:line_items]
1090
+ add_level2_card_and_more_tax(xml, parameters)
1091
+ add_card_commodity_code(xml, parameters)
1092
+ add_level3_vat_fields(xml, parameters)
1034
1093
  end
1035
1094
  end
1036
1095
  xml.target!
@@ -121,7 +121,10 @@ module ActiveMerchant #:nodoc:
121
121
 
122
122
  test_mode = test? || message =~ /TESTMODE/
123
123
 
124
- Response.new(success?(response), message, response,
124
+ Response.new(
125
+ success?(response),
126
+ message,
127
+ response,
125
128
  test: test_mode,
126
129
  authorization: response['TrackingNumber'],
127
130
  fraud_review: fraud_review?(response),
@@ -129,7 +132,8 @@ module ActiveMerchant #:nodoc:
129
132
  postal_match: AVS_POSTAL_CODES[response['AVSPostalResponseCode']],
130
133
  street_match: AVS_ADDRESS_CODES[response['AVSAddressResponseCode']]
131
134
  },
132
- cvv_result: CVV2_CODES[response['CVV2ResponseCode']])
135
+ cvv_result: CVV2_CODES[response['CVV2ResponseCode']]
136
+ )
133
137
  end
134
138
 
135
139
  def url(action)
@@ -178,8 +182,7 @@ module ActiveMerchant #:nodoc:
178
182
  post['RequestID'] = request_id
179
183
  post['Signature'] = signature(action, post, parameters)
180
184
 
181
- request = post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
182
- request
185
+ post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
183
186
  end
184
187
 
185
188
  def timestamp
@@ -264,9 +264,13 @@ module ActiveMerchant #:nodoc:
264
264
 
265
265
  def commit(action, request, authorization = nil)
266
266
  response = parse(action, ssl_post(self.live_url, request))
267
- Response.new(successful?(response), message_from(response), response,
267
+ Response.new(
268
+ successful?(response),
269
+ message_from(response),
270
+ response,
268
271
  test: test?,
269
- authorization: authorization || response[:tid])
272
+ authorization: authorization || response[:tid]
273
+ )
270
274
  end
271
275
 
272
276
  def message_from(response)
@@ -182,14 +182,16 @@ module ActiveMerchant #:nodoc:
182
182
  response = json_error(raw_response)
183
183
  end
184
184
 
185
- Response.new(success,
185
+ Response.new(
186
+ success,
186
187
  response_message(response),
187
188
  response,
188
189
  test: test?,
189
190
  avs_result: { code: response['AVS_RESULT_CODE'] },
190
191
  cvv_result: response['VERIFICATION_RESULT_CODE'],
191
192
  error_code: (success ? nil : STANDARD_ERROR_CODE_MAPPING[response['RESPONSE_CODE']]),
192
- authorization: response['TRANSACTION_ID'])
193
+ authorization: response['TRANSACTION_ID']
194
+ )
193
195
  end
194
196
 
195
197
  def response_error(raw_response)
@@ -337,9 +337,13 @@ module ActiveMerchant #:nodoc:
337
337
 
338
338
  response = parse(ssl_post(url, post_data(action, parameters)))
339
339
 
340
- Response.new(successful?(response), message_from(response), response,
340
+ Response.new(
341
+ successful?(response),
342
+ message_from(response),
343
+ response,
341
344
  test: test?,
342
- authorization: response[:transaction_id] || parameters[:transaction_id])
345
+ authorization: response[:transaction_id] || parameters[:transaction_id]
346
+ )
343
347
  end
344
348
 
345
349
  def successful?(response)
@@ -68,9 +68,13 @@ module ActiveMerchant #:nodoc:
68
68
  def commit(action, money, parameters)
69
69
  response = parse(ssl_post(self.live_url, post_data(action, parameters)))
70
70
 
71
- Response.new(successful?(response), message_from(response), response,
71
+ Response.new(
72
+ successful?(response),
73
+ message_from(response),
74
+ response,
72
75
  test: test_response?(response),
73
- authorization: authorization_from(response))
76
+ authorization: authorization_from(response)
77
+ )
74
78
  end
75
79
 
76
80
  def successful?(response)
@@ -1,7 +1,7 @@
1
1
  module ActiveMerchant #:nodoc:
2
2
  module Billing #:nodoc:
3
3
  class PayTraceGateway < Gateway
4
- self.test_url = 'https://api.paytrace.com'
4
+ self.test_url = 'https://api.sandbox.paytrace.com'
5
5
  self.live_url = 'https://api.paytrace.com'
6
6
 
7
7
  self.supported_countries = ['US']
@@ -46,7 +46,7 @@ module ActiveMerchant #:nodoc:
46
46
  def initialize(options = {})
47
47
  requires!(options, :username, :password, :integrator_id)
48
48
  super
49
- acquire_access_token
49
+ acquire_access_token unless options[:access_token]
50
50
  end
51
51
 
52
52
  def purchase(money, payment_or_customer_id, options = {})
@@ -169,28 +169,35 @@ module ActiveMerchant #:nodoc:
169
169
  transcript.
170
170
  gsub(%r((Authorization: Bearer )[a-zA-Z0-9:_]+), '\1[FILTERED]').
171
171
  gsub(%r(("credit_card\\?":{\\?"number\\?":\\?")\d+), '\1[FILTERED]').
172
- gsub(%r(("cvv\\?":\\?")\d+), '\1[FILTERED]').
172
+ gsub(%r(("csc\\?":\\?")\d+), '\1[FILTERED]').
173
173
  gsub(%r(("username\\?":\\?")\w+@+\w+.+\w+), '\1[FILTERED]').
174
+ gsub(%r(("username\\?":\\?")\w+), '\1[FILTERED]').
174
175
  gsub(%r(("password\\?":\\?")\w+), '\1[FILTERED]').
175
176
  gsub(%r(("integrator_id\\?":\\?")\w+), '\1[FILTERED]')
176
177
  end
177
178
 
178
179
  def acquire_access_token
179
180
  post = {}
181
+ base_url = (test? ? test_url : live_url)
180
182
  post[:grant_type] = 'password'
181
183
  post[:username] = @options[:username]
182
184
  post[:password] = @options[:password]
183
185
  data = post.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
184
- url = live_url + '/oauth/token'
186
+ url = base_url + '/oauth/token'
185
187
  oauth_headers = {
186
188
  'Accept' => '*/*',
187
189
  'Content-Type' => 'application/x-www-form-urlencoded'
188
190
  }
189
191
  response = ssl_post(url, data, oauth_headers)
190
- json_response = JSON.parse(response)
192
+ json_response = parse(response)
191
193
 
192
- @options[:access_token] = json_response['access_token'] if json_response['access_token']
193
- response
194
+ if json_response.include?('error')
195
+ oauth_response = Response.new(false, json_response['error_description'])
196
+ raise OAuthResponseError.new(oauth_response)
197
+ else
198
+ @options[:access_token] = json_response['access_token'] if json_response['access_token']
199
+ response
200
+ end
194
201
  end
195
202
 
196
203
  private
@@ -237,11 +244,11 @@ module ActiveMerchant #:nodoc:
237
244
  end
238
245
 
239
246
  def customer_id?(payment_or_customer_id)
240
- payment_or_customer_id.class == String
247
+ payment_or_customer_id.instance_of?(String)
241
248
  end
242
249
 
243
250
  def string_literal_to_boolean(value)
244
- return value unless value.class == String
251
+ return value unless value.instance_of?(String)
245
252
 
246
253
  if value.casecmp('true').zero?
247
254
  true
@@ -258,15 +265,16 @@ module ActiveMerchant #:nodoc:
258
265
  end
259
266
 
260
267
  def add_address(post, creditcard, options)
261
- return unless options[:billing_address] || options[:address]
262
-
263
- address = options[:billing_address] || options[:address]
264
268
  post[:billing_address] = {}
269
+
270
+ if (address = options[:billing_address] || options[:address])
271
+ post[:billing_address][:street_address] = address[:address1]
272
+ post[:billing_address][:city] = address[:city]
273
+ post[:billing_address][:state] = address[:state]
274
+ post[:billing_address][:zip] = address[:zip]
275
+ end
276
+
265
277
  post[:billing_address][:name] = creditcard.name
266
- post[:billing_address][:street_address] = address[:address1]
267
- post[:billing_address][:city] = address[:city]
268
- post[:billing_address][:state] = address[:state]
269
- post[:billing_address][:zip] = address[:zip]
270
278
  end
271
279
 
272
280
  def add_amount(post, money, options)
@@ -283,6 +291,7 @@ module ActiveMerchant #:nodoc:
283
291
  post[:credit_card][:number] = payment.number
284
292
  post[:credit_card][:expiration_month] = payment.month
285
293
  post[:credit_card][:expiration_year] = payment.year
294
+ post[:csc] = payment.verification_value
286
295
  end
287
296
  end
288
297
 
@@ -373,6 +382,12 @@ module ActiveMerchant #:nodoc:
373
382
  url = base_url + '/v1/' + action
374
383
  raw_response = ssl_post(url, post_data(parameters), headers)
375
384
  response = parse(raw_response)
385
+ handle_final_response(action, response)
386
+ rescue JSON::ParserError
387
+ unparsable_response(raw_response)
388
+ end
389
+
390
+ def handle_final_response(action, response)
376
391
  success = success_from(response)
377
392
 
378
393
  Response.new(
@@ -385,8 +400,6 @@ module ActiveMerchant #:nodoc:
385
400
  test: test?,
386
401
  error_code: success ? nil : error_code_from(response)
387
402
  )
388
- rescue JSON::ParserError
389
- unparsable_response(raw_response)
390
403
  end
391
404
 
392
405
  def unparsable_response(raw_response)
@@ -35,6 +35,8 @@ module ActiveMerchant
35
35
 
36
36
  add_invoice(params, options)
37
37
  add_reversal_id(params, options)
38
+ add_customer_ref(params, options)
39
+ add_reference_3(params, options)
38
40
  add_payment_method(params, payment_method, options)
39
41
  add_address(params, options)
40
42
  add_amount(params, amount, options)
@@ -51,6 +53,8 @@ module ActiveMerchant
51
53
 
52
54
  add_invoice(params, options)
53
55
  add_reversal_id(params, options)
56
+ add_customer_ref(params, options)
57
+ add_reference_3(params, options)
54
58
  add_payment_method(params, payment_method, options)
55
59
  add_address(params, options)
56
60
  add_amount(params, amount, options)
@@ -170,6 +174,14 @@ module ActiveMerchant
170
174
  params[:reversal_id] = options[:reversal_id] if options[:reversal_id]
171
175
  end
172
176
 
177
+ def add_customer_ref(params, options)
178
+ params[:customer_ref] = options[:customer_ref] if options[:customer_ref]
179
+ end
180
+
181
+ def add_reference_3(params, options)
182
+ params[:reference_3] = options[:reference_3] if options[:reference_3]
183
+ end
184
+
173
185
  def amount_from_authorization(authorization)
174
186
  authorization.split('|').last.to_i
175
187
  end
@@ -192,7 +204,7 @@ module ActiveMerchant
192
204
  params[:apikey] = @options[:apikey]
193
205
  params[:ta_token] = options[:ta_token]
194
206
  params[:type] = 'FDToken'
195
- params[:credit_card] = add_card_data(payment_method)
207
+ params[:credit_card] = add_card_data(payment_method, options)
196
208
  params[:auth] = 'false'
197
209
  end
198
210
 
@@ -208,7 +220,7 @@ module ActiveMerchant
208
220
  elsif payment_method.is_a? NetworkTokenizationCreditCard
209
221
  add_network_tokenization(params, payment_method, options)
210
222
  else
211
- add_creditcard(params, payment_method)
223
+ add_creditcard(params, payment_method, options)
212
224
  end
213
225
  end
214
226
 
@@ -245,17 +257,17 @@ module ActiveMerchant
245
257
  params[:token] = token
246
258
  end
247
259
 
248
- def add_creditcard(params, creditcard)
249
- credit_card = add_card_data(creditcard)
260
+ def add_creditcard(params, creditcard, options)
261
+ credit_card = add_card_data(creditcard, options)
250
262
 
251
263
  params[:method] = 'credit_card'
252
264
  params[:credit_card] = credit_card
253
265
  end
254
266
 
255
- def add_card_data(payment_method)
267
+ def add_card_data(payment_method, options = {})
256
268
  card = {}
257
269
  card[:type] = CREDIT_CARD_BRAND[payment_method.brand]
258
- card[:cardholder_name] = payment_method.name
270
+ card[:cardholder_name] = name_from_payment_method(payment_method) || name_from_address(options)
259
271
  card[:card_number] = payment_method.number
260
272
  card[:exp_date] = format_exp_date(payment_method.month, payment_method.year)
261
273
  card[:cvv] = payment_method.verification_value if payment_method.verification_value?
@@ -412,8 +424,7 @@ module ActiveMerchant
412
424
  @options[:token],
413
425
  payload
414
426
  ].join('')
415
- hash = Base64.strict_encode64(OpenSSL::HMAC.hexdigest('sha256', @options[:apisecret], message))
416
- hash
427
+ Base64.strict_encode64(OpenSSL::HMAC.hexdigest('sha256', @options[:apisecret], message))
417
428
  end
418
429
 
419
430
  def headers(payload)
@@ -385,11 +385,13 @@ module ActiveMerchant #:nodoc:
385
385
  'Content-Length' => request.size.to_s
386
386
  }
387
387
  response = parse(ssl_post(url, request, headers))
388
- Response.new(success?(response),
388
+ Response.new(
389
+ success?(response),
389
390
  message_from(response),
390
391
  response,
391
392
  test: test?,
392
- authorization: build_authorization(response))
393
+ authorization: build_authorization(response)
394
+ )
393
395
  end
394
396
 
395
397
  def build_authorization(response)
@@ -99,7 +99,7 @@ module ActiveMerchant #:nodoc:
99
99
  end
100
100
  xml.tag! 'RequestAuth' do
101
101
  xml.tag! 'UserPass' do
102
- xml.tag! 'User', !@options[:user].blank? ? @options[:user] : @options[:login]
102
+ xml.tag! 'User', @options[:user].blank? ? @options[:login] : @options[:user]
103
103
  xml.tag! 'Password', @options[:password]
104
104
  end
105
105
  end
@@ -192,9 +192,7 @@ module ActiveMerchant #:nodoc:
192
192
  xml.tag! 'TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money)
193
193
  end
194
194
 
195
- if %i(authorization purchase).include? action
196
- add_mpi_3ds(xml, options[:three_d_secure]) if options[:three_d_secure]
197
- end
195
+ add_mpi_3ds(xml, options[:three_d_secure]) if %i(authorization purchase).include?(action) && (options[:three_d_secure])
198
196
 
199
197
  xml.tag! 'Tender' do
200
198
  add_credit_card(xml, credit_card, options)
@@ -20,8 +20,8 @@ module ActiveMerchant #:nodoc:
20
20
  self.homepage_url = 'https://www.windcave.com/'
21
21
  self.display_name = 'Windcave (formerly PaymentExpress)'
22
22
 
23
- self.live_url = 'https://sec.paymentexpress.com/pxpost.aspx'
24
- self.test_url = 'https://uat.paymentexpress.com/pxpost.aspx'
23
+ self.live_url = 'https://sec.windcave.com/pxpost.aspx'
24
+ self.test_url = 'https://uat.windcave.com/pxpost.aspx'
25
25
 
26
26
  APPROVED = '1'
27
27
 
@@ -306,9 +306,13 @@ module ActiveMerchant #:nodoc:
306
306
  response = parse(ssl_post(url, request.to_s))
307
307
 
308
308
  # Return a response
309
- PaymentExpressResponse.new(response[:success] == APPROVED, message_from(response), response,
309
+ PaymentExpressResponse.new(
310
+ response[:success] == APPROVED,
311
+ message_from(response),
312
+ response,
310
313
  test: response[:test_mode] == '1',
311
- authorization: authorization_from(action, response))
314
+ authorization: authorization_from(action, response)
315
+ )
312
316
  end
313
317
 
314
318
  # Response XML documentation: http://www.paymentexpress.com/technical_resources/ecommerce_nonhosted/pxpost.html#XMLTxnOutput