activemerchant 1.79.2 → 1.129.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (279) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG +1391 -0
  3. data/README.md +29 -14
  4. data/lib/active_merchant/billing/avs_result.rb +25 -28
  5. data/lib/active_merchant/billing/base.rb +0 -13
  6. data/lib/active_merchant/billing/check.rb +55 -22
  7. data/lib/active_merchant/billing/compatibility.rb +10 -12
  8. data/lib/active_merchant/billing/credit_card.rb +82 -62
  9. data/lib/active_merchant/billing/credit_card_formatting.rb +4 -4
  10. data/lib/active_merchant/billing/credit_card_methods.rb +328 -58
  11. data/lib/active_merchant/billing/cvv_result.rb +0 -1
  12. data/lib/active_merchant/billing/gateway.rb +61 -56
  13. data/lib/active_merchant/billing/gateways/adyen.rb +562 -87
  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 +35 -36
  17. data/lib/active_merchant/billing/gateways/authorize_net.rb +297 -196
  18. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +31 -24
  19. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +94 -98
  20. data/lib/active_merchant/billing/gateways/axcessms.rb +64 -66
  21. data/lib/active_merchant/billing/gateways/balanced.rb +72 -65
  22. data/lib/active_merchant/billing/gateways/bambora_apac.rb +222 -0
  23. data/lib/active_merchant/billing/gateways/bank_frick.rb +16 -16
  24. data/lib/active_merchant/billing/gateways/banwire.rb +12 -12
  25. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +140 -69
  26. data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +7 -7
  27. data/lib/active_merchant/billing/gateways/be2bill.rb +7 -7
  28. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +115 -115
  29. data/lib/active_merchant/billing/gateways/beanstream.rb +39 -13
  30. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +1 -2
  31. data/lib/active_merchant/billing/gateways/blue_pay.rb +87 -58
  32. data/lib/active_merchant/billing/gateways/blue_snap.rb +405 -104
  33. data/lib/active_merchant/billing/gateways/bogus.rb +34 -30
  34. data/lib/active_merchant/billing/gateways/borgun.rb +97 -47
  35. data/lib/active_merchant/billing/gateways/bpoint.rb +20 -20
  36. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -3
  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 +561 -259
  40. data/lib/active_merchant/billing/gateways/braintree_orange.rb +1 -1
  41. data/lib/active_merchant/billing/gateways/bridge_pay.rb +53 -54
  42. data/lib/active_merchant/billing/gateways/cams.rb +31 -31
  43. data/lib/active_merchant/billing/gateways/card_connect.rb +85 -33
  44. data/lib/active_merchant/billing/gateways/card_save.rb +7 -9
  45. data/lib/active_merchant/billing/gateways/card_stream.rb +187 -169
  46. data/lib/active_merchant/billing/gateways/cardknox.rb +24 -25
  47. data/lib/active_merchant/billing/gateways/cardprocess.rb +9 -7
  48. data/lib/active_merchant/billing/gateways/cashnet.rb +43 -27
  49. data/lib/active_merchant/billing/gateways/cc5.rb +14 -17
  50. data/lib/active_merchant/billing/gateways/cecabank.rb +62 -52
  51. data/lib/active_merchant/billing/gateways/cenpos.rb +63 -62
  52. data/lib/active_merchant/billing/gateways/checkout.rb +21 -23
  53. data/lib/active_merchant/billing/gateways/checkout_v2.rb +391 -113
  54. data/lib/active_merchant/billing/gateways/citrus_pay.rb +1 -3
  55. data/lib/active_merchant/billing/gateways/clearhaus.rb +40 -41
  56. data/lib/active_merchant/billing/gateways/commerce_hub.rb +361 -0
  57. data/lib/active_merchant/billing/gateways/commercegate.rb +11 -12
  58. data/lib/active_merchant/billing/gateways/conekta.rb +35 -30
  59. data/lib/active_merchant/billing/gateways/creditcall.rb +59 -59
  60. data/lib/active_merchant/billing/gateways/credorax.rb +326 -145
  61. data/lib/active_merchant/billing/gateways/ct_payment.rb +269 -0
  62. data/lib/active_merchant/billing/gateways/culqi.rb +53 -53
  63. data/lib/active_merchant/billing/gateways/cyber_source/cyber_source_common.rb +36 -0
  64. data/lib/active_merchant/billing/gateways/cyber_source.rb +566 -208
  65. data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +456 -0
  66. data/lib/active_merchant/billing/gateways/d_local.rb +342 -0
  67. data/lib/active_merchant/billing/gateways/data_cash.rb +40 -56
  68. data/lib/active_merchant/billing/gateways/decidir.rb +358 -0
  69. data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
  70. data/lib/active_merchant/billing/gateways/dibs.rb +34 -40
  71. data/lib/active_merchant/billing/gateways/digitzs.rb +48 -45
  72. data/lib/active_merchant/billing/gateways/ebanx.rb +110 -60
  73. data/lib/active_merchant/billing/gateways/efsnet.rb +46 -50
  74. data/lib/active_merchant/billing/gateways/elavon.rb +351 -189
  75. data/lib/active_merchant/billing/gateways/element.rb +106 -56
  76. data/lib/active_merchant/billing/gateways/epay.rb +74 -64
  77. data/lib/active_merchant/billing/gateways/evo_ca.rb +13 -14
  78. data/lib/active_merchant/billing/gateways/eway.rb +74 -73
  79. data/lib/active_merchant/billing/gateways/eway_managed.rb +85 -87
  80. data/lib/active_merchant/billing/gateways/eway_rapid.rb +105 -60
  81. data/lib/active_merchant/billing/gateways/exact.rb +29 -37
  82. data/lib/active_merchant/billing/gateways/ezic.rb +21 -22
  83. data/lib/active_merchant/billing/gateways/fat_zebra.rb +70 -48
  84. data/lib/active_merchant/billing/gateways/federated_canada.rb +11 -13
  85. data/lib/active_merchant/billing/gateways/finansbank.rb +3 -4
  86. data/lib/active_merchant/billing/gateways/first_giving.rb +23 -23
  87. data/lib/active_merchant/billing/gateways/first_pay.rb +33 -13
  88. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +106 -105
  89. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +505 -0
  90. data/lib/active_merchant/billing/gateways/flo2cash.rb +36 -36
  91. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +2 -2
  92. data/lib/active_merchant/billing/gateways/forte.rb +70 -40
  93. data/lib/active_merchant/billing/gateways/garanti.rb +24 -31
  94. data/lib/active_merchant/billing/gateways/global_collect.rb +378 -154
  95. data/lib/active_merchant/billing/gateways/global_transport.rb +12 -13
  96. data/lib/active_merchant/billing/gateways/hdfc.rb +55 -57
  97. data/lib/active_merchant/billing/gateways/hps.rb +236 -69
  98. data/lib/active_merchant/billing/gateways/iats_payments.rb +61 -39
  99. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +1 -1
  100. data/lib/active_merchant/billing/gateways/inspire.rb +41 -47
  101. data/lib/active_merchant/billing/gateways/instapay.rb +10 -14
  102. data/lib/active_merchant/billing/gateways/ipg.rb +420 -0
  103. data/lib/active_merchant/billing/gateways/ipp.rb +25 -24
  104. data/lib/active_merchant/billing/gateways/iridium.rb +243 -244
  105. data/lib/active_merchant/billing/gateways/itransact.rb +14 -14
  106. data/lib/active_merchant/billing/gateways/iveri.rb +73 -34
  107. data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
  108. data/lib/active_merchant/billing/gateways/jetpay.rb +145 -152
  109. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +154 -159
  110. data/lib/active_merchant/billing/gateways/komoju.rb +16 -16
  111. data/lib/active_merchant/billing/gateways/kushki.rb +127 -57
  112. data/lib/active_merchant/billing/gateways/latitude19.rb +111 -115
  113. data/lib/active_merchant/billing/gateways/linkpoint.rb +82 -85
  114. data/lib/active_merchant/billing/gateways/litle.rb +247 -53
  115. data/lib/active_merchant/billing/gateways/mastercard.rb +41 -23
  116. data/lib/active_merchant/billing/gateways/maxipago.rb +5 -5
  117. data/lib/active_merchant/billing/gateways/mercado_pago.rb +135 -49
  118. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +62 -29
  119. data/lib/active_merchant/billing/gateways/merchant_one.rb +16 -20
  120. data/lib/active_merchant/billing/gateways/merchant_partners.rb +40 -40
  121. data/lib/active_merchant/billing/gateways/merchant_ware.rb +54 -60
  122. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +42 -44
  123. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +52 -14
  124. data/lib/active_merchant/billing/gateways/mercury.rb +47 -51
  125. data/lib/active_merchant/billing/gateways/metrics_global.rb +32 -42
  126. data/lib/active_merchant/billing/gateways/micropayment.rb +42 -45
  127. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +7 -7
  128. data/lib/active_merchant/billing/gateways/migs.rb +45 -40
  129. data/lib/active_merchant/billing/gateways/mit.rb +260 -0
  130. data/lib/active_merchant/billing/gateways/modern_payments.rb +2 -2
  131. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +29 -31
  132. data/lib/active_merchant/billing/gateways/moka.rb +290 -0
  133. data/lib/active_merchant/billing/gateways/monei.rb +255 -138
  134. data/lib/active_merchant/billing/gateways/moneris.rb +226 -88
  135. data/lib/active_merchant/billing/gateways/money_movers.rb +11 -13
  136. data/lib/active_merchant/billing/gateways/mundipagg.rb +117 -43
  137. data/lib/active_merchant/billing/gateways/nab_transact.rb +28 -31
  138. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +13 -15
  139. data/lib/active_merchant/billing/gateways/net_registry.rb +12 -12
  140. data/lib/active_merchant/billing/gateways/netaxept.rb +33 -34
  141. data/lib/active_merchant/billing/gateways/netbanx.rb +167 -80
  142. data/lib/active_merchant/billing/gateways/netbilling.rb +27 -30
  143. data/lib/active_merchant/billing/gateways/netpay.rb +10 -10
  144. data/lib/active_merchant/billing/gateways/network_merchants.rb +7 -11
  145. data/lib/active_merchant/billing/gateways/nmi.rb +134 -48
  146. data/lib/active_merchant/billing/gateways/ogone.rb +88 -58
  147. data/lib/active_merchant/billing/gateways/omise.rb +30 -31
  148. data/lib/active_merchant/billing/gateways/openpay.rb +45 -26
  149. data/lib/active_merchant/billing/gateways/opp.rb +166 -144
  150. data/lib/active_merchant/billing/gateways/optimal_payment.rb +67 -64
  151. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +5 -7
  152. data/lib/active_merchant/billing/gateways/orbital.rb +726 -382
  153. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +26 -27
  154. data/lib/active_merchant/billing/gateways/pagarme.rb +47 -56
  155. data/lib/active_merchant/billing/gateways/pago_facil.rb +12 -14
  156. data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
  157. data/lib/active_merchant/billing/gateways/pay_conex.rb +39 -40
  158. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +65 -65
  159. data/lib/active_merchant/billing/gateways/pay_hub.rb +39 -39
  160. data/lib/active_merchant/billing/gateways/pay_junction.rb +37 -37
  161. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +70 -54
  162. data/lib/active_merchant/billing/gateways/pay_secure.rb +15 -17
  163. data/lib/active_merchant/billing/gateways/pay_trace.rb +450 -0
  164. data/lib/active_merchant/billing/gateways/paybox_direct.rb +71 -47
  165. data/lib/active_merchant/billing/gateways/payeezy.rb +159 -32
  166. data/lib/active_merchant/billing/gateways/payex.rb +39 -42
  167. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +41 -36
  168. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +11 -8
  169. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +3 -3
  170. data/lib/active_merchant/billing/gateways/payflow.rb +178 -54
  171. data/lib/active_merchant/billing/gateways/payflow_express.rb +61 -65
  172. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +0 -1
  173. data/lib/active_merchant/billing/gateways/payflow_uk.rb +1 -2
  174. data/lib/active_merchant/billing/gateways/payment_express.rb +66 -58
  175. data/lib/active_merchant/billing/gateways/paymentez.rb +114 -25
  176. data/lib/active_merchant/billing/gateways/paymill.rb +134 -133
  177. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +2 -1
  178. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +4 -0
  179. data/lib/active_merchant/billing/gateways/paypal.rb +27 -14
  180. data/lib/active_merchant/billing/gateways/paypal_ca.rb +1 -1
  181. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +2 -2
  182. data/lib/active_merchant/billing/gateways/paypal_express.rb +5 -2
  183. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +1 -1
  184. data/lib/active_merchant/billing/gateways/paysafe.rb +420 -0
  185. data/lib/active_merchant/billing/gateways/payscout.rb +10 -13
  186. data/lib/active_merchant/billing/gateways/paystation.rb +79 -82
  187. data/lib/active_merchant/billing/gateways/payu_in.rb +59 -58
  188. data/lib/active_merchant/billing/gateways/payu_latam.rb +139 -97
  189. data/lib/active_merchant/billing/gateways/payway.rb +27 -27
  190. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
  191. data/lib/active_merchant/billing/gateways/pin.rb +87 -34
  192. data/lib/active_merchant/billing/gateways/plexo.rb +308 -0
  193. data/lib/active_merchant/billing/gateways/plugnpay.rb +82 -82
  194. data/lib/active_merchant/billing/gateways/priority.rb +392 -0
  195. data/lib/active_merchant/billing/gateways/pro_pay.rb +139 -140
  196. data/lib/active_merchant/billing/gateways/psigate.rb +44 -44
  197. data/lib/active_merchant/billing/gateways/psl_card.rb +29 -37
  198. data/lib/active_merchant/billing/gateways/qbms.rb +75 -76
  199. data/lib/active_merchant/billing/gateways/quantum.rb +21 -23
  200. data/lib/active_merchant/billing/gateways/quickbooks.rb +142 -55
  201. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +103 -107
  202. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +156 -158
  203. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +7 -8
  204. data/lib/active_merchant/billing/gateways/quickpay.rb +1 -3
  205. data/lib/active_merchant/billing/gateways/qvalent.rb +137 -68
  206. data/lib/active_merchant/billing/gateways/rapyd.rb +319 -0
  207. data/lib/active_merchant/billing/gateways/reach.rb +277 -0
  208. data/lib/active_merchant/billing/gateways/realex.rb +132 -50
  209. data/lib/active_merchant/billing/gateways/redsys.rb +382 -186
  210. data/lib/active_merchant/billing/gateways/s5.rb +16 -16
  211. data/lib/active_merchant/billing/gateways/safe_charge.rb +83 -47
  212. data/lib/active_merchant/billing/gateways/sage.rb +49 -48
  213. data/lib/active_merchant/billing/gateways/sage_pay.rb +76 -83
  214. data/lib/active_merchant/billing/gateways/sallie_mae.rb +13 -15
  215. data/lib/active_merchant/billing/gateways/secure_net.rb +32 -40
  216. data/lib/active_merchant/billing/gateways/secure_pay.rb +30 -40
  217. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +23 -26
  218. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +14 -16
  219. data/lib/active_merchant/billing/gateways/securion_pay.rb +69 -31
  220. data/lib/active_merchant/billing/gateways/shift4.rb +342 -0
  221. data/lib/active_merchant/billing/gateways/simetrik.rb +368 -0
  222. data/lib/active_merchant/billing/gateways/skip_jack.rb +52 -53
  223. data/lib/active_merchant/billing/gateways/smart_ps.rb +51 -60
  224. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +29 -29
  225. data/lib/active_merchant/billing/gateways/spreedly_core.rb +66 -47
  226. data/lib/active_merchant/billing/gateways/stripe.rb +309 -148
  227. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +556 -0
  228. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +18 -23
  229. data/lib/active_merchant/billing/gateways/telr.rb +46 -48
  230. data/lib/active_merchant/billing/gateways/tns.rb +8 -7
  231. data/lib/active_merchant/billing/gateways/trans_first.rb +37 -37
  232. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +249 -245
  233. data/lib/active_merchant/billing/gateways/transact_pro.rb +25 -27
  234. data/lib/active_merchant/billing/gateways/transax.rb +6 -8
  235. data/lib/active_merchant/billing/gateways/transnational.rb +1 -2
  236. data/lib/active_merchant/billing/gateways/trexle.rb +22 -18
  237. data/lib/active_merchant/billing/gateways/trust_commerce.rb +161 -88
  238. data/lib/active_merchant/billing/gateways/usa_epay.rb +5 -6
  239. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +231 -238
  240. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +129 -55
  241. data/lib/active_merchant/billing/gateways/vanco.rb +42 -33
  242. data/lib/active_merchant/billing/gateways/verifi.rb +52 -53
  243. data/lib/active_merchant/billing/gateways/viaklix.rb +18 -22
  244. data/lib/active_merchant/billing/gateways/visanet_peru.rb +115 -74
  245. data/lib/active_merchant/billing/gateways/vpos.rb +223 -0
  246. data/lib/active_merchant/billing/gateways/webpay.rb +9 -9
  247. data/lib/active_merchant/billing/gateways/wepay.rb +38 -41
  248. data/lib/active_merchant/billing/gateways/wirecard.rb +36 -37
  249. data/lib/active_merchant/billing/gateways/wompi.rb +197 -0
  250. data/lib/active_merchant/billing/gateways/world_net.rb +39 -38
  251. data/lib/active_merchant/billing/gateways/worldpay.rb +756 -142
  252. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +73 -83
  253. data/lib/active_merchant/billing/gateways/worldpay_us.rb +31 -31
  254. data/lib/active_merchant/billing/model.rb +2 -2
  255. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +3 -3
  256. data/lib/active_merchant/billing/rails.rb +1 -1
  257. data/lib/active_merchant/billing/response.rb +32 -13
  258. data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
  259. data/lib/active_merchant/billing.rb +1 -0
  260. data/lib/active_merchant/connection.rb +24 -38
  261. data/lib/active_merchant/country.rb +9 -5
  262. data/lib/active_merchant/errors.rb +4 -1
  263. data/lib/active_merchant/net_http_ssl_connection.rb +2 -0
  264. data/lib/active_merchant/network_connection_retries.rb +28 -31
  265. data/lib/active_merchant/post_data.rb +5 -3
  266. data/lib/active_merchant/posts_data.rb +5 -7
  267. data/lib/active_merchant/version.rb +1 -1
  268. data/lib/active_merchant.rb +3 -3
  269. data/lib/activemerchant.rb +1 -1
  270. data/lib/certs/cacert.pem +1592 -2329
  271. data/lib/support/gateway_support.rb +8 -10
  272. data/lib/support/ssl_verify.rb +9 -14
  273. data/lib/support/ssl_version.rb +9 -10
  274. metadata +98 -37
  275. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +0 -246
  276. data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +0 -13
  277. data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +0 -29
  278. data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +0 -66
  279. data/lib/active_merchant/billing/gateways/moneris_us.rb +0 -309
