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,956 @@
1
+ # -*- coding: utf-8 -*-
2
+ module ActiveMerchant #:nodoc:
3
+ module Billing #:nodoc:
4
+ # ==== Customer Information Manager (CIM)
5
+ #
6
+ # The Authorize.Net Customer Information Manager (CIM) is an optional additional service that allows you to store sensitive payment information on
7
+ # Authorize.Net's servers, simplifying payments for returning customers and recurring transactions. It can also help with Payment Card Industry (PCI)
8
+ # Data Security Standard compliance, since customer data is no longer stored locally.
9
+ #
10
+ # To use the AuthorizeNetCimGateway CIM must be enabled for your account.
11
+ #
12
+ # Information about CIM is available on the {Authorize.Net website}[http://www.authorize.net/solutions/merchantsolutions/merchantservices/cim/].
13
+ # Information about the CIM API is available at the {Authorize.Net Integration Center}[http://developer.authorize.net/]
14
+ #
15
+ # ==== Login and Password
16
+ #
17
+ # The login and password are not the username and password you use to
18
+ # login to the Authorize.Net Merchant Interface. Instead, you will
19
+ # use the API Login ID as the login and Transaction Key as the
20
+ # password.
21
+ #
22
+ # ==== How to Get Your API Login ID and Transaction Key
23
+ #
24
+ # 1. Log into the Merchant Interface
25
+ # 2. Select Settings from the Main Menu
26
+ # 3. Click on API Login ID and Transaction Key in the Security section
27
+ # 4. Type in the answer to the secret question configured on setup
28
+ # 5. Click Submit
29
+ class AuthorizeNetCimGateway < Gateway
30
+ self.test_url = 'https://apitest.authorize.net/xml/v1/request.api'
31
+ self.live_url = 'https://api.authorize.net/xml/v1/request.api'
32
+
33
+ AUTHORIZE_NET_CIM_NAMESPACE = 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'
34
+
35
+ CIM_ACTIONS = {
36
+ :create_customer_profile => 'createCustomerProfile',
37
+ :create_customer_payment_profile => 'createCustomerPaymentProfile',
38
+ :create_customer_shipping_address => 'createCustomerShippingAddress',
39
+ :get_customer_profile => 'getCustomerProfile',
40
+ :get_customer_profile_ids => 'getCustomerProfileIds',
41
+ :get_customer_payment_profile => 'getCustomerPaymentProfile',
42
+ :get_customer_shipping_address => 'getCustomerShippingAddress',
43
+ :delete_customer_profile => 'deleteCustomerProfile',
44
+ :delete_customer_payment_profile => 'deleteCustomerPaymentProfile',
45
+ :delete_customer_shipping_address => 'deleteCustomerShippingAddress',
46
+ :update_customer_profile => 'updateCustomerProfile',
47
+ :update_customer_payment_profile => 'updateCustomerPaymentProfile',
48
+ :update_customer_shipping_address => 'updateCustomerShippingAddress',
49
+ :create_customer_profile_transaction => 'createCustomerProfileTransaction',
50
+ :validate_customer_payment_profile => 'validateCustomerPaymentProfile'
51
+ }
52
+
53
+ CIM_TRANSACTION_TYPES = {
54
+ :auth_capture => 'profileTransAuthCapture',
55
+ :auth_only => 'profileTransAuthOnly',
56
+ :capture_only => 'profileTransCaptureOnly',
57
+ :prior_auth_capture => 'profileTransPriorAuthCapture',
58
+ :refund => 'profileTransRefund',
59
+ :void => 'profileTransVoid'
60
+ }
61
+
62
+ CIM_VALIDATION_MODES = {
63
+ :none => 'none',
64
+ :test => 'testMode',
65
+ :live => 'liveMode',
66
+ :old => 'oldLiveMode'
67
+ }
68
+
69
+ BANK_ACCOUNT_TYPES = {
70
+ :checking => 'checking',
71
+ :savings => 'savings',
72
+ :business_checking => 'businessChecking'
73
+ }
74
+
75
+ ECHECK_TYPES = {
76
+ :ccd => 'CCD',
77
+ :ppd => 'PPD',
78
+ :web => 'WEB'
79
+ }
80
+
81
+ self.homepage_url = 'http://www.authorize.net/'
82
+ self.display_name = 'Authorize.Net CIM'
83
+ self.supported_countries = ['US']
84
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover]
85
+
86
+ # Creates a new AuthorizeNetCimGateway
87
+ #
88
+ # The gateway requires that a valid API Login ID and Transaction Key be passed
89
+ # in the +options+ hash.
90
+ #
91
+ # ==== Options
92
+ #
93
+ # * <tt>:login</tt> -- The Authorize.Net API Login ID (REQUIRED)
94
+ # * <tt>:password</tt> -- The Authorize.Net Transaction Key. (REQUIRED)
95
+ # * <tt>:test</tt> -- +true+ or +false+. If true, perform transactions against the test server.
96
+ # Otherwise, perform transactions against the production server.
97
+ # * <tt>:delimiter</tt> -- The delimiter used in the direct response. Default is ',' (comma).
98
+ def initialize(options = {})
99
+ requires!(options, :login, :password)
100
+ super
101
+ end
102
+
103
+ # Creates a new customer profile along with any customer payment profiles and customer shipping addresses
104
+ # for the customer profile.
105
+ #
106
+ # Returns a Response with the Customer Profile ID of the new customer profile in the authorization field.
107
+ # It is *CRITICAL* that you save this ID. There is no way to retrieve this through the API. You will not
108
+ # be able to create another Customer Profile with the same information.
109
+ #
110
+ #
111
+ #
112
+ # ==== Options
113
+ #
114
+ # * <tt>:profile</tt> -- A hash containing at least one of the CONDITIONAL profile options below (REQUIRED)
115
+ #
116
+ # ==== Profile
117
+ #
118
+ # * <tt>:email</tt> -- Email address associated with the customer profile (CONDITIONAL)
119
+ # * <tt>:description</tt> -- Description of the customer or customer profile (CONDITIONAL)
120
+ # * <tt>:merchant_customer_id</tt> -- Merchant assigned ID for the customer (CONDITIONAL)
121
+ # * <tt>:payment_profile</tt> -- A hash containing the elements of the new payment profile (optional)
122
+ #
123
+ # ==== Payment Profile
124
+ #
125
+ # * <tt>:payment</tt> -- A hash containing information on payment. Either :credit_card or :bank_account (optional)
126
+ def create_customer_profile(options)
127
+ requires!(options, :profile)
128
+ requires!(options[:profile], :email) unless options[:profile][:merchant_customer_id] || options[:profile][:description]
129
+ requires!(options[:profile], :description) unless options[:profile][:email] || options[:profile][:merchant_customer_id]
130
+ requires!(options[:profile], :merchant_customer_id) unless options[:profile][:description] || options[:profile][:email]
131
+
132
+ request = build_request(:create_customer_profile, options)
133
+ commit(:create_customer_profile, request)
134
+ end
135
+
136
+ # Creates a new customer payment profile for an existing customer profile.
137
+ #
138
+ # ==== Options
139
+ #
140
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer the payment profile will be added to. (REQUIRED)
141
+ # * <tt>:payment_profile</tt> -- A hash containing the elements of the new payment profile (REQUIRED)
142
+ #
143
+ # ==== Payment Profile
144
+ #
145
+ # * <tt>:payment</tt> -- A hash containing information on payment. Either :credit_card or :bank_account (REQUIRED)
146
+ def create_customer_payment_profile(options)
147
+ requires!(options, :customer_profile_id)
148
+ requires!(options, :payment_profile)
149
+ requires!(options[:payment_profile], :payment)
150
+
151
+ request = build_request(:create_customer_payment_profile, options)
152
+ commit(:create_customer_payment_profile, request)
153
+ end
154
+
155
+ # Creates a new customer shipping address for an existing customer profile.
156
+ #
157
+ # ==== Options
158
+ #
159
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer the payment profile will be added to. (REQUIRED)
160
+ # * <tt>:address</tt> -- A hash containing the elements of the shipping address (REQUIRED)
161
+ def create_customer_shipping_address(options)
162
+ requires!(options, :customer_profile_id)
163
+ requires!(options, :address)
164
+
165
+ request = build_request(:create_customer_shipping_address, options)
166
+ commit(:create_customer_shipping_address, request)
167
+ end
168
+
169
+ # Deletes an existing customer profile along with all associated customer payment profiles and customer shipping addresses.
170
+ #
171
+ # ==== Options
172
+ #
173
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer to be deleted. (REQUIRED)
174
+ def delete_customer_profile(options)
175
+ requires!(options, :customer_profile_id)
176
+
177
+ request = build_request(:delete_customer_profile, options)
178
+ commit(:delete_customer_profile, request)
179
+ end
180
+
181
+ # Deletes a customer payment profile from an existing customer profile.
182
+ #
183
+ # ==== Options
184
+ #
185
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer with the payment profile to be deleted. (REQUIRED)
186
+ # * <tt>:customer_payment_profile_id</tt> -- The Payment Profile ID of the payment profile to be deleted. (REQUIRED)
187
+ def delete_customer_payment_profile(options)
188
+ requires!(options, :customer_profile_id)
189
+ requires!(options, :customer_payment_profile_id)
190
+
191
+ request = build_request(:delete_customer_payment_profile, options)
192
+ commit(:delete_customer_payment_profile, request)
193
+ end
194
+
195
+ # Deletes a customer shipping address from an existing customer profile.
196
+ #
197
+ # ==== Options
198
+ #
199
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer with the payment profile to be deleted. (REQUIRED)
200
+ # * <tt>:customer_address_id</tt> -- The Shipping Address ID of the shipping address to be deleted. (REQUIRED)
201
+ def delete_customer_shipping_address(options)
202
+ requires!(options, :customer_profile_id)
203
+ requires!(options, :customer_address_id)
204
+
205
+ request = build_request(:delete_customer_shipping_address, options)
206
+ commit(:delete_customer_shipping_address, request)
207
+ end
208
+
209
+ # Retrieves an existing customer profile along with all the associated customer payment profiles and customer shipping addresses.
210
+ #
211
+ # Returns a Response whose params hash contains all the profile information.
212
+ #
213
+ # ==== Options
214
+ #
215
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer to retrieve. (REQUIRED)
216
+ def get_customer_profile(options)
217
+ requires!(options, :customer_profile_id)
218
+
219
+ request = build_request(:get_customer_profile, options)
220
+ commit(:get_customer_profile, request)
221
+ end
222
+
223
+ def get_customer_profile_ids(options = {})
224
+ request = build_request(:get_customer_profile_ids, options)
225
+ commit(:get_customer_profile_ids, request)
226
+ end
227
+
228
+ # Retrieve a customer payment profile for an existing customer profile.
229
+ #
230
+ # Returns a Response whose params hash contains all the payment profile information. Sensitive information such as credit card
231
+ # numbers will be masked.
232
+ #
233
+ # ==== Options
234
+ #
235
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer with the payment profile to be retrieved. (REQUIRED)
236
+ # * <tt>:customer_payment_profile_id</tt> -- The Payment Profile ID of the payment profile to be retrieved. (REQUIRED)
237
+ def get_customer_payment_profile(options)
238
+ requires!(options, :customer_profile_id)
239
+ requires!(options, :customer_payment_profile_id)
240
+
241
+ request = build_request(:get_customer_payment_profile, options)
242
+ commit(:get_customer_payment_profile, request)
243
+ end
244
+
245
+ # Retrieve a customer shipping address for an existing customer profile.
246
+ #
247
+ # Returns a Response whose params hash contains all the shipping address information.
248
+ #
249
+ # ==== Options
250
+ #
251
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer with the payment profile to be retrieved. (REQUIRED)
252
+ # * <tt>:customer_address_id</tt> -- The Shipping Address ID of the shipping address to be retrieved. (REQUIRED)
253
+ def get_customer_shipping_address(options)
254
+ requires!(options, :customer_profile_id)
255
+ requires!(options, :customer_address_id)
256
+
257
+ request = build_request(:get_customer_shipping_address, options)
258
+ commit(:get_customer_shipping_address, request)
259
+ end
260
+
261
+ # Updates an existing customer profile.
262
+ #
263
+ # Warning: if you do not provide a parameter in the <tt>:payment_profile</tt> hash, it is automatically set to nil at
264
+ # Authorize.Net. You will most likely want to first get the profile hash using get_customer_profile and then only change the
265
+ # elements you wish to change.
266
+ #
267
+ # ==== Options
268
+ #
269
+ # * <tt>:profile</tt> -- A hash containing the values the Customer Profile should be updated to. (REQUIRED)
270
+ #
271
+ # ==== Profile
272
+ #
273
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer profile to update. (REQUIRED)
274
+ def update_customer_profile(options)
275
+ requires!(options, :profile)
276
+ requires!(options[:profile], :customer_profile_id)
277
+
278
+ request = build_request(:update_customer_profile, options)
279
+ commit(:update_customer_profile, request)
280
+ end
281
+
282
+ # Updates a customer payment profile for an existing customer profile.
283
+ #
284
+ # Warning: if you do not provide a parameter in the <tt>:payment_profile</tt> hash, it is automatically set to nil at
285
+ # Authorize.Net. You will most likely want to first get the profile hash using get_customer_payment_profile and then only
286
+ # change the elements you wish to change.
287
+ #
288
+ # ==== Options
289
+ #
290
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer with the payment profile to be updated. (REQUIRED)
291
+ # * <tt>:payment_profile</tt> -- A hash containing the values the Customer Payment Profile should be updated to. (REQUIRED)
292
+ #
293
+ # ==== Payment Profile
294
+ #
295
+ # * <tt>:customer_payment_profile_id</tt> -- The Customer Payment Profile ID of the Customer Payment Profile to update. (REQUIRED)
296
+ def update_customer_payment_profile(options)
297
+ requires!(options, :customer_profile_id, :payment_profile)
298
+ requires!(options[:payment_profile], :customer_payment_profile_id)
299
+
300
+ request = build_request(:update_customer_payment_profile, options)
301
+ commit(:update_customer_payment_profile, request)
302
+ end
303
+
304
+ # Updates a customer shipping address for an existing customer profile.
305
+ #
306
+ # Warning: if you do not provide a parameter in the <tt>:address</tt> hash, it is automatically set to nil at
307
+ # Authorize.Net. You will most likely want to first get the profile hash using get_customer_shipping_address and then only
308
+ # change the elements you wish to change.
309
+ #
310
+ # ==== Options
311
+ #
312
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer with the payment profile to be updated. (REQUIRED)
313
+ # * <tt>:address</tt> -- A hash containing the values the Customer Shipping Address should be updated to. (REQUIRED)
314
+ #
315
+ # ==== Address
316
+ #
317
+ # * <tt>:customer_address_id</tt> -- The Customer Address ID of the Customer Payment Profile to update. (REQUIRED)
318
+ def update_customer_shipping_address(options)
319
+ requires!(options, :customer_profile_id, :address)
320
+ requires!(options[:address], :customer_address_id)
321
+
322
+ request = build_request(:update_customer_shipping_address, options)
323
+ commit(:update_customer_shipping_address, request)
324
+ end
325
+
326
+ # Creates a new payment transaction from an existing customer profile
327
+ #
328
+ # This is what is used to charge a customer whose information you have stored in a Customer Profile.
329
+ #
330
+ # Returns a Response object that contains the result of the transaction in <tt>params['direct_response']</tt>
331
+ #
332
+ # ==== Options
333
+ #
334
+ # * <tt>:transaction</tt> -- A hash containing information on the transaction that is being requested. (REQUIRED)
335
+ #
336
+ # ==== Transaction
337
+ #
338
+ # * <tt>:type</tt> -- The type of transaction. Can be either <tt>:auth_only</tt>, <tt>:capture_only</tt>, <tt>:auth_capture</tt>, <tt>:prior_auth_capture</tt>, <tt>:refund</tt> or <tt>:void</tt>. (REQUIRED)
339
+ # * <tt>:amount</tt> -- The amount for the tranaction. Formatted with a decimal. For example "4.95" (CONDITIONAL)
340
+ # - :type == :void (NOT USED)
341
+ # - :type == :refund (OPTIONAL)
342
+ # - :type == (:auth_only, :capture_only, :auth_capture, :prior_auth_capture) (REQUIRED)
343
+ #
344
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer to use in this transaction. (CONDITIONAL)
345
+ # - :type == (:void, :prior_auth_capture) (OPTIONAL)
346
+ # - :type == :refund (CONDITIONAL - required if masked information is not being submitted [see below])
347
+ # - :type == (:auth_only, :capture_only, :auth_capture) (REQUIRED)
348
+ #
349
+ # * <tt>:customer_payment_profile_id</tt> -- The Customer Payment Profile ID of the Customer Payment Profile to use in this transaction. (CONDITIONAL)
350
+ # - :type == (:void, :prior_auth_capture) (OPTIONAL)
351
+ # - :type == :refund (CONDITIONAL - required if masked information is not being submitted [see below])
352
+ # - :type == (:auth_only, :capture_only, :auth_capture) (REQUIRED)
353
+ #
354
+ # * <tt>:trans_id</tt> -- The payment gateway assigned transaction ID of the original transaction (CONDITIONAL):
355
+ # - :type = (:void, :refund, :prior_auth_capture) (REQUIRED)
356
+ # - :type = (:auth_only, :capture_only, :auth_capture) (NOT USED)
357
+ #
358
+ # * <tt>:card_code</tt> -- CVV/CCV code (OPTIONAL)
359
+ # - :type = (:void, :refund, :prior_auth_capture) (NOT USED)
360
+ # - :type = (:auth_only, :capture_only, :auth_capture) (OPTIONAL)
361
+ #
362
+ # * <tt>:customer_shipping_address_id</tt> -- Payment gateway assigned ID associated with the customer shipping address (CONDITIONAL)
363
+ # - :type = (:void, :refund) (OPTIONAL)
364
+ # - :type = (:auth_only, :capture_only, :auth_capture) (NOT USED)
365
+ # - :type = (:prior_auth_capture) (OPTIONAL)
366
+ #
367
+ # ==== For :type == :refund only
368
+ # * <tt>:credit_card_number_masked</tt> -- (CONDITIONAL - requied for credit card refunds is :customer_profile_id AND :customer_payment_profile_id are missing)
369
+ # * <tt>:bank_routing_number_masked && :bank_account_number_masked</tt> -- (CONDITIONAL - requied for electronic check refunds is :customer_profile_id AND :customer_payment_profile_id are missing) (NOT ABLE TO TEST - I keep getting "ACH transactions are not accepted by this merchant." when trying to make a payment and, until that's possible I can't refund (wiseleyb@gmail.com))
370
+ def create_customer_profile_transaction(options)
371
+ requires!(options, :transaction)
372
+ requires!(options[:transaction], :type)
373
+ case options[:transaction][:type]
374
+ when :void
375
+ requires!(options[:transaction], :trans_id)
376
+ when :refund
377
+ requires!(options[:transaction], :trans_id) &&
378
+ (
379
+ (options[:transaction][:customer_profile_id] && options[:transaction][:customer_payment_profile_id]) ||
380
+ options[:transaction][:credit_card_number_masked] ||
381
+ (options[:transaction][:bank_routing_number_masked] && options[:transaction][:bank_account_number_masked])
382
+ )
383
+ when :prior_auth_capture
384
+ requires!(options[:transaction], :amount, :trans_id)
385
+ else
386
+ requires!(options[:transaction], :amount, :customer_profile_id, :customer_payment_profile_id)
387
+ end
388
+ request = build_request(:create_customer_profile_transaction, options)
389
+ commit(:create_customer_profile_transaction, request)
390
+ end
391
+
392
+ # Creates a new payment transaction for refund from an existing customer profile
393
+ #
394
+ # This is what is used to refund a transaction you have stored in a Customer Profile.
395
+ #
396
+ # Returns a Response object that contains the result of the transaction in <tt>params['direct_response']</tt>
397
+ #
398
+ # ==== Options
399
+ #
400
+ # * <tt>:transaction</tt> -- A hash containing information on the transaction that is being requested. (REQUIRED)
401
+ #
402
+ # ==== Transaction
403
+ #
404
+ # * <tt>:amount</tt> -- The total amount to be refunded (REQUIRED)
405
+ #
406
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer to use in this transaction. (CONDITIONAL :customer_payment_profile_id must be included if used)
407
+ # * <tt>:customer_payment_profile_id</tt> -- The Customer Payment Profile ID of the Customer Payment Profile to use in this transaction. (CONDITIONAL :customer_profile_id must be included if used)
408
+ #
409
+ # * <tt>:credit_card_number_masked</tt> -- Four Xs follwed by the last four digits of the credit card (CONDITIONAL - used if customer_profile_id and customer_payment_profile_id aren't given)
410
+ #
411
+ # * <tt>:bank_routing_number_masked</tt> -- The last four gidits of the routing number to be refunded (CONDITIONAL - must be used with :bank_account_number_masked)
412
+ # * <tt>:bank_account_number_masked</tt> -- The last four digis of the bank account number to be refunded, Ex. XXXX1234 (CONDITIONAL - must be used with :bank_routing_number_masked)
413
+ #
414
+ # * <tt>:tax</tt> - A hash containing tax information for the refund (OPTIONAL - <tt>:amount</tt>, <tt>:name</tt> (31 characters), <tt>:description</tt> (255 characters))
415
+ # * <tt>:duty</tt> - A hash containting duty information for the refund (OPTIONAL - <tt>:amount</tt>, <tt>:name</tt> (31 characters), <tt>:description</tt> (255 characters))
416
+ # * <tt>:shipping</tt> - A hash containing shipping information for the refund (OPTIONAL - <tt>:amount</tt>, <tt>:name</tt> (31 characters), <tt>:description</tt> (255 characters))
417
+ def create_customer_profile_transaction_for_refund(options)
418
+ requires!(options, :transaction)
419
+ options[:transaction][:type] = :refund
420
+ requires!(options[:transaction], :trans_id)
421
+ requires!(options[:transaction], :amount)
422
+ request = build_request(:create_customer_profile_transaction, options)
423
+ commit(:create_customer_profile_transaction, request)
424
+ end
425
+
426
+ # Creates a new payment transaction for void from an existing customer profile
427
+ #
428
+ # This is what is used to void a transaction you have stored in a Customer Profile.
429
+ #
430
+ # Returns a Response object that contains the result of the transaction in <tt>params['direct_response']</tt>
431
+ #
432
+ # ==== Options
433
+ #
434
+ # * <tt>:transaction</tt> -- A hash containing information on the transaction that is being requested. (REQUIRED)
435
+ #
436
+ # ==== Transaction
437
+ #
438
+ # * <tt>:trans_id</tt> -- The payment gateway assigned transaction id of the original transaction. (REQUIRED)
439
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer to use in this transaction.
440
+ # * <tt>:customer_payment_profile_id</tt> -- The Customer Payment Profile ID of the Customer Payment Profile to use in this transaction.
441
+ # * <tt>:customer_shipping_address_id</tt> -- Payment gateway assigned ID associated with the customer shipping address.
442
+ def create_customer_profile_transaction_for_void(options)
443
+ requires!(options, :transaction)
444
+ options[:transaction][:type] = :void
445
+ requires!(options[:transaction], :trans_id)
446
+ request = build_request(:create_customer_profile_transaction, options)
447
+ commit(:create_customer_profile_transaction, request)
448
+ end
449
+
450
+ # Verifies an existing customer payment profile by generating a test transaction
451
+ #
452
+ # Returns a Response object that contains the result of the transaction in <tt>params['direct_response']</tt>
453
+ #
454
+ # ==== Options
455
+ #
456
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer to use in this transaction. (REQUIRED)
457
+ # * <tt>:customer_payment_profile_id</tt> -- The Customer Payment Profile ID of the Customer Payment Profile to be verified. (REQUIRED)
458
+ # * <tt>:customer_address_id</tt> -- The Customer Address ID of the Customer Shipping Address to be verified. (OPTIONAL)
459
+ # * <tt>:card_code</tt> -- If the payment profile is a credit card, the CCV/CVV code to validate with (OPTIONAL)
460
+ # * <tt>:validation_mode</tt> -- <tt>:live</tt> or <tt>:test</tt> In Test Mode, only field validation is performed. (REQUIRED
461
+ # In Live Mode, a transaction is generated and submitted to the processor with the amount of $0.01. If successful, the transaction is immediately voided. (REQUIRED)
462
+ def validate_customer_payment_profile(options)
463
+ requires!(options, :customer_profile_id, :customer_payment_profile_id, :validation_mode)
464
+
465
+ request = build_request(:validate_customer_payment_profile, options)
466
+ commit(:validate_customer_payment_profile, request)
467
+ end
468
+
469
+ private
470
+
471
+ def expdate(credit_card)
472
+ if credit_card.year.present? && credit_card.month.present?
473
+ sprintf('%04d-%02d', credit_card.year, credit_card.month)
474
+ else
475
+ 'XXXX'
476
+ end
477
+ end
478
+
479
+ def build_request(action, options = {})
480
+ unless CIM_ACTIONS.include?(action)
481
+ raise StandardError, "Invalid Customer Information Manager Action: #{action}"
482
+ end
483
+
484
+ xml = Builder::XmlMarkup.new(:indent => 2)
485
+ xml.instruct!(:xml, :version => '1.0', :encoding => 'utf-8')
486
+ xml.tag!("#{CIM_ACTIONS[action]}Request", :xmlns => AUTHORIZE_NET_CIM_NAMESPACE) do
487
+ add_merchant_authentication(xml)
488
+ # Merchant-assigned reference ID for the request
489
+ xml.tag!('refId', options[:ref_id]) if options[:ref_id]
490
+ # Order options
491
+ add_order(xml, options[:order]) if options[:order]
492
+ send("build_#{action}_request", xml, options)
493
+ end
494
+ end
495
+
496
+ # Contains the merchant’s payment gateway account authentication information
497
+ def add_merchant_authentication(xml)
498
+ xml.tag!('merchantAuthentication') do
499
+ xml.tag!('name', @options[:login])
500
+ xml.tag!('transactionKey', @options[:password])
501
+ end
502
+ end
503
+
504
+ def build_create_customer_profile_request(xml, options)
505
+ add_profile(xml, options[:profile])
506
+
507
+ xml.tag!('validationMode', CIM_VALIDATION_MODES[options[:validation_mode]]) if options[:validation_mode]
508
+
509
+ if options.has_key?(:payment_profile)
510
+ xml.tag!('paymentProfile') do
511
+ add_payment_profile(xml, options[:payment_profile])
512
+ end
513
+ end
514
+
515
+ xml.target!
516
+ end
517
+
518
+ def build_create_customer_payment_profile_request(xml, options)
519
+ xml.tag!('customerProfileId', options[:customer_profile_id])
520
+
521
+ xml.tag!('paymentProfile') do
522
+ add_payment_profile(xml, options[:payment_profile])
523
+ end
524
+
525
+ xml.tag!('validationMode', CIM_VALIDATION_MODES[options[:validation_mode]]) if options[:validation_mode]
526
+
527
+ xml.target!
528
+ end
529
+
530
+ def build_create_customer_shipping_address_request(xml, options)
531
+ xml.tag!('customerProfileId', options[:customer_profile_id])
532
+
533
+ xml.tag!('address') do
534
+ add_address(xml, options[:address])
535
+ end
536
+
537
+ xml.target!
538
+ end
539
+
540
+ def build_delete_customer_profile_request(xml, options)
541
+ xml.tag!('customerProfileId', options[:customer_profile_id])
542
+ xml.target!
543
+ end
544
+
545
+ def build_delete_customer_payment_profile_request(xml, options)
546
+ xml.tag!('customerProfileId', options[:customer_profile_id])
547
+ xml.tag!('customerPaymentProfileId', options[:customer_payment_profile_id])
548
+ xml.target!
549
+ end
550
+
551
+ def build_delete_customer_shipping_address_request(xml, options)
552
+ xml.tag!('customerProfileId', options[:customer_profile_id])
553
+ xml.tag!('customerAddressId', options[:customer_address_id])
554
+ xml.target!
555
+ end
556
+
557
+ def build_get_customer_profile_request(xml, options)
558
+ xml.tag!('customerProfileId', options[:customer_profile_id])
559
+ xml.target!
560
+ end
561
+
562
+ def build_get_customer_profile_ids_request(xml, options)
563
+ xml.target!
564
+ end
565
+
566
+ def build_get_customer_payment_profile_request(xml, options)
567
+ xml.tag!('customerProfileId', options[:customer_profile_id])
568
+ xml.tag!('customerPaymentProfileId', options[:customer_payment_profile_id])
569
+ xml.target!
570
+ end
571
+
572
+ def build_get_customer_shipping_address_request(xml, options)
573
+ xml.tag!('customerProfileId', options[:customer_profile_id])
574
+ xml.tag!('customerAddressId', options[:customer_address_id])
575
+ xml.target!
576
+ end
577
+
578
+ def build_update_customer_profile_request(xml, options)
579
+ add_profile(xml, options[:profile], true)
580
+
581
+ xml.target!
582
+ end
583
+
584
+ def build_update_customer_payment_profile_request(xml, options)
585
+ xml.tag!('customerProfileId', options[:customer_profile_id])
586
+
587
+ xml.tag!('paymentProfile') do
588
+ add_payment_profile(xml, options[:payment_profile])
589
+ end
590
+
591
+ xml.tag!('validationMode', CIM_VALIDATION_MODES[options[:validation_mode]]) if options[:validation_mode]
592
+
593
+ xml.target!
594
+ end
595
+
596
+ def build_update_customer_shipping_address_request(xml, options)
597
+ xml.tag!('customerProfileId', options[:customer_profile_id])
598
+
599
+ xml.tag!('address') do
600
+ add_address(xml, options[:address])
601
+ end
602
+
603
+ xml.target!
604
+ end
605
+
606
+ def build_create_customer_profile_transaction_request(xml, options)
607
+ options[:extra_options] ||= {}
608
+ options[:extra_options].merge!('x_test_request' => 'TRUE') if @options[:test]
609
+
610
+ add_transaction(xml, options[:transaction])
611
+ tag_unless_blank(xml, 'extraOptions', format_extra_options(options[:extra_options]))
612
+
613
+ xml.target!
614
+ end
615
+
616
+ def build_validate_customer_payment_profile_request(xml, options)
617
+ xml.tag!('customerProfileId', options[:customer_profile_id])
618
+ xml.tag!('customerPaymentProfileId', options[:customer_payment_profile_id])
619
+ xml.tag!('customerShippingAddressId', options[:customer_address_id]) if options[:customer_address_id]
620
+ tag_unless_blank(xml, 'cardCode', options[:card_code])
621
+ xml.tag!('validationMode', CIM_VALIDATION_MODES[options[:validation_mode]]) if options[:validation_mode]
622
+
623
+ xml.target!
624
+ end
625
+
626
+ # :merchant_customer_id (Optional)
627
+ # :description (Optional)
628
+ # :email (Optional)
629
+ # :payment_profiles (Optional)
630
+ def add_profile(xml, profile, update = false)
631
+ xml.tag!('profile') do
632
+ # Merchant assigned ID for the customer. Up to 20 characters. (optional)
633
+ xml.tag!('merchantCustomerId', profile[:merchant_customer_id]) if profile[:merchant_customer_id]
634
+ # Description of the customer. Up to 255 Characters (optional)
635
+ xml.tag!('description', profile[:description]) if profile[:description]
636
+ # Email Address for the customer. Up to 255 Characters (optional)
637
+ xml.tag!('email', profile[:email]) if profile[:email]
638
+
639
+ if update
640
+ xml.tag!('customerProfileId', profile[:customer_profile_id])
641
+ else
642
+ add_payment_profiles(xml, profile[:payment_profiles]) if profile[:payment_profiles]
643
+ add_ship_to_list(xml, profile[:ship_to_list]) if profile[:ship_to_list]
644
+ end
645
+ end
646
+ end
647
+
648
+ def add_transaction(xml, transaction)
649
+ unless CIM_TRANSACTION_TYPES.include?(transaction[:type])
650
+ raise StandardError, "Invalid Customer Information Manager Transaction Type: #{transaction[:type]}"
651
+ end
652
+
653
+ xml.tag!('transaction') do
654
+ xml.tag!(CIM_TRANSACTION_TYPES[transaction[:type]]) do
655
+ # The amount to be billed to the customer
656
+ case transaction[:type]
657
+ when :void
658
+ tag_unless_blank(xml,'customerProfileId', transaction[:customer_profile_id])
659
+ tag_unless_blank(xml,'customerPaymentProfileId', transaction[:customer_payment_profile_id])
660
+ tag_unless_blank(xml,'customerShippingAddressId', transaction[:customer_shipping_address_id])
661
+ xml.tag!('transId', transaction[:trans_id])
662
+ when :refund
663
+ #TODO - add lineItems field
664
+ xml.tag!('amount', transaction[:amount])
665
+ tag_unless_blank(xml, 'customerProfileId', transaction[:customer_profile_id])
666
+ tag_unless_blank(xml, 'customerPaymentProfileId', transaction[:customer_payment_profile_id])
667
+ tag_unless_blank(xml, 'customerShippingAddressId', transaction[:customer_shipping_address_id])
668
+ tag_unless_blank(xml, 'creditCardNumberMasked', transaction[:credit_card_number_masked])
669
+ tag_unless_blank(xml, 'bankRoutingNumberMasked', transaction[:bank_routing_number_masked])
670
+ tag_unless_blank(xml, 'bankAccountNumberMasked', transaction[:bank_account_number_masked])
671
+ xml.tag!('transId', transaction[:trans_id])
672
+ add_tax(xml, transaction[:tax]) if transaction[:tax]
673
+ add_duty(xml, transaction[:duty]) if transaction[:duty]
674
+ add_shipping(xml, transaction[:shipping]) if transaction[:shipping]
675
+ when :prior_auth_capture
676
+ xml.tag!('amount', transaction[:amount])
677
+ xml.tag!('transId', transaction[:trans_id])
678
+ else
679
+ xml.tag!('amount', transaction[:amount])
680
+ xml.tag!('customerProfileId', transaction[:customer_profile_id])
681
+ xml.tag!('customerPaymentProfileId', transaction[:customer_payment_profile_id])
682
+ xml.tag!('approvalCode', transaction[:approval_code]) if transaction[:type] == :capture_only
683
+ end
684
+ add_order(xml, transaction[:order]) if transaction[:order].present?
685
+ unless [:void,:refund,:prior_auth_capture].include?(transaction[:type])
686
+ tag_unless_blank(xml, 'cardCode', transaction[:card_code])
687
+ end
688
+ end
689
+ end
690
+ end
691
+
692
+ def add_tax(xml, tax)
693
+ xml.tag!('tax') do
694
+ xml.tag!('amount', tax[:amount]) if tax[:amount]
695
+ xml.tag!('name', tax[:name]) if tax[:name]
696
+ xml.tag!('description', tax[:description]) if tax[:description]
697
+ end
698
+ end
699
+
700
+ def add_duty(xml, duty)
701
+ xml.tag!('duty') do
702
+ xml.tag!('amount', duty[:amount]) if duty[:amount]
703
+ xml.tag!('name', duty[:name]) if duty[:name]
704
+ xml.tag!('description', duty[:description]) if duty[:description]
705
+ end
706
+ end
707
+
708
+ def add_shipping(xml, shipping)
709
+ xml.tag!('shipping') do
710
+ xml.tag!('amount', shipping[:amount]) if shipping[:amount]
711
+ xml.tag!('name', shipping[:name]) if shipping[:name]
712
+ xml.tag!('description', shipping[:description]) if shipping[:description]
713
+ end
714
+ end
715
+
716
+ def add_order(xml, order)
717
+ xml.tag!('order') do
718
+ xml.tag!('invoiceNumber', order[:invoice_number]) if order[:invoice_number]
719
+ xml.tag!('description', order[:description]) if order[:description]
720
+ xml.tag!('purchaseOrderNumber', order[:purchase_order_number]) if order[:purchase_order_number]
721
+ end
722
+ end
723
+
724
+ def add_payment_profiles(xml, payment_profiles)
725
+ xml.tag!('paymentProfiles') do
726
+ add_payment_profile(xml, payment_profiles)
727
+ end
728
+ end
729
+
730
+ # :customer_type => 'individual or business', # Optional
731
+ # :bill_to => @address,
732
+ # :payment => @payment
733
+ def add_payment_profile(xml, payment_profile)
734
+ # 'individual' or 'business' (optional)
735
+ xml.tag!('customerType', payment_profile[:customer_type]) if payment_profile[:customer_type]
736
+
737
+ if payment_profile[:bill_to]
738
+ xml.tag!('billTo') do
739
+ add_address(xml, payment_profile[:bill_to])
740
+ end
741
+ end
742
+
743
+ if payment_profile[:payment]
744
+ xml.tag!('payment') do
745
+ add_credit_card(xml, payment_profile[:payment][:credit_card]) if payment_profile[:payment].has_key?(:credit_card)
746
+ add_bank_account(xml, payment_profile[:payment][:bank_account]) if payment_profile[:payment].has_key?(:bank_account)
747
+ add_drivers_license(xml, payment_profile[:payment][:drivers_license]) if payment_profile[:payment].has_key?(:drivers_license)
748
+ # This element is only required for Wells Fargo SecureSource eCheck.Net merchants
749
+ # The customer's Social Security Number or Tax ID
750
+ xml.tag!('taxId', payment_profile[:payment]) if payment_profile[:payment].has_key?(:tax_id)
751
+ end
752
+ end
753
+
754
+ xml.tag!('customerPaymentProfileId', payment_profile[:customer_payment_profile_id]) if payment_profile[:customer_payment_profile_id]
755
+ end
756
+
757
+ def add_ship_to_list(xml, ship_to_list)
758
+ xml.tag!('shipToList') do
759
+ add_address(xml, ship_to_list)
760
+ end
761
+ end
762
+
763
+ def add_address(xml, address)
764
+ xml.tag!('firstName', address[:first_name])
765
+ xml.tag!('lastName', address[:last_name])
766
+ xml.tag!('company', address[:company])
767
+ xml.tag!('address', address[:address1]) if address[:address1]
768
+ xml.tag!('address', address[:address]) if address[:address]
769
+ xml.tag!('city', address[:city])
770
+ xml.tag!('state', address[:state])
771
+ xml.tag!('zip', address[:zip])
772
+ xml.tag!('country', address[:country])
773
+ xml.tag!('phoneNumber', address[:phone_number]) if address[:phone_number]
774
+ xml.tag!('faxNumber', address[:fax_number]) if address[:fax_number]
775
+
776
+ xml.tag!('customerAddressId', address[:customer_address_id]) if address[:customer_address_id]
777
+ end
778
+
779
+ # Adds customer’s credit card information
780
+ # Note: This element should only be included
781
+ # when the payment method is credit card.
782
+ def add_credit_card(xml, credit_card)
783
+ return unless credit_card
784
+ xml.tag!('creditCard') do
785
+ # The credit card number used for payment of the subscription
786
+ xml.tag!('cardNumber', credit_card.number)
787
+ # The expiration date of the credit card used for the subscription
788
+ xml.tag!('expirationDate', expdate(credit_card))
789
+ # Note that Authorize.net does not save CVV codes as part of the
790
+ # payment profile. Any transactions/validations after the payment
791
+ # profile is created that wish to use CVV verification must pass
792
+ # the CVV code to authorize.net again.
793
+ xml.tag!('cardCode', credit_card.verification_value) if credit_card.verification_value?
794
+ end
795
+ end
796
+
797
+ # Adds customer’s bank account information
798
+ # Note: This element should only be included
799
+ # when the payment method is bank account.
800
+ def add_bank_account(xml, bank_account)
801
+ raise StandardError, "Invalid Bank Account Type: #{bank_account[:account_type]}" unless BANK_ACCOUNT_TYPES.include?(bank_account[:account_type])
802
+ raise StandardError, "Invalid eCheck Type: #{bank_account[:echeck_type]}" unless ECHECK_TYPES.include?(bank_account[:echeck_type])
803
+
804
+ xml.tag!('bankAccount') do
805
+ # The type of bank account
806
+ xml.tag!('accountType', BANK_ACCOUNT_TYPES[bank_account[:account_type]])
807
+ # The routing number of the customer’s bank
808
+ xml.tag!('routingNumber', bank_account[:routing_number])
809
+ # The bank account number
810
+ xml.tag!('accountNumber', bank_account[:account_number])
811
+ # The full name of the individual associated
812
+ # with the bank account number
813
+ xml.tag!('nameOnAccount', bank_account[:name_on_account])
814
+ # The type of electronic check transaction
815
+ xml.tag!('echeckType', ECHECK_TYPES[bank_account[:echeck_type]])
816
+ # The full name of the individual associated
817
+ # with the bank account number (optional)
818
+ xml.tag!('bankName', bank_account[:bank_name]) if bank_account[:bank_name]
819
+ end
820
+ end
821
+
822
+ # Adds customer’s driver's license information
823
+ # Note: This element is only required for
824
+ # Wells Fargo SecureSource eCheck.Net merchants
825
+ def add_drivers_license(xml, drivers_license)
826
+ xml.tag!('driversLicense') do
827
+ # The state of the customer's driver's license
828
+ # A valid two character state code
829
+ xml.tag!('state', drivers_license[:state])
830
+ # The customer’s driver's license number
831
+ xml.tag!('number', drivers_license[:number])
832
+ # The date of birth listed on the customer's driver's license
833
+ # YYYY-MM-DD
834
+ xml.tag!('dateOfBirth', drivers_license[:date_of_birth])
835
+ end
836
+ end
837
+
838
+ def commit(action, request)
839
+ url = test? ? test_url : live_url
840
+ xml = ssl_post(url, request, "Content-Type" => "text/xml")
841
+
842
+ response_params = parse(action, xml)
843
+
844
+ message = response_params['messages']['message']['text']
845
+ test_mode = test? || message =~ /Test Mode/
846
+ success = response_params['messages']['result_code'] == 'Ok'
847
+ response_params['direct_response'] = parse_direct_response(response_params['direct_response']) if response_params['direct_response']
848
+ transaction_id = response_params['direct_response']['transaction_id'] if response_params['direct_response']
849
+
850
+ Response.new(success, message, response_params,
851
+ :test => test_mode,
852
+ :authorization => transaction_id || response_params['customer_profile_id'] || (response_params['profile'] ? response_params['profile']['customer_profile_id'] : nil)
853
+ )
854
+ end
855
+
856
+ def tag_unless_blank(xml, tag_name, data)
857
+ xml.tag!(tag_name, data) unless data.blank? || data.nil?
858
+ end
859
+
860
+ def format_extra_options(options)
861
+ options.map{ |k, v| "#{k}=#{v}" }.join('&') unless options.nil?
862
+ end
863
+
864
+ def parse_direct_response(params)
865
+ delimiter = @options[:delimiter] || ','
866
+ direct_response = {'raw' => params}
867
+ direct_response_fields = params.split(delimiter)
868
+ direct_response.merge(
869
+ {
870
+ 'response_code' => direct_response_fields[0],
871
+ 'response_subcode' => direct_response_fields[1],
872
+ 'response_reason_code' => direct_response_fields[2],
873
+ 'message' => direct_response_fields[3],
874
+ 'approval_code' => direct_response_fields[4],
875
+ 'avs_response' => direct_response_fields[5],
876
+ 'transaction_id' => direct_response_fields[6],
877
+ 'invoice_number' => direct_response_fields[7],
878
+ 'order_description' => direct_response_fields[8],
879
+ 'amount' => direct_response_fields[9],
880
+ 'method' => direct_response_fields[10],
881
+ 'transaction_type' => direct_response_fields[11],
882
+ 'customer_id' => direct_response_fields[12],
883
+ 'first_name' => direct_response_fields[13],
884
+ 'last_name' => direct_response_fields[14],
885
+ 'company' => direct_response_fields[15],
886
+ 'address' => direct_response_fields[16],
887
+ 'city' => direct_response_fields[17],
888
+ 'state' => direct_response_fields[18],
889
+ 'zip_code' => direct_response_fields[19],
890
+ 'country' => direct_response_fields[20],
891
+ 'phone' => direct_response_fields[21],
892
+ 'fax' => direct_response_fields[22],
893
+ 'email_address' => direct_response_fields[23],
894
+ 'ship_to_first_name' => direct_response_fields[24],
895
+ 'ship_to_last_name' => direct_response_fields[25],
896
+ 'ship_to_company' => direct_response_fields[26],
897
+ 'ship_to_address' => direct_response_fields[27],
898
+ 'ship_to_city' => direct_response_fields[28],
899
+ 'ship_to_state' => direct_response_fields[29],
900
+ 'ship_to_zip_code' => direct_response_fields[30],
901
+ 'ship_to_country' => direct_response_fields[31],
902
+ 'tax' => direct_response_fields[32],
903
+ 'duty' => direct_response_fields[33],
904
+ 'freight' => direct_response_fields[34],
905
+ 'tax_exempt' => direct_response_fields[35],
906
+ 'purchase_order_number' => direct_response_fields[36],
907
+ 'md5_hash' => direct_response_fields[37],
908
+ 'card_code' => direct_response_fields[38],
909
+ 'cardholder_authentication_verification_response' => direct_response_fields[39],
910
+ # The following direct response fields are only available in version 3.1 of the
911
+ # transaction response. Check your merchant account settings for details.
912
+ 'account_number' => direct_response_fields[50] || '',
913
+ 'card_type' => direct_response_fields[51] || '',
914
+ 'split_tender_id' => direct_response_fields[52] || '',
915
+ 'requested_amount' => direct_response_fields[53] || '',
916
+ 'balance_on_card' => direct_response_fields[54] || '',
917
+ }
918
+ )
919
+ end
920
+
921
+ def parse(action, xml)
922
+ xml = REXML::Document.new(xml)
923
+ root = REXML::XPath.first(xml, "//#{CIM_ACTIONS[action]}Response") ||
924
+ REXML::XPath.first(xml, "//ErrorResponse")
925
+ if root
926
+ response = parse_element(root)
927
+ end
928
+
929
+ response
930
+ end
931
+
932
+ def parse_element(node)
933
+ if node.has_elements?
934
+ response = {}
935
+ node.elements.each{ |e|
936
+ key = e.name.underscore
937
+ value = parse_element(e)
938
+ if response.has_key?(key)
939
+ if response[key].is_a?(Array)
940
+ response[key].push(value)
941
+ else
942
+ response[key] = [response[key], value]
943
+ end
944
+ else
945
+ response[key] = parse_element(e)
946
+ end
947
+ }
948
+ else
949
+ response = node.text
950
+ end
951
+
952
+ response
953
+ end
954
+ end
955
+ end
956
+ end