activemerchant 1.100.0 → 1.133.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (267) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +1057 -0
  3. data/README.md +11 -9
  4. data/lib/active_merchant/billing/avs_result.rb +9 -9
  5. data/lib/active_merchant/billing/base.rb +0 -13
  6. data/lib/active_merchant/billing/check.rb +49 -17
  7. data/lib/active_merchant/billing/compatibility.rb +5 -4
  8. data/lib/active_merchant/billing/credit_card.rb +55 -8
  9. data/lib/active_merchant/billing/credit_card_formatting.rb +1 -0
  10. data/lib/active_merchant/billing/credit_card_methods.rb +209 -36
  11. data/lib/active_merchant/billing/cvv_result.rb +0 -1
  12. data/lib/active_merchant/billing/gateway.rb +38 -36
  13. data/lib/active_merchant/billing/gateways/adyen.rb +399 -78
  14. data/lib/active_merchant/billing/gateways/airwallex.rb +370 -0
  15. data/lib/active_merchant/billing/gateways/alelo.rb +256 -0
  16. data/lib/active_merchant/billing/gateways/allied_wallet.rb +14 -14
  17. data/lib/active_merchant/billing/gateways/authorize_net.rb +200 -130
  18. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +27 -20
  19. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +48 -51
  20. data/lib/active_merchant/billing/gateways/axcessms.rb +13 -15
  21. data/lib/active_merchant/billing/gateways/balanced.rb +43 -36
  22. data/lib/active_merchant/billing/gateways/bambora_apac.rb +16 -20
  23. data/lib/active_merchant/billing/gateways/bank_frick.rb +13 -13
  24. data/lib/active_merchant/billing/gateways/banwire.rb +5 -5
  25. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +43 -30
  26. data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +1 -1
  27. data/lib/active_merchant/billing/gateways/be2bill.rb +5 -5
  28. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +37 -36
  29. data/lib/active_merchant/billing/gateways/beanstream.rb +21 -3
  30. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +1 -1
  31. data/lib/active_merchant/billing/gateways/blue_pay.rb +53 -28
  32. data/lib/active_merchant/billing/gateways/blue_snap.rb +176 -54
  33. data/lib/active_merchant/billing/gateways/bogus.rb +24 -20
  34. data/lib/active_merchant/billing/gateways/borgun.rb +92 -38
  35. data/lib/active_merchant/billing/gateways/bpoint.rb +15 -15
  36. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +8 -2
  37. data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
  38. data/lib/active_merchant/billing/gateways/braintree.rb +1 -1
  39. data/lib/active_merchant/billing/gateways/braintree_blue.rb +387 -175
  40. data/lib/active_merchant/billing/gateways/bridge_pay.rb +13 -13
  41. data/lib/active_merchant/billing/gateways/cams.rb +10 -10
  42. data/lib/active_merchant/billing/gateways/card_connect.rb +33 -14
  43. data/lib/active_merchant/billing/gateways/card_save.rb +3 -4
  44. data/lib/active_merchant/billing/gateways/card_stream.rb +67 -40
  45. data/lib/active_merchant/billing/gateways/cardknox.rb +13 -13
  46. data/lib/active_merchant/billing/gateways/cardprocess.rb +4 -2
  47. data/lib/active_merchant/billing/gateways/cashnet.rb +28 -12
  48. data/lib/active_merchant/billing/gateways/cc5.rb +9 -9
  49. data/lib/active_merchant/billing/gateways/cecabank.rb +38 -38
  50. data/lib/active_merchant/billing/gateways/cenpos.rb +29 -28
  51. data/lib/active_merchant/billing/gateways/checkout.rb +7 -9
  52. data/lib/active_merchant/billing/gateways/checkout_v2.rb +316 -68
  53. data/lib/active_merchant/billing/gateways/citrus_pay.rb +1 -2
  54. data/lib/active_merchant/billing/gateways/clearhaus.rb +32 -33
  55. data/lib/active_merchant/billing/gateways/commerce_hub.rb +370 -0
  56. data/lib/active_merchant/billing/gateways/commercegate.rb +4 -4
  57. data/lib/active_merchant/billing/gateways/conekta.rb +8 -6
  58. data/lib/active_merchant/billing/gateways/creditcall.rb +18 -17
  59. data/lib/active_merchant/billing/gateways/credorax.rb +152 -63
  60. data/lib/active_merchant/billing/gateways/ct_payment.rb +15 -14
  61. data/lib/active_merchant/billing/gateways/culqi.rb +30 -28
  62. data/lib/active_merchant/billing/gateways/cyber_source/cyber_source_common.rb +36 -0
  63. data/lib/active_merchant/billing/gateways/cyber_source.rb +496 -187
  64. data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +454 -0
  65. data/lib/active_merchant/billing/gateways/d_local.rb +148 -31
  66. data/lib/active_merchant/billing/gateways/data_cash.rb +34 -37
  67. data/lib/active_merchant/billing/gateways/decidir.rb +134 -21
  68. data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
  69. data/lib/active_merchant/billing/gateways/dibs.rb +10 -10
  70. data/lib/active_merchant/billing/gateways/digitzs.rb +11 -8
  71. data/lib/active_merchant/billing/gateways/ebanx.rb +90 -40
  72. data/lib/active_merchant/billing/gateways/efsnet.rb +36 -36
  73. data/lib/active_merchant/billing/gateways/elavon.rb +349 -194
  74. data/lib/active_merchant/billing/gateways/element.rb +71 -21
  75. data/lib/active_merchant/billing/gateways/epay.rb +43 -43
  76. data/lib/active_merchant/billing/gateways/evo_ca.rb +12 -13
  77. data/lib/active_merchant/billing/gateways/eway.rb +9 -9
  78. data/lib/active_merchant/billing/gateways/eway_managed.rb +55 -56
  79. data/lib/active_merchant/billing/gateways/eway_rapid.rb +37 -22
  80. data/lib/active_merchant/billing/gateways/exact.rb +19 -20
  81. data/lib/active_merchant/billing/gateways/ezic.rb +9 -9
  82. data/lib/active_merchant/billing/gateways/fat_zebra.rb +24 -19
  83. data/lib/active_merchant/billing/gateways/federated_canada.rb +6 -7
  84. data/lib/active_merchant/billing/gateways/finansbank.rb +3 -3
  85. data/lib/active_merchant/billing/gateways/first_giving.rb +5 -4
  86. data/lib/active_merchant/billing/gateways/first_pay.rb +7 -7
  87. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +39 -38
  88. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +51 -31
  89. data/lib/active_merchant/billing/gateways/flo2cash.rb +24 -24
  90. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +1 -1
  91. data/lib/active_merchant/billing/gateways/forte.rb +38 -22
  92. data/lib/active_merchant/billing/gateways/garanti.rb +12 -15
  93. data/lib/active_merchant/billing/gateways/global_collect.rb +333 -89
  94. data/lib/active_merchant/billing/gateways/global_transport.rb +8 -9
  95. data/lib/active_merchant/billing/gateways/hdfc.rb +22 -23
  96. data/lib/active_merchant/billing/gateways/hps.rb +171 -50
  97. data/lib/active_merchant/billing/gateways/iats_payments.rb +47 -25
  98. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +1 -1
  99. data/lib/active_merchant/billing/gateways/inspire.rb +22 -27
  100. data/lib/active_merchant/billing/gateways/instapay.rb +5 -8
  101. data/lib/active_merchant/billing/gateways/ipg.rb +420 -0
  102. data/lib/active_merchant/billing/gateways/ipp.rb +9 -9
  103. data/lib/active_merchant/billing/gateways/iridium.rb +30 -31
  104. data/lib/active_merchant/billing/gateways/itransact.rb +11 -10
  105. data/lib/active_merchant/billing/gateways/iveri.rb +62 -23
  106. data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
  107. data/lib/active_merchant/billing/gateways/jetpay.rb +10 -17
  108. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +13 -18
  109. data/lib/active_merchant/billing/gateways/komoju.rb +1 -1
  110. data/lib/active_merchant/billing/gateways/kushki.rb +100 -22
  111. data/lib/active_merchant/billing/gateways/latitude19.rb +20 -19
  112. data/lib/active_merchant/billing/gateways/linkpoint.rb +71 -72
  113. data/lib/active_merchant/billing/gateways/litle.rb +181 -45
  114. data/lib/active_merchant/billing/gateways/mastercard.rb +16 -22
  115. data/lib/active_merchant/billing/gateways/maxipago.rb +2 -2
  116. data/lib/active_merchant/billing/gateways/mercado_pago.rb +89 -18
  117. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +58 -24
  118. data/lib/active_merchant/billing/gateways/merchant_one.rb +7 -10
  119. data/lib/active_merchant/billing/gateways/merchant_partners.rb +19 -19
  120. data/lib/active_merchant/billing/gateways/merchant_ware.rb +18 -22
  121. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +15 -17
  122. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +46 -8
  123. data/lib/active_merchant/billing/gateways/mercury.rb +19 -23
  124. data/lib/active_merchant/billing/gateways/metrics_global.rb +24 -33
  125. data/lib/active_merchant/billing/gateways/micropayment.rb +11 -12
  126. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +7 -7
  127. data/lib/active_merchant/billing/gateways/migs.rb +18 -21
  128. data/lib/active_merchant/billing/gateways/mit.rb +260 -0
  129. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +10 -12
  130. data/lib/active_merchant/billing/gateways/moka.rb +290 -0
  131. data/lib/active_merchant/billing/gateways/monei.rb +236 -150
  132. data/lib/active_merchant/billing/gateways/moneris.rb +122 -53
  133. data/lib/active_merchant/billing/gateways/money_movers.rb +6 -7
  134. data/lib/active_merchant/billing/gateways/mundipagg.rb +69 -23
  135. data/lib/active_merchant/billing/gateways/nab_transact.rb +18 -20
  136. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +10 -12
  137. data/lib/active_merchant/billing/gateways/net_registry.rb +8 -9
  138. data/lib/active_merchant/billing/gateways/netaxept.rb +12 -12
  139. data/lib/active_merchant/billing/gateways/netbanx.rb +128 -46
  140. data/lib/active_merchant/billing/gateways/netbilling.rb +18 -21
  141. data/lib/active_merchant/billing/gateways/netpay.rb +5 -4
  142. data/lib/active_merchant/billing/gateways/network_merchants.rb +7 -10
  143. data/lib/active_merchant/billing/gateways/nmi.rb +69 -27
  144. data/lib/active_merchant/billing/gateways/ogone.rb +62 -31
  145. data/lib/active_merchant/billing/gateways/omise.rb +15 -16
  146. data/lib/active_merchant/billing/gateways/openpay.rb +33 -15
  147. data/lib/active_merchant/billing/gateways/opp.rb +39 -33
  148. data/lib/active_merchant/billing/gateways/optimal_payment.rb +43 -42
  149. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +3 -5
  150. data/lib/active_merchant/billing/gateways/orbital.rb +623 -362
  151. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +20 -20
  152. data/lib/active_merchant/billing/gateways/pagarme.rb +16 -23
  153. data/lib/active_merchant/billing/gateways/pago_facil.rb +4 -6
  154. data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
  155. data/lib/active_merchant/billing/gateways/pay_conex.rb +17 -17
  156. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +30 -33
  157. data/lib/active_merchant/billing/gateways/pay_hub.rb +10 -10
  158. data/lib/active_merchant/billing/gateways/pay_junction.rb +31 -31
  159. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +36 -18
  160. data/lib/active_merchant/billing/gateways/pay_secure.rb +10 -11
  161. data/lib/active_merchant/billing/gateways/pay_trace.rb +450 -0
  162. data/lib/active_merchant/billing/gateways/paybox_direct.rb +64 -40
  163. data/lib/active_merchant/billing/gateways/payeezy.rb +130 -27
  164. data/lib/active_merchant/billing/gateways/payex.rb +24 -25
  165. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +17 -17
  166. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +1 -1
  167. data/lib/active_merchant/billing/gateways/payflow.rb +103 -25
  168. data/lib/active_merchant/billing/gateways/payflow_express.rb +4 -4
  169. data/lib/active_merchant/billing/gateways/payflow_uk.rb +1 -1
  170. data/lib/active_merchant/billing/gateways/payment_express.rb +22 -18
  171. data/lib/active_merchant/billing/gateways/paymentez.rb +89 -24
  172. data/lib/active_merchant/billing/gateways/paymill.rb +14 -16
  173. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +2 -1
  174. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +4 -0
  175. data/lib/active_merchant/billing/gateways/paypal.rb +13 -5
  176. data/lib/active_merchant/billing/gateways/paypal_ca.rb +1 -1
  177. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +1 -1
  178. data/lib/active_merchant/billing/gateways/paypal_express.rb +4 -1
  179. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +1 -1
  180. data/lib/active_merchant/billing/gateways/paysafe.rb +420 -0
  181. data/lib/active_merchant/billing/gateways/payscout.rb +8 -9
  182. data/lib/active_merchant/billing/gateways/paystation.rb +6 -9
  183. data/lib/active_merchant/billing/gateways/payu_in.rb +20 -19
  184. data/lib/active_merchant/billing/gateways/payu_latam.rb +70 -37
  185. data/lib/active_merchant/billing/gateways/payway.rb +22 -22
  186. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
  187. data/lib/active_merchant/billing/gateways/pin.rb +60 -21
  188. data/lib/active_merchant/billing/gateways/plexo.rb +308 -0
  189. data/lib/active_merchant/billing/gateways/plugnpay.rb +20 -21
  190. data/lib/active_merchant/billing/gateways/priority.rb +392 -0
  191. data/lib/active_merchant/billing/gateways/pro_pay.rb +13 -14
  192. data/lib/active_merchant/billing/gateways/psigate.rb +29 -29
  193. data/lib/active_merchant/billing/gateways/psl_card.rb +7 -8
  194. data/lib/active_merchant/billing/gateways/qbms.rb +25 -26
  195. data/lib/active_merchant/billing/gateways/quantum.rb +9 -11
  196. data/lib/active_merchant/billing/gateways/quickbooks.rb +126 -39
  197. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +98 -98
  198. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +19 -23
  199. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +3 -3
  200. data/lib/active_merchant/billing/gateways/quickpay.rb +0 -1
  201. data/lib/active_merchant/billing/gateways/qvalent.rb +36 -20
  202. data/lib/active_merchant/billing/gateways/rapyd.rb +319 -0
  203. data/lib/active_merchant/billing/gateways/reach.rb +277 -0
  204. data/lib/active_merchant/billing/gateways/realex.rb +42 -16
  205. data/lib/active_merchant/billing/gateways/redsys.rb +191 -86
  206. data/lib/active_merchant/billing/gateways/s5.rb +10 -9
  207. data/lib/active_merchant/billing/gateways/safe_charge.rb +70 -33
  208. data/lib/active_merchant/billing/gateways/sage.rb +19 -21
  209. data/lib/active_merchant/billing/gateways/sage_pay.rb +57 -57
  210. data/lib/active_merchant/billing/gateways/sallie_mae.rb +3 -4
  211. data/lib/active_merchant/billing/gateways/secure_net.rb +19 -26
  212. data/lib/active_merchant/billing/gateways/secure_pay.rb +24 -33
  213. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +18 -20
  214. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +4 -5
  215. data/lib/active_merchant/billing/gateways/securion_pay.rb +48 -7
  216. data/lib/active_merchant/billing/gateways/shift4.rb +345 -0
  217. data/lib/active_merchant/billing/gateways/simetrik.rb +368 -0
  218. data/lib/active_merchant/billing/gateways/skip_jack.rb +19 -19
  219. data/lib/active_merchant/billing/gateways/smart_ps.rb +26 -32
  220. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +24 -25
  221. data/lib/active_merchant/billing/gateways/spreedly_core.rb +27 -21
  222. data/lib/active_merchant/billing/gateways/stripe.rb +126 -53
  223. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +441 -113
  224. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +7 -8
  225. data/lib/active_merchant/billing/gateways/telr.rb +17 -18
  226. data/lib/active_merchant/billing/gateways/tns.rb +3 -7
  227. data/lib/active_merchant/billing/gateways/trans_first.rb +10 -9
  228. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +28 -24
  229. data/lib/active_merchant/billing/gateways/transact_pro.rb +13 -15
  230. data/lib/active_merchant/billing/gateways/transax.rb +1 -2
  231. data/lib/active_merchant/billing/gateways/trexle.rb +5 -2
  232. data/lib/active_merchant/billing/gateways/trust_commerce.rb +57 -47
  233. data/lib/active_merchant/billing/gateways/usa_epay.rb +1 -2
  234. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +176 -184
  235. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +60 -48
  236. data/lib/active_merchant/billing/gateways/vanco.rb +17 -8
  237. data/lib/active_merchant/billing/gateways/verifi.rb +13 -14
  238. data/lib/active_merchant/billing/gateways/viaklix.rb +9 -14
  239. data/lib/active_merchant/billing/gateways/visanet_peru.rb +26 -21
  240. data/lib/active_merchant/billing/gateways/vpos.rb +223 -0
  241. data/lib/active_merchant/billing/gateways/webpay.rb +4 -4
  242. data/lib/active_merchant/billing/gateways/wepay.rb +14 -16
  243. data/lib/active_merchant/billing/gateways/wirecard.rb +14 -16
  244. data/lib/active_merchant/billing/gateways/wompi.rb +197 -0
  245. data/lib/active_merchant/billing/gateways/world_net.rb +36 -35
  246. data/lib/active_merchant/billing/gateways/worldpay.rb +556 -190
  247. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +47 -54
  248. data/lib/active_merchant/billing/gateways/worldpay_us.rb +16 -16
  249. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +2 -2
  250. data/lib/active_merchant/billing/response.rb +25 -6
  251. data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
  252. data/lib/active_merchant/billing.rb +1 -0
  253. data/lib/active_merchant/connection.rb +14 -15
  254. data/lib/active_merchant/country.rb +3 -1
  255. data/lib/active_merchant/errors.rb +4 -1
  256. data/lib/active_merchant/net_http_ssl_connection.rb +1 -0
  257. data/lib/active_merchant/network_connection_retries.rb +15 -17
  258. data/lib/active_merchant/post_data.rb +3 -2
  259. data/lib/active_merchant/posts_data.rb +2 -2
  260. data/lib/active_merchant/version.rb +1 -1
  261. data/lib/active_merchant.rb +2 -2
  262. data/lib/certs/cacert.pem +1587 -2361
  263. data/lib/support/gateway_support.rb +1 -1
  264. data/lib/support/ssl_verify.rb +3 -7
  265. data/lib/support/ssl_version.rb +2 -3
  266. metadata +86 -34
  267. data/lib/active_merchant/billing/gateways/moneris_us.rb +0 -352