@@ -4,7 +4,7 @@ module ActiveMerchant #:nodoc:
4
4
  self.live_url = self.test_url = 'https://secure.payscout.com/api/transact.php'
5
5
 
6
6
  self.supported_countries = ['US']
7
- self.supported_cardtypes = [:visa, :master, :american_express, :discover]
7
+ self.supported_cardtypes = %i[visa master american_express discover]
8
8
  self.default_currency = 'USD'
9
9
  self.homepage_url = 'http://www.payscout.com/'
10
10
  self.display_name = 'Payscout'
@@ -41,7 +41,6 @@ module ActiveMerchant #:nodoc:
41
41
  commit('capture', money, post)
42
42
  end
43
43
 
44
-
45
44
  def refund(money, authorization, options = {})
46
45
  post = {}
47
46
  post[:transactionid] = authorization
@@ -63,7 +62,7 @@ module ActiveMerchant #:nodoc:
63
62
  post[:address1] = address[:address1].to_s
64
63
  post[:address2] = address[:address2].to_s
65
64
  post[:city] = address[:city].to_s
66
- post[:state] = (address[:state].blank? ? 'n/a' : address[:state])
65
+ post[:state] = (address[:state].blank? ? 'n/a' : address[:state])
67
66
  post[:zip] = address[:zip].to_s
