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,261 @@
1
+ require 'digest/md5'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ # This gateway accepts the following arguments:
6
+ # :login => your PayJunction username
7
+ # :password => your PayJunction pass
8
+ # Example use:
9
+ #
10
+ # gateway = ActiveMerchant::Billing::Base.gateway(:pay_gate_xml).new(
11
+ # :login => "my_account",
12
+ # :password => "my_pass"
13
+ # )
14
+ #
15
+ # # set up credit card obj as in main ActiveMerchant example
16
+ # creditcard = ActiveMerchant::Billing::CreditCard.new(
17
+ # :type => 'visa',
18
+ # :number => '4242424242424242',
19
+ # :month => 8,
20
+ # :year => 2009,
21
+ # :first_name => 'Bob',
22
+ # :last_name => 'Bobsen'
23
+ # )
24
+ #
25
+ # # run request
26
+ # response = gateway.purchase(1000, creditcard) # charge 10 dollars
27
+ #
28
+ # 1) Check whether the transaction was successful
29
+ #
30
+ # response.success?
31
+ #
32
+ # 2) Retrieve the message returned by PayJunction
33
+ #
34
+ # response.message
35
+ #
36
+ # 3) Retrieve the unique transaction ID returned by PayGateXML
37
+ #
38
+ # response.authorization
39
+ #
40
+ # This gateway has many other features which are not implemented here yet
41
+ # The basic setup here only supports auth/capture transactions.
42
+ #
43
+ # Test Transactions
44
+ #
45
+ # PayGateXML has a global test user/pass, but you can also sign up for your own.
46
+ # The class and the test come equipped with the global test creds
47
+ #
48
+ # Usage Details
49
+ #
50
+ # Below is a map of only SOME of the values accepted by PayGateXML and how you should submit
51
+ # each to ActiveMerchant
52
+ #
53
+ # PayGateXML Field ActiveMerchant Use
54
+ #
55
+ # pgid use :login value to gateway instantation
56
+ # pwd use :password value to gateway instantiation
57
+ #
58
+ # cname credit_card.name
59
+ # cc credit_card.number
60
+ # exp credit_card values formatted to YYYYMMDD
61
+ # budp South Africa only - set to 0 if purchase is not on budget
62
+ # amt include as argument to method for your transaction type
63
+ # ver do nothing, always set to current API version
64
+ #
65
+ # cref provide as :invoice in options, varchar(80)
66
+ # cur 3 char field, currently only ZAR
67
+ # cvv credit_card.verification
68
+ # bno batch processing number, i.e. you supply this
69
+ #
70
+ # others -- not used in this implementation
71
+ # nurl, rurl - must remain blank or absent or they will use an alternative authentication mechanism
72
+ # email, ip - must remain blank or absent or they will use a PayGate extra service call PayProtector
73
+ # threed - must remain blank unless you are using your own 3D Secure server
74
+ #
75
+ class PayGateXmlGateway < Gateway
76
+ self.live_url = 'https://www.paygate.co.za/payxml/process.trans'
77
+
78
+ # The countries the gateway supports merchants from as 2 digit ISO country codes
79
+ self.supported_countries = ['US', 'ZA']
80
+
81
+ # The card types supported by the payment gateway
82
+ self.supported_cardtypes = [:visa, :master, :american_express, :diners_club]
83
+
84
+ # The homepage URL of the gateway
85
+ self.homepage_url = 'http://paygate.co.za/'
86
+
87
+ # The name of the gateway
88
+ self.display_name = 'PayGate PayXML'
89
+
90
+ # PayGate only supports Rands
91
+ self.default_currency = 'ZAR'
92
+
93
+ # PayGate accepts only lowest denomination
94
+ self.money_format = :cents
95
+
96
+ # PayGateXML public test account - you can get a private one too
97
+ TEST_ID_3DSECURE = '10011013800'
98
+ TEST_ID = '10011021600'
99
+ TEST_PWD = 'test'
100
+
101
+ API_VERSION = '4.0'
102
+
103
+ DECLINE_CODES = {
104
+ # Credit Card Errors - These RESULT_CODEs are returned if the transaction cannot be authorized due to a problem with the card. The TRANSACTION_STATUS will be 2
105
+ 900001 => "Call for Approval",
106
+ 900002 => "Card Expired",
107
+ 900003 => "Insufficient Funds",
108
+ 900004 => "Invalid Card Number",
109
+ 900005 => "Bank Interface Timeout", # indicates a communications failure between the banks systems
110
+ 900006 => "Invalid Card",
111
+ 900007 => "Declined",
112
+ 900009 => "Lost Card",
113
+ 900010 => "Invalid Card Length",
114
+ 900011 => "Suspected Fraud",
115
+ 900012 => "Card Reported As Stolen",
116
+ 900013 => "Restricted Card",
117
+ 900014 => "Excessive Card Usage",
118
+ 900015 => "Card Blacklisted",
119
+
120
+ 900207 => "Declined; authentication failed", # indicates the cardholder did not enter their MasterCard SecureCode / Verified by Visa password correctly
121
+
122
+ 990020 => "Auth Declined",
123
+
124
+ 991001 => "Invalid expiry date",
125
+ 991002 => "Invalid amount",
126
+
127
+ # Communication Errors - These RESULT_CODEs are returned if the transaction cannot be completed due to an unexpected error. TRANSACTION_STATUS will be 0.
128
+ 900205 => "Unexpected authentication result (phase 1)",
129
+ 900206 => "Unexpected authentication result (phase 1)",
130
+
131
+ 990001 => "Could not insert into Database",
132
+
133
+ 990022 => "Bank not available",
134
+
135
+ 990053 => "Error processing transaction",
136
+
137
+ # Miscellaneous - Unless otherwise noted, the TRANSACTION_STATUS will be 0.
138
+ 900209 => "Transaction verification failed (phase 2)", # Indicates the verification data returned from MasterCard SecureCode / Verified by Visa has been altered
139
+ 900210 => "Authentication complete; transaction must be restarted", # Indicates that the MasterCard SecuerCode / Verified by Visa transaction has already been completed. Most likely caused by the customer clicking the refresh button
140
+
141
+ 990024 => "Duplicate Transaction Detected. Please check before submitting",
142
+
143
+ 990028 => "Transaction cancelled" # Customer clicks the 'Cancel' button on the payment page
144
+ }
145
+
146
+ SUCCESS_CODES = %w( 990004 990005 990017 990012 990018 990031 )
147
+
148
+ TRANSACTION_CODES = {
149
+ 0 => 'Not Done',
150
+ 1 => 'Approved',
151
+ 2 => 'Declined',
152
+ 3 => 'Paid',
153
+ 4 => 'Refunded',
154
+ 5 => 'Received by PayGate',
155
+ 6 => 'Replied to Client'
156
+ }
157
+
158
+ def initialize(options = {})
159
+ requires!(options, :login, :password)
160
+ super
161
+ end
162
+
163
+ def purchase(money, creditcard, options = {})
164
+ MultiResponse.run do |r|
165
+ r.process{authorize(money, creditcard, options)}
166
+ r.process{capture(money, r.authorization, options)}
167
+ end
168
+ end
169
+
170
+ def authorize(money, creditcard, options = {})
171
+ action = 'authtx'
172
+
173
+ options.merge!(:money => money, :creditcard => creditcard)
174
+ commit(action, build_request(action, options))
175
+ end
176
+
177
+ def capture(money, authorization, options = {})
178
+ action = 'settletx'
179
+
180
+ options.merge!(:money => money, :authorization => authorization)
181
+ commit(action, build_request(action, options))
182
+ end
183
+
184
+ private
185
+
186
+ def successful?(response)
187
+ SUCCESS_CODES.include?(response[:res])
188
+ end
189
+
190
+ def build_request(action, options={})
191
+ xml = Builder::XmlMarkup.new
192
+ xml.instruct!
193
+
194
+ xml.tag! 'protocol', :ver => API_VERSION, :pgid => (test? ? TEST_ID : @options[:login]), :pwd => @options[:password] do |protocol|
195
+ case action
196
+ when 'authtx'
197
+ money = options.delete(:money)
198
+ creditcard = options.delete(:creditcard)
199
+ build_authorization(protocol, money, creditcard, options)
200
+ when 'settletx'
201
+ money = options.delete(:money)
202
+ authorization = options.delete(:authorization)
203
+ build_capture(protocol, money, authorization, options)
204
+ else
205
+ raise "no action specified for build_request"
206
+ end
207
+ end
208
+
209
+ xml.target!
210
+ end
211
+
212
+ def build_authorization(xml, money, creditcard, options={})
213
+ xml.tag! 'authtx', {
214
+ :cref => options[:order_id],
215
+ :cname => creditcard.name,
216
+ :cc => creditcard.number,
217
+ :exp => "#{format(creditcard.month, :two_digits)}#{format(creditcard.year, :four_digits)}",
218
+ :budp => 0,
219
+ :amt => amount(money),
220
+ :cur => (options[:currency] || currency(money)),
221
+ :cvv => creditcard.verification_value
222
+ }
223
+ end
224
+
225
+ def build_capture(xml, money, authorization, options={})
226
+ xml.tag! 'settletx', {
227
+ :tid => authorization
228
+ }
229
+ end
230
+
231
+ def parse(action, body)
232
+ hash = {}
233
+ xml = REXML::Document.new(body)
234
+
235
+ response_action = action.gsub(/tx/, 'rx')
236
+ root = REXML::XPath.first(xml.root, response_action)
237
+ # we might have gotten an error
238
+ if root.nil?
239
+ root = REXML::XPath.first(xml.root, 'errorrx')
240
+ end
241
+ root.attributes.each do |name, value|
242
+ hash[name.to_sym] = value
243
+ end
244
+ hash
245
+ end
246
+
247
+ def commit(action, request)
248
+ response = parse(action, ssl_post(self.live_url, request))
249
+ Response.new(successful?(response), message_from(response), response,
250
+ :test => test?,
251
+ :authorization => response[:tid]
252
+ )
253
+ end
254
+
255
+ def message_from(response)
256
+ (response[:rdesc] || response[:edesc])
257
+ end
258
+ end
259
+ end
260
+ end
261
+
@@ -0,0 +1,396 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ # PayJunction Gateway
4
+ #
5
+ # This gateway accepts the following arguments:
6
+ # :login => your PayJunction username
7
+ # :password => your PayJunction pass
8
+ #
9
+ # Example use:
10
+ #
11
+ # gateway = ActiveMerchant::Billing::Base.gateway(:pay_junction).new(
12
+ # :login => "my_account",
13
+ # :password => "my_pass"
14
+ # )
15
+ #
16
+ # # set up credit card obj as in main ActiveMerchant example
17
+ # creditcard = ActiveMerchant::Billing::CreditCard.new(
18
+ # :type => 'visa',
19
+ # :number => '4242424242424242',
20
+ # :month => 8,
21
+ # :year => 2009,
22
+ # :first_name => 'Bob',
23
+ # :last_name => 'Bobsen'
24
+ # )
25
+ #
26
+ # # optionally specify address if using AVS
27
+ # address = { :address1 => '101 Test Ave', :city => 'Test', :state => 'TS',
28
+ # :zip => '10101', :country => 'US' }
29
+ #
30
+ # # run request
31
+ # response = gateway.purchase(1000, creditcard, :address => address) # charge 10 dollars
32
+ #
33
+ # 1) Check whether the transaction was successful
34
+ #
35
+ # response.success?
36
+ #
37
+ # 2) Retrieve the message returned by PayJunction
38
+ #
39
+ # response.message
40
+ #
41
+ # 3) Retrieve the unique transaction ID returned by PayJunction
42
+ #
43
+ # response.authorization
44
+ #
45
+ # This gateway supports "instant" transactions. These transactions allow you
46
+ # to execute an operation on a previously run card without card information
47
+ # provided you have the transaction id from a previous transaction with the
48
+ # same card. All functions that take a credit card object for this gateway
49
+ # can take a transaction id string instead.
50
+ #
51
+ # Test Transactions
52
+ #
53
+ # See the source for initialize() for test account information. Note that
54
+ # PayJunction does not allow test transactions on your account, so if the
55
+ # gateway is running in :test mode your transaction will be run against
56
+ # PayJunction's global test account and will not show up in your account.
57
+ #
58
+ # Transactions ran on this account go through a test processor, so there is no
59
+ # need to void or otherwise cancel transactions. However, for further safety,
60
+ # please use the special card numbers 4433221111223344 or 4444333322221111 and
61
+ # keep transaction amounts below $4.00 when testing.
62
+ #
63
+ # Also note, transactions ran for an amount between $0.00 and $1.99 will likely
64
+ # result in denial. To demonstrate approvals, use amounts between $2.00 and $4.00.
65
+ #
66
+ # Test transactions can be checked by logging into
67
+ # PayJunction Web Login with username 'pj-cm-01' and password 'pj-cm-01p'
68
+ #
69
+ # Usage Details
70
+ #
71
+ # Below is a map of values accepted by PayJunction and how you should submit
72
+ # each to ActiveMerchant
73
+ #
74
+ # PayJunction Field ActiveMerchant Use
75
+ #
76
+ # dc_logon provide as :login value to gateway instantation
77
+ # dc_password provide as :password value to gateway instantiation
78
+ #
79
+ # dc_name will be retrieved from credit_card.name
80
+ # dc_first_name :first_name on CreditCard object instantation
81
+ # dc_last_name :last_name on CreditCard object instantation
82
+ # dc_number :number on CreditCard object instantation
83
+ # dc_expiration_month :month on CreditCard object instantation
84
+ # dc_expiration_year :year on CreditCard object instantation
85
+ # dc_verification_number :verification_value on CC object instantation
86
+ #
87
+ # dc_transaction_amount include as argument to method for your transaction type
88
+ # dc_transaction_type do nothing, set by your transaction type
89
+ # dc_version do nothing, always "1.2"
90
+ #
91
+ # dc_transaction_id submit as a string in place of CreditCard obj for
92
+ # "instant" transactions.
93
+ #
94
+ # dc_invoice :order_id in options for transaction method
95
+ # dc_notes :description in options for transaction method
96
+ #
97
+ # See example use above for address AVS fields
98
+ # See #recurring for periodic transaction fields
99
+ class PayJunctionGateway < Gateway
100
+ API_VERSION = '1.2'
101
+
102
+ class_attribute :test_url, :live_url
103
+
104
+ self.test_url = "https://www.payjunctionlabs.com/quick_link"
105
+ self.live_url = "https://payjunction.com/quick_link"
106
+
107
+ TEST_LOGIN = 'pj-ql-01'
108
+ TEST_PASSWORD = 'pj-ql-01p'
109
+
110
+ SUCCESS_CODES = ["00", "85"]
111
+ SUCCESS_MESSAGE = 'The transaction was approved.'
112
+
113
+ FAILURE_MESSAGE = 'The transaction was declined.'
114
+
115
+ DECLINE_CODES = {
116
+ "AE" => 'Address verification failed because address did not match.',
117
+ 'ZE' => 'Address verification failed because zip did not match.',
118
+ 'XE' => 'Address verification failed because zip and address did not match.',
119
+ 'YE' => 'Address verification failed because zip and address did not match.',
120
+ 'OE' => 'Address verification failed because address or zip did not match.',
121
+ 'UE' => 'Address verification failed because cardholder address unavailable.',
122
+ 'RE' => 'Address verification failed because address verification system is not working.',
123
+ 'SE' => 'Address verification failed because address verification system is unavailable.',
124
+ 'EE' => 'Address verification failed because transaction is not a mail or phone order.',
125
+ 'GE' => 'Address verification failed because international support is unavailable.',
126
+ 'CE' => 'Declined because CVV2/CVC2 code did not match.',
127
+ '04' => 'Declined. Pick up card.',
128
+ '07' => 'Declined. Pick up card (Special Condition).',
129
+ '41' => 'Declined. Pick up card (Lost).',
130
+ '43' => 'Declined. Pick up card (Stolen).',
131
+ '13' => 'Declined because of the amount is invalid.',
132
+ '14' => 'Declined because the card number is invalid.',
133
+ '80' => 'Declined because of an invalid date.',
134
+ '05' => 'Declined. Do not honor.',
135
+ '51' => 'Declined because of insufficient funds.',
136
+ 'N4' => 'Declined because the amount exceeds issuer withdrawal limit.',
137
+ '61' => 'Declined because the amount exceeds withdrawal limit.',
138
+ '62' => 'Declined because of an invalid service code (restricted).',
139
+ '65' => 'Declined because the card activity limit exceeded.',
140
+ '93' => 'Declined because there a violation (the transaction could not be completed).',
141
+ '06' => 'Declined because address verification failed.',
142
+ '54' => 'Declined because the card has expired.',
143
+ '15' => 'Declined because there is no such issuer.',
144
+ '96' => 'Declined because of a system error.',
145
+ 'N7' => 'Declined because of a CVV2/CVC2 mismatch.',
146
+ 'M4' => 'Declined.',
147
+ "FE" => "There was a format error with your Trinity Gateway Service (API) request.",
148
+ "LE" => "Could not log you in (problem with dc_logon and/or dc_password).",
149
+ 'NL' => 'Aborted because of a system error, please try again later. ',
150
+ 'AB' => 'Aborted because of an upstream system error, please try again later.'
151
+ }
152
+
153
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover]
154
+ self.supported_countries = ['US']
155
+ self.homepage_url = 'http://www.payjunction.com/'
156
+ self.display_name = 'PayJunction'
157
+
158
+ def initialize(options = {})
159
+ requires!(options, :login, :password)
160
+ super
161
+ end
162
+
163
+ # The first half of the preauth(authorize)/postauth(capture) model.
164
+ # Checks to make sure funds are available for a transaction, and returns a
165
+ # transaction_id that can be used later to postauthorize (capture) the funds.
166
+ def authorize(money, payment_source, options = {})
167
+ parameters = {
168
+ :transaction_amount => amount(money),
169
+ }
170
+
171
+ add_payment_source(parameters, payment_source)
172
+ add_address(parameters, options)
173
+ add_optional_fields(parameters, options)
174
+ commit('AUTHORIZATION', parameters)
175
+ end
176
+
177
+ # A simple sale, capturing funds immediately.
178
+ # Execute authorization and capture in a single step.
179
+ def purchase(money, payment_source, options = {})
180
+ parameters = {
181
+ :transaction_amount => amount(money),
182
+ }
183
+
184
+ add_payment_source(parameters, payment_source)
185
+ add_address(parameters, options)
186
+ add_optional_fields(parameters, options)
187
+ commit('AUTHORIZATION_CAPTURE', parameters)
188
+ end
189
+
190
+ # The second half of the preauth(authorize)/postauth(capture) model.
191
+ # Retrieve funds that have been previously authorized with _authorization_
192
+ def capture(money, authorization, options = {})
193
+ parameters = {
194
+ :transaction_id => authorization,
195
+ :posture => 'capture'
196
+ }
197
+
198
+ add_optional_fields(parameters, options)
199
+ commit('update', parameters)
200
+ end
201
+
202
+ # Return money to a card that was previously billed.
203
+ # _authorization_ should be the transaction id of the transaction we are returning.
204
+ def refund(money, authorization, options = {})
205
+ parameters = {
206
+ :transaction_amount => amount(money),
207
+ :transaction_id => authorization
208
+ }
209
+
210
+ commit('CREDIT', parameters)
211
+ end
212
+
213
+ def credit(money, authorization, options = {})
214
+ deprecated CREDIT_DEPRECATION_MESSAGE
215
+ refund(money, authorization, options)
216
+ end
217
+
218
+ # Cancel a transaction that has been charged but has not yet made it
219
+ # through the batch process.
220
+ def void(authorization, options = {})
221
+ parameters = {
222
+ :transaction_id => authorization,
223
+ :posture => 'void'
224
+ }
225
+
226
+ add_optional_fields(parameters, options)
227
+ commit('update', parameters)
228
+ end
229
+
230
+ # Set up a sale that will be made on a regular basis for the same amount
231
+ # (ex. $20 a month for 12 months)
232
+ #
233
+ # The parameter :periodicity should be specified as either :monthly, :weekly, or :daily
234
+ # The parameter :payments should be the number of payments to be made
235
+ #
236
+ # gateway.recurring('2000', creditcard, :periodicity => :monthly, :payments => 12)
237
+ #
238
+ # The optional parameter :starting_at takes a date or time argument or a string in
239
+ # YYYYMMDD format and can be used to specify when the first charge will be made.
240
+ # If omitted the first charge will be immediate.
241
+ def recurring(money, payment_source, options = {})
242
+ requires!(options, [:periodicity, :monthly, :weekly, :daily], :payments)
243
+
244
+ periodic_type = case options[:periodicity]
245
+ when :monthly
246
+ 'month'
247
+ when :weekly
248
+ 'week'
249
+ when :daily
250
+ 'day'
251
+ end
252
+
253
+ if options[:starting_at].nil?
254
+ start_date = Time.now.strftime('%Y-%m-%d')
255
+ elsif options[:starting_at].is_a?(String)
256
+ sa = options[:starting_at]
257
+ start_date = "#{sa[0..3]}-#{sa[4..5]}-#{sa[6..7]}"
258
+ else
259
+ start_date = options[:starting_at].strftime('%Y-%m-%d')
260
+ end
261
+
262
+ parameters = {
263
+ :transaction_amount => amount(money),
264
+ :schedule_periodic_type => periodic_type,
265
+ :schedule_create => 'true',
266
+ :schedule_limit => options[:payments].to_i > 1 ? options[:payments] : 1,
267
+ :schedule_periodic_number => 1,
268
+ :schedule_start => start_date
269
+ }
270
+
271
+ add_payment_source(parameters, payment_source)
272
+ add_optional_fields(parameters, options)
273
+ add_address(parameters, options)
274
+ commit('AUTHORIZATION_CAPTURE', parameters)
275
+ end
276
+
277
+ def test?
278
+ (test_login? || super)
279
+ end
280
+
281
+ private
282
+
283
+ def test_login?
284
+ @options[:login] == TEST_LOGIN && @options[:password] == TEST_PASSWORD
285
+ end
286
+
287
+ # add fields depending on payment source selected (cc or transaction id)
288
+ def add_payment_source(params, source)
289
+ if source.is_a?(String)
290
+ add_billing_id(params, source)
291
+ else
292
+ add_creditcard(params, source)
293
+ end
294
+ end
295
+
296
+ # add fields for credit card
297
+ def add_creditcard(params, creditcard)
298
+ params[:name] = creditcard.name
299
+ params[:number] = creditcard.number
300
+ params[:expiration_month] = creditcard.month
301
+ params[:expiration_year] = creditcard.year
302
+ params[:verification_number] = creditcard.verification_value if creditcard.verification_value?
303
+ end
304
+
305
+ # add field for "instant" transaction, using previous transaction id
306
+ def add_billing_id(params, billingid)
307
+ params[:transaction_id] = billingid
308
+ end
309
+
310
+ # add address fields if present
311
+ def add_address(params, options)
312
+ address = options[:billing_address] || options[:address]
313
+
314
+ if address
315
+ params[:address] = address[:address1] unless address[:address1].blank?
316
+ params[:city] = address[:city] unless address[:city].blank?
317
+ params[:state] = address[:state] unless address[:state].blank?
318
+ params[:zipcode] = address[:zip] unless address[:zip].blank?
319
+ params[:country] = address[:country] unless address[:country].blank?
320
+ end
321
+ end
322
+
323
+ def add_optional_fields(params, options)
324
+ params[:notes] = options[:description] unless options[:description].blank?
325
+ params[:invoice] = options[:order_id].to_s.gsub(/[^-\/\w.,']/, '') unless options[:order_id].blank?
326
+ end
327
+
328
+ def commit(action, parameters)
329
+ url = test? ? self.test_url : self.live_url
330
+
331
+ response = parse( ssl_post(url, post_data(action, parameters)) )
332
+
333
+ Response.new(successful?(response), message_from(response), response,
334
+ :test => test?,
335
+ :authorization => response[:transaction_id] || parameters[:transaction_id]
336
+ )
337
+ end
338
+
339
+ def successful?(response)
340
+ SUCCESS_CODES.include?(response[:response_code]) || response[:query_status] == true
341
+ end
342
+
343
+ def message_from(response)
344
+ if successful?(response)
345
+ SUCCESS_MESSAGE
346
+ else
347
+ DECLINE_CODES[response[:response_code]] || FAILURE_MESSAGE
348
+ end
349
+ end
350
+
351
+ def post_data(action, params)
352
+ if test?
353
+ # test requests must use global test account
354
+ params[:logon] = TEST_LOGIN
355
+ params[:password] = TEST_PASSWORD
356
+ else
357
+ params[:logon] = @options[:login]
358
+ params[:password] = @options[:password]
359
+ end
360
+ params[:version] = API_VERSION
361
+ params[:transaction_type] = action
362
+
363
+ params.reject{|k,v| v.blank?}.collect{ |k, v| "dc_#{k.to_s}=#{CGI.escape(v.to_s)}" }.join("&")
364
+ end
365
+
366
+ def parse(body)
367
+ # PayJunction uses the Field Separator ASCII character to separate key/val
368
+ # pairs in the response. The <FS> character's octal value is 034.
369
+ #
370
+ # Sample response:
371
+ #
372
+ # transaction_id=44752<FS>response_code=M4<FS>response_message=Declined (INV TEST CARD).
373
+
374
+ pairs = body.chomp.split("\034")
375
+ response = {}
376
+ pairs.each do |pair|
377
+ key, val = pair.split('=')
378
+ response[key[3..-1].to_sym] = val ? normalize(val) : nil
379
+ end
380
+ response
381
+ end
382
+
383
+ # Make a ruby type out of the response string
384
+ def normalize(field)
385
+ case field
386
+ when "true" then true
387
+ when "false" then false
388
+ when "" then nil
389
+ when "null" then nil
390
+ else field
391
+ end
392
+ end
393
+
394
+ end
395
+ end
396
+ end