@@ -4,19 +4,20 @@ module ActiveMerchant #:nodoc:
4
4
  self.live_url = 'https://www.usaepay.com/gate'
5
5
  self.test_url = 'https://sandbox.usaepay.com/gate'
6
6
 
7
- self.supported_cardtypes = [:visa, :master, :american_express]
7
+ self.supported_cardtypes = %i[visa master american_express]
8
8
  self.supported_countries = ['US']
9
9
  self.homepage_url = 'http://www.usaepay.com/'
10
10
  self.display_name = 'USA ePay'
11
11
 
12
12
  TRANSACTIONS = {
13
- :authorization => 'cc:authonly',
14
- :purchase => 'cc:sale',
15
- :capture => 'cc:capture',
16
- :refund => 'cc:refund',
17
- :void => 'cc:void',
18
- :void_release => 'cc:void:release',
19
- :check_purchase => 'check:sale'
13
+ authorization: 'cc:authonly',
14
+ purchase: 'cc:sale',
15
+ capture: 'cc:capture',
16
+ refund: 'cc:refund',
17
+ void: 'cc:void',
18
+ void_release: 'cc:void:release',
19
+ check_purchase: 'check:sale',
20
+ store: 'cc:save'
20
21
  }
21
22
 
22
23
  STANDARD_ERROR_CODE_MAPPING = {
@@ -43,14 +44,14 @@ module ActiveMerchant #:nodoc:
43
44
  super
44
45
  end
45
46
 
46
- def authorize(money, credit_card, options = {})
47
+ def authorize(money, payment, options = {})
47
48
  post = {}
48
49
 
49
50
  add_amount(post, money)
50
51
  add_invoice(post, options)
51
- add_payment(post, credit_card)
52
- unless credit_card.track_data.present?
53
- add_address(post, credit_card, options)
52
+ add_payment(post, payment)
53
+ unless payment.is_a?(CreditCard) && payment.track_data.present?
54
+ add_address(post, payment, options)
54
55
  add_customer_data(post, options)
55
56
  end
56
57
  add_split_payments(post, options)
@@ -82,7 +83,7 @@ module ActiveMerchant #:nodoc:
82
83
  end
83
84
 
84
85
  def capture(money, authorization, options = {})
85
- post = { :refNum => authorization }
86
+ post = { refNum: authorization }
86
87
 
87
88
  add_amount(post, money)
88
89
  add_test_mode(post, options)
@@ -90,13 +91,19 @@ module ActiveMerchant #:nodoc:
90
91
  end
91
92
 
92
93
  def refund(money, authorization, options = {})
93
- post = { :refNum => authorization }
94
+ post = { refNum: authorization }
94
95
 
95
96
  add_amount(post, money)
96
97
  add_test_mode(post, options)
97
98
  commit(:refund, post)
98
99
  end
99
100
 
101
+ def store(payment, options = {})
102
+ post = {}
103
+ add_payment(post, payment, options)
104
+ commit(:store, post)
105
+ end
106
+
100
107
  def verify(creditcard, options = {})
101
108
  MultiResponse.run(:use_first_response) do |r|
102
109
  r.process { authorize(1, creditcard, options) }
@@ -107,7 +114,7 @@ module ActiveMerchant #:nodoc:
107
114
  # Pass `no_release: true` to keep the void from immediately settling
108
115
  def void(authorization, options = {})
109
116
  command = (options[:no_release] ? :void : :void_release)
110
- post = { :refNum => authorization }
117
+ post = { refNum: authorization }
111
118
  add_test_mode(post, options)
112
119
  commit(command, post)
113
120
  end
@@ -153,13 +160,9 @@ module ActiveMerchant #:nodoc:
153
160
  end
154
161
  end
155
162
 
156
- if options.has_key? :customer
157
- post[:custid] = options[:customer]
158
- end
163
+ post[:custid] = options[:customer] if options.has_key? :customer
159
164
 
160
- if options.has_key? :ip
161
- post[:ip] = options[:ip]
162
- end
165
+ post[:ip] = options[:ip] if options.has_key? :ip
163
166
  end
164
167
 
165
168
  def add_address(post, payment, options)
@@ -202,12 +205,13 @@ module ActiveMerchant #:nodoc:
202
205
  post[:description] = options[:description]
203
206
  end
204
207
 
205
- def add_payment(post, payment, options={})
208
+ def add_payment(post, payment, options = {})
206
209
  if payment.respond_to?(:routing_number)
207
210
  post[:checkformat] = options[:check_format] if options[:check_format]
208
211
  if payment.account_type
209
212
  account_type = payment.account_type.to_s.capitalize
210
213
  raise ArgumentError, 'account_type must be checking or savings' unless %w(Checking Savings).include?(account_type)
214
+
211
215
  post[:accounttype] = account_type
212
216
  end
213
217
  post[:account] = payment.account_number
@@ -216,6 +220,8 @@ module ActiveMerchant #:nodoc:
216
220
  elsif payment.respond_to?(:track_data) && payment.track_data.present?
217
221
  post[:magstripe] = payment.track_data
218
222
  post[:cardpresent] = true
223
+ elsif payment.is_a?(String)
224
+ post[:card] = payment
219
225
  else
220
226
  post[:card] = payment.number
221
227
  post[:cvv2] = payment.verification_value if payment.verification_value?
@@ -232,6 +238,7 @@ module ActiveMerchant #:nodoc:
232
238
  # see: http://wiki.usaepay.com/developer/transactionapi#split_payments
233
239
  def add_split_payments(post, options)
234
240
  return unless options[:split_payments].is_a?(Array)
241
+
235
242
  options[:split_payments].each_with_index do |payment, index|
236
243
  prefix = '%02d' % (index + 2)
237
244
  post["#{prefix}key"] = payment[:key]
@@ -245,6 +252,7 @@ module ActiveMerchant #:nodoc:
245
252
 
246
253
  def add_recurring_fields(post, options)
247
254
  return unless options[:recurring_fields].is_a?(Hash)
255
+
248
256
  options[:recurring_fields].each do |key, value|
249
257
  if value == true
250
258
  value = 'yes'
@@ -252,9 +260,7 @@ module ActiveMerchant #:nodoc:
252
260
  next
253
261
  end
254
262
 
255
- if key == :bill_amount
256
- value = amount(value)
257
- end
263
+ value = amount(value) if key == :bill_amount
258
264
 
259
265
  post[key.to_s.delete('_')] = value
260
266
  end
@@ -274,6 +280,7 @@ module ActiveMerchant #:nodoc:
274
280
  # see: https://wiki.usaepay.com/developer/transactionapi#line_item_details
275
281
  def add_line_items(post, options)
276
282
  return unless options[:line_items].is_a?(Array)
283
+
277
284
  options[:line_items].each_with_index do |line_item, index|
278
285
  %w(product_ref_num sku qty name description taxable tax_rate tax_amount commodity_code discount_rate discount_amount).each do |key|
279
286
  post["line#{index}#{key.delete('_')}"] = line_item[key.to_sym] if line_item.has_key?(key.to_sym)
@@ -281,7 +288,7 @@ module ActiveMerchant #:nodoc:
281
288
 
282
289
  {
283
290
  quantity: 'qty',
284
- unit: 'um',
291
+ unit: 'um'
285
292
  }.each do |key, umkey|
286
293
  post["line#{index}#{umkey}"] = line_item[key.to_sym] if line_item.has_key?(key.to_sym)
287
294
  end
@@ -298,21 +305,22 @@ module ActiveMerchant #:nodoc:
298
305
  end
299
306
 
300
307
  {
301
- :status => fields['UMstatus'],
302
- :auth_code => fields['UMauthCode'],
303
- :ref_num => fields['UMrefNum'],
304
- :batch => fields['UMbatch'],
305
- :avs_result => fields['UMavsResult'],
306
- :avs_result_code => fields['UMavsResultCode'],
307
- :cvv2_result => fields['UMcvv2Result'],
308
- :cvv2_result_code => fields['UMcvv2ResultCode'],
309
- :vpas_result_code => fields['UMvpasResultCode'],
310
- :result => fields['UMresult'],
311
- :error => fields['UMerror'],
312
- :error_code => fields['UMerrorcode'],
313
- :acs_url => fields['UMacsurl'],
314
- :payload => fields['UMpayload']
315
- }.delete_if { |k, v| v.nil? }
308
+ status: fields['UMstatus'],
309
+ auth_code: fields['UMauthCode'],
310
+ ref_num: fields['UMrefNum'],
311
+ card_ref: fields['UMcardRef'],
312
+ batch: fields['UMbatch'],
313
+ avs_result: fields['UMavsResult'],
314
+ avs_result_code: fields['UMavsResultCode'],
315
+ cvv2_result: fields['UMcvv2Result'],
316
+ cvv2_result_code: fields['UMcvv2ResultCode'],
317
+ vpas_result_code: fields['UMvpasResultCode'],
318
+ result: fields['UMresult'],
319
+ error: fields['UMerror'],
320
+ error_code: fields['UMerrorcode'],
321
+ acs_url: fields['UMacsurl'],
322
+ payload: fields['UMpayload']
323
+ }.delete_if { |_k, v| v.nil? }
316
324
  end