68
67
  post[:country] = address[:country].to_s
69
68
  post[:phone] = address[:phone].to_s
@@ -79,7 +78,7 @@ module ActiveMerchant #:nodoc:
79
78
  post[:shipping_address2] = address[:address2].to_s
80
79
  post[:shipping_city] = address[:city].to_s
81
80
  post[:shipping_country] = address[:country].to_s
82
- post[:shipping_state] = (address[:state].blank? ? 'n/a' : address[:state])
81
+ post[:shipping_state] = (address[:state].blank? ? 'n/a' : address[:state])
83
82
  post[:shipping_zip] = address[:zip].to_s
84
83
  post[:shipping_email] = address[:email].to_s
85
84
  end
@@ -103,7 +102,7 @@ module ActiveMerchant #:nodoc:
103
102
  end
104
103
 
105
104
  def parse(body)
106
- Hash[body.split('&').map{|x|x.split('=')}]
105
+ Hash[body.split('&').map { |x| x.split('=') }]
107
106
  end
108
107
 
109
108
  def commit(action, money, parameters)
@@ -117,12 +116,11 @@ module ActiveMerchant #:nodoc:
117
116
  message = message_from(response)
118
117
  test_mode = (test? || message =~ /TESTMODE/)
119
118
  Response.new(success?(response), message, response,
120
- :test => test_mode,
121
- :authorization => response['transactionid'],
122
- :fraud_review => fraud_review?(response),
123
- :avs_result => { :code => response['avsresponse'] },
124
- :cvv_result => response['cvvresponse']
125
- )
119
+ test: test_mode,
120
+ authorization: response['transactionid'],
121
+ fraud_review: fraud_review?(response),
122
+ avs_result: { code: response['avsresponse'] },
123
+ cvv_result: response['cvvresponse'])
126
124
  end
