activemerchant 1.38.0 → 1.79.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (400) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +1402 -3
  3. data/CONTRIBUTORS +154 -0
  4. data/README.md +157 -144
  5. data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
  6. data/lib/active_merchant/billing/base.rb +21 -17
  7. data/lib/active_merchant/billing/check.rb +32 -22
  8. data/lib/active_merchant/billing/compatibility.rb +120 -0
  9. data/lib/active_merchant/billing/credit_card.rb +215 -67
  10. data/lib/active_merchant/billing/credit_card_formatting.rb +4 -1
  11. data/lib/active_merchant/billing/credit_card_methods.rb +152 -53
  12. data/lib/active_merchant/billing/cvv_result.rb +15 -15
  13. data/lib/active_merchant/billing/gateway.rb +170 -24
  14. data/lib/active_merchant/billing/gateways/adyen.rb +299 -0
  15. data/lib/active_merchant/billing/gateways/allied_wallet.rb +206 -0
  16. data/lib/active_merchant/billing/gateways/authorize_net.rb +904 -606
  17. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +417 -0
  18. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +43 -18
  19. data/lib/active_merchant/billing/gateways/axcessms.rb +181 -0
  20. data/lib/active_merchant/billing/gateways/balanced.rb +134 -346
  21. data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
  22. data/lib/active_merchant/billing/gateways/banwire.rb +13 -2
  23. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +326 -0
  24. data/lib/active_merchant/billing/gateways/be2bill.rb +131 -0
  25. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +96 -15
  26. data/lib/active_merchant/billing/gateways/beanstream.rb +52 -9
  27. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +12 -8
  28. data/lib/active_merchant/billing/gateways/blue_pay.rb +520 -501
  29. data/lib/active_merchant/billing/gateways/blue_snap.rb +343 -0
  30. data/lib/active_merchant/billing/gateways/bogus.rb +94 -50
  31. data/lib/active_merchant/billing/gateways/borgun.rb +221 -0
  32. data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
  33. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +15 -2
  34. data/lib/active_merchant/billing/gateways/braintree.rb +2 -2
  35. data/lib/active_merchant/billing/gateways/braintree_blue.rb +387 -139
  36. data/lib/active_merchant/billing/gateways/braintree_orange.rb +4 -4
  37. data/lib/active_merchant/billing/gateways/bridge_pay.rb +245 -0
  38. data/lib/active_merchant/billing/gateways/cams.rb +230 -0
  39. data/lib/active_merchant/billing/gateways/card_connect.rb +286 -0
  40. data/lib/active_merchant/billing/gateways/card_stream.rb +269 -118
  41. data/lib/active_merchant/billing/gateways/cardknox.rb +328 -0
  42. data/lib/active_merchant/billing/gateways/cardprocess.rb +254 -0
  43. data/lib/active_merchant/billing/gateways/cashnet.rb +219 -0
  44. data/lib/active_merchant/billing/gateways/cc5.rb +45 -0
  45. data/lib/active_merchant/billing/gateways/cecabank.rb +239 -0
  46. data/lib/active_merchant/billing/gateways/cenpos.rb +327 -0
  47. data/lib/active_merchant/billing/gateways/checkout.rb +214 -0
  48. data/lib/active_merchant/billing/gateways/checkout_v2.rb +233 -0
  49. data/lib/active_merchant/billing/gateways/citrus_pay.rb +23 -0
  50. data/lib/active_merchant/billing/gateways/clearhaus.rb +220 -0
  51. data/lib/active_merchant/billing/gateways/commercegate.rb +143 -0
  52. data/lib/active_merchant/billing/gateways/conekta.rb +225 -0
  53. data/lib/active_merchant/billing/gateways/creditcall.rb +272 -0
  54. data/lib/active_merchant/billing/gateways/credorax.rb +345 -0
  55. data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
  56. data/lib/active_merchant/billing/gateways/cyber_source.rb +237 -98
  57. data/lib/active_merchant/billing/gateways/data_cash.rb +41 -314
  58. data/lib/active_merchant/billing/gateways/dibs.rb +205 -0
  59. data/lib/active_merchant/billing/gateways/digitzs.rb +292 -0
  60. data/lib/active_merchant/billing/gateways/ebanx.rb +296 -0
  61. data/lib/active_merchant/billing/gateways/efsnet.rb +3 -14
  62. data/lib/active_merchant/billing/gateways/elavon.rb +143 -142
  63. data/lib/active_merchant/billing/gateways/element.rb +356 -0
  64. data/lib/active_merchant/billing/gateways/epay.rb +23 -12
  65. data/lib/active_merchant/billing/gateways/eway.rb +12 -12
  66. data/lib/active_merchant/billing/gateways/eway_managed.rb +1 -1
  67. data/lib/active_merchant/billing/gateways/eway_rapid.rb +417 -204
  68. data/lib/active_merchant/billing/gateways/exact.rb +10 -1
  69. data/lib/active_merchant/billing/gateways/ezic.rb +196 -0
  70. data/lib/active_merchant/billing/gateways/fat_zebra.rb +65 -37
  71. data/lib/active_merchant/billing/gateways/federated_canada.rb +1 -8
  72. data/lib/active_merchant/billing/gateways/finansbank.rb +3 -2
  73. data/lib/active_merchant/billing/gateways/first_giving.rb +143 -0
  74. data/lib/active_merchant/billing/gateways/first_pay.rb +110 -124
  75. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +155 -29
  76. data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
  77. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
  78. data/lib/active_merchant/billing/gateways/forte.rb +256 -0
  79. data/lib/active_merchant/billing/gateways/garanti.rb +11 -5
  80. data/lib/active_merchant/billing/gateways/global_collect.rb +334 -0
  81. data/lib/active_merchant/billing/gateways/global_transport.rb +194 -0
  82. data/lib/active_merchant/billing/gateways/hps.rb +305 -0
  83. data/lib/active_merchant/billing/gateways/iats_payments.rb +271 -16
  84. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +2 -5
  85. data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +0 -0
  86. data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +1 -1
  87. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
  88. data/lib/active_merchant/billing/gateways/inspire.rb +8 -10
  89. data/lib/active_merchant/billing/gateways/instapay.rb +0 -0
  90. data/lib/active_merchant/billing/gateways/ipp.rb +175 -0
  91. data/lib/active_merchant/billing/gateways/iridium.rb +210 -4
  92. data/lib/active_merchant/billing/gateways/iveri.rb +251 -0
  93. data/lib/active_merchant/billing/gateways/jetpay.rb +176 -49
  94. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +437 -0
  95. data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
  96. data/lib/active_merchant/billing/gateways/kushki.rb +227 -0
  97. data/lib/active_merchant/billing/gateways/latitude19.rb +416 -0
  98. data/lib/active_merchant/billing/gateways/linkpoint.rb +17 -13
  99. data/lib/active_merchant/billing/gateways/litle.rb +329 -439
  100. data/lib/active_merchant/billing/gateways/mastercard.rb +268 -0
  101. data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
  102. data/lib/active_merchant/billing/gateways/mercado_pago.rb +262 -0
  103. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +26 -7
  104. data/lib/active_merchant/billing/gateways/merchant_one.rb +0 -1
  105. data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
  106. data/lib/active_merchant/billing/gateways/merchant_ware.rb +12 -15
  107. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +24 -13
  108. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +33 -14
  109. data/lib/active_merchant/billing/gateways/mercury.rb +74 -29
  110. data/lib/active_merchant/billing/gateways/metrics_global.rb +2 -21
  111. data/lib/active_merchant/billing/gateways/micropayment.rb +185 -0
  112. data/lib/active_merchant/billing/gateways/migs.rb +73 -14
  113. data/lib/active_merchant/billing/gateways/modern_payments.rb +1 -1
  114. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +1 -3
  115. data/lib/active_merchant/billing/gateways/monei.rb +307 -0
  116. data/lib/active_merchant/billing/gateways/moneris.rb +119 -36
  117. data/lib/active_merchant/billing/gateways/moneris_us.rb +146 -45
  118. data/lib/active_merchant/billing/gateways/money_movers.rb +152 -0
  119. data/lib/active_merchant/billing/gateways/mundipagg.rb +292 -0
  120. data/lib/active_merchant/billing/gateways/nab_transact.rb +81 -56
  121. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +165 -0
  122. data/lib/active_merchant/billing/gateways/net_registry.rb +8 -3
  123. data/lib/active_merchant/billing/gateways/netbanx.rb +289 -0
  124. data/lib/active_merchant/billing/gateways/netbilling.rb +61 -26
  125. data/lib/active_merchant/billing/gateways/netpay.rb +1 -1
  126. data/lib/active_merchant/billing/gateways/network_merchants.rb +242 -0
  127. data/lib/active_merchant/billing/gateways/nmi.rb +265 -10
  128. data/lib/active_merchant/billing/gateways/ogone.rb +85 -27
  129. data/lib/active_merchant/billing/gateways/omise.rb +324 -0
  130. data/lib/active_merchant/billing/gateways/openpay.rb +227 -0
  131. data/lib/active_merchant/billing/gateways/opp.rb +372 -0
  132. data/lib/active_merchant/billing/gateways/optimal_payment.rb +59 -28
  133. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +22 -21
  134. data/lib/active_merchant/billing/gateways/orbital.rb +346 -56
  135. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +207 -0
  136. data/lib/active_merchant/billing/gateways/pagarme.rb +248 -0
  137. data/lib/active_merchant/billing/gateways/pago_facil.rb +122 -0
  138. data/lib/active_merchant/billing/gateways/pay_conex.rb +246 -0
  139. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +30 -14
  140. data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
  141. data/lib/active_merchant/billing/gateways/pay_junction.rb +19 -25
  142. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +190 -0
  143. data/lib/active_merchant/billing/gateways/pay_secure.rb +0 -7
  144. data/lib/active_merchant/billing/gateways/paybox_direct.rb +16 -12
  145. data/lib/active_merchant/billing/gateways/payeezy.rb +386 -0
  146. data/lib/active_merchant/billing/gateways/payex.rb +412 -0
  147. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +38 -17
  148. data/lib/active_merchant/billing/gateways/payflow.rb +100 -19
  149. data/lib/active_merchant/billing/gateways/payflow_express.rb +22 -22
  150. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +2 -2
  151. data/lib/active_merchant/billing/gateways/payflow_uk.rb +6 -6
  152. data/lib/active_merchant/billing/gateways/payment_express.rb +15 -3
  153. data/lib/active_merchant/billing/gateways/paymentez.rb +276 -0
  154. data/lib/active_merchant/billing/gateways/paymill.rb +237 -48
  155. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +55 -8
  156. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +4 -0
  157. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +18 -4
  158. data/lib/active_merchant/billing/gateways/paypal.rb +37 -20
  159. data/lib/active_merchant/billing/gateways/paypal_ca.rb +1 -1
  160. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +6 -5
  161. data/lib/active_merchant/billing/gateways/paypal_express.rb +32 -4
  162. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +3 -3
  163. data/lib/active_merchant/billing/gateways/payscout.rb +162 -0
  164. data/lib/active_merchant/billing/gateways/paystation.rb +32 -24
  165. data/lib/active_merchant/billing/gateways/payu_in.rb +248 -0
  166. data/lib/active_merchant/billing/gateways/payu_latam.rb +440 -0
  167. data/lib/active_merchant/billing/gateways/pin.rb +68 -13
  168. data/lib/active_merchant/billing/gateways/plugnpay.rb +1 -12
  169. data/lib/active_merchant/billing/gateways/pro_pay.rb +326 -0
  170. data/lib/active_merchant/billing/gateways/psigate.rb +14 -14
  171. data/lib/active_merchant/billing/gateways/psl_card.rb +3 -3
  172. data/lib/active_merchant/billing/gateways/qbms.rb +12 -1
  173. data/lib/active_merchant/billing/gateways/quantum.rb +2 -2
  174. data/lib/active_merchant/billing/gateways/quickbooks.rb +290 -0
  175. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +188 -0
  176. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +299 -0
  177. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +227 -0
  178. data/lib/active_merchant/billing/gateways/quickpay.rb +10 -319
  179. data/lib/active_merchant/billing/gateways/qvalent.rb +236 -0
  180. data/lib/active_merchant/billing/gateways/realex.rb +40 -25
  181. data/lib/active_merchant/billing/gateways/redsys.rb +212 -80
  182. data/lib/active_merchant/billing/gateways/s5.rb +247 -0
  183. data/lib/active_merchant/billing/gateways/safe_charge.rb +262 -0
  184. data/lib/active_merchant/billing/gateways/sage.rb +412 -119
  185. data/lib/active_merchant/billing/gateways/sage_pay.rb +176 -59
  186. data/lib/active_merchant/billing/gateways/secure_net.rb +35 -29
  187. data/lib/active_merchant/billing/gateways/secure_pay.rb +182 -9
  188. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +21 -7
  189. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +0 -7
  190. data/lib/active_merchant/billing/gateways/securion_pay.rb +267 -0
  191. data/lib/active_merchant/billing/gateways/skip_jack.rb +1 -3
  192. data/lib/active_merchant/billing/gateways/smart_ps.rb +14 -3
  193. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
  194. data/lib/active_merchant/billing/gateways/spreedly_core.rb +74 -14
  195. data/lib/active_merchant/billing/gateways/stripe.rb +472 -83
  196. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +156 -0
  197. data/lib/active_merchant/billing/gateways/telr.rb +275 -0
  198. data/lib/active_merchant/billing/gateways/tns.rb +22 -0
  199. data/lib/active_merchant/billing/gateways/trans_first.rb +142 -28
  200. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +608 -0
  201. data/lib/active_merchant/billing/gateways/transact_pro.rb +224 -0
  202. data/lib/active_merchant/billing/gateways/transnational.rb +2 -231
  203. data/lib/active_merchant/billing/gateways/trexle.rb +217 -0
  204. data/lib/active_merchant/billing/gateways/trust_commerce.rb +17 -11
  205. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +193 -75
  206. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +156 -64
  207. data/lib/active_merchant/billing/gateways/vanco.rb +294 -0
  208. data/lib/active_merchant/billing/gateways/verifi.rb +1 -8
  209. data/lib/active_merchant/billing/gateways/viaklix.rb +1 -15
  210. data/lib/active_merchant/billing/gateways/visanet_peru.rb +209 -0
  211. data/lib/active_merchant/billing/gateways/webpay.rb +45 -28
  212. data/lib/active_merchant/billing/gateways/wepay.rb +238 -0
  213. data/lib/active_merchant/billing/gateways/wirecard.rb +167 -49
  214. data/lib/active_merchant/billing/gateways/world_net.rb +344 -0
  215. data/lib/active_merchant/billing/gateways/worldpay.rb +171 -45
  216. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +218 -0
  217. data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
  218. data/lib/active_merchant/billing/gateways.rb +8 -11
  219. data/lib/active_merchant/billing/model.rb +30 -0
  220. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
  221. data/lib/active_merchant/billing/payment_token.rb +21 -0
  222. data/lib/active_merchant/billing/rails.rb +3 -0
  223. data/lib/active_merchant/billing/response.rb +24 -17
  224. data/lib/active_merchant/billing.rb +7 -1
  225. data/lib/active_merchant/connection.rb +208 -0
  226. data/lib/active_merchant/country.rb +334 -0
  227. data/lib/active_merchant/empty.rb +20 -0
  228. data/lib/active_merchant/errors.rb +35 -0
  229. data/lib/active_merchant/net_http_ssl_connection.rb +9 -0
  230. data/lib/active_merchant/network_connection_retries.rb +81 -0
  231. data/lib/active_merchant/post_data.rb +24 -0
  232. data/lib/active_merchant/posts_data.rb +94 -0
  233. data/lib/active_merchant/version.rb +1 -1
  234. data/lib/active_merchant.rb +22 -22
  235. data/lib/certs/cacert.pem +3951 -0
  236. data/lib/support/gateway_support.rb +16 -10
  237. data/lib/support/outbound_hosts.rb +13 -10
  238. data/lib/support/ssl_version.rb +87 -0
  239. metadata +164 -306
  240. data/gem-public_cert.pem +0 -20
  241. data/lib/active_merchant/billing/expiry_date.rb +0 -34
  242. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +0 -314
  243. data/lib/active_merchant/billing/gateways/card_stream_modern.rb +0 -155
  244. data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -277
  245. data/lib/active_merchant/billing/gateways/orbital/avs_result.rb +0 -93
  246. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +0 -93
  247. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +0 -114
  248. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +0 -102
  249. data/lib/active_merchant/billing/gateways/samurai.rb +0 -118
  250. data/lib/active_merchant/billing/gateways/vindicia.rb +0 -361
  251. data/lib/active_merchant/billing/integrations/a1agregator/helper.rb +0 -31
  252. data/lib/active_merchant/billing/integrations/a1agregator/notification.rb +0 -186
  253. data/lib/active_merchant/billing/integrations/a1agregator/status.rb +0 -38
  254. data/lib/active_merchant/billing/integrations/a1agregator.rb +0 -26
  255. data/lib/active_merchant/billing/integrations/action_view_helper.rb +0 -73
  256. data/lib/active_merchant/billing/integrations/authorize_net_sim/helper.rb +0 -229
  257. data/lib/active_merchant/billing/integrations/authorize_net_sim/notification.rb +0 -340
  258. data/lib/active_merchant/billing/integrations/authorize_net_sim.rb +0 -38
  259. data/lib/active_merchant/billing/integrations/bogus/helper.rb +0 -17
  260. data/lib/active_merchant/billing/integrations/bogus/notification.rb +0 -11
  261. data/lib/active_merchant/billing/integrations/bogus/return.rb +0 -10
  262. data/lib/active_merchant/billing/integrations/bogus.rb +0 -23
  263. data/lib/active_merchant/billing/integrations/chronopay/helper.rb +0 -120
  264. data/lib/active_merchant/billing/integrations/chronopay/notification.rb +0 -158
  265. data/lib/active_merchant/billing/integrations/chronopay/return.rb +0 -10
  266. data/lib/active_merchant/billing/integrations/chronopay.rb +0 -23
  267. data/lib/active_merchant/billing/integrations/direc_pay/helper.rb +0 -200
  268. data/lib/active_merchant/billing/integrations/direc_pay/notification.rb +0 -76
  269. data/lib/active_merchant/billing/integrations/direc_pay/return.rb +0 -32
  270. data/lib/active_merchant/billing/integrations/direc_pay/status.rb +0 -37
  271. data/lib/active_merchant/billing/integrations/direc_pay.rb +0 -41
  272. data/lib/active_merchant/billing/integrations/directebanking/helper.rb +0 -90
  273. data/lib/active_merchant/billing/integrations/directebanking/notification.rb +0 -120
  274. data/lib/active_merchant/billing/integrations/directebanking/return.rb +0 -11
  275. data/lib/active_merchant/billing/integrations/directebanking.rb +0 -47
  276. data/lib/active_merchant/billing/integrations/dotpay/helper.rb +0 -77
  277. data/lib/active_merchant/billing/integrations/dotpay/notification.rb +0 -86
  278. data/lib/active_merchant/billing/integrations/dotpay/return.rb +0 -11
  279. data/lib/active_merchant/billing/integrations/dotpay.rb +0 -22
  280. data/lib/active_merchant/billing/integrations/dwolla/common.rb +0 -23
  281. data/lib/active_merchant/billing/integrations/dwolla/helper.rb +0 -43
  282. data/lib/active_merchant/billing/integrations/dwolla/notification.rb +0 -64
  283. data/lib/active_merchant/billing/integrations/dwolla/return.rb +0 -49
  284. data/lib/active_merchant/billing/integrations/dwolla.rb +0 -23
  285. data/lib/active_merchant/billing/integrations/e_payment_plans/helper.rb +0 -34
  286. data/lib/active_merchant/billing/integrations/e_payment_plans/notification.rb +0 -84
  287. data/lib/active_merchant/billing/integrations/e_payment_plans.rb +0 -48
  288. data/lib/active_merchant/billing/integrations/easy_pay/common.rb +0 -40
  289. data/lib/active_merchant/billing/integrations/easy_pay/helper.rb +0 -36
  290. data/lib/active_merchant/billing/integrations/easy_pay/notification.rb +0 -59
  291. data/lib/active_merchant/billing/integrations/easy_pay.rb +0 -30
  292. data/lib/active_merchant/billing/integrations/epay/helper.rb +0 -55
  293. data/lib/active_merchant/billing/integrations/epay/notification.rb +0 -110
  294. data/lib/active_merchant/billing/integrations/epay.rb +0 -21
  295. data/lib/active_merchant/billing/integrations/first_data/helper.rb +0 -61
  296. data/lib/active_merchant/billing/integrations/first_data/notification.rb +0 -56
  297. data/lib/active_merchant/billing/integrations/first_data.rb +0 -38
  298. data/lib/active_merchant/billing/integrations/gestpay/common.rb +0 -42
  299. data/lib/active_merchant/billing/integrations/gestpay/helper.rb +0 -70
  300. data/lib/active_merchant/billing/integrations/gestpay/notification.rb +0 -85
  301. data/lib/active_merchant/billing/integrations/gestpay/return.rb +0 -10
  302. data/lib/active_merchant/billing/integrations/gestpay.rb +0 -25
  303. data/lib/active_merchant/billing/integrations/helper.rb +0 -117
  304. data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +0 -58
  305. data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +0 -59
  306. data/lib/active_merchant/billing/integrations/hi_trust/return.rb +0 -68
  307. data/lib/active_merchant/billing/integrations/hi_trust.rb +0 -27
  308. data/lib/active_merchant/billing/integrations/ipay88/helper.rb +0 -114
  309. data/lib/active_merchant/billing/integrations/ipay88/return.rb +0 -95
  310. data/lib/active_merchant/billing/integrations/ipay88.rb +0 -19
  311. data/lib/active_merchant/billing/integrations/liqpay/helper.rb +0 -43
  312. data/lib/active_merchant/billing/integrations/liqpay/notification.rb +0 -89
  313. data/lib/active_merchant/billing/integrations/liqpay/return.rb +0 -83
  314. data/lib/active_merchant/billing/integrations/liqpay.rb +0 -30
  315. data/lib/active_merchant/billing/integrations/maksuturva/helper.rb +0 -119
  316. data/lib/active_merchant/billing/integrations/maksuturva/notification.rb +0 -48
  317. data/lib/active_merchant/billing/integrations/maksuturva.rb +0 -86
  318. data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +0 -75
  319. data/lib/active_merchant/billing/integrations/moneybookers/notification.rb +0 -129
  320. data/lib/active_merchant/billing/integrations/moneybookers.rb +0 -26
  321. data/lib/active_merchant/billing/integrations/nochex/helper.rb +0 -68
  322. data/lib/active_merchant/billing/integrations/nochex/notification.rb +0 -94
  323. data/lib/active_merchant/billing/integrations/nochex/return.rb +0 -10
  324. data/lib/active_merchant/billing/integrations/nochex.rb +0 -88
  325. data/lib/active_merchant/billing/integrations/notification.rb +0 -71
  326. data/lib/active_merchant/billing/integrations/paxum/common.rb +0 -24
  327. data/lib/active_merchant/billing/integrations/paxum/helper.rb +0 -42
  328. data/lib/active_merchant/billing/integrations/paxum/notification.rb +0 -33
  329. data/lib/active_merchant/billing/integrations/paxum.rb +0 -44
  330. data/lib/active_merchant/billing/integrations/pay_fast/common.rb +0 -42
  331. data/lib/active_merchant/billing/integrations/pay_fast/helper.rb +0 -50
  332. data/lib/active_merchant/billing/integrations/pay_fast/notification.rb +0 -134
  333. data/lib/active_merchant/billing/integrations/pay_fast/return.rb +0 -10
  334. data/lib/active_merchant/billing/integrations/pay_fast.rb +0 -70
  335. data/lib/active_merchant/billing/integrations/payflow_link/helper.rb +0 -116
  336. data/lib/active_merchant/billing/integrations/payflow_link/notification.rb +0 -78
  337. data/lib/active_merchant/billing/integrations/payflow_link.rb +0 -21
  338. data/lib/active_merchant/billing/integrations/paypal/helper.rb +0 -119
  339. data/lib/active_merchant/billing/integrations/paypal/notification.rb +0 -227
  340. data/lib/active_merchant/billing/integrations/paypal/return.rb +0 -10
  341. data/lib/active_merchant/billing/integrations/paypal.rb +0 -39
  342. data/lib/active_merchant/billing/integrations/paypal_payments_advanced/helper.rb +0 -15
  343. data/lib/active_merchant/billing/integrations/paypal_payments_advanced.rb +0 -20
  344. data/lib/active_merchant/billing/integrations/paysbuy/helper.rb +0 -15
  345. data/lib/active_merchant/billing/integrations/paysbuy/notification.rb +0 -28
  346. data/lib/active_merchant/billing/integrations/paysbuy.rb +0 -36
  347. data/lib/active_merchant/billing/integrations/payu_in/helper.rb +0 -74
  348. data/lib/active_merchant/billing/integrations/payu_in/notification.rb +0 -165
  349. data/lib/active_merchant/billing/integrations/payu_in/return.rb +0 -36
  350. data/lib/active_merchant/billing/integrations/payu_in.rb +0 -43
  351. data/lib/active_merchant/billing/integrations/platron/helper.rb +0 -32
  352. data/lib/active_merchant/billing/integrations/platron/notification.rb +0 -113
  353. data/lib/active_merchant/billing/integrations/platron.rb +0 -28
  354. data/lib/active_merchant/billing/integrations/pxpay/helper.rb +0 -112
  355. data/lib/active_merchant/billing/integrations/pxpay/notification.rb +0 -157
  356. data/lib/active_merchant/billing/integrations/pxpay/return.rb +0 -25
  357. data/lib/active_merchant/billing/integrations/pxpay.rb +0 -31
  358. data/lib/active_merchant/billing/integrations/quickpay/helper.rb +0 -74
  359. data/lib/active_merchant/billing/integrations/quickpay/notification.rb +0 -137
  360. data/lib/active_merchant/billing/integrations/quickpay.rb +0 -21
  361. data/lib/active_merchant/billing/integrations/rbkmoney/helper.rb +0 -23
  362. data/lib/active_merchant/billing/integrations/rbkmoney/notification.rb +0 -91
  363. data/lib/active_merchant/billing/integrations/rbkmoney.rb +0 -17
  364. data/lib/active_merchant/billing/integrations/return.rb +0 -42
  365. data/lib/active_merchant/billing/integrations/robokassa/common.rb +0 -19
  366. data/lib/active_merchant/billing/integrations/robokassa/helper.rb +0 -50
  367. data/lib/active_merchant/billing/integrations/robokassa/notification.rb +0 -55
  368. data/lib/active_merchant/billing/integrations/robokassa/return.rb +0 -17
  369. data/lib/active_merchant/billing/integrations/robokassa.rb +0 -49
  370. data/lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb +0 -33
  371. data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +0 -136
  372. data/lib/active_merchant/billing/integrations/sage_pay_form/notification.rb +0 -210
  373. data/lib/active_merchant/billing/integrations/sage_pay_form/return.rb +0 -31
  374. data/lib/active_merchant/billing/integrations/sage_pay_form.rb +0 -37
  375. data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +0 -91
  376. data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +0 -139
  377. data/lib/active_merchant/billing/integrations/two_checkout/return.rb +0 -17
  378. data/lib/active_merchant/billing/integrations/two_checkout.rb +0 -44
  379. data/lib/active_merchant/billing/integrations/valitor/helper.rb +0 -86
  380. data/lib/active_merchant/billing/integrations/valitor/notification.rb +0 -13
  381. data/lib/active_merchant/billing/integrations/valitor/response_fields.rb +0 -97
  382. data/lib/active_merchant/billing/integrations/valitor/return.rb +0 -13
  383. data/lib/active_merchant/billing/integrations/valitor.rb +0 -33
  384. data/lib/active_merchant/billing/integrations/verkkomaksut/helper.rb +0 -88
  385. data/lib/active_merchant/billing/integrations/verkkomaksut/notification.rb +0 -59
  386. data/lib/active_merchant/billing/integrations/verkkomaksut.rb +0 -20
  387. data/lib/active_merchant/billing/integrations/web_pay/common.rb +0 -50
  388. data/lib/active_merchant/billing/integrations/web_pay/helper.rb +0 -68
  389. data/lib/active_merchant/billing/integrations/web_pay/notification.rb +0 -51
  390. data/lib/active_merchant/billing/integrations/web_pay.rb +0 -45
  391. data/lib/active_merchant/billing/integrations/webmoney/common.rb +0 -17
  392. data/lib/active_merchant/billing/integrations/webmoney/helper.rb +0 -40
  393. data/lib/active_merchant/billing/integrations/webmoney/notification.rb +0 -47
  394. data/lib/active_merchant/billing/integrations/webmoney.rb +0 -43
  395. data/lib/active_merchant/billing/integrations/world_pay/helper.rb +0 -101
  396. data/lib/active_merchant/billing/integrations/world_pay/notification.rb +0 -160
  397. data/lib/active_merchant/billing/integrations/world_pay.rb +0 -34
  398. data/lib/active_merchant/billing/integrations.rb +0 -17
  399. data.tar.gz.sig +0 -0
  400. metadata.gz.sig +0 -0