317
325
 
318
326
  def commit(action, parameters)
@@ -322,12 +330,11 @@ module ActiveMerchant #:nodoc:
322
330
  error_code = nil
323
331
  error_code = (STANDARD_ERROR_CODE_MAPPING[response[:error_code]] || STANDARD_ERROR_CODE[:processing_error]) unless approved
324
332
  Response.new(approved, message_from(response), response,
325
- :test => test?,
326
- :authorization => response[:ref_num],
327
- :cvv_result => response[:cvv2_result_code],
328
- :avs_result => { :code => response[:avs_result_code] },
329
- :error_code => error_code
330
- )
333
+ test: test?,
334
+ authorization: authorization_from(action, response),
335
+ cvv_result: response[:cvv2_result_code],
336
+ avs_result: { code: response[:avs_result_code] },
337
+ error_code: error_code)
331
338
  end
332
339
 
333
340
  def message_from(response)
@@ -335,17 +342,22 @@ module ActiveMerchant #:nodoc:
335
342
  return 'Success'
336
343
  else
337
344
  return 'Unspecified error' if response[:error].blank?
345
+
338
346
  return response[:error]
339
347
  end
340
348
  end
341
349
 
350
+ def authorization_from(action, response)
351
+ return (action == :store ? response[:card_ref] : response[:ref_num])
352
+ end
353
+
342
354
  def post_data(action, parameters = {})