127
125
 
128
126
  def message_from(response)
@@ -153,10 +151,9 @@ module ActiveMerchant #:nodoc:
153
151
  post[:password] = @options[:password]
154
152
  post[:type] = action
155
153
 
156
- request = post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
154
+ request = post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
157
155
  request
158
156
  end
159
157
  end
160
158
  end
161
159
  end
162
-
@@ -1,8 +1,7 @@
1
1
  module ActiveMerchant #:nodoc:
2
2
  module Billing #:nodoc:
3
3
  class PaystationGateway < Gateway
4
-
5
- self.live_url = self.test_url = "https://www.paystation.co.nz/direct/paystation.dll"
4
+ self.live_url = self.test_url = 'https://www.paystation.co.nz/direct/paystation.dll'
6
5
 
7
6
  # an "error code" of "0" means "No error - transaction successful"
8
7
  SUCCESSFUL_RESPONSE_CODE = '0'
@@ -14,7 +13,7 @@ module ActiveMerchant #:nodoc:
14
13
  self.supported_countries = ['NZ']
15
14
 
16
15
  # TODO: check this with paystation (amex and diners need to be enabled)
17
- self.supported_cardtypes = [:visa, :master, :american_express, :diners_club ]
16
+ self.supported_cardtypes = %i[visa master american_express diners_club]
18
17
 
