tanga_activemerchant 1.37.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (306) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +1202 -0
  3. data/CONTRIBUTORS +414 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.md +221 -0
  6. data/gem-public_cert.pem +20 -0
  7. data/lib/active_merchant/billing/avs_result.rb +98 -0
  8. data/lib/active_merchant/billing/base.rb +57 -0
  9. data/lib/active_merchant/billing/check.rb +69 -0
  10. data/lib/active_merchant/billing/credit_card.rb +283 -0
  11. data/lib/active_merchant/billing/credit_card_formatting.rb +21 -0
  12. data/lib/active_merchant/billing/credit_card_methods.rb +143 -0
  13. data/lib/active_merchant/billing/cvv_result.rb +38 -0
  14. data/lib/active_merchant/billing/expiry_date.rb +34 -0
  15. data/lib/active_merchant/billing/gateway.rb +181 -0
  16. data/lib/active_merchant/billing/gateways/authorize_net.rb +725 -0
  17. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +956 -0
  18. data/lib/active_merchant/billing/gateways/balanced.rb +468 -0
  19. data/lib/active_merchant/billing/gateways/banwire.rb +105 -0
  20. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +314 -0
  21. data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +15 -0
  22. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +393 -0
  23. data/lib/active_merchant/billing/gateways/beanstream.rb +169 -0
  24. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
  25. data/lib/active_merchant/billing/gateways/blue_pay.rb +501 -0
  26. data/lib/active_merchant/billing/gateways/bogus.rb +142 -0
  27. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -0
  28. data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
  29. data/lib/active_merchant/billing/gateways/braintree_blue.rb +401 -0
  30. data/lib/active_merchant/billing/gateways/braintree_orange.rb +19 -0
  31. data/lib/active_merchant/billing/gateways/card_save.rb +23 -0
  32. data/lib/active_merchant/billing/gateways/card_stream.rb +225 -0
  33. data/lib/active_merchant/billing/gateways/card_stream_modern.rb +155 -0
  34. data/lib/active_merchant/billing/gateways/cc5.rb +156 -0
  35. data/lib/active_merchant/billing/gateways/certo_direct.rb +277 -0
  36. data/lib/active_merchant/billing/gateways/cyber_source.rb +639 -0
  37. data/lib/active_merchant/billing/gateways/data_cash.rb +591 -0
  38. data/lib/active_merchant/billing/gateways/efsnet.rb +230 -0
  39. data/lib/active_merchant/billing/gateways/elavon.rb +312 -0
  40. data/lib/active_merchant/billing/gateways/epay.rb +275 -0
  41. data/lib/active_merchant/billing/gateways/evo_ca.rb +308 -0
  42. data/lib/active_merchant/billing/gateways/eway.rb +225 -0
  43. data/lib/active_merchant/billing/gateways/eway_managed.rb +291 -0
  44. data/lib/active_merchant/billing/gateways/eway_rapid.rb +320 -0
  45. data/lib/active_merchant/billing/gateways/exact.rb +218 -0
  46. data/lib/active_merchant/billing/gateways/fat_zebra.rb +173 -0
  47. data/lib/active_merchant/billing/gateways/federated_canada.rb +167 -0
  48. data/lib/active_merchant/billing/gateways/finansbank.rb +22 -0
  49. data/lib/active_merchant/billing/gateways/first_pay.rb +176 -0
  50. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +314 -0
  51. data/lib/active_merchant/billing/gateways/garanti.rb +257 -0
  52. data/lib/active_merchant/billing/gateways/hdfc.rb +207 -0
  53. data/lib/active_merchant/billing/gateways/iats_payments.rb +35 -0
  54. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +249 -0
  55. data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +13 -0
  56. data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +29 -0
  57. data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +66 -0
  58. data/lib/active_merchant/billing/gateways/inspire.rb +221 -0
  59. data/lib/active_merchant/billing/gateways/instapay.rb +163 -0
  60. data/lib/active_merchant/billing/gateways/iridium.rb +262 -0
  61. data/lib/active_merchant/billing/gateways/itransact.rb +448 -0
  62. data/lib/active_merchant/billing/gateways/jetpay.rb +275 -0
  63. data/lib/active_merchant/billing/gateways/linkpoint.rb +447 -0
  64. data/lib/active_merchant/billing/gateways/litle.rb +554 -0
  65. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +176 -0
  66. data/lib/active_merchant/billing/gateways/merchant_one.rb +115 -0
  67. data/lib/active_merchant/billing/gateways/merchant_ware.rb +322 -0
  68. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +275 -0
  69. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +191 -0
  70. data/lib/active_merchant/billing/gateways/mercury.rb +311 -0
  71. data/lib/active_merchant/billing/gateways/metrics_global.rb +322 -0
  72. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
  73. data/lib/active_merchant/billing/gateways/migs.rb +265 -0
  74. data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
  75. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +219 -0
  76. data/lib/active_merchant/billing/gateways/moneris.rb +244 -0
  77. data/lib/active_merchant/billing/gateways/moneris_us.rb +208 -0
  78. data/lib/active_merchant/billing/gateways/nab_transact.rb +277 -0
  79. data/lib/active_merchant/billing/gateways/net_registry.rb +193 -0
  80. data/lib/active_merchant/billing/gateways/netaxept.rb +181 -0
  81. data/lib/active_merchant/billing/gateways/netbilling.rb +197 -0
  82. data/lib/active_merchant/billing/gateways/netpay.rb +223 -0
  83. data/lib/active_merchant/billing/gateways/nmi.rb +20 -0
  84. data/lib/active_merchant/billing/gateways/ogone.rb +421 -0
  85. data/lib/active_merchant/billing/gateways/optimal_payment.rb +297 -0
  86. data/lib/active_merchant/billing/gateways/orbital/avs_result.rb +93 -0
  87. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +46 -0
  88. data/lib/active_merchant/billing/gateways/orbital.rb +633 -0
  89. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +261 -0
  90. data/lib/active_merchant/billing/gateways/pay_junction.rb +396 -0
  91. data/lib/active_merchant/billing/gateways/pay_secure.rb +119 -0
  92. data/lib/active_merchant/billing/gateways/paybox_direct.rb +196 -0
  93. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +209 -0
  94. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +39 -0
  95. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
  96. data/lib/active_merchant/billing/gateways/payflow.rb +268 -0
  97. data/lib/active_merchant/billing/gateways/payflow_express.rb +224 -0
  98. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +15 -0
  99. data/lib/active_merchant/billing/gateways/payflow_uk.rb +21 -0
  100. data/lib/active_merchant/billing/gateways/payment_express.rb +353 -0
  101. data/lib/active_merchant/billing/gateways/paymill.rb +179 -0
  102. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +670 -0
  103. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +61 -0
  104. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +248 -0
  105. data/lib/active_merchant/billing/gateways/paypal.rb +106 -0
  106. data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
  107. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +43 -0
  108. data/lib/active_merchant/billing/gateways/paypal_express.rb +239 -0
  109. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
  110. data/lib/active_merchant/billing/gateways/paystation.rb +199 -0
  111. data/lib/active_merchant/billing/gateways/payway.rb +207 -0
  112. data/lib/active_merchant/billing/gateways/pin.rb +165 -0
  113. data/lib/active_merchant/billing/gateways/plugnpay.rb +294 -0
  114. data/lib/active_merchant/billing/gateways/psigate.rb +227 -0
  115. data/lib/active_merchant/billing/gateways/psl_card.rb +303 -0
  116. data/lib/active_merchant/billing/gateways/qbms.rb +292 -0
  117. data/lib/active_merchant/billing/gateways/quantum.rb +276 -0
  118. data/lib/active_merchant/billing/gateways/quickpay.rb +335 -0
  119. data/lib/active_merchant/billing/gateways/realex.rb +303 -0
  120. data/lib/active_merchant/billing/gateways/redsys.rb +394 -0
  121. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +93 -0
  122. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +114 -0
  123. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +102 -0
  124. data/lib/active_merchant/billing/gateways/sage.rb +152 -0
  125. data/lib/active_merchant/billing/gateways/sage_pay.rb +324 -0
  126. data/lib/active_merchant/billing/gateways/sallie_mae.rb +143 -0
  127. data/lib/active_merchant/billing/gateways/samurai.rb +118 -0
  128. data/lib/active_merchant/billing/gateways/secure_net.rb +261 -0
  129. data/lib/active_merchant/billing/gateways/secure_pay.rb +28 -0
  130. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +279 -0
  131. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +112 -0
  132. data/lib/active_merchant/billing/gateways/skip_jack.rb +453 -0
  133. data/lib/active_merchant/billing/gateways/smart_ps.rb +272 -0
  134. data/lib/active_merchant/billing/gateways/spreedly_core.rb +233 -0
  135. data/lib/active_merchant/billing/gateways/stripe.rb +316 -0
  136. data/lib/active_merchant/billing/gateways/trans_first.rb +126 -0
  137. data/lib/active_merchant/billing/gateways/transax.rb +23 -0
  138. data/lib/active_merchant/billing/gateways/transnational.rb +239 -0
  139. data/lib/active_merchant/billing/gateways/trust_commerce.rb +421 -0
  140. data/lib/active_merchant/billing/gateways/usa_epay.rb +25 -0
  141. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1501 -0
  142. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +201 -0
  143. data/lib/active_merchant/billing/gateways/verifi.rb +232 -0
  144. data/lib/active_merchant/billing/gateways/viaklix.rb +189 -0
  145. data/lib/active_merchant/billing/gateways/vindicia.rb +361 -0
  146. data/lib/active_merchant/billing/gateways/webpay.rb +57 -0
  147. data/lib/active_merchant/billing/gateways/wirecard.rb +313 -0
  148. data/lib/active_merchant/billing/gateways/worldpay.rb +303 -0
  149. data/lib/active_merchant/billing/gateways.rb +17 -0
  150. data/lib/active_merchant/billing/integrations/a1agregator/helper.rb +31 -0
  151. data/lib/active_merchant/billing/integrations/a1agregator/notification.rb +186 -0
  152. data/lib/active_merchant/billing/integrations/a1agregator/status.rb +38 -0
  153. data/lib/active_merchant/billing/integrations/a1agregator.rb +26 -0
  154. data/lib/active_merchant/billing/integrations/action_view_helper.rb +73 -0
  155. data/lib/active_merchant/billing/integrations/authorize_net_sim/helper.rb +229 -0
  156. data/lib/active_merchant/billing/integrations/authorize_net_sim/notification.rb +340 -0
  157. data/lib/active_merchant/billing/integrations/authorize_net_sim.rb +38 -0
  158. data/lib/active_merchant/billing/integrations/bogus/helper.rb +17 -0
  159. data/lib/active_merchant/billing/integrations/bogus/notification.rb +11 -0
  160. data/lib/active_merchant/billing/integrations/bogus/return.rb +10 -0
  161. data/lib/active_merchant/billing/integrations/bogus.rb +23 -0
  162. data/lib/active_merchant/billing/integrations/chronopay/helper.rb +120 -0
  163. data/lib/active_merchant/billing/integrations/chronopay/notification.rb +158 -0
  164. data/lib/active_merchant/billing/integrations/chronopay/return.rb +10 -0
  165. data/lib/active_merchant/billing/integrations/chronopay.rb +23 -0
  166. data/lib/active_merchant/billing/integrations/direc_pay/helper.rb +200 -0
  167. data/lib/active_merchant/billing/integrations/direc_pay/notification.rb +76 -0
  168. data/lib/active_merchant/billing/integrations/direc_pay/return.rb +32 -0
  169. data/lib/active_merchant/billing/integrations/direc_pay/status.rb +37 -0
  170. data/lib/active_merchant/billing/integrations/direc_pay.rb +41 -0
  171. data/lib/active_merchant/billing/integrations/directebanking/helper.rb +90 -0
  172. data/lib/active_merchant/billing/integrations/directebanking/notification.rb +120 -0
  173. data/lib/active_merchant/billing/integrations/directebanking/return.rb +11 -0
  174. data/lib/active_merchant/billing/integrations/directebanking.rb +47 -0
  175. data/lib/active_merchant/billing/integrations/dotpay/helper.rb +77 -0
  176. data/lib/active_merchant/billing/integrations/dotpay/notification.rb +86 -0
  177. data/lib/active_merchant/billing/integrations/dotpay/return.rb +11 -0
  178. data/lib/active_merchant/billing/integrations/dotpay.rb +22 -0
  179. data/lib/active_merchant/billing/integrations/dwolla/common.rb +23 -0
  180. data/lib/active_merchant/billing/integrations/dwolla/helper.rb +43 -0
  181. data/lib/active_merchant/billing/integrations/dwolla/notification.rb +64 -0
  182. data/lib/active_merchant/billing/integrations/dwolla/return.rb +49 -0
  183. data/lib/active_merchant/billing/integrations/dwolla.rb +23 -0
  184. data/lib/active_merchant/billing/integrations/e_payment_plans/helper.rb +34 -0
  185. data/lib/active_merchant/billing/integrations/e_payment_plans/notification.rb +84 -0
  186. data/lib/active_merchant/billing/integrations/e_payment_plans.rb +48 -0
  187. data/lib/active_merchant/billing/integrations/easy_pay/common.rb +40 -0
  188. data/lib/active_merchant/billing/integrations/easy_pay/helper.rb +36 -0
  189. data/lib/active_merchant/billing/integrations/easy_pay/notification.rb +59 -0
  190. data/lib/active_merchant/billing/integrations/easy_pay.rb +30 -0
  191. data/lib/active_merchant/billing/integrations/epay/helper.rb +55 -0
  192. data/lib/active_merchant/billing/integrations/epay/notification.rb +110 -0
  193. data/lib/active_merchant/billing/integrations/epay.rb +21 -0
  194. data/lib/active_merchant/billing/integrations/first_data/helper.rb +61 -0
  195. data/lib/active_merchant/billing/integrations/first_data/notification.rb +56 -0
  196. data/lib/active_merchant/billing/integrations/first_data.rb +38 -0
  197. data/lib/active_merchant/billing/integrations/gestpay/common.rb +42 -0
  198. data/lib/active_merchant/billing/integrations/gestpay/helper.rb +70 -0
  199. data/lib/active_merchant/billing/integrations/gestpay/notification.rb +85 -0
  200. data/lib/active_merchant/billing/integrations/gestpay/return.rb +10 -0
  201. data/lib/active_merchant/billing/integrations/gestpay.rb +25 -0
  202. data/lib/active_merchant/billing/integrations/helper.rb +117 -0
  203. data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +58 -0
  204. data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +59 -0
  205. data/lib/active_merchant/billing/integrations/hi_trust/return.rb +67 -0
  206. data/lib/active_merchant/billing/integrations/hi_trust.rb +27 -0
  207. data/lib/active_merchant/billing/integrations/ipay88/helper.rb +114 -0
  208. data/lib/active_merchant/billing/integrations/ipay88/return.rb +95 -0
  209. data/lib/active_merchant/billing/integrations/ipay88.rb +19 -0
  210. data/lib/active_merchant/billing/integrations/liqpay/helper.rb +43 -0
  211. data/lib/active_merchant/billing/integrations/liqpay/notification.rb +89 -0
  212. data/lib/active_merchant/billing/integrations/liqpay/return.rb +83 -0
  213. data/lib/active_merchant/billing/integrations/liqpay.rb +30 -0
  214. data/lib/active_merchant/billing/integrations/maksuturva/helper.rb +119 -0
  215. data/lib/active_merchant/billing/integrations/maksuturva/notification.rb +48 -0
  216. data/lib/active_merchant/billing/integrations/maksuturva.rb +86 -0
  217. data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +75 -0
  218. data/lib/active_merchant/billing/integrations/moneybookers/notification.rb +129 -0
  219. data/lib/active_merchant/billing/integrations/moneybookers.rb +26 -0
  220. data/lib/active_merchant/billing/integrations/nochex/helper.rb +68 -0
  221. data/lib/active_merchant/billing/integrations/nochex/notification.rb +94 -0
  222. data/lib/active_merchant/billing/integrations/nochex/return.rb +10 -0
  223. data/lib/active_merchant/billing/integrations/nochex.rb +88 -0
  224. data/lib/active_merchant/billing/integrations/notification.rb +71 -0
  225. data/lib/active_merchant/billing/integrations/paxum/common.rb +24 -0
  226. data/lib/active_merchant/billing/integrations/paxum/helper.rb +42 -0
  227. data/lib/active_merchant/billing/integrations/paxum/notification.rb +33 -0
  228. data/lib/active_merchant/billing/integrations/paxum.rb +44 -0
  229. data/lib/active_merchant/billing/integrations/pay_fast/common.rb +42 -0
  230. data/lib/active_merchant/billing/integrations/pay_fast/helper.rb +50 -0
  231. data/lib/active_merchant/billing/integrations/pay_fast/notification.rb +134 -0
  232. data/lib/active_merchant/billing/integrations/pay_fast/return.rb +10 -0
  233. data/lib/active_merchant/billing/integrations/pay_fast.rb +70 -0
  234. data/lib/active_merchant/billing/integrations/payflow_link/helper.rb +116 -0
  235. data/lib/active_merchant/billing/integrations/payflow_link/notification.rb +78 -0
  236. data/lib/active_merchant/billing/integrations/payflow_link.rb +21 -0
  237. data/lib/active_merchant/billing/integrations/paypal/helper.rb +119 -0
  238. data/lib/active_merchant/billing/integrations/paypal/notification.rb +227 -0
  239. data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
  240. data/lib/active_merchant/billing/integrations/paypal.rb +39 -0
  241. data/lib/active_merchant/billing/integrations/paypal_payments_advanced/helper.rb +15 -0
  242. data/lib/active_merchant/billing/integrations/paypal_payments_advanced.rb +20 -0
  243. data/lib/active_merchant/billing/integrations/paysbuy/helper.rb +15 -0
  244. data/lib/active_merchant/billing/integrations/paysbuy/notification.rb +28 -0
  245. data/lib/active_merchant/billing/integrations/paysbuy.rb +36 -0
  246. data/lib/active_merchant/billing/integrations/payu_in/helper.rb +74 -0
  247. data/lib/active_merchant/billing/integrations/payu_in/notification.rb +165 -0
  248. data/lib/active_merchant/billing/integrations/payu_in/return.rb +36 -0
  249. data/lib/active_merchant/billing/integrations/payu_in.rb +43 -0
  250. data/lib/active_merchant/billing/integrations/platron/helper.rb +32 -0
  251. data/lib/active_merchant/billing/integrations/platron/notification.rb +113 -0
  252. data/lib/active_merchant/billing/integrations/platron.rb +28 -0
  253. data/lib/active_merchant/billing/integrations/pxpay/helper.rb +112 -0
  254. data/lib/active_merchant/billing/integrations/pxpay/notification.rb +157 -0
  255. data/lib/active_merchant/billing/integrations/pxpay/return.rb +25 -0
  256. data/lib/active_merchant/billing/integrations/pxpay.rb +31 -0
  257. data/lib/active_merchant/billing/integrations/quickpay/helper.rb +74 -0
  258. data/lib/active_merchant/billing/integrations/quickpay/notification.rb +137 -0
  259. data/lib/active_merchant/billing/integrations/quickpay.rb +21 -0
  260. data/lib/active_merchant/billing/integrations/rbkmoney/helper.rb +23 -0
  261. data/lib/active_merchant/billing/integrations/rbkmoney/notification.rb +91 -0
  262. data/lib/active_merchant/billing/integrations/rbkmoney.rb +17 -0
  263. data/lib/active_merchant/billing/integrations/return.rb +42 -0
  264. data/lib/active_merchant/billing/integrations/robokassa/common.rb +19 -0
  265. data/lib/active_merchant/billing/integrations/robokassa/helper.rb +50 -0
  266. data/lib/active_merchant/billing/integrations/robokassa/notification.rb +55 -0
  267. data/lib/active_merchant/billing/integrations/robokassa/return.rb +17 -0
  268. data/lib/active_merchant/billing/integrations/robokassa.rb +49 -0
  269. data/lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb +33 -0
  270. data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +136 -0
  271. data/lib/active_merchant/billing/integrations/sage_pay_form/notification.rb +210 -0
  272. data/lib/active_merchant/billing/integrations/sage_pay_form/return.rb +31 -0
  273. data/lib/active_merchant/billing/integrations/sage_pay_form.rb +37 -0
  274. data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +91 -0
  275. data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +139 -0
  276. data/lib/active_merchant/billing/integrations/two_checkout/return.rb +17 -0
  277. data/lib/active_merchant/billing/integrations/two_checkout.rb +44 -0
  278. data/lib/active_merchant/billing/integrations/valitor/helper.rb +86 -0
  279. data/lib/active_merchant/billing/integrations/valitor/notification.rb +13 -0
  280. data/lib/active_merchant/billing/integrations/valitor/response_fields.rb +97 -0
  281. data/lib/active_merchant/billing/integrations/valitor/return.rb +13 -0
  282. data/lib/active_merchant/billing/integrations/valitor.rb +33 -0
  283. data/lib/active_merchant/billing/integrations/verkkomaksut/helper.rb +88 -0
  284. data/lib/active_merchant/billing/integrations/verkkomaksut/notification.rb +59 -0
  285. data/lib/active_merchant/billing/integrations/verkkomaksut.rb +20 -0
  286. data/lib/active_merchant/billing/integrations/web_pay/common.rb +50 -0
  287. data/lib/active_merchant/billing/integrations/web_pay/helper.rb +68 -0
  288. data/lib/active_merchant/billing/integrations/web_pay/notification.rb +51 -0
  289. data/lib/active_merchant/billing/integrations/web_pay.rb +45 -0
  290. data/lib/active_merchant/billing/integrations/webmoney/common.rb +17 -0
  291. data/lib/active_merchant/billing/integrations/webmoney/helper.rb +40 -0
  292. data/lib/active_merchant/billing/integrations/webmoney/notification.rb +47 -0
  293. data/lib/active_merchant/billing/integrations/webmoney.rb +43 -0
  294. data/lib/active_merchant/billing/integrations/world_pay/helper.rb +101 -0
  295. data/lib/active_merchant/billing/integrations/world_pay/notification.rb +160 -0
  296. data/lib/active_merchant/billing/integrations/world_pay.rb +34 -0
  297. data/lib/active_merchant/billing/integrations.rb +17 -0
  298. data/lib/active_merchant/billing/response.rb +77 -0
  299. data/lib/active_merchant/billing.rb +9 -0
  300. data/lib/active_merchant/version.rb +3 -0
  301. data/lib/active_merchant.rb +63 -0
  302. data/lib/activemerchant.rb +1 -0
  303. data/lib/support/gateway_support.rb +65 -0
  304. data/lib/support/outbound_hosts.rb +25 -0
  305. data/lib/support/ssl_verify.rb +93 -0
  306. metadata +506 -0