343
355
  parameters[:command] = TRANSACTIONS[action]
344
356
  parameters[:key] = @options[:login]
345
357
  parameters[:software] = 'Active Merchant'
346
358
  parameters[:testmode] = (@options[:test] ? 1 : 0) unless parameters.has_key?(:testmode)
347
359
  seed = SecureRandom.hex(32).upcase
348
- hash = Digest::SHA1.hexdigest("#{parameters[:command]}:#{@options[:password]}:#{parameters[:amount]}:#{parameters[:invoice]}:#{seed}")
360
+ hash = Digest::SHA1.hexdigest("#{parameters[:command]}:#{@options[:pin] || @options[:password]}:#{parameters[:amount]}:#{parameters[:invoice]}:#{seed}")
349
361
  parameters[:hash] = "s/#{seed}/#{hash}/n"
350
362
 
351
363
  parameters.collect { |key, value| "UM#{key}=#{CGI.escape(value.to_s)}" }.join('&')
@@ -10,24 +10,33 @@ module ActiveMerchant
10
10
 
11
11
  self.supported_countries = ['US']
12
12
  self.default_currency = 'USD'
13
- self.supported_cardtypes = [:visa, :master, :american_express, :discover]
13
+ self.supported_cardtypes = %i[visa master american_express discover]
14
14
 