19
18
  self.homepage_url = 'http://paystation.co.nz'
20
19
  self.display_name = 'Paystation'
@@ -75,7 +74,7 @@ module ActiveMerchant #:nodoc:
75
74
  commit(post)
76
75
  end
77
76
 
78
- def refund(money, authorization, options={})
77
+ def refund(money, authorization, options = {})
79
78
  post = new_request
80
79
  add_amount(post, money, options)
81
80
  add_invoice(post, options)
@@ -84,7 +83,7 @@ module ActiveMerchant #:nodoc:
84
83
  commit(post)
85
84
  end
86
85
 
87
- def verify(credit_card, options={})
86
+ def verify(credit_card, options = {})
88
87
  authorize(0, credit_card, options)
89
88
  end
90
89
 
@@ -100,107 +99,105 @@ module ActiveMerchant #:nodoc:
100
99
 
101
100
  private
102
101
 
103
- def new_request
104
- {
105
- :pi => @options[:paystation_id], # paystation account id
106
- :gi => @options[:gateway_id], # paystation gateway id
107
- "2p" => "t", # two-party transaction type
108
- :nr => "t", # -- redirect??
109
- :df => "yymm" # date format: optional sometimes, required others
110
- }
111
- end
112
-
113
- def add_customer_data(post, options)
114
- post[:mc] = options[:customer]
115
- end
102
+ def new_request
103
+ {
104
+ :pi => @options[:paystation_id], # paystation account id
105
+ :gi => @options[:gateway_id], # paystation gateway id
106
+ '2p' => 't', # two-party transaction type
107
+ :nr => 't', # -- redirect??
108
+ :df => 'yymm' # date format: optional sometimes, required others
109
+ }
110
+ end
116
111
 
117
- def add_invoice(post, options)
118
- post[:ms] = generate_unique_id
119
- post[:mo] = options[:description]
120
- post[:mr] = options[:order_id]
121
- end
112
+ def add_customer_data(post, options)
113
+ post[:mc] = options[:customer]
114
+ end
122
115
 
123
- def add_credit_card(post, credit_card)
124
- post[:cn] = credit_card.number
125
- post[:ct] = credit_card.brand
126
- post[:ex] = format_date(credit_card.month, credit_card.year)
127
- post[:cc] = credit_card.verification_value if credit_card.verification_value?
128
- end
116
+ def add_invoice(post, options)
117
+ post[:ms] = generate_unique_id
118
+ post[:mo] = options[:description]
119
+ post[:mr] = options[:order_id]
120
+ end
129
121
 
130
- def add_token(post, token)
131
- post[:fp] = "t" # turn on "future payments" - what paystation calls Token Billing
132
- post[:ft] = token
133
- end
122
+ def add_credit_card(post, credit_card)
123
+ post[:cn] = credit_card.number
124
+ post[:ct] = credit_card.brand
125
+ post[:ex] = format_date(credit_card.month, credit_card.year)
126
+ post[:cc] = credit_card.verification_value if credit_card.verification_value?
127
+ end
134
128
 