@@ -2,9 +2,9 @@ module ActiveMerchant #:nodoc:
2
2
  module Billing #:nodoc:
3
3
  # Convenience methods that can be included into a custom Credit Card object, such as an ActiveRecord based Credit Card object.
4
4
  module CreditCardMethods
5
- CARD_COMPANIES = {
6
- 'visa' => /^4\d{12}(\d{3})?$/,
7
- 'master' => /^(5[1-5]\d{4}|677189)\d{10}$/,
5
+ CARD_COMPANIES = {
6
+ 'visa' => /^4\d{12}(\d{3})?(\d{3})?$/,
7
+ 'master' => /^(5[1-5]\d{4}|677189|222[1-9]\d{2}|22[3-9]\d{3}|2[3-6]\d{4}|27[01]\d{3}|2720\d{2})\d{10}$/,
8
8
  'discover' => /^(6011|65\d{2}|64[4-9]\d)\d{12}|(62\d{14})$/,
9
9
  'american_express' => /^3[47]\d{13}$/,
10
10
  'diners_club' => /^3(0[0-5]|[68]\d)\d{11}$/,
@@ -14,128 +14,227 @@ module ActiveMerchant #:nodoc:
14
14
  'dankort' => /^5019\d{12}$/,
15
15
  'maestro' => /^(5[06-8]|6\d)\d{10,17}$/,
16
16
  'forbrugsforeningen' => /^600722\d{10}$/,
17
- 'laser' => /^(6304|6706|6709|6771(?!89))\d{8}(\d{4}|\d{6,7})?$/
17
+ 'laser' => /^(6304|6706|6709|6771(?!89))\d{8}(\d{4}|\d{6,7})?$/,
18
+ 'sodexo' => /^(606071|603389|606070|606069|606068|600818)\d{8}$/,
19
+ 'vr' => /^(627416|637036)\d{8}$/
18
20
  }
19
-
21
+
22
+ # http://www.barclaycard.co.uk/business/files/bin_rules.pdf
23
+ ELECTRON_RANGES = [
24
+ [400115],
25
+ (400837..400839),
26
+ (412921..412923),
27
+ [417935],
28
+ (419740..419741),
29
+ (419773..419775),
30
+ [424519],
31
+ (424962..424963),
32
+ [437860],
33
+ [444000],
34
+ [459472],
35
+ (484406..484411),
36
+ (484413..484414),
37
+ (484418..484418),
38
+ (484428..484455),
39
+ (491730..491759),
40
+ ]
41
+
20
42
  def self.included(base)
21
43
  base.extend(ClassMethods)
22
44
  end
23
-
45
+
24
46
  def valid_month?(month)
25
47
  (1..12).include?(month.to_i)
26
48
  end
27
-
49
+
50
+ def credit_card?
51
+ true
52
+ end
53
+
28
54
  def valid_expiry_year?(year)
29
55
  (Time.now.year..Time.now.year + 20).include?(year.to_i)
30
56
  end
31
-
57
+
32
58
  def valid_start_year?(year)
33
- year.to_s =~ /^\d{4}$/ && year.to_i > 1987
59
+ ((year.to_s =~ /^\d{4}$/) && (year.to_i > 1987))
60
+ end
61
+
62
+ # Credit card providers have 3 digit verification values
63
+ # This isn't standardised, these are called various names such as
64
+ # CVC, CVV, CID, CSC and more
65
+ # See: http://en.wikipedia.org/wiki/Card_security_code
66
+ # American Express is the exception with 4 digits
67
+ #
68
+ # Below are links from the card providers with their requirements
69
+ # visa: http://usa.visa.com/personal/security/3-digit-security-code.jsp
70
+ # master: http://www.mastercard.com/ca/merchant/en/getstarted/Anatomy_MasterCard.html
71
+ # jcb: http://www.jcbcard.com/security/info.html
72
+ # diners_club: http://www.dinersclub.com/assets/DinersClub_card_ID_features.pdf
73
+ # discover: https://www.discover.com/credit-cards/help-center/glossary.html
74
+ # american_express: https://online.americanexpress.com/myca/fuidfyp/us/action?request_type=un_fuid&Face=en_US
75
+ def valid_card_verification_value?(cvv, brand)
76
+ cvv.to_s =~ /^\d{#{card_verification_value_length(brand)}}$/
77
+ end
78
+
79
+ def card_verification_value_length(brand)
80
+ brand == 'american_express' ? 4 : 3
34
81
  end
35
-
82
+
36
83
  def valid_issue_number?(number)
37
- number.to_s =~ /^\d{1,2}$/
84
+ (number.to_s =~ /^\d{1,2}$/)
85
+ end
86
+
87
+ # Returns if the card matches known Electron BINs
88
+ def electron?
89
+ self.class.electron?(number)
38
90
  end
39
-
91
+
40
92
  module ClassMethods
41
- # Returns true if it validates. Optionally, you can pass a card brand as an argument and
93
+ # Returns true if it validates. Optionally, you can pass a card brand as an argument and
42
94
  # make sure it is of the correct brand.
43
95
  #
44
96
  # References:
45
97
  # - http://perl.about.com/compute/perl/library/nosearch/P073000.htm
46
98
  # - http://www.beachnet.com/~hstiles/cardtype.html
47
99
  def valid_number?(number)
48
- valid_test_mode_card_number?(number) ||
49
- valid_card_number_length?(number) &&
100
+ valid_test_mode_card_number?(number) ||
101
+ valid_card_number_length?(number) &&
102
+ valid_card_number_characters?(number) &&
50
103
  valid_checksum?(number)
51
104
  end
52
-
105
+
53
106
  # Regular expressions for the known card companies.
54
- #
55
- # References:
56
- # - http://en.wikipedia.org/wiki/Credit_card_number
57
- # - http://www.barclaycardbusiness.co.uk/information_zone/processing/bin_rules.html
107
+ #
108
+ # References:
109
+ # - http://en.wikipedia.org/wiki/Credit_card_number
110
+ # - http://www.barclaycardbusiness.co.uk/information_zone/processing/bin_rules.html
58
111
  def card_companies
59
112
  CARD_COMPANIES
60
113
  end
61
-
114
+
62
115
  # Returns a string containing the brand of card from the list of known information below.
63
116
  # Need to check the cards in a particular order, as there is some overlap of the allowable ranges
64
117
  #--
65
- # TODO Refactor this method. We basically need to tighten up the Maestro Regexp.
66
- #
67
- # Right now the Maestro regexp overlaps with the MasterCard regexp (IIRC). If we can tighten
68
- # things up, we can boil this whole thing down to something like...
69
- #
118
+ # TODO Refactor this method. We basically need to tighten up the Maestro Regexp.
119
+ #
120
+ # Right now the Maestro regexp overlaps with the MasterCard regexp (IIRC). If we can tighten
121
+ # things up, we can boil this whole thing down to something like...
122
+ #
70
123
  # def brand?(number)
71
124
  # return 'visa' if valid_test_mode_card_number?(number)
72
125
  # card_companies.find([nil]) { |brand, regexp| number =~ regexp }.first.dup
73
126
  # end
74
- #
127
+ #
75
128
  def brand?(number)
76
129
  return 'bogus' if valid_test_mode_card_number?(number)
77
130
 
78
131
  card_companies.reject { |c,p| c == 'maestro' }.each do |company, pattern|
79
- return company.dup if number =~ pattern
132
+ return company.dup if number =~ pattern
80
133
  end
81
-
134
+
82
135
  return 'maestro' if number =~ card_companies['maestro']
83
136
 
84
137
  return nil
85
138
  end
86
139
 
140
+ def electron?(number)
141
+ return false unless [16, 19].include?(number.length)
142
+
143
+ # don't recalculate for each range
144
+ bank_identification_number = first_digits(number).to_i
145
+
146
+ ELECTRON_RANGES.any? do |range|
147
+ range.include?(bank_identification_number)
148
+ end
149
+ end
150
+
87
151
  def type?(number)
88
- deprecated "CreditCard#type? is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#brand? instead."
152
+ ActiveMerchant.deprecated "CreditCard#type? is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#brand? instead."
89
153
  brand?(number)
90
154
  end
91
-
155
+
92
156
  def first_digits(number)
93
- number.to_s.slice(0,6)
157
+ number.to_s.slice(0,6)
94
158
  end
95
-
96
- def last_digits(number)
97
- number.to_s.length <= 4 ? number : number.to_s.slice(-4..-1)
159
+
160
+ def last_digits(number)
161
+ number.to_s.length <= 4 ? number : number.to_s.slice(-4..-1)
98
162
  end
99
-
163
+
100
164
  def mask(number)
101
165
  "XXXX-XXXX-XXXX-#{last_digits(number)}"
102
166
  end
103
-
167
+
104
168
  # Checks to see if the calculated brand matches the specified brand
105
169
  def matching_brand?(number, brand)
106
170
  brand?(number) == brand
107
171
  end
108
172
 
109
173
  def matching_type?(number, brand)
110
- deprecated "CreditCard#matching_type? is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#matching_brand? instead."
174
+ ActiveMerchant.deprecated "CreditCard#matching_type? is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#matching_brand? instead."
111
175
  matching_brand?(number, brand)
112
176
  end
113
177
 
114
- def deprecated(message)
115
- warn(Kernel.caller[1] + message)
116
- end
117
-
118
178
  private
119
-
179
+
120
180
  def valid_card_number_length?(number) #:nodoc:
121
181
  number.to_s.length >= 12
122
182
  end
123
-
183
+
184
+ def valid_card_number_characters?(number) #:nodoc:
185
+ !number.to_s.match(/\D/)
186
+ end
187
+
124
188
  def valid_test_mode_card_number?(number) #:nodoc:
125
- ActiveMerchant::Billing::Base.test? &&
189
+ ActiveMerchant::Billing::Base.test? &&
126
190
  %w[1 2 3 success failure error].include?(number.to_s)
127
191
  end
128
-
129
- # Checks the validity of a card number by use of the the Luhn Algorithm.
192
+
193
+ ODD_LUHN_VALUE = {
194
+ 48 => 0,
195
+ 49 => 1,
196
+ 50 => 2,
197
+ 51 => 3,
198
+ 52 => 4,
199
+ 53 => 5,
200
+ 54 => 6,
201
+ 55 => 7,
202
+ 56 => 8,
203
+ 57 => 9,
204
+ nil => 0
205
+ }.freeze
206
+
207
+ EVEN_LUHN_VALUE = {
208
+ 48 => 0, # 0 * 2
209
+ 49 => 2, # 1 * 2
210
+ 50 => 4, # 2 * 2
211
+ 51 => 6, # 3 * 2
212
+ 52 => 8, # 4 * 2
213
+ 53 => 1, # 5 * 2 - 9
214
+ 54 => 3, # 6 * 2 - 9
215
+ 55 => 5, # etc ...
216
+ 56 => 7,
217
+ 57 => 9,
218
+ }.freeze
219
+
220
+ # Checks the validity of a card number by use of the Luhn Algorithm.
130
221
  # Please see http://en.wikipedia.org/wiki/Luhn_algorithm for details.
131
- def valid_checksum?(number) #:nodoc:
222
+ # This implementation is from the luhn_checksum gem, https://github.com/zendesk/luhn_checksum.
223
+ def valid_checksum?(numbers) #:nodoc:
132
224
  sum = 0
133
- for i in 0..number.length
134
- weight = number[-1 * (i + 2), 1].to_i * (2 - (i % 2))
135
- sum += (weight < 10) ? weight : weight - 9
225
+
226
+ odd = true
227
+ numbers.reverse.bytes.each do |number|
228
+ if odd
229
+ odd = false
230
+ sum += ODD_LUHN_VALUE[number]
231
+ else
232
+ odd = true
233
+ sum += EVEN_LUHN_VALUE[number]
234
+ end
136
235
  end
137
-
138
- (number[-1,1].to_i == (10 - sum % 10) % 10)
236
+
237
+ sum % 10 == 0
139
238
  end
140
239
  end
141
240
  end
@@ -4,29 +4,29 @@ module ActiveMerchant
4
4
  # http://www.bbbonline.org/eExport/doc/MerchantGuide_cvv2.pdf
5
5
  # Check additional codes from cybersource website
6
6
  class CVVResult
7
-
7
+
8
8
  MESSAGES = {
9
- 'D' => 'Suspicious transaction',
10
- 'I' => 'Failed data validation check',
11
- 'M' => 'Match',
12
- 'N' => 'No Match',
13
- 'P' => 'Not Processed',
14
- 'S' => 'Should have been present',
15
- 'U' => 'Issuer unable to process request',
16
- 'X' => 'Card does not support verification'
9
+ 'D' => 'CVV check flagged transaction as suspicious',
10
+ 'I' => 'CVV failed data validation check',
11
+ 'M' => 'CVV matches',
12
+ 'N' => 'CVV does not match',
13
+ 'P' => 'CVV not processed',
14
+ 'S' => 'CVV should have been present',
15
+ 'U' => 'CVV request unable to be processed by issuer',
16
+ 'X' => 'CVV check not supported for card'
17
17
  }
18
-
18
+
19
19
  def self.messages
20
20
  MESSAGES
21
21
  end
22
-
22
+
23
23
  attr_reader :code, :message
24
-
24
+
25
25
  def initialize(code)
26
- @code = code.upcase unless code.blank?
26
+ @code = (code.blank? ? nil : code.upcase)
27
27
  @message = MESSAGES[@code]
28
28
  end
29
-
29
+
30
30
  def to_hash
31
31
  {
32
32
  'code' => code,
@@ -35,4 +35,4 @@ module ActiveMerchant
35
35
  end
36
36
  end
37
37
  end
38
- end
38
+ end
@@ -10,19 +10,16 @@ module ActiveMerchant #:nodoc:
10
10
  #
11
11
  # The standard list of gateway functions that most concrete gateway subclasses implement is:
12
12
  #
13
- # * <tt>purchase(money, creditcard, options = {})</tt>
14
- # * <tt>authorize(money, creditcard, options = {})</tt>
13
+ # * <tt>purchase(money, credit_card, options = {})</tt>
14
+ # * <tt>authorize(money, credit_card, options = {})</tt>
15
15
  # * <tt>capture(money, authorization, options = {})</tt>
16
16
  # * <tt>void(identification, options = {})</tt>
17
- # * <tt>credit(money, identification, options = {})</tt>
18
- #
19
- # Some gateways include features for recurring billing
20
- #
21
- # * <tt>recurring(money, creditcard, options = {})</tt>
17
+ # * <tt>refund(money, identification, options = {})</tt>
18
+ # * <tt>verify(credit_card, options = {})</tt>
22
19
  #
23
20
  # Some gateways also support features for storing credit cards:
24
21
  #
25
- # * <tt>store(creditcard, options = {})</tt>
22
+ # * <tt>store(credit_card, options = {})</tt>
26
23
  # * <tt>unstore(identification, options = {})</tt>
27
24
  #
28
25
  # === Gateway Options
@@ -51,19 +48,57 @@ module ActiveMerchant #:nodoc:
51
48
  # * <tt>:zip</tt> - The zip or postal code of the customer.
52
49
  # * <tt>:phone</tt> - The phone number of the customer.
53
50
  #
54
- # == Implmenting new gateways
51
+ # == Implementing new gateways
55
52
  #
56
- # See the {ActiveMerchant Guide to Contributing}[https://github.com/Shopify/active_merchant/wiki/Contributing]
53
+ # See the {ActiveMerchant Guide to Contributing}[https://github.com/activemerchant/active_merchant/wiki/Contributing]
57
54
  #
58
55
  class Gateway
59
56
  include PostsData
60
- include RequiresParameters
61
57
  include CreditCardFormatting
62
- include Utils
63
58
 
64
59
  DEBIT_CARDS = [ :switch, :solo ]
65
- CURRENCIES_WITHOUT_FRACTIONS = [ 'JPY', 'HUF', 'TWD' ]
60
+
66
61
  CREDIT_DEPRECATION_MESSAGE = "Support for using credit to refund existing transactions is deprecated and will be removed from a future release of ActiveMerchant. Please use the refund method instead."
62
+ RECURRING_DEPRECATION_MESSAGE = "Recurring functionality in ActiveMerchant is deprecated and will be removed in a future version. Please contact the ActiveMerchant maintainers if you have an interest in taking ownership of a separate gem that continues support for it."
63
+
64
+ # == Standardized Error Codes
65
+ #
66
+ # :incorrect_number - Card number does not comply with ISO/IEC 7812 numbering standard
67
+ # :invalid_number - Card number was not matched by processor
68
+ # :invalid_expiry_date - Expiry date does not match correct formatting
69
+ # :invalid_cvc - Security codes does not match correct format (3-4 digits)
70
+ # :expired_card - Card number is expired
71
+ # :incorrect_cvc - Security code was not matched by the processor
72
+ # :incorrect_zip - Zip code is not in correct format
73
+ # :incorrect_address - Billing address info was not matched by the processor
74
+ # :incorrect_pin - Card PIN is incorrect
75
+ # :card_declined - Card number declined by processor
76
+ # :processing_error - Processor error
77
+ # :call_issuer - Transaction requires voice authentication, call issuer
78
+ # :pickup_card - Issuer requests that you pickup the card from merchant
79
+ # :test_mode_live_card - Card was declined. Request was in test mode, but used a non test card.
80
+ # :unsupported_feature - Transaction failed due to gateway or merchant
81
+ # configuration not supporting a feature used, such
82
+ # as network tokenization.
83
+
84
+ STANDARD_ERROR_CODE = {
85
+ :incorrect_number => 'incorrect_number',
86
+ :invalid_number => 'invalid_number',
87
+ :invalid_expiry_date => 'invalid_expiry_date',
88
+ :invalid_cvc => 'invalid_cvc',
89
+ :expired_card => 'expired_card',
90
+ :incorrect_cvc => 'incorrect_cvc',
91
+ :incorrect_zip => 'incorrect_zip',
92
+ :incorrect_address => 'incorrect_address',
93
+ :incorrect_pin => 'incorrect_pin',
94
+ :card_declined => 'card_declined',
95
+ :processing_error => 'processing_error',
96
+ :call_issuer => 'call_issuer',
97
+ :pickup_card => 'pick_up_card',
98
+ :config_error => 'config_error',
99
+ :test_mode_live_card => 'test_mode_live_card',
100
+ :unsupported_feature => 'unsupported_feature',
101
+ }
67
102
 
68
103
  cattr_reader :implementations
69
104
  @@implementations = []
@@ -73,6 +108,10 @@ module ActiveMerchant #:nodoc:
73
108
  @@implementations << subclass
74
109
  end
75
110
 
111
+ def generate_unique_id
112
+ SecureRandom.hex(16)
113
+ end
114
+
76
115
  # The format of the amounts used by the gateway
77
116
  # :dollars => '12.50'
78
117
  # :cents => '1250'
@@ -82,14 +121,14 @@ module ActiveMerchant #:nodoc:
82
121
  # The default currency for the transactions if no currency is provided
83
122
  class_attribute :default_currency
84
123
 
85
- # The countries of merchants the gateway supports
86
- class_attribute :supported_countries
87
- self.supported_countries = []
88
-
89
124
  # The supported card types for the gateway
90
125
  class_attribute :supported_cardtypes
91
126
  self.supported_cardtypes = []
92
127
 
128
+ class_attribute :currencies_without_fractions, :currencies_with_three_decimal_places
129
+ self.currencies_without_fractions = %w(BIF BYR CLP CVE DJF GNF ISK JPY KMF KRW PYG RWF UGX VND VUV XAF XOF XPF)
130
+ self.currencies_with_three_decimal_places = %w()
131
+
93
132
  class_attribute :homepage_url
94
133
  class_attribute :display_name
95
134
 
@@ -101,8 +140,8 @@ module ActiveMerchant #:nodoc:
101
140
 
102
141
  # The application making the calls to the gateway
103
142
  # Useful for things like the PayPal build notation (BN) id fields
104
- superclass_delegating_accessor :application_id
105
- self.application_id = 'ActiveMerchant'
143
+ class_attribute :application_id, instance_writer: false
144
+ self.application_id = nil
106
145
 
107
146
  attr_reader :options
108
147
 
@@ -116,6 +155,23 @@ module ActiveMerchant #:nodoc:
116
155
  result.to_s.downcase
117
156
  end
118
157
 
158
+ def self.supported_countries=(country_codes)
159
+ country_codes.each do |country_code|
160
+ unless ActiveMerchant::Country.find(country_code)
161
+ raise ActiveMerchant::InvalidCountryCodeError, "No country could be found for the country #{country_code}"
162
+ end
163
+ end
164
+ @supported_countries = country_codes.dup
165
+ end
166
+
167
+ def self.supported_countries
168
+ @supported_countries ||= []
169
+ end
170
+
171
+ def supported_countries
172
+ self.class.supported_countries
173
+ end
174
+
119
175
  def card_brand(source)
120
176
  self.class.card_brand(source)
121
177
  end
@@ -133,6 +189,51 @@ module ActiveMerchant #:nodoc:
133
189
  (@options.has_key?(:test) ? @options[:test] : Base.test?)
134
190
  end
135
191
 
192
+ # Does this gateway know how to scrub sensitive information out of HTTP transcripts?
193
+ def supports_scrubbing?
194
+ false
195
+ end
196
+
197
+ def scrub(transcript)
198
+ raise RuntimeError.new("This gateway does not support scrubbing.")
199
+ end
200
+
201
+ def supports_network_tokenization?
202
+ false
203
+ end
204
+
205
+ protected # :nodoc: all
206
+
207
+ def normalize(field)
208
+ case field
209
+ when "true" then true
210
+ when "false" then false
211
+ when "" then nil
212
+ when "null" then nil
213
+ else field
214
+ end
215
+ end
216
+
217
+ def user_agent
218
+ @@ua ||= JSON.dump({
219
+ :bindings_version => ActiveMerchant::VERSION,
220
+ :lang => 'ruby',
221
+ :lang_version => "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})",
222
+ :platform => RUBY_PLATFORM,
223
+ :publisher => 'active_merchant'
224
+ })
225
+ end
226
+
227
+ def strip_invalid_xml_chars(xml)
228
+ begin
229
+ REXML::Document.new(xml)
230
+ rescue REXML::ParseException
231
+ xml = xml.gsub(/&(?!(?:[a-z]+|#[0-9]+|x[a-zA-Z0-9]+);)/, '&amp;')
232
+ end
233
+
234
+ xml
235
+ end
236
+
136
237
  private # :nodoc: all
137
238
 
138
239
  def name
@@ -142,7 +243,7 @@ module ActiveMerchant #:nodoc:
142
243
  def amount(money)
143
244
  return nil if money.nil?
144
245
  cents = if money.respond_to?(:cents)
145
- deprecated "Support for Money objects is deprecated and will be removed from a future release of ActiveMerchant. Please use an Integer value in cents"
246
+ ActiveMerchant.deprecated "Support for Money objects is deprecated and will be removed from a future release of ActiveMerchant. Please use an Integer value in cents"
146
247
  money.cents
147
248
  else
148
249
  money
@@ -159,23 +260,68 @@ module ActiveMerchant #:nodoc:
159
260
  end
160
261
  end
161
262
 
263
+ def non_fractional_currency?(currency)
264
+ self.currencies_without_fractions.include?(currency.to_s)
265
+ end
266
+
267
+ def three_decimal_currency?(currency)
268
+ self.currencies_with_three_decimal_places.include?(currency.to_s)
269
+ end
270
+
162
271
  def localized_amount(money, currency)
163
272
  amount = amount(money)
164
- non_fractional_currency?(currency) ? amount.split('.').first : amount
165
- end
166
273
 
167
- def non_fractional_currency?(currency)
168
- CURRENCIES_WITHOUT_FRACTIONS.include?(currency.to_s)
274
+ return amount unless non_fractional_currency?(currency) || three_decimal_currency?(currency)
275
+ if non_fractional_currency?(currency)
276
+ if self.money_format == :cents
277
+ sprintf("%.0f", amount.to_f / 100)
278
+ else
279
+ amount.split('.').first
280
+ end
281
+ elsif three_decimal_currency?(currency)
282
+ if self.money_format == :cents
283
+ amount.to_s
284
+ else
285
+ sprintf("%.3f", (amount.to_f / 10))
286
+ end
287
+ end
169
288
  end
170
289
 
171
290
  def currency(money)
172
291
  money.respond_to?(:currency) ? money.currency : self.default_currency
173
292
  end
174
293
 
294
+ def truncate(value, max_size)
295
+ return nil unless value
296
+ value.to_s[0, max_size]
297
+ end
298
+
299
+ def split_names(full_name)
300
+ names = (full_name || "").split
301
+ return [nil, nil] if names.size == 0
302
+
303
+ last_name = names.pop
304
+ first_name = names.join(" ")
305
+ [first_name, last_name]
306
+ end
307
+
175
308
  def requires_start_date_or_issue_number?(credit_card)
176
309
  return false if card_brand(credit_card).blank?
177
310
  DEBIT_CARDS.include?(card_brand(credit_card).to_sym)
178
311
  end
312
+
313
+ def requires!(hash, *params)
314
+ params.each do |param|
315
+ if param.is_a?(Array)
316
+ raise ArgumentError.new("Missing required parameter: #{param.first}") unless hash.has_key?(param.first)
317
+
318
+ valid_options = param[1..-1]
319
+ raise ArgumentError.new("Parameter: #{param.first} must be one of #{valid_options.to_sentence(:words_connector => 'or')}") unless valid_options.include?(hash[param.first])
320
+ else
321
+ raise ArgumentError.new("Missing required parameter: #{param}") unless hash.has_key?(param)
322
+ end
323
+ end
324
+ end
179
325
  end
180
326
  end
181
327
  end