15
15
  self.homepage_url = 'http://vancopayments.com/'
16
16
  self.display_name = 'Vanco Payment Solutions'
17
17
 
18
- def initialize(options={})
18
+ SECONDS_PER_DAY = 3600 * 24
19
+ BUFFER_TIME_IN_SECS = 60 * 3
20
+
21
+ def initialize(options = {})
19
22
  requires!(options, :user_id, :password, :client_id)
20
23
  super
21
24
  end
22
25
 
23
- def purchase(money, payment_method, options={})
24
- MultiResponse.run do |r|
25
- r.process { login }
26
- r.process { commit(purchase_request(money, payment_method, r.params['response_sessionid'], options), :response_transactionref) }
26
+ def purchase(money, payment_method, options = {})
27
+ moment_less_than_24_hours_ago = Time.now - SECONDS_PER_DAY - BUFFER_TIME_IN_SECS
28
+
29
+ if options[:session_id] && options[:session_id][:created_at] >= moment_less_than_24_hours_ago
30
+ commit(purchase_request(money, payment_method, options[:session_id][:id], options), :response_transactionref)
31
+ else
32
+ MultiResponse.run do |r|
33
+ r.process { login }
34
+ r.process { commit(purchase_request(money, payment_method, r.params['response_sessionid'], options), :response_transactionref) }
35
+ end
27
36
  end