135
- def store_credit_card(post, options)
136
- post[:fp] = "t" # turn on "future payments" - what paystation calls Token Billing
137
- post[:fs] = "t" # tells paystation to store right now, not bill
138
- post[:ft] = options[:token] if options[:token] # specify a token to use that, or let Paystation generate one
139
- end
129
+ def add_token(post, token)
130
+ post[:fp] = 't' # turn on "future payments" - what paystation calls Token Billing
131
+ post[:ft] = token
132
+ end
140
133
 
141
- def add_authorize_flag(post, options)
142
- post[:pa] = "t" # tells Paystation that this is a pre-auth authorisation payment (account must be in pre-auth mode)
143
- end
134
+ def store_credit_card(post, options)
135
+ post[:fp] = 't' # turn on "future payments" - what paystation calls Token Billing
136
+ post[:fs] = 't' # tells paystation to store right now, not bill
137
+ post[:ft] = options[:token] if options[:token] # specify a token to use that, or let Paystation generate one
138
+ end
144
139
 
145
- def add_refund_specific_fields(post, authorization)
146
- post[:rc] = "t"
147
- post[:rt] = authorization
148
- end
140
+ def add_authorize_flag(post, options)
141
+ post[:pa] = 't' # tells Paystation that this is a pre-auth authorisation payment (account must be in pre-auth mode)
142
+ end
149
143
 
150
- def add_authorization_token(post, auth_token, verification_value = nil)
151
- post[:cp] = "t" # Capture Payment flag – tells Paystation this transaction should be treated as a capture payment
152
- post[:cx] = auth_token
153
- post[:cc] = verification_value
154
- end
144
+ def add_refund_specific_fields(post, authorization)
145
+ post[:rc] = 't'
146
+ post[:rt] = authorization
147
+ end
155
148
 
156
- def add_amount(post, money, options)
157
- post[:am] = amount(money)
158
- post[:cu] = options[:currency] || currency(money)
159
- end
149
+ def add_authorization_token(post, auth_token, verification_value = nil)
150
+ post[:cp] = 't' # Capture Payment flag – tells Paystation this transaction should be treated as a capture payment
151
+ post[:cx] = auth_token
152
+ post[:cc] = verification_value
153
+ end
160
154
 
161
- def parse(xml_response)
162
- response = {}
155
+ def add_amount(post, money, options)
156
+ post[:am] = amount(money)
157
+ post[:cu] = options[:currency] || currency(money)
158
+ end
163
159
 
164
- xml = REXML::Document.new(xml_response)
160
+ def parse(xml_response)
161
+ response = {}
165
162
 
166
- xml.elements.each("#{xml.root.name}/*") do |element|
167
- response[element.name.underscore.to_sym] = element.text
168
- end
163
+ xml = REXML::Document.new(xml_response)
169
164
 
170
- response
165
+ xml.elements.each("#{xml.root.name}/*") do |element|
166
+ response[element.name.underscore.to_sym] = element.text
171
167
  end
172
168
 
173
- def commit(post)
174
- post[:tm] = "T" if test?
175
- pstn_prefix_params = post.collect { |key, value| "pstn_#{key}=#{CGI.escape(value.to_s)}" }.join("&")
169
+ response
170
+ end
176
171
 
177
- data = ssl_post(self.live_url, "#{pstn_prefix_params}&paystation=_empty")
178
- response = parse(data)
179
- message = message_from(response)
172
+ def commit(post)
173
+ post[:tm] = 'T' if test?
174
+ pstn_prefix_params = post.collect { |key, value| "pstn_#{key}=#{CGI.escape(value.to_s)}" }.join('&')
180
175
 
181
- PaystationResponse.new(success?(response), message, response,
182
- :test => (response[:tm] && response[:tm].downcase == "t"),
183
- :authorization => response[:paystation_transaction_id]
184
- )
185
- end
176
+ data = ssl_post(self.live_url, "#{pstn_prefix_params}&paystation=_empty")
177
+ response = parse(data)
178
+ message = message_from(response)
186
179
 
187
- def success?(response)
188
- (response[:ec] == SUCCESSFUL_RESPONSE_CODE) || (response[:ec] == SUCCESSFUL_FUTURE_PAYMENT)
189
- end
180
+ PaystationResponse.new(success?(response), message, response,
181
+ test: (response[:tm]&.casecmp('t')&.zero?),
182
+ authorization: response[:paystation_transaction_id])
183
+ end
190
184
 
191
- def message_from(response)
192
- response[:em]
193
- end
185
+ def success?(response)
186
+ (response[:ec] == SUCCESSFUL_RESPONSE_CODE) || (response[:ec] == SUCCESSFUL_FUTURE_PAYMENT)
187
+ end
194
188
 
195
- def format_date(month, year)
196
- "#{format(year, :two_digits)}#{format(month, :two_digits)}"
197
- end
189
+ def message_from(response)
190
+ response[:em]
191
+ end
198
192
 
193
+ def format_date(month, year)
194
+ "#{format(year, :two_digits)}#{format(month, :two_digits)}"
195
+ end
199
196
  end
200
197
 
201
198
  class PaystationResponse < Response
202
199
  def token
203
- @params["future_payment_token"]
200
+ @params['future_payment_token']
204
201
  end
205
202
  end
206
203
  end
