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,316 @@
1
+ require 'active_support/core_ext/hash/slice'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ class StripeGateway < Gateway
6
+ self.live_url = 'https://api.stripe.com/v1/'
7
+
8
+ AVS_CODE_TRANSLATOR = {
9
+ 'line1: pass, zip: pass' => 'Y',
10
+ 'line1: pass, zip: fail' => 'A',
11
+ 'line1: pass, zip: unchecked' => 'B',
12
+ 'line1: fail, zip: pass' => 'Z',
13
+ 'line1: fail, zip: fail' => 'N',
14
+ 'line1: unchecked, zip: pass' => 'P',
15
+ 'line1: unchecked, zip: unchecked' => 'I'
16
+ }
17
+
18
+ CVC_CODE_TRANSLATOR = {
19
+ 'pass' => 'M',
20
+ 'fail' => 'N',
21
+ 'unchecked' => 'P'
22
+ }
23
+
24
+ self.supported_countries = ['US', 'CA']
25
+ self.default_currency = 'USD'
26
+ self.money_format = :cents
27
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club]
28
+
29
+ self.homepage_url = 'https://stripe.com/'
30
+ self.display_name = 'Stripe'
31
+
32
+ def initialize(options = {})
33
+ requires!(options, :login)
34
+ @api_key = options[:login]
35
+ @fee_refund_api_key = options[:fee_refund_login]
36
+ super
37
+ end
38
+
39
+ def authorize(money, creditcard, options = {})
40
+ post = create_post_for_auth_or_purchase(money, creditcard, options)
41
+ post[:capture] = "false"
42
+
43
+ commit(:post, 'charges', post, generate_meta(options), creditcard)
44
+ end
45
+
46
+ # To create a charge on a card or a token, call
47
+ #
48
+ # purchase(money, card_hash_or_token, { ... })
49
+ #
50
+ # To create a charge on a customer, call
51
+ #
52
+ # purchase(money, nil, { :customer => id, ... })
53
+ def purchase(money, creditcard, options = {})
54
+ post = create_post_for_auth_or_purchase(money, creditcard, options)
55
+
56
+ commit(:post, 'charges', post, generate_meta(options), creditcard)
57
+ end
58
+
59
+ def capture(money, authorization, options = {})
60
+ post = {:amount => amount(money)}
61
+ add_application_fee(post, nil, options)
62
+
63
+ commit(:post, "charges/#{CGI.escape(authorization)}/capture", post)
64
+ end
65
+
66
+ def void(identification, options = {})
67
+ commit(:post, "charges/#{CGI.escape(identification)}/refund", {})
68
+ end
69
+
70
+ def refund(money, identification, options = {})
71
+ post = {:amount => amount(money)}
72
+ commit_options = generate_meta(options)
73
+
74
+ MultiResponse.run do |r|
75
+ r.process { commit(:post, "charges/#{CGI.escape(identification)}/refund", post, commit_options) }
76
+
77
+ return r unless options[:refund_fee_amount]
78
+
79
+ r.process { fetch_application_fees(identification, commit_options) }
80
+ r.process { refund_application_fee(options[:refund_fee_amount], application_fee_from_response(r), commit_options) }
81
+ end
82
+ end
83
+
84
+ def application_fee_from_response(response)
85
+ return unless response.success?
86
+
87
+ application_fees = response.params["data"].select { |fee| fee["object"] == "application_fee" }
88
+ application_fees.first["id"] unless application_fees.empty?
89
+ end
90
+
91
+ def refund_application_fee(money, identification, options = {})
92
+ return Response.new(false, "Application fee id could not be found") unless identification
93
+
94
+ post = {:amount => amount(money)}
95
+ options.merge!(:key => @fee_refund_api_key)
96
+
97
+ commit(:post, "application_fees/#{CGI.escape(identification)}/refund", post, options)
98
+ end
99
+
100
+ def store(creditcard, options = {})
101
+ post = {}
102
+ add_creditcard(post, creditcard, options)
103
+ post[:description] = options[:description]
104
+ post[:email] = options[:email]
105
+
106
+ path = if options[:customer]
107
+ "customers/#{CGI.escape(options[:customer])}"
108
+ else
109
+ 'customers'
110
+ end
111
+
112
+ commit(:post, path, post, generate_meta(options))
113
+ end
114
+
115
+ def update(customer_id, creditcard, options = {})
116
+ options = options.merge(:customer => customer_id)
117
+ store(creditcard, options)
118
+ end
119
+
120
+ def unstore(customer_id, options = {})
121
+ commit(:delete, "customers/#{CGI.escape(customer_id)}", nil, generate_meta(options))
122
+ end
123
+
124
+ private
125
+
126
+ def create_post_for_auth_or_purchase(money, creditcard, options)
127
+ post = {}
128
+ add_amount(post, money, options)
129
+ add_creditcard(post, creditcard, options)
130
+ add_customer(post, options)
131
+ add_customer_data(post,options)
132
+ post[:description] = options[:description] || options[:email]
133
+ add_flags(post, options)
134
+ add_application_fee(post, creditcard, options)
135
+ post
136
+ end
137
+
138
+ def add_amount(post, money, options)
139
+ post[:amount] = amount(money)
140
+ post[:currency] = (options[:currency] || currency(money)).downcase
141
+ end
142
+
143
+ def add_application_fee(post, creditcard, options)
144
+ return unless options[:application_fee]
145
+ if use_card_not_present_fee?(creditcard, options)
146
+ post[:application_fee] = options[:card_not_present_fee]
147
+ else
148
+ post[:application_fee] = options[:application_fee]
149
+ end
150
+ end
151
+
152
+ def use_card_not_present_fee?(creditcard, options)
153
+ options[:card_not_present_fee].present? && !includes_track_data?(creditcard, options)
154
+ end
155
+
156
+ def includes_track_data?(creditcard, options)
157
+ if creditcard.respond_to?(:track_data)
158
+ creditcard.track_data.present?
159
+ else
160
+ options[:track_data].present?
161
+ end
162
+ end
163
+
164
+ def add_customer_data(post, options)
165
+ metadata_options = [:description,:browser_ip,:user_agent,:referrer]
166
+ post.update(options.slice(*metadata_options))
167
+
168
+ post[:external_id] = options[:order_id]
169
+ post[:payment_user_agent] = "Stripe/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}"
170
+ end
171
+
172
+ def add_address(post, options)
173
+ return unless post[:card] && post[:card].kind_of?(Hash)
174
+ if address = options[:billing_address] || options[:address]
175
+ post[:card][:address_line1] = address[:address1] if address[:address1]
176
+ post[:card][:address_line2] = address[:address2] if address[:address2]
177
+ post[:card][:address_country] = address[:country] if address[:country]
178
+ post[:card][:address_zip] = address[:zip] if address[:zip]
179
+ post[:card][:address_state] = address[:state] if address[:state]
180
+ post[:card][:address_city] = address[:city] if address[:city]
181
+ end
182
+ end
183
+
184
+ def add_creditcard(post, creditcard, options)
185
+ card = {}
186
+ if creditcard.respond_to?(:number)
187
+ if creditcard.respond_to?(:track_data) && creditcard.track_data.present?
188
+ card[:swipe_data] = creditcard.track_data
189
+ else
190
+ card[:number] = creditcard.number
191
+ card[:exp_month] = creditcard.month
192
+ card[:exp_year] = creditcard.year
193
+ card[:cvc] = creditcard.verification_value if creditcard.verification_value?
194
+ card[:name] = creditcard.name if creditcard.name
195
+ end
196
+
197
+ post[:card] = card
198
+ add_address(post, options)
199
+ elsif creditcard.kind_of?(String)
200
+ if options[:track_data]
201
+ card[:swipe_data] = options[:track_data]
202
+ else
203
+ card[:number] = creditcard
204
+ end
205
+ post[:card] = card
206
+ end
207
+ end
208
+
209
+ def add_customer(post, options)
210
+ post[:customer] = options[:customer] if options[:customer] && !post[:card]
211
+ end
212
+
213
+ def add_flags(post, options)
214
+ post[:uncaptured] = true if options[:uncaptured]
215
+ end
216
+
217
+ def fetch_application_fees(identification, options = {})
218
+ options.merge!(:key => @fee_refund_api_key)
219
+
220
+ commit(:get, "application_fees?charge=#{identification}", nil, options)
221
+ end
222
+
223
+ def parse(body)
224
+ JSON.parse(body)
225
+ end
226
+
227
+ def post_data(params)
228
+ return nil unless params
229
+
230
+ params.map do |key, value|
231
+ next if value.blank?
232
+ if value.is_a?(Hash)
233
+ h = {}
234
+ value.each do |k, v|
235
+ h["#{key}[#{k}]"] = v unless v.blank?
236
+ end
237
+ post_data(h)
238
+ else
239
+ "#{key}=#{CGI.escape(value.to_s)}"
240
+ end
241
+ end.compact.join("&")
242
+ end
243
+
244
+ def generate_meta(options)
245
+ {:meta => {:ip => options[:ip]}}
246
+ end
247
+
248
+ def headers(options = {})
249
+ @@ua ||= JSON.dump({
250
+ :bindings_version => ActiveMerchant::VERSION,
251
+ :lang => 'ruby',
252
+ :lang_version => "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})",
253
+ :platform => RUBY_PLATFORM,
254
+ :publisher => 'active_merchant',
255
+ :uname => (RUBY_PLATFORM =~ /linux|darwin/i ? `uname -a 2>/dev/null`.strip : nil)
256
+ })
257
+
258
+ key = options[:key] || @api_key
259
+
260
+ {
261
+ "Authorization" => "Basic " + Base64.encode64(key.to_s + ":").strip,
262
+ "User-Agent" => "Stripe/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
263
+ "X-Stripe-Client-User-Agent" => @@ua,
264
+ "X-Stripe-Client-User-Metadata" => options[:meta].to_json
265
+ }
266
+ end
267
+
268
+ def commit(method, url, parameters=nil, options = {}, creditcard = nil)
269
+ raw_response = response = nil
270
+ success = false
271
+ begin
272
+ raw_response = ssl_request(method, self.live_url + url, post_data(parameters), headers(options))
273
+ response = parse(raw_response)
274
+ success = !response.key?("error")
275
+ rescue ResponseError => e
276
+ raw_response = e.response.body
277
+ response = response_error(raw_response)
278
+ rescue JSON::ParserError
279
+ response = json_error(raw_response)
280
+ end
281
+
282
+ response[:card_present] = includes_track_data?(creditcard, options)
283
+
284
+ card = response["card"] || response["active_card"] || {}
285
+ avs_code = AVS_CODE_TRANSLATOR["line1: #{card["address_line1_check"]}, zip: #{card["address_zip_check"]}"]
286
+ cvc_code = CVC_CODE_TRANSLATOR[card["cvc_check"]]
287
+ Response.new(success,
288
+ success ? "Transaction approved" : response["error"]["message"],
289
+ response,
290
+ :test => response.has_key?("livemode") ? !response["livemode"] : false,
291
+ :authorization => response["id"],
292
+ :avs_result => { :code => avs_code },
293
+ :cvv_result => cvc_code
294
+ )
295
+ end
296
+
297
+ def response_error(raw_response)
298
+ begin
299
+ parse(raw_response)
300
+ rescue JSON::ParserError
301
+ json_error(raw_response)
302
+ end
303
+ end
304
+
305
+ def json_error(raw_response)
306
+ msg = 'Invalid response received from the Stripe API. Please contact support@stripe.com if you continue to receive this message.'
307
+ msg += " (The raw response returned by the API was #{raw_response.inspect})"
308
+ {
309
+ "error" => {
310
+ "message" => msg
311
+ }
312
+ }
313
+ end
314
+ end
315
+ end
316
+ end
@@ -0,0 +1,126 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class TransFirstGateway < Gateway
4
+ self.live_url = self.test_url = 'https://webservices.primerchants.com/creditcard.asmx/CCSale'
5
+
6
+ self.supported_countries = ['US']
7
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover]
8
+ self.homepage_url = 'http://www.transfirst.com/'
9
+ self.display_name = 'TransFirst'
10
+
11
+ UNUSED_FIELDS = %w(ECIValue UserId CAVVData TrackData POSInd EComInd MerchZIP MerchCustPNum MCC InstallmentNum InstallmentOf POSEntryMode POSConditionCode AuthCharInd CardCertData)
12
+
13
+ DECLINED = 'The transaction was declined'
14
+
15
+ def initialize(options = {})
16
+ requires!(options, :login, :password)
17
+ super
18
+ end
19
+
20
+ def purchase(money, credit_card, options = {})
21
+ post = {}
22
+
23
+ add_amount(post, money)
24
+ add_invoice(post, options)
25
+ add_credit_card(post, credit_card)
26
+ add_address(post, options)
27
+
28
+ commit(post)
29
+ end
30
+
31
+ private
32
+ def add_amount(post, money)
33
+ add_pair(post, :Amount, amount(money), :required => true)
34
+ end
35
+
36
+ def add_address(post, options)
37
+ address = options[:billing_address] || options[:address]
38
+
39
+ if address
40
+ add_pair(post, :Address, address[:address1])
41
+ add_pair(post, :ZipCode, address[:zip])
42
+ end
43
+ end
44
+
45
+ def add_invoice(post, options)
46
+ add_pair(post, :RefID, options[:order_id], :required => true)
47
+ add_pair(post, :PONumber, options[:invoice], :required => true)
48
+ add_pair(post, :SaleTaxAmount, amount(options[:tax] || 0))
49
+ add_pair(post, :PaymentDesc, options[:description], :required => true)
50
+ add_pair(post, :TaxIndicator, 0)
51
+ end
52
+
53
+ def add_credit_card(post, credit_card)
54
+ add_pair(post, :CardHolderName, credit_card.name, :required => true)
55
+ add_pair(post, :CardNumber, credit_card.number, :required => true)
56
+
57
+ add_pair(post, :Expiration, expdate(credit_card), :required => true)
58
+ add_pair(post, :CVV2, credit_card.verification_value)
59
+ end
60
+
61
+ def add_unused_fields(post)
62
+ UNUSED_FIELDS.each do |f|
63
+ post[f] = ""
64
+ end
65
+ end
66
+
67
+ def expdate(credit_card)
68
+ year = format(credit_card.year, :two_digits)
69
+ month = format(credit_card.month, :two_digits)
70
+
71
+ "#{month}#{year}"
72
+ end
73
+
74
+ def parse(data)
75
+ response = {}
76
+
77
+ xml = REXML::Document.new(data)
78
+ root = REXML::XPath.first(xml, "//CCSaleDebitResponse")
79
+
80
+ if root.nil?
81
+ response[:message] = data.to_s.strip
82
+ else
83
+ root.elements.to_a.each do |node|
84
+ response[node.name.underscore.to_sym] = node.text
85
+ end
86
+ end
87
+
88
+ response
89
+ end
90
+
91
+ def commit(params)
92
+ response = parse( ssl_post(self.live_url, post_data(params)) )
93
+
94
+ Response.new(response[:status] == "Authorized", message_from(response), response,
95
+ :test => test?,
96
+ :authorization => response[:trans_id],
97
+ :avs_result => { :code => response[:avs_code] },
98
+ :cvv_result => response[:cvv2_code]
99
+ )
100
+ end
101
+
102
+ def message_from(response)
103
+ case response[:message]
104
+ when 'Call Voice Center'
105
+ DECLINED
106
+ else
107
+ response[:message]
108
+ end
109
+ end
110
+
111
+ def post_data(params = {})
112
+ add_unused_fields(params)
113
+ params[:MerchantID] = @options[:login]
114
+ params[:RegKey] = @options[:password]
115
+
116
+ request = params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
117
+ request
118
+ end
119
+
120
+ def add_pair(post, key, value, options = {})
121
+ post[key] = value if !value.blank? || options[:required]
122
+ end
123
+ end
124
+ end
125
+ end
126
+
@@ -0,0 +1,23 @@
1
+ require File.join(File.dirname(__FILE__),'smart_ps.rb')
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ class TransaxGateway < SmartPs
6
+ self.live_url = self.test_url = 'https://secure.nelixtransax.net/api/transact.php'
7
+
8
+ # The countries the gateway supports merchants from as 2 digit ISO country codes
9
+ self.supported_countries = ['US']
10
+
11
+ # The card types supported by the payment gateway
12
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover]
13
+
14
+ # The homepage URL of the gateway
15
+ self.homepage_url = 'https://www.nelixtransax.com/'
16
+
17
+ # The name of the gateway
18
+ self.display_name = 'NELiX TransaX'
19
+
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,239 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class TransnationalGateway < Gateway
4
+ self.live_url = self.test_url = 'https://secure.networkmerchants.com/api/transact.php'
5
+
6
+ self.supported_countries = ['US']
7
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover]
8
+
9
+ self.homepage_url = 'http://www.tnbci.com/'
10
+ self.display_name = 'Transnational'
11
+
12
+ self.money_format = :dollars
13
+ self.default_currency = 'USD'
14
+
15
+ def initialize(options = {})
16
+ requires!(options, :login, :password)
17
+ super
18
+ end
19
+
20
+ def authorize(money, creditcard_or_vault_id, options = {})
21
+ post = build_auth_post(money, creditcard_or_vault_id, options)
22
+ commit('auth', post)
23
+ end
24
+
25
+ def purchase(money, creditcard_or_vault_id, options = {})
26
+ post = build_purchase_post(money, creditcard_or_vault_id, options)
27
+ commit('sale', post)
28
+ end
29
+
30
+ def capture(money, authorization, options = {})
31
+ post = build_capture_post(money, authorization, options)
32
+ commit('capture', post)
33
+ end
34
+
35
+ def void(authorization, options = {})
36
+ post = build_void_post(authorization, options)
37
+ commit('void', post)
38
+ end
39
+
40
+ def refund(money, authorization, options = {})
41
+ post = build_refund_post(money, authorization, options)
42
+ commit('refund', post)
43
+ end
44
+
45
+ def store(creditcard, options = {})
46
+ post = build_store_post(creditcard, options)
47
+ commit_vault('add_customer', post)
48
+ end
49
+
50
+ def unstore(customer_vault_id, options = {})
51
+ post = build_unstore_post(customer_vault_id, options)
52
+ commit_vault('delete_customer', post)
53
+ end
54
+
55
+ private
56
+
57
+ def build_auth_post(money, creditcard_or_vault_id, options)
58
+ post = {}
59
+ add_order(post, options)
60
+ add_address(post, options)
61
+ add_shipping_address(post, options)
62
+ add_payment_method(post, creditcard_or_vault_id, options)
63
+ add_amount(post, money)
64
+ post
65
+ end
66
+
67
+ def build_purchase_post(money, creditcard, options)
68
+ build_auth_post(money, creditcard, options)
69
+ end
70
+
71
+ def build_capture_post(money, authorization, option)
72
+ post = {}
73
+ post[:transactionid] = authorization
74
+ add_amount(post, money)
75
+ post
76
+ end
77
+
78
+ def build_void_post(authorization, options)
79
+ post = {}
80
+ post[:transactionid] = authorization
81
+ post
82
+ end
83
+
84
+ def build_refund_post(money, authorization, options)
85
+ post = {}
86
+ post[:transactionid] = authorization
87
+ add_amount(post, money)
88
+ post
89
+ end
90
+
91
+ def build_store_post(creditcard_or_check, options)
92
+ post = {}
93
+ add_address(post, options)
94
+ add_shipping_address(post, options)
95
+ add_payment_method(post, creditcard_or_check, options)
96
+ post
97
+ end
98
+
99
+ def build_unstore_post(customer_vault_id, options)
100
+ post = {}
101
+ post['customer_vault_id'] = customer_vault_id
102
+ post
103
+ end
104
+
105
+ def add_order(post, options)
106
+ post[:orderid] = options[:order_id]
107
+ post[:orderdescription] = options[:description]
108
+ end
109
+
110
+ def add_address(post, options)
111
+ post[:email] = options[:email]
112
+ post[:ipaddress] = options[:ip]
113
+
114
+ address = options[:billing_address] || options[:address] || {}
115
+ post[:address1] = address[:address1]
116
+ post[:address2] = address[:address2]
117
+ post[:city] = address[:city]
118
+ post[:state] = address[:state]
119
+ post[:zip] = address[:zip]
120
+ post[:country] = address[:country]
121
+ post[:phone] = address[:phone]
122
+ end
123
+
124
+ def add_shipping_address(post, options)
125
+ shipping_address = options[:shipping_address] || {}
126
+ post[:shipping_address1] = shipping_address[:address1]
127
+ post[:shipping_address2] = shipping_address[:address2]
128
+ post[:shipping_city] = shipping_address[:city]
129
+ post[:shipping_state] = shipping_address[:state]
130
+ post[:shipping_zip] = shipping_address[:zip]
131
+ post[:shipping_country] = shipping_address[:country]
132
+ end
133
+
134
+ def add_swipe_data(post, options)
135
+ # unencrypted tracks
136
+ post[:track_1] = options[:track_1]
137
+ post[:track_2] = options[:track_2]
138
+ post[:track_3] = options[:track_3]
139
+
140
+ # encrypted tracks
141
+ post[:magnesafe_track_1] = options[:magnesafe_track_1]
142
+ post[:magnesafe_track_2] = options[:magnesafe_track_2]
143
+ post[:magnesafe_track_3] = options[:magnesafe_track_3]
144
+ post[:magnesafe_magneprint] = options[:magnesafe_magneprint]
145
+ post[:magnesafe_ksn] = options[:magnesafe_ksn]
146
+ post[:magnesafe_magneprint_status] = options[:magnesafe_magneprint_status]
147
+ end
148
+
149
+ def add_payment_method(post, creditcard_or_check_or_vault_id, options)
150
+ post[:processor_id] = options[:processor_id]
151
+ post[:customer_vault] = 'add_customer' if options[:store]
152
+
153
+ add_swipe_data(post, options)
154
+
155
+ # creditcard_or_check can be blank if using swipe data
156
+ if creditcard_or_check_or_vault_id.is_a?(CreditCard) # creditcard or check
157
+ creditcard = creditcard_or_check_or_vault_id
158
+ post[:firstname] = creditcard.first_name
159
+ post[:lastname] = creditcard.last_name
160
+ post[:ccnumber] = creditcard.number
161
+ post[:ccexp] = format(creditcard.month, :two_digits) + format(creditcard.year, :two_digits)
162
+ post[:cvv] = creditcard.verification_value
163
+ post[:payment] = 'creditcard'
164
+ elsif creditcard_or_check_or_vault_id.is_a?(Check)
165
+ check = creditcard_or_check_or_vault_id
166
+ post[:firstname] = check.first_name
167
+ post[:lastname] = check.last_name
168
+ post[:checkname] = check.name
169
+ post[:checkaba] = check.routing_number
170
+ post[:checkaccount] = check.account_number
171
+ post[:account_type] = check.account_type
172
+ post[:account_holder_type] = check.account_holder_type
173
+ post[:payment] = 'check'
174
+ else
175
+ post[:customer_vault_id] = creditcard_or_check_or_vault_id
176
+ end
177
+ end
178
+
179
+ def add_login(post)
180
+ post[:username] = @options[:login]
181
+ post[:password] = @options[:password]
182
+ end
183
+
184
+ def add_amount(post, money)
185
+ post[:currency] = options[:currency] || currency(money)
186
+ post[:amount] = amount(money)
187
+ end
188
+
189
+ def commit_vault(action, parameters)
190
+ commit(nil, parameters.merge(:customer_vault => action))
191
+ end
192
+
193
+ def commit(action, parameters)
194
+ raw = parse(ssl_post(self.live_url, build_request(action, parameters)))
195
+
196
+ success = (raw['response'] == ResponseCodes::APPROVED)
197
+
198
+ authorization = authorization_from(success, parameters, raw)
199
+
200
+ Response.new(success, raw['responsetext'], raw,
201
+ :test => test?,
202
+ :authorization => authorization,
203
+ :avs_result => { :code => raw['avsresponse']},
204
+ :cvv_result => raw['cvvresponse']
205
+ )
206
+ end
207
+
208
+ def build_request(action, parameters)
209
+ parameters[:type] = action if action
210
+ add_login(parameters)
211
+ parameters.to_query
212
+ end
213
+
214
+ def authorization_from(success, parameters, response)
215
+ return nil unless success
216
+
217
+ authorization = response['transactionid']
218
+ if(parameters[:customer_vault] && (authorization.nil? || authorization.empty?))
219
+ authorization = response['customer_vault_id']
220
+ end
221
+
222
+ authorization
223
+ end
224
+
225
+ class ResponseCodes
226
+ APPROVED = '1'
227
+ DENIED = '2'
228
+ ERROR = '3'
229
+ end
230
+
231
+ def parse(raw_response)
232
+ rsp = CGI.parse(raw_response)
233
+ rsp.keys.each { |k| rsp[k] = rsp[k].first } # flatten out the values
234
+ rsp
235
+ end
236
+ end
237
+ end
238
+ end
239
+