28
37
  end
29
38
 
30
- def refund(money, authorization, options={})
39
+ def refund(money, authorization, options = {})
31
40
  MultiResponse.run do |r|
32
41
  r.process { login }
33
42
  r.process { commit(refund_request(money, authorization, r.params['response_sessionid']), :response_creditrequestreceived) }
@@ -108,6 +117,7 @@ module ActiveMerchant
108
117
 
109
118
  def message_from(succeeded, response)
110
119
  return 'Success' if succeeded
120
+
111
121
  response[:error_message]
112
122
  end
113
123
 
@@ -288,7 +298,6 @@ module ActiveMerchant
288
298
  'Content-Type' => 'text/xml'
289
299
  }
290
300
  end
291
-
292
301
  end
293
302
  end
294
303
  end
@@ -5,8 +5,8 @@ module ActiveMerchant #:nodoc:
5
5
  class VerifiGateway < Gateway
6
6
  class VerifiPostData < PostData
7
7
  # Fields that will be sent even if they are blank
8
- self.required_fields = [:amount, :type, :ccnumber, :ccexp, :firstname, :lastname,
9
- :company, :address1, :address2, :city, :state, :zip, :country, :phone]
8
+ self.required_fields = %i[amount type ccnumber ccexp firstname lastname
9
+ company address1 address2 city state zip country phone]
10
10
  end
