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,501 @@
1
+ require 'digest/md5'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ class BluePayGateway < Gateway
6
+ class_attribute :rebilling_url, :ignore_http_status
7
+
8
+ self.live_url = 'https://secure.bluepay.com/interfaces/bp20post'
9
+ self.rebilling_url = 'https://secure.bluepay.com/interfaces/bp20rebadmin'
10
+
11
+ self.ignore_http_status = true
12
+
13
+ CARD_CODE_ERRORS = %w( N S )
14
+ AVS_ERRORS = %w( A E N R W Z )
15
+ AVS_REASON_CODES = %w(27 45)
16
+
17
+ FRAUD_REVIEW_STATUSES = %w( E 0 )
18
+
19
+ FIELD_MAP = {
20
+ 'TRANS_ID' => :transaction_id,
21
+ 'STATUS' => :response_code,
22
+ 'AVS' => :avs_result_code,
23
+ 'CVV2'=> :card_code,
24
+ 'AUTH_CODE' => :authorization,
25
+ 'MESSAGE' => :message,
26
+ 'REBID' => :rebid,
27
+ 'TRANS_TYPE' => :trans_type,
28
+ 'PAYMENT_ACCOUNT_MASK' => :acct_mask,
29
+ 'CARD_TYPE' => :card_type,
30
+ }
31
+
32
+ REBILL_FIELD_MAP = {
33
+ 'REBILL_ID' => :rebill_id,
34
+ 'ACCOUNT_ID'=> :account_id,
35
+ 'USER_ID' => :user_id,
36
+ 'TEMPLATE_ID' => :template_id,
37
+ 'STATUS' => :status,
38
+ 'CREATION_DATE' => :creation_date,
39
+ 'NEXT_DATE' => :next_date,
40
+ 'LAST_DATE' => :last_date,
41
+ 'SCHED_EXPR' => :schedule,
42
+ 'CYCLES_REMAIN' => :cycles_remain,
43
+ 'REB_AMOUNT' => :rebill_amount,
44
+ 'NEXT_AMOUNT' => :next_amount,
45
+ 'USUAL_DATE' => :undoc_usual_date, # Not found in the bp20rebadmin API doc.
46
+ }
47
+
48
+ self.supported_countries = ['US']
49
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb]
50
+ self.homepage_url = 'http://www.bluepay.com/'
51
+ self.display_name = 'BluePay'
52
+ self.money_format = :dollars
53
+
54
+ # Creates a new BluepayGateway
55
+ #
56
+ # The gateway requires that a valid Account ID and Secret Key be passed
57
+ # in the +options+ hash.
58
+ #
59
+ # ==== Options
60
+ #
61
+ # * <tt>:account_id</tt> -- The BluePay gateway Account ID (REQUIRED)
62
+ # * <tt>:secret_key</tt> -- The BluePay gateway Secret Key (REQUIRED)
63
+ # * <tt>:test</tt> -- set to true for TEST mode or false for LIVE mode
64
+ def initialize(options = {})
65
+ requires!(options, :login, :password)
66
+ super
67
+ end
68
+
69
+ # Performs an authorization, which reserves the funds on the customer's credit card. This does not actually take funds from the customer
70
+ # This is referred to an AUTH transaction in BluePay
71
+ #
72
+ # ==== Parameters
73
+ #
74
+ # * <tt>money</tt> -- The amount to be authorized as an Integer value in cents.
75
+ # * <tt>payment_object</tt> -- This can either be one of three things:
76
+ # A CreditCard object,
77
+ # A Check object,
78
+ # or a token. The token is called the Master ID. This is a unique transaction ID returned from a previous transaction. This token associates all the stored information for a previous transaction.
79
+ # * <tt>options</tt> -- A hash of optional parameters.
80
+ def authorize(money, payment_object, options = {})
81
+ post = {}
82
+ add_payment_method(post, payment_object)
83
+ add_invoice(post, options)
84
+ add_address(post, options)
85
+ add_customer_data(post, options)
86
+ add_rebill(post, options) if options[:rebill]
87
+ add_duplicate_override(post, options)
88
+ post[:TRANS_TYPE] = 'AUTH'
89
+ commit('AUTH_ONLY', money, post)
90
+ end
91
+
92
+ # Perform a purchase, which is essentially an authorization and capture in a single operation.
93
+ # This is referred to a SALE transaction in BluePay
94
+ #
95
+ # ==== Parameters
96
+ #
97
+ # * <tt>money</tt> -- The amount to be purchased as an Integer value in cents.
98
+ # * <tt>payment_object</tt> -- This can either be one of three things:
99
+ # A CreditCard object,
100
+ # A Check object,
101
+ # or a token. The token is called the Master ID. This is a unique transaction ID returned from a previous transaction. This token associates all the stored information for a previous transaction.
102
+ # * <tt>options</tt> -- A hash of optional parameters.,
103
+ def purchase(money, payment_object, options = {})
104
+ post = {}
105
+ add_payment_method(post, payment_object)
106
+ add_invoice(post, options)
107
+ add_address(post, options)
108
+ add_customer_data(post, options)
109
+ add_rebill(post, options) if options[:rebill]
110
+ add_duplicate_override(post, options)
111
+ post[:TRANS_TYPE] = 'SALE'
112
+ commit('AUTH_CAPTURE', money, post)
113
+ end
114
+
115
+ # Captures the funds from an authorize transaction.
116
+ # This is referred to a CAPTURE transaction in BluePay
117
+ #
118
+ # ==== Parameters
119
+ #
120
+ # * <tt>money</tt> -- The amount to be captured as an Integer value in cents.
121
+ # * <tt>identification</tt> -- The Master ID, or token, returned from the previous authorize transaction.
122
+ def capture(money, identification, options = {})
123
+ post = {}
124
+ add_address(post, options)
125
+ add_customer_data(post, options)
126
+ post[:MASTER_ID] = identification
127
+ post[:TRANS_TYPE] = 'CAPTURE'
128
+ commit('PRIOR_AUTH_CAPTURE', money, post)
129
+ end
130
+
131
+ # Void a previous transaction
132
+ # This is referred to a VOID transaction in BluePay
133
+ #
134
+ # ==== Parameters
135
+ #
136
+ # * <tt>identification</tt> - The Master ID, or token, returned from a previous authorize transaction.
137
+ def void(identification, options = {})
138
+ post = {}
139
+ post[:MASTER_ID] = identification
140
+ post[:TRANS_TYPE] = 'VOID'
141
+ commit('VOID', nil, post)
142
+ end
143
+
144
+ # Performs a credit.
145
+ #
146
+ # This transaction indicates that money should flow from the merchant to the customer.
147
+ #
148
+ # ==== Parameters
149
+ #
150
+ # * <tt>money</tt> -- The amount to be credited to the customer as an Integer value in cents.
151
+ # * <tt>payment_object</tt> -- This can either be one of three things:
152
+ # A CreditCard object,
153
+ # A Check object,
154
+ # or a token. The token is called the Master ID. This is a unique transaction ID returned from a previous transaction. This token associates all the stored information for a previous transaction.
155
+ # If the payment_object is a token, then the transaction type will reverse a previous capture or purchase transaction, returning the funds to the customer. If the amount is nil, a full credit will be processed. This is referred to a REFUND transaction in BluePay.
156
+ # If the payment_object is either a CreditCard or Check object, then the transaction type will be an unmatched credit placing funds in the specified account. This is referred to a CREDIT transaction in BluePay.
157
+ # * <tt>options</tt> -- A hash of parameters.
158
+ def refund(money, identification, options = {})
159
+ if(identification && !identification.kind_of?(String))
160
+ deprecated "refund should only be used to refund a referenced transaction"
161
+ return credit(money, identification, options)
162
+ end
163
+
164
+ post = {}
165
+ post[:PAYMENT_ACCOUNT] = ''
166
+ post[:MASTER_ID] = identification
167
+ post[:TRANS_TYPE] = 'REFUND'
168
+ post[:NAME1] = (options[:first_name] ? options[:first_name] : "")
169
+ post[:NAME2] = options[:last_name] if options[:last_name]
170
+ post[:ZIP] = options[:zip] if options[:zip]
171
+ add_invoice(post, options)
172
+ add_address(post, options)
173
+ add_customer_data(post, options)
174
+ commit('CREDIT', money, post)
175
+ end
176
+
177
+ def credit(money, payment_object, options = {})
178
+ if(payment_object && payment_object.kind_of?(String))
179
+ deprecated "credit should only be used to credit a payment method"
180
+ return refund(money, payment_object, options)
181
+ end
182
+
183
+ post = {}
184
+ post[:PAYMENT_ACCOUNT] = ''
185
+ add_payment_method(post, payment_object)
186
+ post[:TRANS_TYPE] = 'CREDIT'
187
+
188
+ post[:NAME1] = (options[:first_name] ? options[:first_name] : "")
189
+ post[:NAME2] = options[:last_name] if options[:last_name]
190
+ post[:ZIP] = options[:zip] if options[:zip]
191
+ add_invoice(post, options)
192
+ add_address(post, options)
193
+ add_customer_data(post, options)
194
+ commit('CREDIT', money, post)
195
+ end
196
+
197
+ # Create a new recurring payment.
198
+ #
199
+ # ==== Parameters
200
+ #
201
+ # * <tt>money</tt> -- The amount to charge the customer at the time of the recurring payment setup, in cents. Set to zero if you do not want the customer to be charged at this time.
202
+ # * <tt>payment_object</tt> -- This can either be one of three things:
203
+ # A CreditCard object,
204
+ # A Check object,
205
+ # or a token. The token is called the Master ID. This is a unique transaction ID returned from a previous transaction. This token associates all the stored information for a previous transaction.
206
+ # * <tt>options</tt> -- A hash of optional parameters.,
207
+
208
+ # ==== Options
209
+ #
210
+ # * <tt>:rebill_start_date</tt> is a string that tells the gateway when to start the rebill. (REQUIRED)
211
+ # Has two valid formats:
212
+ # "YYYY-MM-DD HH:MM:SS" Hours, minutes, and seconds are optional.
213
+ # "XX UNITS" Relative date as explained below. Marked from the time of the
214
+ # transaction (i.e.: 10 DAYS, 1 MONTH, 1 YEAR)
215
+ # * <tt>:rebill_expression</tt> is the period of time in-between rebillings. (REQUIRED)
216
+ # It uses the same "XX UNITS" format as rebill_start_date, explained above.
217
+ # Optional parameters include:
218
+ # * <tt>rebill_cycles</tt>: Number of times to rebill. Don't send or set to nil for infinite rebillings (or
219
+ # until canceled).
220
+ # * <tt>rebill_amount</tt>: Amount to rebill. Defaults to amount of transaction for rebillings.
221
+ #
222
+ # For example, to charge the customer $19.95 now and then charge $39.95 in 60 days every 3 months for 5 times, the options hash would be as follows:
223
+ # :rebill_start_date => '60 DAYS',
224
+ # :rebill_expression => '3 MONTHS',
225
+ # :rebill_cycles => '5',
226
+ # :rebill_amount => '39.95'
227
+ # A money object of 1995 cents would be passed into the 'money' parameter.
228
+ def recurring(money, payment_object, options = {})
229
+ requires!(options, :rebill_start_date, :rebill_expression)
230
+ options[:rebill] = true
231
+ if money
232
+ purchase(money, payment_object, options)
233
+ else
234
+ authorize(money, payment_object, options)
235
+ end
236
+ end
237
+
238
+ # View a recurring payment
239
+ #
240
+ # This will pull data associated with a current recurring billing
241
+ #
242
+ # ==== Parameters
243
+ #
244
+ # * <tt>rebill_id</tt> -- A string containing the rebill_id of the recurring billing that is already active (REQUIRED)
245
+ def status_recurring(rebill_id)
246
+ post = {}
247
+ requires!(rebill_id)
248
+ post[:REBILL_ID] = rebill_id
249
+ post[:TRANS_TYPE] = 'GET'
250
+ commit('rebill', 'nil', post)
251
+ end
252
+
253
+ # Update a recurring payment's details.
254
+ #
255
+ # This transaction updates an existing recurring billing
256
+ #
257
+ # ==== Options
258
+ #
259
+ # * <tt>:rebill_id</tt> -- The 12 digit rebill ID used to update a particular rebilling cycle. (REQUIRED)
260
+ # * <tt>:rebill_amount</tt> -- A string containing the new rebilling amount.
261
+ # * <tt>:rebill_next_date</tt> -- A string containing the new rebilling next date.
262
+ # * <tt>:rebill_expression</tt> -- A string containing the new rebilling expression.
263
+ # * <tt>:rebill_cycles</tt> -- A string containing the new rebilling cycles.
264
+ # * <tt>:rebill_next_amount</tt> -- A string containing the next rebilling amount to charge the customer. This ONLY affects the next scheduled charge; all other rebillings will continue at the regular (rebill_amount) amount.
265
+ # Take a look above at the recurring_payment method for similar examples on how to use.
266
+ def update_recurring(options = {})
267
+ post = {}
268
+ requires!(options, :rebill_id)
269
+ post[:REBILL_ID] = options[:rebill_id]
270
+ post[:TRANS_TYPE] = 'SET'
271
+ post[:REB_AMOUNT] = amount(options[:rebill_amount]) if options[:rebill_amount]
272
+ post[:NEXT_DATE] = options[:rebill_next_date]
273
+ post[:REB_EXPR] = options[:rebill_expression]
274
+ post[:REB_CYCLES] = options[:rebill_cycles]
275
+ post[:NEXT_AMOUNT] = options[:rebill_next_amount]
276
+ commit('rebill', 'nil', post)
277
+ end
278
+
279
+ # Cancel a recurring payment.
280
+ #
281
+ # This transaction cancels an existing recurring billing.
282
+ #
283
+ # ==== Parameters
284
+ #
285
+ # * <tt>rebill_id</tt> -- A string containing the rebill_id of the recurring billing that you wish to cancel/stop (REQUIRED)
286
+ def cancel_recurring(rebill_id)
287
+ post = {}
288
+ requires!(rebill_id)
289
+ post[:REBILL_ID] = rebill_id
290
+ post[:TRANS_TYPE] = 'SET'
291
+ post[:STATUS] = 'stopped'
292
+ commit('rebill', 'nil', post)
293
+ end
294
+
295
+ private
296
+
297
+ def commit(action, money, fields)
298
+ fields[:AMOUNT] = amount(money) unless(fields[:TRANS_TYPE] == 'VOID' || action == 'rebill')
299
+ fields[:MODE] = (test? ? 'TEST' : 'LIVE')
300
+ fields[:ACCOUNT_ID] = @options[:login]
301
+
302
+ if action == 'rebill'
303
+ url = rebilling_url
304
+ fields[:TAMPER_PROOF_SEAL] = calc_rebill_tps(fields)
305
+ else
306
+ url = live_url
307
+ fields[:TAMPER_PROOF_SEAL] = calc_tps(amount(money), fields)
308
+ end
309
+ parse(ssl_post(url, post_data(action, fields)))
310
+ end
311
+
312
+ def parse_recurring(response_fields, opts={}) # expected status?
313
+ parsed = {}
314
+ response_fields.each do |k,v|
315
+ mapped_key = REBILL_FIELD_MAP.include?(k) ? REBILL_FIELD_MAP[k] : k
316
+ parsed[mapped_key] = v
317
+ end
318
+
319
+ success = parsed[:status] != 'error'
320
+ message = parsed[:status]
321
+
322
+ Response.new(success, message, parsed,
323
+ :test => test?,
324
+ :authorization => parsed[:rebill_id])
325
+ end
326
+
327
+ def parse(body)
328
+ # The bp20api has max one value per form field.
329
+ response_fields = Hash[CGI::parse(body).map{|k,v| [k.upcase,v.first]}]
330
+
331
+ if response_fields.include? "REBILL_ID"
332
+ return parse_recurring(response_fields)
333
+ end
334
+
335
+ parsed = {}
336
+ response_fields.each do |k,v|
337
+ mapped_key = FIELD_MAP.include?(k) ? FIELD_MAP[k] : k
338
+ parsed[mapped_key] = v
339
+ end
340
+
341
+ # normalize message
342
+ message = message_from(parsed)
343
+ success = parsed[:response_code] == '1'
344
+ Response.new(success, message, parsed,
345
+ :test => test?,
346
+ :authorization => (parsed[:rebid] && parsed[:rebid] != '' ? parsed[:rebid] : parsed[:transaction_id]),
347
+ :fraud_review => FRAUD_REVIEW_STATUSES.include?(parsed[:response_code]),
348
+ :avs_result => { :code => parsed[:avs_result_code] },
349
+ :cvv_result => parsed[:card_code]
350
+ )
351
+ end
352
+
353
+ def message_from(parsed)
354
+ message = parsed[:message]
355
+ if(parsed[:response_code].to_i == 2)
356
+ if CARD_CODE_ERRORS.include?(parsed[:card_code])
357
+ message = CVVResult.messages[parsed[:card_code]]
358
+ elsif AVS_ERRORS.include?(parsed[:avs_result_code])
359
+ message = AVSResult.messages[ parsed[:avs_result_code] ]
360
+ else
361
+ message = message.chomp('.')
362
+ end
363
+ elsif message == "Missing ACCOUNT_ID"
364
+ message = "The merchant login ID or password is invalid"
365
+ elsif message =~ /Approved/
366
+ message = "This transaction has been approved"
367
+ elsif message =~ /Expired/
368
+ message = "The credit card has expired"
369
+ end
370
+ message
371
+ end
372
+
373
+ def add_invoice(post, options)
374
+ post[:ORDER_ID] = options[:order_id]
375
+ post[:INVOICE_ID] = options[:invoice]
376
+ post[:invoice_num] = options[:order_id]
377
+ post[:MEMO] = options[:description]
378
+ post[:description] = options[:description]
379
+ end
380
+
381
+ def add_payment_method(post, payment_object)
382
+ post[:MASTER_ID] = ''
383
+ case payment_object
384
+ when String
385
+ post[:MASTER_ID] = payment_object
386
+ when Check
387
+ add_check(post, payment_object)
388
+ else
389
+ add_creditcard(post, payment_object)
390
+ end
391
+ end
392
+
393
+ def add_creditcard(post, creditcard)
394
+ post[:PAYMENT_TYPE] = 'CREDIT'
395
+ post[:PAYMENT_ACCOUNT] = creditcard.number
396
+ post[:CARD_CVV2] = creditcard.verification_value
397
+ post[:CARD_EXPIRE] = expdate(creditcard)
398
+ post[:NAME1] = creditcard.first_name
399
+ post[:NAME2] = creditcard.last_name
400
+ end
401
+
402
+ CHECK_ACCOUNT_TYPES = {
403
+ "checking" => "C",
404
+ "savings" => "S"
405
+ }
406
+
407
+ def add_check(post, check)
408
+ post[:PAYMENT_TYPE] = 'ACH'
409
+ post[:PAYMENT_ACCOUNT] = [CHECK_ACCOUNT_TYPES[check.account_type], check.routing_number, check.account_number].join(":")
410
+ post[:NAME1] = check.first_name
411
+ post[:NAME2] = check.last_name
412
+ end
413
+
414
+ def add_customer_data(post, options)
415
+ post[:EMAIL] = options[:email]
416
+ post[:CUSTOM_ID] = options[:customer]
417
+ end
418
+
419
+ def add_duplicate_override(post, options)
420
+ post[:DUPLICATE_OVERRIDE] = options[:duplicate_override]
421
+ end
422
+
423
+ def add_address(post, options)
424
+ if address = (options[:shipping_address] || options[:billing_address] || options[:address])
425
+ post[:ADDR1] = address[:address1]
426
+ post[:ADDR2] = address[:address2]
427
+ post[:COMPANY_NAME] = address[:company]
428
+ post[:PHONE] = address[:phone]
429
+ post[:CITY] = address[:city]
430
+ post[:STATE] = (address[:state].blank? ? 'n/a' : address[:state])
431
+ post[:ZIP] = address[:zip]
432
+ post[:COUNTRY] = address[:country]
433
+ end
434
+ end
435
+
436
+ def add_rebill(post, options)
437
+ post[:DO_REBILL] = '1'
438
+ post[:REB_AMOUNT] = amount(options[:rebill_amount])
439
+ post[:REB_FIRST_DATE] = options[:rebill_start_date]
440
+ post[:REB_EXPR] = options[:rebill_expression]
441
+ post[:REB_CYCLES] = options[:rebill_cycles]
442
+ end
443
+
444
+ def post_data(action, parameters = {})
445
+ post = {}
446
+ post[:version] = '1'
447
+ post[:login] = ''
448
+ post[:tran_key] = ''
449
+ post[:relay_response] = "FALSE"
450
+ post[:type] = action
451
+ post[:delim_data] = "TRUE"
452
+ post[:delim_char] = ","
453
+ post[:encap_char] = "$"
454
+ post[:card_num] = '4111111111111111'
455
+ post[:exp_date] = '1212'
456
+ post[:solution_ID] = application_id if(application_id && application_id != "ActiveMerchant")
457
+ post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
458
+ end
459
+
460
+ def expdate(creditcard)
461
+ year = format(creditcard.year, :two_digits)
462
+ month = format(creditcard.month, :two_digits)
463
+
464
+ "#{month}#{year}"
465
+ end
466
+
467
+ def calc_tps(amount, post)
468
+ post[:NAME1] ||= ''
469
+ Digest::MD5.hexdigest(
470
+ [
471
+ @options[:password],
472
+ @options[:login],
473
+ post[:TRANS_TYPE],
474
+ amount,
475
+ post[:MASTER_ID],
476
+ post[:NAME1],
477
+ post[:PAYMENT_ACCOUNT]
478
+ ].join("")
479
+ )
480
+ end
481
+
482
+ def calc_rebill_tps(post)
483
+ Digest::MD5.hexdigest(
484
+ [
485
+ @options[:password],
486
+ @options[:login],
487
+ post[:TRANS_TYPE],
488
+ post[:REBILL_ID]
489
+ ].join("")
490
+ )
491
+ end
492
+
493
+ def handle_response(response)
494
+ if ignore_http_status || (200...300).include?(response.code.to_i)
495
+ return response.body
496
+ end
497
+ raise ResponseError.new(response)
498
+ end
499
+ end
500
+ end
501
+ end
@@ -0,0 +1,142 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ # Bogus Gateway
4
+ class BogusGateway < Gateway
5
+ AUTHORIZATION = '53433'
6
+
7
+ SUCCESS_MESSAGE = "Bogus Gateway: Forced success"
8
+ FAILURE_MESSAGE = "Bogus Gateway: Forced failure"
9
+ ERROR_MESSAGE = "Bogus Gateway: Use CreditCard number ending in 1 for success, 2 for exception and anything else for error"
10
+ CREDIT_ERROR_MESSAGE = "Bogus Gateway: Use CreditCard number ending in 1 for success, 2 for exception and anything else for error"
11
+ UNSTORE_ERROR_MESSAGE = "Bogus Gateway: Use trans_id ending in 1 for success, 2 for exception and anything else for error"
12
+ CAPTURE_ERROR_MESSAGE = "Bogus Gateway: Use authorization number ending in 1 for exception, 2 for error and anything else for success"
13
+ VOID_ERROR_MESSAGE = "Bogus Gateway: Use authorization number ending in 1 for exception, 2 for error and anything else for success"
14
+ REFUND_ERROR_MESSAGE = "Bogus Gateway: Use trans_id number ending in 1 for exception, 2 for error and anything else for success"
15
+
16
+ self.supported_countries = ['US']
17
+ self.supported_cardtypes = [:bogus]
18
+ self.homepage_url = 'http://example.com'
19
+ self.display_name = 'Bogus'
20
+
21
+ def authorize(money, credit_card_or_reference, options = {})
22
+ money = amount(money)
23
+ case normalize(credit_card_or_reference)
24
+ when /1$/
25
+ Response.new(true, SUCCESS_MESSAGE, {:authorized_amount => money}, :test => true, :authorization => AUTHORIZATION )
26
+ when /2$/
27
+ Response.new(false, FAILURE_MESSAGE, {:authorized_amount => money, :error => FAILURE_MESSAGE }, :test => true)
28
+ else
29
+ raise Error, ERROR_MESSAGE
30
+ end
31
+ end
32
+
33
+ def purchase(money, credit_card_or_reference, options = {})
34
+ money = amount(money)
35
+ case normalize(credit_card_or_reference)
36
+ when /1$/, AUTHORIZATION
37
+ Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money}, :test => true, :authorization => AUTHORIZATION)
38
+ when /2$/
39
+ Response.new(false, FAILURE_MESSAGE, {:paid_amount => money, :error => FAILURE_MESSAGE },:test => true)
40
+ else
41
+ raise Error, ERROR_MESSAGE
42
+ end
43
+ end
44
+
45
+ def recurring(money, credit_card_or_reference, options = {})
46
+ money = amount(money)
47
+ case normalize(credit_card_or_reference)
48
+ when /1$/
49
+ Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money}, :test => true)
50
+ when /2$/
51
+ Response.new(false, FAILURE_MESSAGE, {:paid_amount => money, :error => FAILURE_MESSAGE },:test => true)
52
+ else
53
+ raise Error, ERROR_MESSAGE
54
+ end
55
+ end
56
+
57
+ def credit(money, credit_card_or_reference, options = {})
58
+ if credit_card_or_reference.is_a?(String)
59
+ deprecated CREDIT_DEPRECATION_MESSAGE
60
+ return refund(money, credit_card_or_reference, options)
61
+ end
62
+
63
+ money = amount(money)
64
+ case normalize(credit_card_or_reference)
65
+ when /1$/
66
+ Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money}, :test => true )
67
+ when /2$/
68
+ Response.new(false, FAILURE_MESSAGE, {:paid_amount => money, :error => FAILURE_MESSAGE }, :test => true)
69
+ else
70
+ raise Error, CREDIT_ERROR_MESSAGE
71
+ end
72
+ end
73
+
74
+ def refund(money, reference, options = {})
75
+ money = amount(money)
76
+ case reference
77
+ when /1$/
78
+ raise Error, REFUND_ERROR_MESSAGE
79
+ when /2$/
80
+ Response.new(false, FAILURE_MESSAGE, {:paid_amount => money, :error => FAILURE_MESSAGE }, :test => true)
81
+ else
82
+ Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money}, :test => true)
83
+ end
84
+ end
85
+
86
+ def capture(money, reference, options = {})
87
+ money = amount(money)
88
+ case reference
89
+ when /1$/
90
+ raise Error, CAPTURE_ERROR_MESSAGE
91
+ when /2$/
92
+ Response.new(false, FAILURE_MESSAGE, {:paid_amount => money, :error => FAILURE_MESSAGE }, :test => true)
93
+ else
94
+ Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money}, :test => true)
95
+ end
96
+ end
97
+
98
+ def void(reference, options = {})
99
+ case reference
100
+ when /1$/
101
+ raise Error, VOID_ERROR_MESSAGE
102
+ when /2$/
103
+ Response.new(false, FAILURE_MESSAGE, {:authorization => reference, :error => FAILURE_MESSAGE }, :test => true)
104
+ else
105
+ Response.new(true, SUCCESS_MESSAGE, {:authorization => reference}, :test => true)
106
+ end
107
+ end
108
+
109
+ def store(credit_card_or_reference, options = {})
110
+ case normalize(credit_card_or_reference)
111
+ when /1$/
112
+ Response.new(true, SUCCESS_MESSAGE, {:billingid => '1'}, :test => true, :authorization => AUTHORIZATION)
113
+ when /2$/
114
+ Response.new(false, FAILURE_MESSAGE, {:billingid => nil, :error => FAILURE_MESSAGE }, :test => true)
115
+ else
116
+ raise Error, ERROR_MESSAGE
117
+ end
118
+ end
119
+
120
+ def unstore(reference, options = {})
121
+ case reference
122
+ when /1$/
123
+ Response.new(true, SUCCESS_MESSAGE, {}, :test => true)
124
+ when /2$/
125
+ Response.new(false, FAILURE_MESSAGE, {:error => FAILURE_MESSAGE },:test => true)
126
+ else
127
+ raise Error, UNSTORE_ERROR_MESSAGE
128
+ end
129
+ end
130
+
131
+ private
132
+
133
+ def normalize(credit_card_or_reference)
134
+ if credit_card_or_reference.respond_to?(:number)
135
+ credit_card_or_reference.number
136
+ else
137
+ credit_card_or_reference.to_s
138
+ end
139
+ end
140
+ end
141
+ end
142
+ end
@@ -0,0 +1,9 @@
1
+ module BraintreeCommon
2
+ def self.included(base)
3
+ base.supported_countries = ['US']
4
+ base.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club]
5
+ base.homepage_url = 'http://www.braintreepaymentsolutions.com'
6
+ base.display_name = 'Braintree'
7
+ base.default_currency = 'USD'
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ require File.dirname(__FILE__) + '/braintree/braintree_common'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ class BraintreeGateway < Gateway
6
+ include BraintreeCommon
7
+
8
+ self.abstract_class = true
9
+
10
+ def self.new(options={})
11
+ if options.has_key?(:login)
12
+ BraintreeOrangeGateway.new(options)
13
+ else
14
+ BraintreeBlueGateway.new(options)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end