@@ -3,25 +3,25 @@
3
3
  module ActiveMerchant #:nodoc:
4
4
  module Billing #:nodoc:
5
5
  class PayuInGateway < Gateway
6
- self.test_url = "https://test.payu.in/_payment"
7
- self.live_url = "https://secure.payu.in/_payment"
6
+ self.test_url = 'https://test.payu.in/_payment'
7
+ self.live_url = 'https://secure.payu.in/_payment'
8
8
 
9
- TEST_INFO_URL = "https://test.payu.in/merchant/postservice.php?form=2"
10
- LIVE_INFO_URL = "https://info.payu.in/merchant/postservice.php?form=2"
9
+ TEST_INFO_URL = 'https://test.payu.in/merchant/postservice.php?form=2'
10
+ LIVE_INFO_URL = 'https://info.payu.in/merchant/postservice.php?form=2'
11
11
 
12
12
  self.supported_countries = ['IN']
13
13
  self.default_currency = 'INR'
14
- self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :maestro]
14
+ self.supported_cardtypes = %i[visa master american_express diners_club maestro]
15
15
 
16
16
  self.homepage_url = 'https://www.payu.in/'
17
17
  self.display_name = 'PayU India'
18
18
 
19
- def initialize(options={})
19
+ def initialize(options = {})
20
20
  requires!(options, :key, :salt)
21
21
  super
22
22
  end
23
23
 
24
- def purchase(money, payment, options={})
24
+ def purchase(money, payment, options = {})
25
25
  requires!(options, :order_id)
26
26
 
27
27
  post = {}
@@ -32,28 +32,28 @@ module ActiveMerchant #:nodoc:
32
32
  add_auth(post)
33
33
 
34
34
  MultiResponse.run do |r|
35
- r.process{commit(url("purchase"), post)}
36
- if(r.params["enrolled"].to_s == "0")
37
- r.process{commit(r.params["post_uri"], r.params["form_post_vars"])}
35
+ r.process { commit(url('purchase'), post) }
36
+ if r.params['enrolled'].to_s == '0'
37
+ r.process { commit(r.params['post_uri'], r.params['form_post_vars']) }
38
38
  else
39
- r.process{handle_3dsecure(r)}
39
+ r.process { handle_3dsecure(r) }
40
40
  end
41
41
  end
42
42
  end
43
43
 
44
- def refund(money, authorization, options={})
45
- raise ArgumentError, "Amount is required" unless money
44
+ def refund(money, authorization, options = {})
45
+ raise ArgumentError, 'Amount is required' unless money
46
46
 
47
47
  post = {}
48
48
 
49
- post[:command] = "cancel_refund_transaction"
49
+ post[:command] = 'cancel_refund_transaction'
50
50
  post[:var1] = authorization
51
51
  post[:var2] = generate_unique_id
52
52
  post[:var3] = amount(money)
53
53
 
54
54
  add_auth(post, :command, :var1)
55
55
 
56
- commit(url("refund"), post)
56
+ commit(url('refund'), post)
57
57
  end
58
58
 
59
59
  def supports_scrubbing?
@@ -82,17 +82,17 @@ module ActiveMerchant #:nodoc:
82
82
 
83
83
  digest_keys = PAYMENT_DIGEST_KEYS if digest_keys.empty?
84
84
  digest = Digest::SHA2.new(512)
85
- digest << @options[:key] << "|"
85
+ digest << @options[:key] << '|'
86
86
  digest_keys.each do |key|
87
- digest << (post[key.to_sym] || "") << "|"
87
+ digest << (post[key.to_sym] || '') << '|'
88
88
  end
89
89
  digest << @options[:salt]
90
90
  post[:hash] = digest.hexdigest
91
91
  end
92
92
 
93
93
  def add_customer_data(post, options)
94
- post[:email] = clean(options[:email] || "unknown@example.com", nil, 50)
95
- post[:phone] = clean((options[:billing_address] && options[:billing_address][:phone]) || "11111111111", :numeric, 50)
94
+ post[:email] = clean(options[:email] || 'unknown@example.com', nil, 50)
95
+ post[:phone] = clean((options[:billing_address] && options[:billing_address][:phone]) || '11111111111', :numeric, 50)
96
96
  end
97
97
 
98
98
  def add_addresses(post, options)
@@ -109,7 +109,7 @@ module ActiveMerchant #:nodoc:
109
109
  if options[:shipping_address][:name]
110
110
  first, *rest = options[:shipping_address][:name].split(/\s+/)
111
111
  post[:shipping_firstname] = clean(first, :name, 60)
112
- post[:shipping_lastname] = clean(rest.join(" "), :name, 20)
112
+ post[:shipping_lastname] = clean(rest.join(' '), :name, 20)
113
113
  end
114
114
  post[:shipping_address1] = clean(options[:shipping_address][:address1], :text, 100)
115
115
  post[:shipping_address2] = clean(options[:shipping_address][:address2], :text, 100)
@@ -125,22 +125,22 @@ module ActiveMerchant #:nodoc:
125
125
  post[:amount] = amount(money)
126
126
 
127
127
  post[:txnid] = clean(options[:order_id], :alphanumeric, 30)
128
- post[:productinfo] = clean(options[:description] || "Purchase", nil, 100)
128
+ post[:productinfo] = clean(options[:description] || 'Purchase', nil, 100)
129
129
 