11
11
 
12
12
  self.live_url = self.test_url = 'https://secure.verifi.com/gw/api/transact.php'
@@ -50,16 +50,16 @@ module ActiveMerchant #:nodoc:
50
50
  SUCCESS = 1
51
51
 
52
52
  TRANSACTIONS = {
53
- :authorization => 'auth',
54
- :purchase => 'sale',
55
- :capture => 'capture',
56
- :void => 'void',
57
- :credit => 'credit',
58
- :refund => 'refund'
53
+ authorization: 'auth',
54
+ purchase: 'sale',
55
+ capture: 'capture',
56
+ void: 'void',
57
+ credit: 'credit',
58
+ refund: 'refund'
59
59
  }
60
60
 
61
61
  self.supported_countries = ['US']
62
- self.supported_cardtypes = [:visa, :master, :american_express, :discover]
62
+ self.supported_cardtypes = %i[visa master american_express discover]
63
63
  self.homepage_url = 'http://www.verifi.com/'
64
64
  self.display_name = 'Verifi'
65
65
 
@@ -195,11 +195,10 @@ module ActiveMerchant #:nodoc:
195
195
  response = parse(ssl_post(self.live_url, post_data(trx_type, post)))
196
196
 
197
197
  Response.new(response[:response].to_i == SUCCESS, message_from(response), response,
198
- :test => test?,
199
- :authorization => response[:transactionid],
200
- :avs_result => { :code => response[:avsresponse] },
201
- :cvv_result => response[:cvvresponse]
202
- )
198
+ test: test?,
199
+ authorization: response[:transactionid],
200
+ avs_result: { code: response[:avsresponse] },
201
+ cvv_result: response[:cvvresponse])
203
202
  end
204
203
 
205
204
  def message_from(response)
@@ -8,13 +8,13 @@ module ActiveMerchant #:nodoc:
8
8
  self.delimiter = "\r\n"
9
9
 
10
10
  self.actions = {
11
- :purchase => 'SALE',
12
- :credit => 'CREDIT'
11
+ purchase: 'SALE',
12
+ credit: 'CREDIT'
13
13
  }
14
14
 
15
15
  APPROVED = '0'
16
16
 
17
- self.supported_cardtypes = [:visa, :master, :american_express, :discover]
17
+ self.supported_cardtypes = %i[visa master american_express discover]
18
18
  self.supported_countries = ['US']
19
19
  self.display_name = 'ViaKLIX'
20
20
  self.homepage_url = 'http://viaklix.com'
@@ -49,9 +49,7 @@ module ActiveMerchant #:nodoc:
49
49
  # Make a credit to a card (Void can only be done from the virtual terminal)
50
50
  # Viaklix does not support credits by reference. You must pass in the credit card
51
51
  def credit(money, creditcard, options = {})
52
- if creditcard.is_a?(String)
53
- raise ArgumentError, 'Reference credits are not supported. Please supply the original credit card'
54
- end
52
+ raise ArgumentError, 'Reference credits are not supported. Please supply the original credit card' if creditcard.is_a?(String)
55
53
 
56
54
  form = {}
57
55
  add_invoice(form, options)
@@ -109,9 +107,7 @@ module ActiveMerchant #:nodoc:
109
107
  form[:card_number] = creditcard.number
110
108
  form[:exp_date] = expdate(creditcard)
111
109
 
112
- if creditcard.verification_value?
113
- add_verification_value(form, creditcard)
114
- end
110
+ add_verification_value(form, creditcard) if creditcard.verification_value?
115
111
 
116
112
  form[:first_name] = creditcard.first_name.to_s.slice(0, 20)
117
113
  form[:last_name] = creditcard.last_name.to_s.slice(0, 30)
@@ -141,11 +137,10 @@ module ActiveMerchant #:nodoc:
141
137
  response = parse(ssl_post(test? ? self.test_url : self.live_url, post_data(parameters)))
142
138
 
143
139
  Response.new(response['result'] == APPROVED, message_from(response), response,
144
- :test => @options[:test] || test?,
145
- :authorization => authorization_from(response),
146
- :avs_result => { :code => response['avs_response'] },
147
- :cvv_result => response['cvv2_response']
148
- )
140
+ test: @options[:test] || test?,
141
+ authorization: authorization_from(response),
142
+ avs_result: { code: response['avs_response'] },
143
+ cvv_result: response['cvv2_response'])
149
144
  end
150
145
 
151
146
  def authorization_from(response)
@@ -8,24 +8,24 @@ module ActiveMerchant #:nodoc:
8
8
  self.test_url = 'https://devapi.vnforapps.com/api.tokenization/api/v2/merchant'
9
9
  self.live_url = 'https://api.vnforapps.com/api.tokenization/api/v2/merchant'
10
10
 
11
- self.supported_countries = ['US', 'PE']
11
+ self.supported_countries = %w[US PE]
12
12
  self.default_currency = 'PEN'
13
13
  self.money_format = :dollars
14
- self.supported_cardtypes = [:visa, :master, :american_express, :discover]
14
+ self.supported_cardtypes = %i[visa master american_express discover]
15
15
 