@@ -0,0 +1,98 @@
1
+ #!ruby19
2
+ # encoding: utf-8
3
+
4
+ module ActiveMerchant
5
+ module Billing
6
+ # Implements the Address Verification System
7
+ # https://www.wellsfargo.com/downloads/pdf/biz/merchant/visa_avs.pdf
8
+ # http://en.wikipedia.org/wiki/Address_Verification_System
9
+ # http://apps.cybersource.com/library/documentation/dev_guides/CC_Svcs_IG/html/app_avs_cvn_codes.htm#app_AVS_CVN_codes_7891_48375
10
+ # http://imgserver.skipjack.com/imgServer/5293710/AVS%20and%20CVV2.pdf
11
+ # http://www.emsecommerce.net/avs_cvv2_response_codes.htm
12
+ class AVSResult
13
+ MESSAGES = {
14
+ 'A' => 'Street address matches, but 5-digit and 9-digit postal code do not match.',
15
+ 'B' => 'Street address matches, but postal code not verified.',
16
+ 'C' => 'Street address and postal code do not match.',
17
+ 'D' => 'Street address and postal code match.',
18
+ 'E' => 'AVS data is invalid or AVS is not allowed for this card type.',
19
+ 'F' => 'Card member\'s name does not match, but billing postal code matches.',
20
+ 'G' => 'Non-U.S. issuing bank does not support AVS.',
21
+ 'H' => 'Card member\'s name does not match. Street address and postal code match.',
22
+ 'I' => 'Address not verified.',
23
+ 'J' => 'Card member\'s name, billing address, and postal code match. Shipping information verified and chargeback protection guaranteed through the Fraud Protection Program.',
24
+ 'K' => 'Card member\'s name matches but billing address and billing postal code do not match.',
25
+ 'L' => 'Card member\'s name and billing postal code match, but billing address does not match.',
26
+ 'M' => 'Street address and postal code match.',
27
+ 'N' => 'Street address and postal code do not match.',
28
+ 'O' => 'Card member\'s name and billing address match, but billing postal code does not match.',
29
+ 'P' => 'Postal code matches, but street address not verified.',
30
+ 'Q' => 'Card member\'s name, billing address, and postal code match. Shipping information verified but chargeback protection not guaranteed.',
31
+ 'R' => 'System unavailable.',
32
+ 'S' => 'U.S.-issuing bank does not support AVS.',
33
+ 'T' => 'Card member\'s name does not match, but street address matches.',
34
+ 'U' => 'Address information unavailable.',
35
+ 'V' => 'Card member\'s name, billing address, and billing postal code match.',
36
+ 'W' => 'Street address does not match, but 9-digit postal code matches.',
37
+ 'X' => 'Street address and 9-digit postal code match.',
38
+ 'Y' => 'Street address and 5-digit postal code match.',
39
+ 'Z' => 'Street address does not match, but 5-digit postal code matches.'
40
+ }
41
+
42
+ # Map vendor's AVS result code to a postal match code
43
+ POSTAL_MATCH_CODE = {
44
+ 'Y' => %w( D H F H J L M P Q V W X Y Z ),
45
+ 'N' => %w( A C K N O ),
46
+ 'X' => %w( G S ),
47
+ nil => %w( B E I R T U )
48
+ }.inject({}) do |map, (type, codes)|
49
+ codes.each { |code| map[code] = type }
50
+ map
51
+ end
52
+
53
+ # Map vendor's AVS result code to a street match code
54
+ STREET_MATCH_CODE = {
55
+ 'Y' => %w( A B D H J M O Q T V X Y ),
56
+ 'N' => %w( C K L N W Z ),
57
+ 'X' => %w( G S ),
58
+ nil => %w( E F I P R U )
59
+ }.inject({}) do |map, (type, codes)|
60
+ codes.each { |code| map[code] = type }
61
+ map
62
+ end
63
+
64
+ attr_reader :code, :message, :street_match, :postal_match
65
+
66
+ def self.messages
67
+ MESSAGES
68
+ end
69
+
70
+ def initialize(attrs)
71
+ attrs ||= {}
72
+
73
+ @code = attrs[:code].upcase unless attrs[:code].blank?
74
+ @message = self.class.messages[code]
75
+
76
+ if attrs[:street_match].blank?
77
+ @street_match = STREET_MATCH_CODE[code]
78
+ else
79
+ @street_match = attrs[:street_match].upcase
80
+ end
81
+
82
+ if attrs[:postal_match].blank?
83
+ @postal_match = POSTAL_MATCH_CODE[code]
84
+ else
85
+ @postal_match = attrs[:postal_match].upcase
86
+ end
87
+ end
88
+
89
+ def to_hash
90
+ { 'code' => code,
91
+ 'message' => message,
92
+ 'street_match' => street_match,
93
+ 'postal_match' => postal_match
94
+ }
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,57 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Base
4
+ # Set ActiveMerchant gateways in test mode.
5
+ #
6
+ # ActiveMerchant::Billing::Base.gateway_mode = :test
7
+ mattr_accessor :gateway_mode
8
+
9
+ # Set ActiveMerchant integrations in test mode.
10
+ #
11
+ # ActiveMerchant::Billing::Base.integration_mode = :test
12
+ mattr_accessor :integration_mode
13
+
14
+ # Set both the mode of both the gateways and integrations
15
+ # at once
16
+ mattr_reader :mode
17
+
18
+ def self.mode=(mode)
19
+ @@mode = mode
20
+ self.gateway_mode = mode
21
+ self.integration_mode = mode
22
+ end
23
+
24
+ self.mode = :production
25
+
26
+ # Return the matching gateway for the provider
27
+ # * <tt>bogus</tt>: BogusGateway - Does nothing (for testing)
28
+ # * <tt>moneris</tt>: MonerisGateway
29
+ # * <tt>authorize_net</tt>: AuthorizeNetGateway
30
+ # * <tt>trust_commerce</tt>: TrustCommerceGateway
31
+ #
32
+ # ActiveMerchant::Billing::Base.gateway('moneris').new
33
+ def self.gateway(name)
34
+ raise NameError if (name_str = name.to_s.downcase).blank?
35
+ Billing.const_get("#{name_str}_gateway".camelize)
36
+ end
37
+
38
+ # Return the matching integration module
39
+ # You can then get the notification from the module
40
+ # * <tt>bogus</tt>: Bogus - Does nothing (for testing)
41
+ # * <tt>chronopay</tt>: Chronopay
42
+ # * <tt>paypal</tt>: Paypal
43
+ #
44
+ # chronopay = ActiveMerchant::Billing::Base.integration('chronopay')
45
+ # notification = chronopay.notification(raw_post)
46
+ #
47
+ def self.integration(name)
48
+ Billing::Integrations.const_get("#{name.to_s.downcase}".camelize)
49
+ end
50
+
51
+ # A check to see if we're in test mode
52
+ def self.test?
53
+ self.gateway_mode == :test
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,69 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ # The Check object is a plain old Ruby object, similar to CreditCard. It supports validation
4
+ # of necessary attributes such as checkholder's name, routing and account numbers, but it is
5
+ # not backed by any database.
6
+ #
7
+ # You may use Check in place of CreditCard with any gateway that supports it.
8
+ class Check
9
+ include Validateable
10
+
11
+ attr_accessor :first_name, :last_name,
12
+ :bank_name, :routing_number, :account_number,
13
+ :account_holder_type, :account_type, :number
14
+
15
+ # Used for Canadian bank accounts
16
+ attr_accessor :institution_number, :transit_number
17
+
18
+ def name
19
+ @name ||= "#{@first_name} #{@last_name}".strip
20
+ end
21
+
22
+ def name=(value)
23
+ return if value.blank?
24
+
25
+ @name = value
26
+ segments = value.split(' ')
27
+ @last_name = segments.pop
28
+ @first_name = segments.join(' ')
29
+ end
30
+
31
+ def validate
32
+ [:name, :routing_number, :account_number].each do |attr|
33
+ errors.add(attr, "cannot be empty") if self.send(attr).blank?
34
+ end
35
+
36
+ errors.add(:routing_number, "is invalid") unless valid_routing_number?
37
+
38
+ errors.add(:account_holder_type, "must be personal or business") if
39
+ !account_holder_type.blank? && !%w[business personal].include?(account_holder_type.to_s)
40
+
41
+ errors.add(:account_type, "must be checking or savings") if
42
+ !account_type.blank? && !%w[checking savings].include?(account_type.to_s)
43
+ end
44
+
45
+ def type
46
+ 'check'
47
+ end
48
+
49
+ # Routing numbers may be validated by calculating a checksum and dividing it by 10. The
50
+ # formula is:
51
+ # (3(d1 + d4 + d7) + 7(d2 + d5 + d8) + 1(d3 + d6 + d9))mod 10 = 0
52
+ # See http://en.wikipedia.org/wiki/Routing_transit_number#Internal_checksums
53
+ def valid_routing_number?
54
+ d = routing_number.to_s.split('').map(&:to_i).select { |d| (0..9).include?(d) }
55
+ case d.size
56
+ when 9 then
57
+ checksum = ((3 * (d[0] + d[3] + d[6])) +
58
+ (7 * (d[1] + d[4] + d[7])) +
59
+ (d[2] + d[5] + d[8])) % 10
60
+ case checksum
61
+ when 0 then true
62
+ else false
63
+ end
64
+ else false
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,283 @@
1
+ require 'time'
2
+ require 'date'
3
+ require 'active_merchant/billing/expiry_date'
4
+
5
+ module ActiveMerchant #:nodoc:
6
+ module Billing #:nodoc:
7
+ # A +CreditCard+ object represents a physical credit card, and is capable of validating the various
8
+ # data associated with these.
9
+ #
10
+ # At the moment, the following credit card types are supported:
11
+ #
12
+ # * Visa
13
+ # * MasterCard
14
+ # * Discover
15
+ # * American Express
16
+ # * Diner's Club
17
+ # * JCB
18
+ # * Switch
19
+ # * Solo
20
+ # * Dankort
21
+ # * Maestro
22
+ # * Forbrugsforeningen
23
+ # * Laser
24
+ #
25
+ # For testing purposes, use the 'bogus' credit card brand. This skips the vast majority of
26
+ # validations, allowing you to focus on your core concerns until you're ready to be more concerned
27
+ # with the details of particular credit cards or your gateway.
28
+ #
29
+ # == Testing With CreditCard
30
+ # Often when testing we don't care about the particulars of a given card brand. When using the 'test'
31
+ # mode in your {Gateway}, there are six different valid card numbers: 1, 2, 3, 'success', 'fail',
32
+ # and 'error'.
33
+ #
34
+ # For details, see {CreditCardMethods::ClassMethods#valid_number?}
35
+ #
36
+ # == Example Usage
37
+ # cc = CreditCard.new(
38
+ # :first_name => 'Steve',
39
+ # :last_name => 'Smith',
40
+ # :month => '9',
41
+ # :year => '2010',
42
+ # :brand => 'visa',
43
+ # :number => '4242424242424242'
44
+ # )
45
+ #
46
+ # cc.valid? # => true
47
+ # cc.display_number # => XXXX-XXXX-XXXX-4242
48
+ #
49
+ class CreditCard
50
+ include CreditCardMethods
51
+ include Validateable
52
+
53
+ cattr_accessor :require_verification_value
54
+ self.require_verification_value = true
55
+
56
+ # Returns or sets the credit card number.
57
+ #
58
+ # @return [String]
59
+ attr_accessor :number
60
+
61
+ # Returns or sets the expiry month for the card.
62
+ #
63
+ # @return [Integer]
64
+ attr_accessor :month
65
+
66
+ # Returns or sets the expiry year for the card.
67
+ #
68
+ # @return [Integer]
69
+ attr_accessor :year
70
+
71
+ # Returns or sets the credit card brand.
72
+ #
73
+ # Valid card types are
74
+ #
75
+ # * +'visa'+
76
+ # * +'master'+
77
+ # * +'discover'+
78
+ # * +'american_express'+
79
+ # * +'diners_club'+
80
+ # * +'jcb'+
81
+ # * +'switch'+
82
+ # * +'solo'+
83
+ # * +'dankort'+
84
+ # * +'maestro'+
85
+ # * +'forbrugsforeningen'+
86
+ # * +'laser'+
87
+ #
88
+ # Or, if you wish to test your implementation, +'bogus'+.
89
+ #
90
+ # @return (String) the credit card brand
91
+ attr_accessor :brand
92
+
93
+ # Returns or sets the first name of the card holder.
94
+ #
95
+ # @return [String]
96
+ attr_accessor :first_name
97
+
98
+ # Returns or sets the last name of the card holder.
99
+ #
100
+ # @return [String]
101
+ attr_accessor :last_name
102
+
103
+ # Required for Switch / Solo cards
104
+ attr_accessor :start_month, :start_year, :issue_number
105
+
106
+ # Returns or sets the card verification value.
107
+ #
108
+ # This attribute is optional but recommended. The verification value is
109
+ # a {card security code}[http://en.wikipedia.org/wiki/Card_security_code]. If provided,
110
+ # the gateway will attempt to validate the value.
111
+ #
112
+ # @return [String] the verification value
113
+ attr_accessor :verification_value
114
+
115
+ # Returns or sets the track data for the card
116
+ #
117
+ # @return [String]
118
+ attr_accessor :track_data
119
+
120
+ def type
121
+ self.class.deprecated "CreditCard#type is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#brand instead."
122
+ brand
123
+ end
124
+
125
+ def type=(value)
126
+ self.class.deprecated "CreditCard#type is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#brand instead."
127
+ self.brand = value
128
+ end
129
+
130
+ # Provides proxy access to an expiry date object
131
+ #
132
+ # @return [ExpiryDate]
133
+ def expiry_date
134
+ ExpiryDate.new(@month, @year)
135
+ end
136
+
137
+ # Returns whether the credit card has expired.
138
+ #
139
+ # @return +true+ if the card has expired, +false+ otherwise
140
+ def expired?
141
+ expiry_date.expired?
142
+ end
143
+
144
+ # Returns whether either the +first_name+ or the +last_name+ attributes has been set.
145
+ def name?
146
+ first_name? || last_name?
147
+ end
148
+
149
+ # Returns whether the +first_name+ attribute has been set.
150
+ def first_name?
151
+ @first_name.present?
152
+ end
153
+
154
+ # Returns whether the +last_name+ attribute has been set.
155
+ def last_name?
156
+ @last_name.present?
157
+ end
158
+
159
+ # Returns the full name of the card holder.
160
+ #
161
+ # @return [String] the full name of the card holder
162
+ def name
163
+ [@first_name, @last_name].compact.join(' ')
164
+ end
165
+
166
+ def name=(full_name)
167
+ names = full_name.split
168
+ self.last_name = names.pop
169
+ self.first_name = names.join(" ")
170
+ end
171
+
172
+ def verification_value?
173
+ !@verification_value.blank?
174
+ end
175
+
176
+ # Returns a display-friendly version of the card number.
177
+ #
178
+ # All but the last 4 numbers are replaced with an "X", and hyphens are
179
+ # inserted in order to improve legibility.
180
+ #
181
+ # @example
182
+ # credit_card = CreditCard.new(:number => "2132542376824338")
183
+ # credit_card.display_number # "XXXX-XXXX-XXXX-4338"
184
+ #
185
+ # @return [String] a display-friendly version of the card number
186
+ def display_number
187
+ self.class.mask(number)
188
+ end
189
+
190
+ def first_digits
191
+ self.class.first_digits(number)
192
+ end
193
+
194
+ def last_digits
195
+ self.class.last_digits(number)
196
+ end
197
+
198
+ # Validates the credit card details.
199
+ #
200
+ # Any validation errors are added to the {#errors} attribute.
201
+ def validate
202
+ validate_essential_attributes
203
+
204
+ # Bogus card is pretty much for testing purposes. Lets just skip these extra tests if its used
205
+ return if brand == 'bogus'
206
+
207
+ validate_card_brand
208
+ validate_card_number
209
+ validate_verification_value
210
+ validate_switch_or_solo_attributes
211
+ end
212
+
213
+ def self.requires_verification_value?
214
+ require_verification_value
215
+ end
216
+
217
+ private
218
+
219
+ def before_validate #:nodoc:
220
+ self.month = month.to_i
221
+ self.year = year.to_i
222
+ self.start_month = start_month.to_i unless start_month.nil?
223
+ self.start_year = start_year.to_i unless start_year.nil?
224
+ self.number = number.to_s.gsub(/[^\d]/, "")
225
+ self.brand.downcase! if brand.respond_to?(:downcase)
226
+ self.brand = self.class.brand?(number) if brand.blank?
227
+ end
228
+
229
+ def validate_card_number #:nodoc:
230
+ if number.blank?
231
+ errors.add :number, "is required"
232
+ elsif !CreditCard.valid_number?(number)
233
+ errors.add :number, "is not a valid credit card number"
234
+ end
235
+
236
+ unless errors.on(:number) || errors.on(:brand)
237
+ errors.add :brand, "does not match the card number" unless CreditCard.matching_brand?(number, brand)
238
+ end
239
+ end
240
+
241
+ def validate_card_brand #:nodoc:
242
+ errors.add :brand, "is required" if brand.blank? && number.present?
243
+ errors.add :brand, "is invalid" unless brand.blank? || CreditCard.card_companies.keys.include?(brand)
244
+ end
245
+
246
+ alias_method :validate_card_type, :validate_card_brand
247
+
248
+ def validate_essential_attributes #:nodoc:
249
+ errors.add :first_name, "cannot be empty" if @first_name.blank?
250
+ errors.add :last_name, "cannot be empty" if @last_name.blank?
251
+
252
+ if @month.to_i.zero? || @year.to_i.zero?
253
+ errors.add :month, "is required" if @month.to_i.zero?
254
+ errors.add :year, "is required" if @year.to_i.zero?
255
+ else
256
+ errors.add :month, "is not a valid month" unless valid_month?(@month)
257
+ errors.add :year, "expired" if expired?
258
+ errors.add :year, "is not a valid year" unless expired? || valid_expiry_year?(@year)
259
+ end
260
+ end
261
+
262
+ def validate_switch_or_solo_attributes #:nodoc:
263
+ if %w[switch solo].include?(brand)
264
+ unless valid_month?(@start_month) && valid_start_year?(@start_year) || valid_issue_number?(@issue_number)
265
+ if @issue_number.blank?
266
+ errors.add :start_month, "is invalid" unless valid_month?(@start_month)
267
+ errors.add :start_year, "is invalid" unless valid_start_year?(@start_year)
268
+ errors.add :issue_number, "cannot be empty"
269
+ else
270
+ errors.add :issue_number, "is invalid" unless valid_issue_number?(@issue_number)
271
+ end
272
+ end
273
+ end
274
+ end
275
+
276
+ def validate_verification_value #:nodoc:
277
+ if CreditCard.requires_verification_value?
278
+ errors.add :verification_value, "is required" unless verification_value?
279
+ end
280
+ end
281
+ end
282
+ end
283
+ end
@@ -0,0 +1,21 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module CreditCardFormatting
4
+
5
+ # This method is used to format numerical information pertaining to credit cards.
6
+ #
7
+ # format(2005, :two_digits) # => "05"
8
+ # format(05, :four_digits) # => "0005"
9
+ def format(number, option)
10
+ return '' if number.blank?
11
+
12
+ case option
13
+ when :two_digits ; sprintf("%.2i", number.to_i)[-2..-1]
14
+ when :four_digits ; sprintf("%.4i", number.to_i)[-4..-1]
15
+ else number
16
+ end
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,143 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ # Convenience methods that can be included into a custom Credit Card object, such as an ActiveRecord based Credit Card object.
4
+ module CreditCardMethods
5
+ CARD_COMPANIES = {
6
+ 'visa' => /^4\d{12}(\d{3})?$/,
7
+ 'master' => /^(5[1-5]\d{4}|677189)\d{10}$/,
8
+ 'discover' => /^(6011|65\d{2}|64[4-9]\d)\d{12}|(62\d{14})$/,
9
+ 'american_express' => /^3[47]\d{13}$/,
10
+ 'diners_club' => /^3(0[0-5]|[68]\d)\d{11}$/,
11
+ 'jcb' => /^35(28|29|[3-8]\d)\d{12}$/,
12
+ 'switch' => /^6759\d{12}(\d{2,3})?$/,
13
+ 'solo' => /^6767\d{12}(\d{2,3})?$/,
14
+ 'dankort' => /^5019\d{12}$/,
15
+ 'maestro' => /^(5[06-8]|6\d)\d{10,17}$/,
16
+ 'forbrugsforeningen' => /^600722\d{10}$/,
17
+ 'laser' => /^(6304|6706|6709|6771(?!89))\d{8}(\d{4}|\d{6,7})?$/
18
+ }
19
+
20
+ def self.included(base)
21
+ base.extend(ClassMethods)
22
+ end
23
+
24
+ def valid_month?(month)
25
+ (1..12).include?(month.to_i)
26
+ end
27
+
28
+ def valid_expiry_year?(year)
29
+ (Time.now.year..Time.now.year + 20).include?(year.to_i)
30
+ end
31
+
32
+ def valid_start_year?(year)
33
+ year.to_s =~ /^\d{4}$/ && year.to_i > 1987
34
+ end
35
+
36
+ def valid_issue_number?(number)
37
+ number.to_s =~ /^\d{1,2}$/
38
+ end
39
+
40
+ module ClassMethods
41
+ # Returns true if it validates. Optionally, you can pass a card brand as an argument and
42
+ # make sure it is of the correct brand.
43
+ #
44
+ # References:
45
+ # - http://perl.about.com/compute/perl/library/nosearch/P073000.htm
46
+ # - http://www.beachnet.com/~hstiles/cardtype.html
47
+ def valid_number?(number)
48
+ valid_test_mode_card_number?(number) ||
49
+ valid_card_number_length?(number) &&
50
+ valid_checksum?(number)
51
+ end
52
+
53
+ # 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
58
+ def card_companies
59
+ CARD_COMPANIES
60
+ end
61
+
62
+ # Returns a string containing the brand of card from the list of known information below.
63
+ # Need to check the cards in a particular order, as there is some overlap of the allowable ranges
64
+ #--
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
+ #
70
+ # def brand?(number)
71
+ # return 'visa' if valid_test_mode_card_number?(number)
72
+ # card_companies.find([nil]) { |brand, regexp| number =~ regexp }.first.dup
73
+ # end
74
+ #
75
+ def brand?(number)
76
+ return 'bogus' if valid_test_mode_card_number?(number)
77
+
78
+ card_companies.reject { |c,p| c == 'maestro' }.each do |company, pattern|
79
+ return company.dup if number =~ pattern
80
+ end
81
+
82
+ return 'maestro' if number =~ card_companies['maestro']
83
+
84
+ return nil
85
+ end
86
+
87
+ def type?(number)
88
+ deprecated "CreditCard#type? is deprecated and will be removed from a future release of ActiveMerchant. Please use CreditCard#brand? instead."
89
+ brand?(number)
90
+ end
91
+
92
+ def first_digits(number)
93
+ number.to_s.slice(0,6)
94
+ end
95
+
96
+ def last_digits(number)
97
+ number.to_s.length <= 4 ? number : number.to_s.slice(-4..-1)
98
+ end
99
+
100
+ def mask(number)
101
+ "XXXX-XXXX-XXXX-#{last_digits(number)}"
102
+ end
103
+
104
+ # Checks to see if the calculated brand matches the specified brand
105
+ def matching_brand?(number, brand)
106
+ brand?(number) == brand
107
+ end
108
+
109
+ 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."
111
+ matching_brand?(number, brand)
112
+ end
113
+
114
+ def deprecated(message)
115
+ warn(Kernel.caller[1] + message)
116
+ end
117
+
118
+ private
119
+
120
+ def valid_card_number_length?(number) #:nodoc:
121
+ number.to_s.length >= 12
122
+ end
123
+
124
+ def valid_test_mode_card_number?(number) #:nodoc:
125
+ ActiveMerchant::Billing::Base.test? &&
126
+ %w[1 2 3 success failure error].include?(number.to_s)
127
+ end
128
+
129
+ # Checks the validity of a card number by use of the the Luhn Algorithm.
130
+ # Please see http://en.wikipedia.org/wiki/Luhn_algorithm for details.
131
+ def valid_checksum?(number) #:nodoc:
132
+ 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
136
+ end
137
+
138
+ (number[-1,1].to_i == (10 - sum % 10) % 10)
139
+ end
140
+ end
141
+ end
142
+ end
143
+ end