130
- post[:surl] = "http://example.com"
131
- post[:furl] = "http://example.com"
130
+ post[:surl] = 'http://example.com'
131
+ post[:furl] = 'http://example.com'
132
132
  end
133
133
 
134
134
  BRAND_MAP = {
135
- visa: "VISA",
136
- master: "MAST",
137
- american_express: "AMEX",
138
- diners_club: "DINR",
139
- maestro: "MAES"
135
+ visa: 'VISA',
136
+ master: 'MAST',
137
+ american_express: 'AMEX',
138
+ diners_club: 'DINR',
139
+ maestro: 'MAES'
140
140
  }
141
141
 
142
142
  def add_payment(post, payment)
143
- post[:pg] = "CC"
143
+ post[:pg] = 'CC'
144
144
  post[:firstname] = clean(payment.first_name, :name, 60)
145
145
  post[:lastname] = clean(payment.last_name, :name, 20)
146
146
 
@@ -153,31 +153,32 @@ module ActiveMerchant #:nodoc:
153
153
  end
154
154
 
155
155
  def clean(value, format, maxlength)
156
- value ||= ""
157
- value = case format
158
- when :alphanumeric
159
- value.gsub(/[^A-Za-z0-9]/, "")
160
- when :name
161
- value.gsub(/[^A-Za-z ]/, "")
162
- when :numeric
163
- value.gsub(/[^0-9]/, "")
164
- when :text
165
- value.gsub(/[^A-Za-z0-9@\-_\/\. ]/, "")
166
- when nil
167
- value
168
- else
169
- raise "Unknown format #{format} for #{value}"
170
- end
156
+ value ||= ''
157
+ value =
158
+ case format
159
+ when :alphanumeric
160
+ value.gsub(/[^A-Za-z0-9]/, '')
161
+ when :name
162
+ value.gsub(/[^A-Za-z ]/, '')
163
+ when :numeric
164
+ value.gsub(/[^0-9]/, '')
165
+ when :text
166
+ value.gsub(/[^A-Za-z0-9@\-_\/\. ]/, '')
167
+ when nil
168
+ value
169
+ else
170
+ raise "Unknown format #{format} for #{value}"
171
+ end
171
172
  value[0...maxlength]
172
173
  end
173
174
 
174
175
  def parse(body)
175
176
  top = JSON.parse(body)
176
177
 
177
- if result = top.delete("result")
178
- result.split("&").inject({}) do |hash, string|
179
- key, value = string.split("=")
180
- hash[CGI.unescape(key).downcase] = CGI.unescape(value || "")
178
+ if result = top.delete('result')
179
+ result.split('&').inject({}) do |hash, string|
180
+ key, value = string.split('=')
181
+ hash[CGI.unescape(key).downcase] = CGI.unescape(value || '')
181
182
  hash
182
183
  end.each do |key, value|
183
184
  if top[key]
@@ -188,19 +189,19 @@ module ActiveMerchant #:nodoc:
188
189
  end
189
190
  end
190
191
 
191
- if response = top.delete("response")
192
+ if response = top.delete('response')
192
193
  top.merge!(response)
193
194
  end
194
195
 
195
196
  top
196
197
  rescue JSON::ParserError
197
198
  {
198
- "error" => "Invalid response received from the PayU API. (The raw response was `#{body}`)."
199
+ 'error' => "Invalid response received from the PayU API. (The raw response was `#{body}`)."
199
200
  }
200
201
  end
201
202
 
202
203
  def commit(url, parameters)
203
- response = parse(ssl_post(url, post_data(parameters), "Accept-Encoding" => "identity"))
204
+ response = parse(ssl_post(url, post_data(parameters), 'Accept-Encoding' => 'identity'))
204
205
 
205
206
  Response.new(
206
207
  success_from(response),
@@ -213,7 +214,7 @@ module ActiveMerchant #:nodoc:
213
214
 
214
215
  def url(action)
215
216
  case action
216
- when "purchase"
217
+ when 'purchase'
217
218
  (test? ? test_url : live_url)
218
219
  else
219
220
  (test? ? TEST_INFO_URL : LIVE_INFO_URL)
@@ -221,19 +222,19 @@ module ActiveMerchant #:nodoc:
221
222
  end
222
223
 
223
224
  def success_from(response)
224
- if response["result_status"]
225
- (response["status"] == "success" && response["result_status"] == "success")
225
+ if response['result_status']
226
+ (response['status'] == 'success' && response['result_status'] == 'success')
226
227
  else
227
- (response["status"] == "success" || response["status"].to_s == "1")
228
+ (response['status'] == 'success' || response['status'].to_s == '1')
228
229
  end
229
230
  end
230
231
 
231
232
  def message_from(response)
232
- (response["error_message"] || response["error"] || response["msg"])
233
+ (response['error_message'] || response['error'] || response['msg'])
233
234
  end
234
235
 
235
236
  def authorization_from(response)
236
- response["mihpayid"]
237
+ response['mihpayid']
237
238
  end
238
239
 
239
240
  def post_data(parameters = {})
@@ -241,7 +242,7 @@ module ActiveMerchant #:nodoc:
241
242
  end
242
243
 
243
244
  def handle_3dsecure(response)
244
- Response.new(false, "3D-secure enrolled cards are not supported.")
245
+ Response.new(false, '3D-secure enrolled cards are not supported.')
245
246
  end
246
247
  end
247
248
  end