16
- def initialize(options={})
16
+ def initialize(options = {})
17
17
  requires!(options, :access_key_id, :secret_access_key, :merchant_id)
18
18
  super
19
19
  end
20
20
 
21
- def purchase(amount, payment_method, options={})
21
+ def purchase(amount, payment_method, options = {})
22
22
  MultiResponse.run() do |r|
23
23
  r.process { authorize(amount, payment_method, options) }
24
24
  r.process { capture(amount, r.authorization, options) }
25
25
  end
26
26
  end
27
27
 
28
- def authorize(amount, payment_method, options={})
28
+ def authorize(amount, payment_method, options = {})
29
29
  params = {}
30
30
 
31
31
  add_invoice(params, amount, options)
@@ -37,20 +37,20 @@ module ActiveMerchant #:nodoc:
37
37
  commit('authorize', params, options)
38
38
  end
39
39
 
40
- def capture(amount, authorization, options={})
40
+ def capture(amount, authorization, options = {})
41
41
  params = {}
42
42
  options[:id_unico] = split_authorization(authorization)[1]
43
43
  add_auth_order_id(params, authorization, options)
44
44
  commit('deposit', params, options)
45
45
  end
46
46
 
47
- def void(authorization, options={})
47
+ def void(authorization, options = {})
48
48
  params = {}
49
49
  add_auth_order_id(params, authorization, options)
50
50
  commit('void', params, options)
51
51
  end
52
52
 
53
- def refund(amount, authorization, options={})
53
+ def refund(amount, authorization, options = {})
54
54
  params = {}
55
55
  params[:amount] = amount(amount) if amount
56
56
  add_auth_order_id(params, authorization, options)
@@ -65,7 +65,7 @@ module ActiveMerchant #:nodoc:
65
65
  commit('refund', params, options)
66
66
  end
67
67
 
68
- def verify(credit_card, options={})
68
+ def verify(credit_card, options = {})
69
69
  MultiResponse.run(:use_first_response) do |r|
70
70
  r.process { authorize(100, credit_card, options) }
71
71
  r.process(:ignore_result) { void(r.authorization, options) }
@@ -85,20 +85,20 @@ module ActiveMerchant #:nodoc:
85
85
 
86
86
  private
87
87
 
88
- CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency: #{k}") }
88
+ CURRENCY_CODES = Hash.new { |_h, k| raise ArgumentError.new("Unsupported currency: #{k}") }
89
89
  CURRENCY_CODES['USD'] = 840
90
90
  CURRENCY_CODES['PEN'] = 604
91
91
 
92
92
  def add_invoice(params, money, options)
93
- # Visanet Peru expects a 9-digit numeric purchaseNumber
94
- params[:purchaseNumber] = (SecureRandom.random_number(900_000_000) + 100_000_000).to_s
93
+ # Visanet Peru expects a 12-digit alphanumeric purchaseNumber
94
+ params[:purchaseNumber] = generate_purchase_number_stamp
95
95
  params[:externalTransactionId] = options[:order_id]
96
96
  params[:amount] = amount(money)
97
97
  params[:currencyId] = CURRENCY_CODES[options[:currency] || currency(money)]
98
98
  end
99
99
 
100
100
  def add_auth_order_id(params, authorization, options)
101
- purchase_number, _ = split_authorization(authorization)
101
+ purchase_number, = split_authorization(authorization)
102
102
  params[:purchaseNumber] = purchase_number
103
103
  params[:externalTransactionId] = options[:order_id]
104
104
  end
@@ -142,7 +142,11 @@ module ActiveMerchant #:nodoc:
142
142
  authorization.split('|')
143
143
  end
144
144
 
145
- def commit(action, params, options={})
145
+ def generate_purchase_number_stamp
146
+ Time.now.to_f.to_s.delete('.')[1..10] + rand(99).to_s
147
+ end
148
+
149
+ def commit(action, params, options = {})
146
150
  raw_response = ssl_request(method(action), url(action, params, options), params.to_json, headers)
147
151
  response = parse(raw_response)
148
152
  rescue ResponseError => e
@@ -155,9 +159,9 @@ module ActiveMerchant #:nodoc:
155
159
  success_from(response),
156
160
  message_from(response, options, action),
157
161
  response,
158
- :test => test?,
159
- :authorization => authorization_from(params, response, options),
160
- :error_code => response['errorCode']
162
+ test: test?,
163
+ authorization: authorization_from(params, response, options),
164
+ error_code: response['errorCode']
161
165
  )
162
166
  end
163
167
 
@@ -168,7 +172,7 @@ module ActiveMerchant #:nodoc:
168
172
  }
169
173
  end
170
174
 
171
- def url(action, params, options={})
175
+ def url(action, params, options = {})
172
176
  if action == 'authorize'
173
177
  "#{base_url}/#{@options[:merchant_id]}"
174
178
  elsif action == 'refund'
@@ -213,6 +217,7 @@ module ActiveMerchant #:nodoc:
213
217
 
214
218
  def action_code_description(response)
215
219
  return nil unless response['data']
220
+
216
221
  response['data']['DSC_COD_ACCION']
217
222
  end
218
223
 
@@ -229,9 +234,9 @@ module ActiveMerchant #:nodoc:
229
234
  false,
230
235
  message_from(response, options, action),
231
236
  response,
232
- :test => test?,
233
- :authorization => response['transactionUUID'],
234
- :error_code => response['errorCode']
237
+ test: test?,
238
+ authorization: response['transactionUUID'],
239
+ error_code: response['errorCode']
235
240
  )
236
241
  end
237
242