activemerchant 1.42.6 → 1.90.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (450) hide show
  1. checksums.yaml +5 -13
  2. data/CHANGELOG +1420 -2
  3. data/CONTRIBUTORS +106 -0
  4. data/README.md +107 -103
  5. data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
  6. data/lib/active_merchant/billing/avs_result.rb +12 -13
  7. data/lib/active_merchant/billing/base.rb +13 -16
  8. data/lib/active_merchant/billing/check.rb +35 -24
  9. data/lib/active_merchant/billing/compatibility.rb +117 -0
  10. data/lib/active_merchant/billing/credit_card.rb +196 -81
  11. data/lib/active_merchant/billing/credit_card_formatting.rb +6 -4
  12. data/lib/active_merchant/billing/credit_card_methods.rb +199 -75
  13. data/lib/active_merchant/billing/cvv_result.rb +15 -15
  14. data/lib/active_merchant/billing/gateway.rb +171 -39
  15. data/lib/active_merchant/billing/gateways/adyen.rb +380 -0
  16. data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
  17. data/lib/active_merchant/billing/gateways/authorize_net.rb +933 -604
  18. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +417 -0
  19. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +74 -54
  20. data/lib/active_merchant/billing/gateways/axcessms.rb +181 -0
  21. data/lib/active_merchant/billing/gateways/balanced.rb +130 -370
  22. data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
  23. data/lib/active_merchant/billing/gateways/banwire.rb +23 -12
  24. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +351 -0
  25. data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +6 -6
  26. data/lib/active_merchant/billing/gateways/be2bill.rb +2 -2
  27. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +109 -32
  28. data/lib/active_merchant/billing/gateways/beanstream.rb +59 -13
  29. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +12 -9
  30. data/lib/active_merchant/billing/gateways/blue_pay.rb +520 -498
  31. data/lib/active_merchant/billing/gateways/blue_snap.rb +347 -0
  32. data/lib/active_merchant/billing/gateways/bogus.rb +80 -46
  33. data/lib/active_merchant/billing/gateways/borgun.rb +220 -0
  34. data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
  35. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +15 -2
  36. data/lib/active_merchant/billing/gateways/braintree.rb +2 -2
  37. data/lib/active_merchant/billing/gateways/braintree_blue.rb +311 -121
  38. data/lib/active_merchant/billing/gateways/braintree_orange.rb +4 -4
  39. data/lib/active_merchant/billing/gateways/bridge_pay.rb +244 -0
  40. data/lib/active_merchant/billing/gateways/cams.rb +230 -0
  41. data/lib/active_merchant/billing/gateways/card_connect.rb +311 -0
  42. data/lib/active_merchant/billing/gateways/card_save.rb +6 -7
  43. data/lib/active_merchant/billing/gateways/card_stream.rb +235 -89
  44. data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
  45. data/lib/active_merchant/billing/gateways/cardprocess.rb +254 -0
  46. data/lib/active_merchant/billing/gateways/cashnet.rb +219 -0
  47. data/lib/active_merchant/billing/gateways/cc5.rb +50 -8
  48. data/lib/active_merchant/billing/gateways/cecabank.rb +27 -14
  49. data/lib/active_merchant/billing/gateways/cenpos.rb +327 -0
  50. data/lib/active_merchant/billing/gateways/checkout.rb +214 -0
  51. data/lib/active_merchant/billing/gateways/checkout_v2.rb +233 -0
  52. data/lib/active_merchant/billing/gateways/citrus_pay.rb +22 -0
  53. data/lib/active_merchant/billing/gateways/clearhaus.rb +220 -0
  54. data/lib/active_merchant/billing/gateways/commercegate.rb +142 -0
  55. data/lib/active_merchant/billing/gateways/conekta.rb +91 -97
  56. data/lib/active_merchant/billing/gateways/creditcall.rb +271 -0
  57. data/lib/active_merchant/billing/gateways/credorax.rb +356 -0
  58. data/lib/active_merchant/billing/gateways/ct_payment.rb +268 -0
  59. data/lib/active_merchant/billing/gateways/culqi.rb +277 -0
  60. data/lib/active_merchant/billing/gateways/cyber_source.rb +294 -158
  61. data/lib/active_merchant/billing/gateways/d_local.rb +226 -0
  62. data/lib/active_merchant/billing/gateways/data_cash.rb +59 -347
  63. data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
  64. data/lib/active_merchant/billing/gateways/digitzs.rb +292 -0
  65. data/lib/active_merchant/billing/gateways/ebanx.rb +296 -0
  66. data/lib/active_merchant/billing/gateways/efsnet.rb +24 -39
  67. data/lib/active_merchant/billing/gateways/elavon.rb +146 -147
  68. data/lib/active_merchant/billing/gateways/element.rb +356 -0
  69. data/lib/active_merchant/billing/gateways/epay.rb +41 -31
  70. data/lib/active_merchant/billing/gateways/evo_ca.rb +1 -1
  71. data/lib/active_merchant/billing/gateways/eway.rb +79 -78
  72. data/lib/active_merchant/billing/gateways/eway_managed.rb +35 -36
  73. data/lib/active_merchant/billing/gateways/eway_rapid.rb +369 -228
  74. data/lib/active_merchant/billing/gateways/exact.rb +32 -26
  75. data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
  76. data/lib/active_merchant/billing/gateways/fat_zebra.rb +90 -64
  77. data/lib/active_merchant/billing/gateways/federated_canada.rb +6 -14
  78. data/lib/active_merchant/billing/gateways/finansbank.rb +3 -3
  79. data/lib/active_merchant/billing/gateways/first_giving.rb +142 -0
  80. data/lib/active_merchant/billing/gateways/first_pay.rb +128 -122
  81. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +190 -64
  82. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +446 -0
  83. data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
  84. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
  85. data/lib/active_merchant/billing/gateways/forte.rb +270 -0
  86. data/lib/active_merchant/billing/gateways/garanti.rb +29 -27
  87. data/lib/active_merchant/billing/gateways/global_collect.rb +340 -0
  88. data/lib/active_merchant/billing/gateways/global_transport.rb +194 -0
  89. data/lib/active_merchant/billing/gateways/hdfc.rb +35 -36
  90. data/lib/active_merchant/billing/gateways/hps.rb +305 -0
  91. data/lib/active_merchant/billing/gateways/iats_payments.rb +271 -16
  92. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
  93. data/lib/active_merchant/billing/gateways/inspire.rb +29 -32
  94. data/lib/active_merchant/billing/gateways/instapay.rb +5 -6
  95. data/lib/active_merchant/billing/gateways/ipp.rb +175 -0
  96. data/lib/active_merchant/billing/gateways/iridium.rb +247 -41
  97. data/lib/active_merchant/billing/gateways/itransact.rb +4 -5
  98. data/lib/active_merchant/billing/gateways/iveri.rb +251 -0
  99. data/lib/active_merchant/billing/gateways/jetpay.rb +198 -71
  100. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +437 -0
  101. data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
  102. data/lib/active_merchant/billing/gateways/kushki.rb +219 -0
  103. data/lib/active_merchant/billing/gateways/latitude19.rb +411 -0
  104. data/lib/active_merchant/billing/gateways/linkpoint.rb +45 -43
  105. data/lib/active_merchant/billing/gateways/litle.rb +328 -444
  106. data/lib/active_merchant/billing/gateways/mastercard.rb +267 -0
  107. data/lib/active_merchant/billing/gateways/maxipago.rb +145 -115
  108. data/lib/active_merchant/billing/gateways/mercado_pago.rb +277 -0
  109. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +37 -19
  110. data/lib/active_merchant/billing/gateways/merchant_one.rb +13 -15
  111. data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
  112. data/lib/active_merchant/billing/gateways/merchant_ware.rb +57 -60
  113. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +59 -48
  114. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +38 -19
  115. data/lib/active_merchant/billing/gateways/mercury.rb +77 -54
  116. data/lib/active_merchant/billing/gateways/metrics_global.rb +11 -30
  117. data/lib/active_merchant/billing/gateways/micropayment.rb +183 -0
  118. data/lib/active_merchant/billing/gateways/migs.rb +81 -22
  119. data/lib/active_merchant/billing/gateways/modern_payments.rb +3 -3
  120. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +23 -25
  121. data/lib/active_merchant/billing/gateways/monei.rb +307 -0
  122. data/lib/active_merchant/billing/gateways/moneris.rb +146 -64
  123. data/lib/active_merchant/billing/gateways/moneris_us.rb +197 -53
  124. data/lib/active_merchant/billing/gateways/money_movers.rb +6 -15
  125. data/lib/active_merchant/billing/gateways/mundipagg.rb +292 -0
  126. data/lib/active_merchant/billing/gateways/nab_transact.rb +86 -64
  127. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +165 -0
  128. data/lib/active_merchant/billing/gateways/net_registry.rb +11 -5
  129. data/lib/active_merchant/billing/gateways/netaxept.rb +21 -22
  130. data/lib/active_merchant/billing/gateways/netbanx.rb +290 -0
  131. data/lib/active_merchant/billing/gateways/netbilling.rb +70 -35
  132. data/lib/active_merchant/billing/gateways/netpay.rb +5 -6
  133. data/lib/active_merchant/billing/gateways/network_merchants.rb +241 -0
  134. data/lib/active_merchant/billing/gateways/nmi.rb +274 -10
  135. data/lib/active_merchant/billing/gateways/ogone.rb +90 -47
  136. data/lib/active_merchant/billing/gateways/omise.rb +324 -0
  137. data/lib/active_merchant/billing/gateways/openpay.rb +48 -20
  138. data/lib/active_merchant/billing/gateways/opp.rb +369 -0
  139. data/lib/active_merchant/billing/gateways/optimal_payment.rb +79 -44
  140. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +22 -21
  141. data/lib/active_merchant/billing/gateways/orbital.rb +346 -102
  142. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +48 -29
  143. data/lib/active_merchant/billing/gateways/pagarme.rb +246 -0
  144. data/lib/active_merchant/billing/gateways/pago_facil.rb +122 -0
  145. data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
  146. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +67 -48
  147. data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
  148. data/lib/active_merchant/billing/gateways/pay_junction.rb +20 -26
  149. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +188 -0
  150. data/lib/active_merchant/billing/gateways/pay_secure.rb +7 -15
  151. data/lib/active_merchant/billing/gateways/paybox_direct.rb +40 -36
  152. data/lib/active_merchant/billing/gateways/payeezy.rb +410 -0
  153. data/lib/active_merchant/billing/gateways/payex.rb +38 -30
  154. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +62 -36
  155. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +11 -7
  156. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +3 -3
  157. data/lib/active_merchant/billing/gateways/payflow.rb +74 -27
  158. data/lib/active_merchant/billing/gateways/payflow_express.rb +77 -81
  159. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +2 -3
  160. data/lib/active_merchant/billing/gateways/payflow_uk.rb +5 -6
  161. data/lib/active_merchant/billing/gateways/payment_express.rb +54 -45
  162. data/lib/active_merchant/billing/gateways/paymentez.rb +304 -0
  163. data/lib/active_merchant/billing/gateways/paymill.rb +160 -66
  164. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +54 -7
  165. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +4 -0
  166. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +17 -3
  167. data/lib/active_merchant/billing/gateways/paypal.rb +36 -27
  168. data/lib/active_merchant/billing/gateways/paypal_ca.rb +1 -1
  169. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +7 -6
  170. data/lib/active_merchant/billing/gateways/paypal_express.rb +32 -4
  171. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +3 -3
  172. data/lib/active_merchant/billing/gateways/payscout.rb +2 -13
  173. data/lib/active_merchant/billing/gateways/paystation.rb +96 -88
  174. data/lib/active_merchant/billing/gateways/payu_in.rb +248 -0
  175. data/lib/active_merchant/billing/gateways/payu_latam.rb +445 -0
  176. data/lib/active_merchant/billing/gateways/payway.rb +8 -8
  177. data/lib/active_merchant/billing/gateways/pin.rb +74 -18
  178. data/lib/active_merchant/billing/gateways/plugnpay.rb +66 -76
  179. data/lib/active_merchant/billing/gateways/pro_pay.rb +326 -0
  180. data/lib/active_merchant/billing/gateways/psigate.rb +30 -30
  181. data/lib/active_merchant/billing/gateways/psl_card.rb +27 -34
  182. data/lib/active_merchant/billing/gateways/qbms.rb +65 -54
  183. data/lib/active_merchant/billing/gateways/quantum.rb +18 -18
  184. data/lib/active_merchant/billing/gateways/quickbooks.rb +290 -0
  185. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
  186. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +295 -0
  187. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
  188. data/lib/active_merchant/billing/gateways/quickpay.rb +10 -350
  189. data/lib/active_merchant/billing/gateways/qvalent.rb +236 -0
  190. data/lib/active_merchant/billing/gateways/realex.rb +78 -48
  191. data/lib/active_merchant/billing/gateways/redsys.rb +310 -170
  192. data/lib/active_merchant/billing/gateways/s5.rb +246 -0
  193. data/lib/active_merchant/billing/gateways/safe_charge.rb +262 -0
  194. data/lib/active_merchant/billing/gateways/sage.rb +415 -119
  195. data/lib/active_merchant/billing/gateways/sage_pay.rb +195 -90
  196. data/lib/active_merchant/billing/gateways/sallie_mae.rb +11 -12
  197. data/lib/active_merchant/billing/gateways/secure_net.rb +51 -43
  198. data/lib/active_merchant/billing/gateways/secure_pay.rb +182 -10
  199. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +25 -14
  200. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +10 -18
  201. data/lib/active_merchant/billing/gateways/securion_pay.rb +264 -0
  202. data/lib/active_merchant/billing/gateways/skip_jack.rb +35 -38
  203. data/lib/active_merchant/billing/gateways/smart_ps.rb +50 -42
  204. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +9 -9
  205. data/lib/active_merchant/billing/gateways/spreedly_core.rb +62 -12
  206. data/lib/active_merchant/billing/gateways/stripe.rb +536 -103
  207. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +12 -18
  208. data/lib/active_merchant/billing/gateways/telr.rb +274 -0
  209. data/lib/active_merchant/billing/gateways/tns.rb +22 -0
  210. data/lib/active_merchant/billing/gateways/trans_first.rb +143 -30
  211. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +608 -0
  212. data/lib/active_merchant/billing/gateways/transact_pro.rb +224 -0
  213. data/lib/active_merchant/billing/gateways/transax.rb +5 -6
  214. data/lib/active_merchant/billing/gateways/transnational.rb +2 -232
  215. data/lib/active_merchant/billing/gateways/trexle.rb +218 -0
  216. data/lib/active_merchant/billing/gateways/trust_commerce.rb +86 -57
  217. data/lib/active_merchant/billing/gateways/usa_epay.rb +4 -4
  218. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +196 -89
  219. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +157 -32
  220. data/lib/active_merchant/billing/gateways/vanco.rb +294 -0
  221. data/lib/active_merchant/billing/gateways/verifi.rb +42 -49
  222. data/lib/active_merchant/billing/gateways/viaklix.rb +11 -24
  223. data/lib/active_merchant/billing/gateways/visanet_peru.rb +233 -0
  224. data/lib/active_merchant/billing/gateways/webpay.rb +26 -28
  225. data/lib/active_merchant/billing/gateways/wepay.rb +237 -0
  226. data/lib/active_merchant/billing/gateways/wirecard.rb +153 -31
  227. data/lib/active_merchant/billing/gateways/world_net.rb +344 -0
  228. data/lib/active_merchant/billing/gateways/worldpay.rb +207 -63
  229. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +215 -0
  230. data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
  231. data/lib/active_merchant/billing/gateways.rb +8 -11
  232. data/lib/active_merchant/billing/model.rb +30 -0
  233. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
  234. data/lib/active_merchant/billing/payment_token.rb +21 -0
  235. data/lib/active_merchant/billing/rails.rb +3 -0
  236. data/lib/active_merchant/billing/response.rb +31 -24
  237. data/lib/active_merchant/billing.rb +7 -1
  238. data/lib/active_merchant/connection.rb +195 -0
  239. data/lib/active_merchant/country.rb +335 -0
  240. data/lib/active_merchant/empty.rb +20 -0
  241. data/lib/active_merchant/errors.rb +35 -0
  242. data/lib/active_merchant/net_http_ssl_connection.rb +10 -0
  243. data/lib/active_merchant/network_connection_retries.rb +80 -0
  244. data/lib/active_merchant/post_data.rb +25 -0
  245. data/lib/active_merchant/posts_data.rb +92 -0
  246. data/lib/active_merchant/version.rb +1 -1
  247. data/lib/active_merchant.rb +23 -27
  248. data/lib/activemerchant.rb +1 -1
  249. data/lib/certs/cacert.pem +3988 -0
  250. data/lib/support/gateway_support.rb +7 -9
  251. data/lib/support/outbound_hosts.rb +13 -10
  252. data/lib/support/ssl_verify.rb +6 -7
  253. data/lib/support/ssl_version.rb +87 -0
  254. metadata +148 -323
  255. checksums.yaml.gz.sig +0 -0
  256. data/gem-public_cert.pem +0 -21
  257. data/lib/active_merchant/billing/expiry_date.rb +0 -34
  258. data/lib/active_merchant/billing/gateways/app55.rb +0 -185
  259. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +0 -314
  260. data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -277
  261. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +0 -249
  262. data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +0 -13
  263. data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +0 -29
  264. data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +0 -66
  265. data/lib/active_merchant/billing/gateways/orbital/avs_result.rb +0 -93
  266. data/lib/active_merchant/billing/gateways/orbital/cvv_result.rb +0 -34
  267. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +0 -93
  268. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +0 -114
  269. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +0 -102
  270. data/lib/active_merchant/billing/gateways/samurai.rb +0 -118
  271. data/lib/active_merchant/billing/gateways/vindicia.rb +0 -361
  272. data/lib/active_merchant/billing/integrations/a1agregator/helper.rb +0 -31
  273. data/lib/active_merchant/billing/integrations/a1agregator/notification.rb +0 -186
  274. data/lib/active_merchant/billing/integrations/a1agregator/status.rb +0 -38
  275. data/lib/active_merchant/billing/integrations/a1agregator.rb +0 -26
  276. data/lib/active_merchant/billing/integrations/action_view_helper.rb +0 -74
  277. data/lib/active_merchant/billing/integrations/alipay/helper.rb +0 -34
  278. data/lib/active_merchant/billing/integrations/alipay/notification.rb +0 -101
  279. data/lib/active_merchant/billing/integrations/alipay.rb +0 -18
  280. data/lib/active_merchant/billing/integrations/authorize_net_sim/helper.rb +0 -229
  281. data/lib/active_merchant/billing/integrations/authorize_net_sim/notification.rb +0 -340
  282. data/lib/active_merchant/billing/integrations/authorize_net_sim.rb +0 -38
  283. data/lib/active_merchant/billing/integrations/bit_pay/helper.rb +0 -64
  284. data/lib/active_merchant/billing/integrations/bit_pay/notification.rb +0 -74
  285. data/lib/active_merchant/billing/integrations/bit_pay/return.rb +0 -10
  286. data/lib/active_merchant/billing/integrations/bit_pay.rb +0 -30
  287. data/lib/active_merchant/billing/integrations/bogus/helper.rb +0 -17
  288. data/lib/active_merchant/billing/integrations/bogus/notification.rb +0 -11
  289. data/lib/active_merchant/billing/integrations/bogus/return.rb +0 -10
  290. data/lib/active_merchant/billing/integrations/bogus.rb +0 -23
  291. data/lib/active_merchant/billing/integrations/chronopay/helper.rb +0 -120
  292. data/lib/active_merchant/billing/integrations/chronopay/notification.rb +0 -158
  293. data/lib/active_merchant/billing/integrations/chronopay/return.rb +0 -10
  294. data/lib/active_merchant/billing/integrations/chronopay.rb +0 -23
  295. data/lib/active_merchant/billing/integrations/citrus/helper.rb +0 -40
  296. data/lib/active_merchant/billing/integrations/citrus/notification.rb +0 -133
  297. data/lib/active_merchant/billing/integrations/citrus/return.rb +0 -40
  298. data/lib/active_merchant/billing/integrations/citrus.rb +0 -51
  299. data/lib/active_merchant/billing/integrations/direc_pay/helper.rb +0 -200
  300. data/lib/active_merchant/billing/integrations/direc_pay/notification.rb +0 -76
  301. data/lib/active_merchant/billing/integrations/direc_pay/return.rb +0 -32
  302. data/lib/active_merchant/billing/integrations/direc_pay/status.rb +0 -37
  303. data/lib/active_merchant/billing/integrations/direc_pay.rb +0 -41
  304. data/lib/active_merchant/billing/integrations/directebanking/helper.rb +0 -90
  305. data/lib/active_merchant/billing/integrations/directebanking/notification.rb +0 -120
  306. data/lib/active_merchant/billing/integrations/directebanking/return.rb +0 -11
  307. data/lib/active_merchant/billing/integrations/directebanking.rb +0 -47
  308. data/lib/active_merchant/billing/integrations/doku/helper.rb +0 -102
  309. data/lib/active_merchant/billing/integrations/doku/notification.rb +0 -69
  310. data/lib/active_merchant/billing/integrations/doku/return.rb +0 -10
  311. data/lib/active_merchant/billing/integrations/doku.rb +0 -24
  312. data/lib/active_merchant/billing/integrations/dotpay/helper.rb +0 -77
  313. data/lib/active_merchant/billing/integrations/dotpay/notification.rb +0 -86
  314. data/lib/active_merchant/billing/integrations/dotpay/return.rb +0 -11
  315. data/lib/active_merchant/billing/integrations/dotpay.rb +0 -22
  316. data/lib/active_merchant/billing/integrations/dwolla/common.rb +0 -23
  317. data/lib/active_merchant/billing/integrations/dwolla/helper.rb +0 -43
  318. data/lib/active_merchant/billing/integrations/dwolla/notification.rb +0 -64
  319. data/lib/active_merchant/billing/integrations/dwolla/return.rb +0 -49
  320. data/lib/active_merchant/billing/integrations/dwolla.rb +0 -23
  321. data/lib/active_merchant/billing/integrations/e_payment_plans/helper.rb +0 -34
  322. data/lib/active_merchant/billing/integrations/e_payment_plans/notification.rb +0 -84
  323. data/lib/active_merchant/billing/integrations/e_payment_plans.rb +0 -48
  324. data/lib/active_merchant/billing/integrations/easy_pay/common.rb +0 -40
  325. data/lib/active_merchant/billing/integrations/easy_pay/helper.rb +0 -36
  326. data/lib/active_merchant/billing/integrations/easy_pay/notification.rb +0 -59
  327. data/lib/active_merchant/billing/integrations/easy_pay.rb +0 -30
  328. data/lib/active_merchant/billing/integrations/epay/helper.rb +0 -55
  329. data/lib/active_merchant/billing/integrations/epay/notification.rb +0 -110
  330. data/lib/active_merchant/billing/integrations/epay.rb +0 -21
  331. data/lib/active_merchant/billing/integrations/first_data/helper.rb +0 -61
  332. data/lib/active_merchant/billing/integrations/first_data/notification.rb +0 -56
  333. data/lib/active_merchant/billing/integrations/first_data.rb +0 -38
  334. data/lib/active_merchant/billing/integrations/gestpay/common.rb +0 -42
  335. data/lib/active_merchant/billing/integrations/gestpay/helper.rb +0 -70
  336. data/lib/active_merchant/billing/integrations/gestpay/notification.rb +0 -85
  337. data/lib/active_merchant/billing/integrations/gestpay/return.rb +0 -10
  338. data/lib/active_merchant/billing/integrations/gestpay.rb +0 -25
  339. data/lib/active_merchant/billing/integrations/helper.rb +0 -117
  340. data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +0 -58
  341. data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +0 -59
  342. data/lib/active_merchant/billing/integrations/hi_trust/return.rb +0 -68
  343. data/lib/active_merchant/billing/integrations/hi_trust.rb +0 -27
  344. data/lib/active_merchant/billing/integrations/ipay88/helper.rb +0 -118
  345. data/lib/active_merchant/billing/integrations/ipay88/notification.rb +0 -103
  346. data/lib/active_merchant/billing/integrations/ipay88/return.rb +0 -29
  347. data/lib/active_merchant/billing/integrations/ipay88.rb +0 -23
  348. data/lib/active_merchant/billing/integrations/liqpay/helper.rb +0 -43
  349. data/lib/active_merchant/billing/integrations/liqpay/notification.rb +0 -89
  350. data/lib/active_merchant/billing/integrations/liqpay/return.rb +0 -83
  351. data/lib/active_merchant/billing/integrations/liqpay.rb +0 -30
  352. data/lib/active_merchant/billing/integrations/maksuturva/helper.rb +0 -119
  353. data/lib/active_merchant/billing/integrations/maksuturva/notification.rb +0 -48
  354. data/lib/active_merchant/billing/integrations/maksuturva.rb +0 -86
  355. data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +0 -75
  356. data/lib/active_merchant/billing/integrations/moneybookers/notification.rb +0 -123
  357. data/lib/active_merchant/billing/integrations/moneybookers.rb +0 -26
  358. data/lib/active_merchant/billing/integrations/nochex/helper.rb +0 -68
  359. data/lib/active_merchant/billing/integrations/nochex/notification.rb +0 -94
  360. data/lib/active_merchant/billing/integrations/nochex/return.rb +0 -10
  361. data/lib/active_merchant/billing/integrations/nochex.rb +0 -88
  362. data/lib/active_merchant/billing/integrations/notification.rb +0 -71
  363. data/lib/active_merchant/billing/integrations/paxum/common.rb +0 -24
  364. data/lib/active_merchant/billing/integrations/paxum/helper.rb +0 -42
  365. data/lib/active_merchant/billing/integrations/paxum/notification.rb +0 -33
  366. data/lib/active_merchant/billing/integrations/paxum.rb +0 -44
  367. data/lib/active_merchant/billing/integrations/pay_fast/common.rb +0 -42
  368. data/lib/active_merchant/billing/integrations/pay_fast/helper.rb +0 -50
  369. data/lib/active_merchant/billing/integrations/pay_fast/notification.rb +0 -134
  370. data/lib/active_merchant/billing/integrations/pay_fast/return.rb +0 -10
  371. data/lib/active_merchant/billing/integrations/pay_fast.rb +0 -70
  372. data/lib/active_merchant/billing/integrations/paydollar/helper.rb +0 -41
  373. data/lib/active_merchant/billing/integrations/paydollar/notification.rb +0 -60
  374. data/lib/active_merchant/billing/integrations/paydollar/return.rb +0 -15
  375. data/lib/active_merchant/billing/integrations/paydollar.rb +0 -59
  376. data/lib/active_merchant/billing/integrations/payflow_link/helper.rb +0 -116
  377. data/lib/active_merchant/billing/integrations/payflow_link/notification.rb +0 -78
  378. data/lib/active_merchant/billing/integrations/payflow_link.rb +0 -21
  379. data/lib/active_merchant/billing/integrations/paypal/helper.rb +0 -119
  380. data/lib/active_merchant/billing/integrations/paypal/notification.rb +0 -227
  381. data/lib/active_merchant/billing/integrations/paypal/return.rb +0 -10
  382. data/lib/active_merchant/billing/integrations/paypal.rb +0 -39
  383. data/lib/active_merchant/billing/integrations/paypal_payments_advanced/helper.rb +0 -15
  384. data/lib/active_merchant/billing/integrations/paypal_payments_advanced.rb +0 -20
  385. data/lib/active_merchant/billing/integrations/paysbuy/helper.rb +0 -15
  386. data/lib/active_merchant/billing/integrations/paysbuy/notification.rb +0 -39
  387. data/lib/active_merchant/billing/integrations/paysbuy.rb +0 -36
  388. data/lib/active_merchant/billing/integrations/payu_in/helper.rb +0 -76
  389. data/lib/active_merchant/billing/integrations/payu_in/notification.rb +0 -154
  390. data/lib/active_merchant/billing/integrations/payu_in/return.rb +0 -36
  391. data/lib/active_merchant/billing/integrations/payu_in.rb +0 -36
  392. data/lib/active_merchant/billing/integrations/payu_in_paisa/helper.rb +0 -19
  393. data/lib/active_merchant/billing/integrations/payu_in_paisa/notification.rb +0 -13
  394. data/lib/active_merchant/billing/integrations/payu_in_paisa/return.rb +0 -16
  395. data/lib/active_merchant/billing/integrations/payu_in_paisa.rb +0 -30
  396. data/lib/active_merchant/billing/integrations/platron/helper.rb +0 -32
  397. data/lib/active_merchant/billing/integrations/platron/notification.rb +0 -113
  398. data/lib/active_merchant/billing/integrations/platron.rb +0 -28
  399. data/lib/active_merchant/billing/integrations/pxpay/helper.rb +0 -112
  400. data/lib/active_merchant/billing/integrations/pxpay/notification.rb +0 -157
  401. data/lib/active_merchant/billing/integrations/pxpay/return.rb +0 -25
  402. data/lib/active_merchant/billing/integrations/pxpay.rb +0 -31
  403. data/lib/active_merchant/billing/integrations/quickpay/helper.rb +0 -96
  404. data/lib/active_merchant/billing/integrations/quickpay/notification.rb +0 -137
  405. data/lib/active_merchant/billing/integrations/quickpay.rb +0 -21
  406. data/lib/active_merchant/billing/integrations/rbkmoney/helper.rb +0 -23
  407. data/lib/active_merchant/billing/integrations/rbkmoney/notification.rb +0 -91
  408. data/lib/active_merchant/billing/integrations/rbkmoney.rb +0 -17
  409. data/lib/active_merchant/billing/integrations/return.rb +0 -42
  410. data/lib/active_merchant/billing/integrations/robokassa/common.rb +0 -19
  411. data/lib/active_merchant/billing/integrations/robokassa/helper.rb +0 -50
  412. data/lib/active_merchant/billing/integrations/robokassa/notification.rb +0 -55
  413. data/lib/active_merchant/billing/integrations/robokassa/return.rb +0 -17
  414. data/lib/active_merchant/billing/integrations/robokassa.rb +0 -49
  415. data/lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb +0 -33
  416. data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +0 -136
  417. data/lib/active_merchant/billing/integrations/sage_pay_form/notification.rb +0 -210
  418. data/lib/active_merchant/billing/integrations/sage_pay_form/return.rb +0 -31
  419. data/lib/active_merchant/billing/integrations/sage_pay_form.rb +0 -37
  420. data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +0 -107
  421. data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +0 -171
  422. data/lib/active_merchant/billing/integrations/two_checkout/return.rb +0 -58
  423. data/lib/active_merchant/billing/integrations/two_checkout.rb +0 -44
  424. data/lib/active_merchant/billing/integrations/valitor/helper.rb +0 -86
  425. data/lib/active_merchant/billing/integrations/valitor/notification.rb +0 -13
  426. data/lib/active_merchant/billing/integrations/valitor/response_fields.rb +0 -97
  427. data/lib/active_merchant/billing/integrations/valitor/return.rb +0 -13
  428. data/lib/active_merchant/billing/integrations/valitor.rb +0 -33
  429. data/lib/active_merchant/billing/integrations/verkkomaksut/helper.rb +0 -88
  430. data/lib/active_merchant/billing/integrations/verkkomaksut/notification.rb +0 -59
  431. data/lib/active_merchant/billing/integrations/verkkomaksut.rb +0 -20
  432. data/lib/active_merchant/billing/integrations/web_pay/common.rb +0 -50
  433. data/lib/active_merchant/billing/integrations/web_pay/helper.rb +0 -68
  434. data/lib/active_merchant/billing/integrations/web_pay/notification.rb +0 -51
  435. data/lib/active_merchant/billing/integrations/web_pay.rb +0 -45
  436. data/lib/active_merchant/billing/integrations/webmoney/common.rb +0 -17
  437. data/lib/active_merchant/billing/integrations/webmoney/helper.rb +0 -40
  438. data/lib/active_merchant/billing/integrations/webmoney/notification.rb +0 -47
  439. data/lib/active_merchant/billing/integrations/webmoney.rb +0 -43
  440. data/lib/active_merchant/billing/integrations/wirecard_checkout_page/common.rb +0 -104
  441. data/lib/active_merchant/billing/integrations/wirecard_checkout_page/helper.rb +0 -145
  442. data/lib/active_merchant/billing/integrations/wirecard_checkout_page/notification.rb +0 -101
  443. data/lib/active_merchant/billing/integrations/wirecard_checkout_page/return.rb +0 -35
  444. data/lib/active_merchant/billing/integrations/wirecard_checkout_page.rb +0 -39
  445. data/lib/active_merchant/billing/integrations/world_pay/helper.rb +0 -101
  446. data/lib/active_merchant/billing/integrations/world_pay/notification.rb +0 -160
  447. data/lib/active_merchant/billing/integrations/world_pay.rb +0 -34
  448. data/lib/active_merchant/billing/integrations.rb +0 -17
  449. data.tar.gz.sig +0 -0
  450. metadata.gz.sig +0 -1
@@ -1,498 +1,520 @@
1
- require 'digest/md5'
2
-
3
- module ActiveMerchant #:nodoc:
4
- module Billing #:nodoc:
5
- class BluePayGateway < Gateway
6
- class_attribute :rebilling_url, :ignore_http_status
7
-
8
- self.live_url = 'https://secure.bluepay.com/interfaces/bp20post'
9
- self.rebilling_url = 'https://secure.bluepay.com/interfaces/bp20rebadmin'
10
-
11
- self.ignore_http_status = true
12
-
13
- CARD_CODE_ERRORS = %w( N S )
14
- AVS_ERRORS = %w( A E N R W Z )
15
- AVS_REASON_CODES = %w(27 45)
16
-
17
- FIELD_MAP = {
18
- 'TRANS_ID' => :transaction_id,
19
- 'STATUS' => :response_code,
20
- 'AVS' => :avs_result_code,
21
- 'CVV2'=> :card_code,
22
- 'AUTH_CODE' => :authorization,
23
- 'MESSAGE' => :message,
24
- 'REBID' => :rebid,
25
- 'TRANS_TYPE' => :trans_type,
26
- 'PAYMENT_ACCOUNT_MASK' => :acct_mask,
27
- 'CARD_TYPE' => :card_type,
28
- }
29
-
30
- REBILL_FIELD_MAP = {
31
- 'REBILL_ID' => :rebill_id,
32
- 'ACCOUNT_ID'=> :account_id,
33
- 'USER_ID' => :user_id,
34
- 'TEMPLATE_ID' => :template_id,
35
- 'STATUS' => :status,
36
- 'CREATION_DATE' => :creation_date,
37
- 'NEXT_DATE' => :next_date,
38
- 'LAST_DATE' => :last_date,
39
- 'SCHED_EXPR' => :schedule,
40
- 'CYCLES_REMAIN' => :cycles_remain,
41
- 'REB_AMOUNT' => :rebill_amount,
42
- 'NEXT_AMOUNT' => :next_amount,
43
- 'USUAL_DATE' => :undoc_usual_date, # Not found in the bp20rebadmin API doc.
44
- }
45
-
46
- self.supported_countries = ['US']
47
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb]
48
- self.homepage_url = 'http://www.bluepay.com/'
49
- self.display_name = 'BluePay'
50
- self.money_format = :dollars
51
-
52
- # Creates a new BluepayGateway
53
- #
54
- # The gateway requires that a valid Account ID and Secret Key be passed
55
- # in the +options+ hash.
56
- #
57
- # ==== Options
58
- #
59
- # * <tt>:account_id</tt> -- The BluePay gateway Account ID (REQUIRED)
60
- # * <tt>:secret_key</tt> -- The BluePay gateway Secret Key (REQUIRED)
61
- # * <tt>:test</tt> -- set to true for TEST mode or false for LIVE mode
62
- def initialize(options = {})
63
- requires!(options, :login, :password)
64
- super
65
- end
66
-
67
- # Performs an authorization, which reserves the funds on the customer's credit card. This does not actually take funds from the customer
68
- # This is referred to an AUTH transaction in BluePay
69
- #
70
- # ==== Parameters
71
- #
72
- # * <tt>money</tt> -- The amount to be authorized as an Integer value in cents.
73
- # * <tt>payment_object</tt> -- This can either be one of three things:
74
- # A CreditCard object,
75
- # A Check object,
76
- # or a token. The token is called the Master ID. This is a unique transaction ID returned from a previous transaction. This token associates all the stored information for a previous transaction.
77
- # * <tt>options</tt> -- A hash of optional parameters.
78
- def authorize(money, payment_object, options = {})
79
- post = {}
80
- add_payment_method(post, payment_object)
81
- add_invoice(post, options)
82
- add_address(post, options)
83
- add_customer_data(post, options)
84
- add_rebill(post, options) if options[:rebill]
85
- add_duplicate_override(post, options)
86
- post[:TRANS_TYPE] = 'AUTH'
87
- commit('AUTH_ONLY', money, post)
88
- end
89
-
90
- # Perform a purchase, which is essentially an authorization and capture in a single operation.
91
- # This is referred to a SALE transaction in BluePay
92
- #
93
- # ==== Parameters
94
- #
95
- # * <tt>money</tt> -- The amount to be purchased as an Integer value in cents.
96
- # * <tt>payment_object</tt> -- This can either be one of three things:
97
- # A CreditCard object,
98
- # A Check object,
99
- # or a token. The token is called the Master ID. This is a unique transaction ID returned from a previous transaction. This token associates all the stored information for a previous transaction.
100
- # * <tt>options</tt> -- A hash of optional parameters.,
101
- def purchase(money, payment_object, options = {})
102
- post = {}
103
- add_payment_method(post, payment_object)
104
- add_invoice(post, options)
105
- add_address(post, options)
106
- add_customer_data(post, options)
107
- add_rebill(post, options) if options[:rebill]
108
- add_duplicate_override(post, options)
109
- post[:TRANS_TYPE] = 'SALE'
110
- commit('AUTH_CAPTURE', money, post)
111
- end
112
-
113
- # Captures the funds from an authorize transaction.
114
- # This is referred to a CAPTURE transaction in BluePay
115
- #
116
- # ==== Parameters
117
- #
118
- # * <tt>money</tt> -- The amount to be captured as an Integer value in cents.
119
- # * <tt>identification</tt> -- The Master ID, or token, returned from the previous authorize transaction.
120
- def capture(money, identification, options = {})
121
- post = {}
122
- add_address(post, options)
123
- add_customer_data(post, options)
124
- post[:MASTER_ID] = identification
125
- post[:TRANS_TYPE] = 'CAPTURE'
126
- commit('PRIOR_AUTH_CAPTURE', money, post)
127
- end
128
-
129
- # Void a previous transaction
130
- # This is referred to a VOID transaction in BluePay
131
- #
132
- # ==== Parameters
133
- #
134
- # * <tt>identification</tt> - The Master ID, or token, returned from a previous authorize transaction.
135
- def void(identification, options = {})
136
- post = {}
137
- post[:MASTER_ID] = identification
138
- post[:TRANS_TYPE] = 'VOID'
139
- commit('VOID', nil, post)
140
- end
141
-
142
- # Performs a credit.
143
- #
144
- # This transaction indicates that money should flow from the merchant to the customer.
145
- #
146
- # ==== Parameters
147
- #
148
- # * <tt>money</tt> -- The amount to be credited to the customer as an Integer value in cents.
149
- # * <tt>payment_object</tt> -- This can either be one of three things:
150
- # A CreditCard object,
151
- # A Check object,
152
- # or a token. The token is called the Master ID. This is a unique transaction ID returned from a previous transaction. This token associates all the stored information for a previous transaction.
153
- # If the payment_object is a token, then the transaction type will reverse a previous capture or purchase transaction, returning the funds to the customer. If the amount is nil, a full credit will be processed. This is referred to a REFUND transaction in BluePay.
154
- # If the payment_object is either a CreditCard or Check object, then the transaction type will be an unmatched credit placing funds in the specified account. This is referred to a CREDIT transaction in BluePay.
155
- # * <tt>options</tt> -- A hash of parameters.
156
- def refund(money, identification, options = {})
157
- if(identification && !identification.kind_of?(String))
158
- deprecated "refund should only be used to refund a referenced transaction"
159
- return credit(money, identification, options)
160
- end
161
-
162
- post = {}
163
- post[:PAYMENT_ACCOUNT] = ''
164
- post[:MASTER_ID] = identification
165
- post[:TRANS_TYPE] = 'REFUND'
166
- post[:NAME1] = (options[:first_name] ? options[:first_name] : "")
167
- post[:NAME2] = options[:last_name] if options[:last_name]
168
- post[:ZIP] = options[:zip] if options[:zip]
169
- add_invoice(post, options)
170
- add_address(post, options)
171
- add_customer_data(post, options)
172
- commit('CREDIT', money, post)
173
- end
174
-
175
- def credit(money, payment_object, options = {})
176
- if(payment_object && payment_object.kind_of?(String))
177
- deprecated "credit should only be used to credit a payment method"
178
- return refund(money, payment_object, options)
179
- end
180
-
181
- post = {}
182
- post[:PAYMENT_ACCOUNT] = ''
183
- add_payment_method(post, payment_object)
184
- post[:TRANS_TYPE] = 'CREDIT'
185
-
186
- post[:NAME1] = (options[:first_name] ? options[:first_name] : "")
187
- post[:NAME2] = options[:last_name] if options[:last_name]
188
- post[:ZIP] = options[:zip] if options[:zip]
189
- add_invoice(post, options)
190
- add_address(post, options)
191
- add_customer_data(post, options)
192
- commit('CREDIT', money, post)
193
- end
194
-
195
- # Create a new recurring payment.
196
- #
197
- # ==== Parameters
198
- #
199
- # * <tt>money</tt> -- The amount to charge the customer at the time of the recurring payment setup, in cents. Set to zero if you do not want the customer to be charged at this time.
200
- # * <tt>payment_object</tt> -- This can either be one of three things:
201
- # A CreditCard object,
202
- # A Check object,
203
- # or a token. The token is called the Master ID. This is a unique transaction ID returned from a previous transaction. This token associates all the stored information for a previous transaction.
204
- # * <tt>options</tt> -- A hash of optional parameters.,
205
-
206
- # ==== Options
207
- #
208
- # * <tt>:rebill_start_date</tt> is a string that tells the gateway when to start the rebill. (REQUIRED)
209
- # Has two valid formats:
210
- # "YYYY-MM-DD HH:MM:SS" Hours, minutes, and seconds are optional.
211
- # "XX UNITS" Relative date as explained below. Marked from the time of the
212
- # transaction (i.e.: 10 DAYS, 1 MONTH, 1 YEAR)
213
- # * <tt>:rebill_expression</tt> is the period of time in-between rebillings. (REQUIRED)
214
- # It uses the same "XX UNITS" format as rebill_start_date, explained above.
215
- # Optional parameters include:
216
- # * <tt>rebill_cycles</tt>: Number of times to rebill. Don't send or set to nil for infinite rebillings (or
217
- # until canceled).
218
- # * <tt>rebill_amount</tt>: Amount to rebill. Defaults to amount of transaction for rebillings.
219
- #
220
- # For example, to charge the customer $19.95 now and then charge $39.95 in 60 days every 3 months for 5 times, the options hash would be as follows:
221
- # :rebill_start_date => '60 DAYS',
222
- # :rebill_expression => '3 MONTHS',
223
- # :rebill_cycles => '5',
224
- # :rebill_amount => '39.95'
225
- # A money object of 1995 cents would be passed into the 'money' parameter.
226
- def recurring(money, payment_object, options = {})
227
- requires!(options, :rebill_start_date, :rebill_expression)
228
- options[:rebill] = true
229
- if money
230
- purchase(money, payment_object, options)
231
- else
232
- authorize(money, payment_object, options)
233
- end
234
- end
235
-
236
- # View a recurring payment
237
- #
238
- # This will pull data associated with a current recurring billing
239
- #
240
- # ==== Parameters
241
- #
242
- # * <tt>rebill_id</tt> -- A string containing the rebill_id of the recurring billing that is already active (REQUIRED)
243
- def status_recurring(rebill_id)
244
- post = {}
245
- requires!(rebill_id)
246
- post[:REBILL_ID] = rebill_id
247
- post[:TRANS_TYPE] = 'GET'
248
- commit('rebill', 'nil', post)
249
- end
250
-
251
- # Update a recurring payment's details.
252
- #
253
- # This transaction updates an existing recurring billing
254
- #
255
- # ==== Options
256
- #
257
- # * <tt>:rebill_id</tt> -- The 12 digit rebill ID used to update a particular rebilling cycle. (REQUIRED)
258
- # * <tt>:rebill_amount</tt> -- A string containing the new rebilling amount.
259
- # * <tt>:rebill_next_date</tt> -- A string containing the new rebilling next date.
260
- # * <tt>:rebill_expression</tt> -- A string containing the new rebilling expression.
261
- # * <tt>:rebill_cycles</tt> -- A string containing the new rebilling cycles.
262
- # * <tt>:rebill_next_amount</tt> -- A string containing the next rebilling amount to charge the customer. This ONLY affects the next scheduled charge; all other rebillings will continue at the regular (rebill_amount) amount.
263
- # Take a look above at the recurring_payment method for similar examples on how to use.
264
- def update_recurring(options = {})
265
- post = {}
266
- requires!(options, :rebill_id)
267
- post[:REBILL_ID] = options[:rebill_id]
268
- post[:TRANS_TYPE] = 'SET'
269
- post[:REB_AMOUNT] = amount(options[:rebill_amount]) if options[:rebill_amount]
270
- post[:NEXT_DATE] = options[:rebill_next_date]
271
- post[:REB_EXPR] = options[:rebill_expression]
272
- post[:REB_CYCLES] = options[:rebill_cycles]
273
- post[:NEXT_AMOUNT] = options[:rebill_next_amount]
274
- commit('rebill', 'nil', post)
275
- end
276
-
277
- # Cancel a recurring payment.
278
- #
279
- # This transaction cancels an existing recurring billing.
280
- #
281
- # ==== Parameters
282
- #
283
- # * <tt>rebill_id</tt> -- A string containing the rebill_id of the recurring billing that you wish to cancel/stop (REQUIRED)
284
- def cancel_recurring(rebill_id)
285
- post = {}
286
- requires!(rebill_id)
287
- post[:REBILL_ID] = rebill_id
288
- post[:TRANS_TYPE] = 'SET'
289
- post[:STATUS] = 'stopped'
290
- commit('rebill', 'nil', post)
291
- end
292
-
293
- private
294
-
295
- def commit(action, money, fields)
296
- fields[:AMOUNT] = amount(money) unless(fields[:TRANS_TYPE] == 'VOID' || action == 'rebill')
297
- fields[:MODE] = (test? ? 'TEST' : 'LIVE')
298
- fields[:ACCOUNT_ID] = @options[:login]
299
-
300
- if action == 'rebill'
301
- url = rebilling_url
302
- fields[:TAMPER_PROOF_SEAL] = calc_rebill_tps(fields)
303
- else
304
- url = live_url
305
- fields[:TAMPER_PROOF_SEAL] = calc_tps(amount(money), fields)
306
- end
307
- parse(ssl_post(url, post_data(action, fields)))
308
- end
309
-
310
- def parse_recurring(response_fields, opts={}) # expected status?
311
- parsed = {}
312
- response_fields.each do |k,v|
313
- mapped_key = REBILL_FIELD_MAP.include?(k) ? REBILL_FIELD_MAP[k] : k
314
- parsed[mapped_key] = v
315
- end
316
-
317
- success = parsed[:status] != 'error'
318
- message = parsed[:status]
319
-
320
- Response.new(success, message, parsed,
321
- :test => test?,
322
- :authorization => parsed[:rebill_id])
323
- end
324
-
325
- def parse(body)
326
- # The bp20api has max one value per form field.
327
- response_fields = Hash[CGI::parse(body).map{|k,v| [k.upcase,v.first]}]
328
-
329
- if response_fields.include? "REBILL_ID"
330
- return parse_recurring(response_fields)
331
- end
332
-
333
- parsed = {}
334
- response_fields.each do |k,v|
335
- mapped_key = FIELD_MAP.include?(k) ? FIELD_MAP[k] : k
336
- parsed[mapped_key] = v
337
- end
338
-
339
- # normalize message
340
- message = message_from(parsed)
341
- success = parsed[:response_code] == '1'
342
- Response.new(success, message, parsed,
343
- :test => test?,
344
- :authorization => (parsed[:rebid] && parsed[:rebid] != '' ? parsed[:rebid] : parsed[:transaction_id]),
345
- :avs_result => { :code => parsed[:avs_result_code] },
346
- :cvv_result => parsed[:card_code]
347
- )
348
- end
349
-
350
- def message_from(parsed)
351
- message = parsed[:message]
352
- if(parsed[:response_code].to_i == 2)
353
- if CARD_CODE_ERRORS.include?(parsed[:card_code])
354
- message = CVVResult.messages[parsed[:card_code]]
355
- elsif AVS_ERRORS.include?(parsed[:avs_result_code])
356
- message = AVSResult.messages[ parsed[:avs_result_code] ]
357
- else
358
- message = message.chomp('.')
359
- end
360
- elsif message == "Missing ACCOUNT_ID"
361
- message = "The merchant login ID or password is invalid"
362
- elsif message =~ /Approved/
363
- message = "This transaction has been approved"
364
- elsif message =~ /Expired/
365
- message = "The credit card has expired"
366
- end
367
- message
368
- end
369
-
370
- def add_invoice(post, options)
371
- post[:ORDER_ID] = options[:order_id]
372
- post[:INVOICE_ID] = options[:invoice]
373
- post[:invoice_num] = options[:order_id]
374
- post[:MEMO] = options[:description]
375
- post[:description] = options[:description]
376
- end
377
-
378
- def add_payment_method(post, payment_object)
379
- post[:MASTER_ID] = ''
380
- case payment_object
381
- when String
382
- post[:MASTER_ID] = payment_object
383
- when Check
384
- add_check(post, payment_object)
385
- else
386
- add_creditcard(post, payment_object)
387
- end
388
- end
389
-
390
- def add_creditcard(post, creditcard)
391
- post[:PAYMENT_TYPE] = 'CREDIT'
392
- post[:PAYMENT_ACCOUNT] = creditcard.number
393
- post[:CARD_CVV2] = creditcard.verification_value
394
- post[:CARD_EXPIRE] = expdate(creditcard)
395
- post[:NAME1] = creditcard.first_name
396
- post[:NAME2] = creditcard.last_name
397
- end
398
-
399
- CHECK_ACCOUNT_TYPES = {
400
- "checking" => "C",
401
- "savings" => "S"
402
- }
403
-
404
- def add_check(post, check)
405
- post[:PAYMENT_TYPE] = 'ACH'
406
- post[:PAYMENT_ACCOUNT] = [CHECK_ACCOUNT_TYPES[check.account_type], check.routing_number, check.account_number].join(":")
407
- post[:NAME1] = check.first_name
408
- post[:NAME2] = check.last_name
409
- end
410
-
411
- def add_customer_data(post, options)
412
- post[:EMAIL] = options[:email]
413
- post[:CUSTOM_ID] = options[:customer]
414
- end
415
-
416
- def add_duplicate_override(post, options)
417
- post[:DUPLICATE_OVERRIDE] = options[:duplicate_override]
418
- end
419
-
420
- def add_address(post, options)
421
- if address = (options[:shipping_address] || options[:billing_address] || options[:address])
422
- post[:ADDR1] = address[:address1]
423
- post[:ADDR2] = address[:address2]
424
- post[:COMPANY_NAME] = address[:company]
425
- post[:PHONE] = address[:phone]
426
- post[:CITY] = address[:city]
427
- post[:STATE] = (address[:state].blank? ? 'n/a' : address[:state])
428
- post[:ZIP] = address[:zip]
429
- post[:COUNTRY] = address[:country]
430
- end
431
- end
432
-
433
- def add_rebill(post, options)
434
- post[:DO_REBILL] = '1'
435
- post[:REB_AMOUNT] = amount(options[:rebill_amount])
436
- post[:REB_FIRST_DATE] = options[:rebill_start_date]
437
- post[:REB_EXPR] = options[:rebill_expression]
438
- post[:REB_CYCLES] = options[:rebill_cycles]
439
- end
440
-
441
- def post_data(action, parameters = {})
442
- post = {}
443
- post[:version] = '1'
444
- post[:login] = ''
445
- post[:tran_key] = ''
446
- post[:relay_response] = "FALSE"
447
- post[:type] = action
448
- post[:delim_data] = "TRUE"
449
- post[:delim_char] = ","
450
- post[:encap_char] = "$"
451
- post[:card_num] = '4111111111111111'
452
- post[:exp_date] = '1212'
453
- post[:solution_ID] = application_id if(application_id && application_id != "ActiveMerchant")
454
- post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
455
- end
456
-
457
- def expdate(creditcard)
458
- year = format(creditcard.year, :two_digits)
459
- month = format(creditcard.month, :two_digits)
460
-
461
- "#{month}#{year}"
462
- end
463
-
464
- def calc_tps(amount, post)
465
- post[:NAME1] ||= ''
466
- Digest::MD5.hexdigest(
467
- [
468
- @options[:password],
469
- @options[:login],
470
- post[:TRANS_TYPE],
471
- amount,
472
- post[:MASTER_ID],
473
- post[:NAME1],
474
- post[:PAYMENT_ACCOUNT]
475
- ].join("")
476
- )
477
- end
478
-
479
- def calc_rebill_tps(post)
480
- Digest::MD5.hexdigest(
481
- [
482
- @options[:password],
483
- @options[:login],
484
- post[:TRANS_TYPE],
485
- post[:REBILL_ID]
486
- ].join("")
487
- )
488
- end
489
-
490
- def handle_response(response)
491
- if ignore_http_status || (200...300).include?(response.code.to_i)
492
- return response.body
493
- end
494
- raise ResponseError.new(response)
495
- end
496
- end
497
- end
498
- end
1
+ require 'digest/md5'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ class BluePayGateway < Gateway
6
+ class_attribute :rebilling_url, :ignore_http_status
7
+
8
+ self.live_url = 'https://secure.bluepay.com/interfaces/bp20post'
9
+ self.rebilling_url = 'https://secure.bluepay.com/interfaces/bp20rebadmin'
10
+
11
+ self.ignore_http_status = true
12
+
13
+ CARD_CODE_ERRORS = %w( N S )
14
+ AVS_ERRORS = %w( A E N R W Z )
15
+ AVS_REASON_CODES = %w(27 45)
16
+
17
+ FIELD_MAP = {
18
+ 'TRANS_ID' => :transaction_id,
19
+ 'STATUS' => :response_code,
20
+ 'AVS' => :avs_result_code,
21
+ 'CVV2'=> :card_code,
22
+ 'AUTH_CODE' => :authorization,
23
+ 'MESSAGE' => :message,
24
+ 'REBID' => :rebid,
25
+ 'TRANS_TYPE' => :trans_type,
26
+ 'PAYMENT_ACCOUNT_MASK' => :acct_mask,
27
+ 'CARD_TYPE' => :card_type,
28
+ }
29
+
30
+ REBILL_FIELD_MAP = {
31
+ 'REBILL_ID' => :rebill_id,
32
+ 'ACCOUNT_ID'=> :account_id,
33
+ 'USER_ID' => :user_id,
34
+ 'TEMPLATE_ID' => :template_id,
35
+ 'STATUS' => :status,
36
+ 'CREATION_DATE' => :creation_date,
37
+ 'NEXT_DATE' => :next_date,
38
+ 'LAST_DATE' => :last_date,
39
+ 'SCHED_EXPR' => :schedule,
40
+ 'CYCLES_REMAIN' => :cycles_remain,
41
+ 'REB_AMOUNT' => :rebill_amount,
42
+ 'NEXT_AMOUNT' => :next_amount,
43
+ 'USUAL_DATE' => :undoc_usual_date, # Not found in the bp20rebadmin API doc.
44
+ }
45
+
46
+ self.supported_countries = ['US', 'CA']
47
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb]
48
+ self.homepage_url = 'http://www.bluepay.com/'
49
+ self.display_name = 'BluePay'
50
+ self.money_format = :dollars
51
+
52
+ # Creates a new BluepayGateway
53
+ #
54
+ # The gateway requires that a valid Account ID and Secret Key be passed
55
+ # in the +options+ hash.
56
+ #
57
+ # ==== Options
58
+ #
59
+ # * <tt>:account_id</tt> -- The BluePay gateway Account ID (REQUIRED)
60
+ # * <tt>:secret_key</tt> -- The BluePay gateway Secret Key (REQUIRED)
61
+ # * <tt>:test</tt> -- set to true for TEST mode or false for LIVE mode
62
+ def initialize(options = {})
63
+ requires!(options, :login, :password)
64
+ super
65
+ end
66
+
67
+ # Performs an authorization, which reserves the funds on the customer's credit card. This does not actually take funds from the customer
68
+ # This is referred to an AUTH transaction in BluePay
69
+ #
70
+ # ==== Parameters
71
+ #
72
+ # * <tt>money</tt> -- The amount to be authorized as an Integer value in cents.
73
+ # * <tt>payment_object</tt> -- This can either be one of three things:
74
+ # A CreditCard object,
75
+ # A Check object,
76
+ # or a token. The token is called the Master ID. This is a unique transaction ID returned from a previous transaction. This token associates all the stored information for a previous transaction.
77
+ # * <tt>options</tt> -- A hash of optional parameters.
78
+ def authorize(money, payment_object, options = {})
79
+ post = {}
80
+ add_payment_method(post, payment_object)
81
+ add_invoice(post, options)
82
+ add_address(post, options)
83
+ add_customer_data(post, options)
84
+ add_rebill(post, options) if options[:rebill]
85
+ add_duplicate_override(post, options)
86
+ post[:TRANS_TYPE] = 'AUTH'
87
+ commit('AUTH_ONLY', money, post)
88
+ end
89
+
90
+ # Perform a purchase, which is essentially an authorization and capture in a single operation.
91
+ # This is referred to a SALE transaction in BluePay
92
+ #
93
+ # ==== Parameters
94
+ #
95
+ # * <tt>money</tt> -- The amount to be purchased as an Integer value in cents.
96
+ # * <tt>payment_object</tt> -- This can either be one of three things:
97
+ # A CreditCard object,
98
+ # A Check object,
99
+ # or a token. The token is called the Master ID. This is a unique transaction ID returned from a previous transaction. This token associates all the stored information for a previous transaction.
100
+ # * <tt>options</tt> -- A hash of optional parameters.,
101
+ def purchase(money, payment_object, options = {})
102
+ post = {}
103
+ add_payment_method(post, payment_object)
104
+ add_invoice(post, options)
105
+ add_address(post, options)
106
+ add_customer_data(post, options)
107
+ add_rebill(post, options) if options[:rebill]
108
+ add_duplicate_override(post, options)
109
+ post[:TRANS_TYPE] = 'SALE'
110
+ commit('AUTH_CAPTURE', money, post)
111
+ end
112
+
113
+ # Captures the funds from an authorize transaction.
114
+ # This is referred to a CAPTURE transaction in BluePay
115
+ #
116
+ # ==== Parameters
117
+ #
118
+ # * <tt>money</tt> -- The amount to be captured as an Integer value in cents.
119
+ # * <tt>identification</tt> -- The Master ID, or token, returned from the previous authorize transaction.
120
+ def capture(money, identification, options = {})
121
+ post = {}
122
+ add_address(post, options)
123
+ add_customer_data(post, options)
124
+ post[:MASTER_ID] = identification
125
+ post[:TRANS_TYPE] = 'CAPTURE'
126
+ commit('PRIOR_AUTH_CAPTURE', money, post)
127
+ end
128
+
129
+ # Void a previous transaction
130
+ # This is referred to a VOID transaction in BluePay
131
+ #
132
+ # ==== Parameters
133
+ #
134
+ # * <tt>identification</tt> - The Master ID, or token, returned from a previous authorize transaction.
135
+ def void(identification, options = {})
136
+ post = {}
137
+ post[:MASTER_ID] = identification
138
+ post[:TRANS_TYPE] = 'VOID'
139
+ commit('VOID', nil, post)
140
+ end
141
+
142
+ # Performs a credit.
143
+ #
144
+ # This transaction indicates that money should flow from the merchant to the customer.
145
+ #
146
+ # ==== Parameters
147
+ #
148
+ # * <tt>money</tt> -- The amount to be credited to the customer as an Integer value in cents.
149
+ # * <tt>payment_object</tt> -- This can either be one of three things:
150
+ # A CreditCard object,
151
+ # A Check object,
152
+ # or a token. The token is called the Master ID. This is a unique transaction ID returned from a previous transaction. This token associates all the stored information for a previous transaction.
153
+ # If the payment_object is a token, then the transaction type will reverse a previous capture or purchase transaction, returning the funds to the customer. If the amount is nil, a full credit will be processed. This is referred to a REFUND transaction in BluePay.
154
+ # If the payment_object is either a CreditCard or Check object, then the transaction type will be an unmatched credit placing funds in the specified account. This is referred to a CREDIT transaction in BluePay.
155
+ # * <tt>options</tt> -- A hash of parameters.
156
+ def refund(money, identification, options = {})
157
+ if(identification && !identification.kind_of?(String))
158
+ ActiveMerchant.deprecated 'refund should only be used to refund a referenced transaction'
159
+ return credit(money, identification, options)
160
+ end
161
+
162
+ post = {}
163
+ post[:PAYMENT_ACCOUNT] = ''
164
+ post[:MASTER_ID] = identification
165
+ post[:TRANS_TYPE] = 'REFUND'
166
+ post[:NAME1] = options[:first_name] || ''
167
+ post[:NAME2] = options[:last_name] if options[:last_name]
168
+ post[:ZIP] = options[:zip] if options[:zip]
169
+ add_invoice(post, options)
170
+ add_address(post, options)
171
+ add_customer_data(post, options)
172
+ commit('CREDIT', money, post)
173
+ end
174
+
175
+ def credit(money, payment_object, options = {})
176
+ if payment_object&.kind_of?(String)
177
+ ActiveMerchant.deprecated 'credit should only be used to credit a payment method'
178
+ return refund(money, payment_object, options)
179
+ end
180
+
181
+ post = {}
182
+ post[:PAYMENT_ACCOUNT] = ''
183
+ add_payment_method(post, payment_object)
184
+ post[:TRANS_TYPE] = 'CREDIT'
185
+
186
+ post[:NAME1] = options[:first_name] || ''
187
+ post[:NAME2] = options[:last_name] if options[:last_name]
188
+ post[:ZIP] = options[:zip] if options[:zip]
189
+ add_invoice(post, options)
190
+ add_address(post, options)
191
+ add_customer_data(post, options)
192
+ commit('CREDIT', money, post)
193
+ end
194
+
195
+ # Create a new recurring payment.
196
+ #
197
+ # ==== Parameters
198
+ #
199
+ # * <tt>money</tt> -- The amount to charge the customer at the time of the recurring payment setup, in cents. Set to zero if you do not want the customer to be charged at this time.
200
+ # * <tt>payment_object</tt> -- This can either be one of three things:
201
+ # A CreditCard object,
202
+ # A Check object,
203
+ # or a token. The token is called the Master ID. This is a unique transaction ID returned from a previous transaction. This token associates all the stored information for a previous transaction.
204
+ # * <tt>options</tt> -- A hash of optional parameters.,
205
+
206
+ # ==== Options
207
+ #
208
+ # * <tt>:rebill_start_date</tt> is a string that tells the gateway when to start the rebill. (REQUIRED)
209
+ # Has two valid formats:
210
+ # "YYYY-MM-DD HH:MM:SS" Hours, minutes, and seconds are optional.
211
+ # "XX UNITS" Relative date as explained below. Marked from the time of the
212
+ # transaction (i.e.: 10 DAYS, 1 MONTH, 1 YEAR)
213
+ # * <tt>:rebill_expression</tt> is the period of time in-between rebillings. (REQUIRED)
214
+ # It uses the same "XX UNITS" format as rebill_start_date, explained above.
215
+ # Optional parameters include:
216
+ # * <tt>rebill_cycles</tt>: Number of times to rebill. Don't send or set to nil for infinite rebillings (or
217
+ # until canceled).
218
+ # * <tt>rebill_amount</tt>: Amount to rebill. Defaults to amount of transaction for rebillings.
219
+ #
220
+ # For example, to charge the customer $19.95 now and then charge $39.95 in 60 days every 3 months for 5 times, the options hash would be as follows:
221
+ # :rebill_start_date => '60 DAYS',
222
+ # :rebill_expression => '3 MONTHS',
223
+ # :rebill_cycles => '5',
224
+ # :rebill_amount => '39.95'
225
+ # A money object of 1995 cents would be passed into the 'money' parameter.
226
+ def recurring(money, payment_object, options = {})
227
+ ActiveMerchant.deprecated RECURRING_DEPRECATION_MESSAGE
228
+
229
+ requires!(options, :rebill_start_date, :rebill_expression)
230
+ options[:rebill] = true
231
+ if money
232
+ purchase(money, payment_object, options)
233
+ else
234
+ authorize(money, payment_object, options)
235
+ end
236
+ end
237
+
238
+ # View a recurring payment
239
+ #
240
+ # This will pull data associated with a current recurring billing
241
+ #
242
+ # ==== Parameters
243
+ #
244
+ # * <tt>rebill_id</tt> -- A string containing the rebill_id of the recurring billing that is already active (REQUIRED)
245
+ def status_recurring(rebill_id)
246
+ ActiveMerchant.deprecated RECURRING_DEPRECATION_MESSAGE
247
+
248
+ post = {}
249
+ requires!(rebill_id)
250
+ post[:REBILL_ID] = rebill_id
251
+ post[:TRANS_TYPE] = 'GET'
252
+ commit('rebill', 'nil', post)
253
+ end
254
+
255
+ # Update a recurring payment's details.
256
+ #
257
+ # This transaction updates an existing recurring billing
258
+ #
259
+ # ==== Options
260
+ #
261
+ # * <tt>:rebill_id</tt> -- The 12 digit rebill ID used to update a particular rebilling cycle. (REQUIRED)
262
+ # * <tt>:rebill_amount</tt> -- A string containing the new rebilling amount.
263
+ # * <tt>:rebill_next_date</tt> -- A string containing the new rebilling next date.
264
+ # * <tt>:rebill_expression</tt> -- A string containing the new rebilling expression.
265
+ # * <tt>:rebill_cycles</tt> -- A string containing the new rebilling cycles.
266
+ # * <tt>:rebill_next_amount</tt> -- A string containing the next rebilling amount to charge the customer. This ONLY affects the next scheduled charge; all other rebillings will continue at the regular (rebill_amount) amount.
267
+ # Take a look above at the recurring_payment method for similar examples on how to use.
268
+ def update_recurring(options = {})
269
+ ActiveMerchant.deprecated RECURRING_DEPRECATION_MESSAGE
270
+
271
+ post = {}
272
+ requires!(options, :rebill_id)
273
+ post[:REBILL_ID] = options[:rebill_id]
274
+ post[:TRANS_TYPE] = 'SET'
275
+ post[:REB_AMOUNT] = amount(options[:rebill_amount]) if options[:rebill_amount]
276
+ post[:NEXT_DATE] = options[:rebill_next_date]
277
+ post[:REB_EXPR] = options[:rebill_expression]
278
+ post[:REB_CYCLES] = options[:rebill_cycles]
279
+ post[:NEXT_AMOUNT] = options[:rebill_next_amount]
280
+ commit('rebill', 'nil', post)
281
+ end
282
+
283
+ # Cancel a recurring payment.
284
+ #
285
+ # This transaction cancels an existing recurring billing.
286
+ #
287
+ # ==== Parameters
288
+ #
289
+ # * <tt>rebill_id</tt> -- A string containing the rebill_id of the recurring billing that you wish to cancel/stop (REQUIRED)
290
+ def cancel_recurring(rebill_id)
291
+ ActiveMerchant.deprecated RECURRING_DEPRECATION_MESSAGE
292
+
293
+ post = {}
294
+ requires!(rebill_id)
295
+ post[:REBILL_ID] = rebill_id
296
+ post[:TRANS_TYPE] = 'SET'
297
+ post[:STATUS] = 'stopped'
298
+ commit('rebill', 'nil', post)
299
+ end
300
+
301
+ def supports_scrubbing
302
+ true
303
+ end
304
+
305
+ def scrub(transcript)
306
+ transcript.
307
+ gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
308
+ gsub(%r((&?card_num=)[^&]*)i, '\1[FILTERED]').
309
+ gsub(%r((&?CARD_CVV2=)[^&]*)i, '\1[FILTERED]').
310
+ gsub(%r((&?PAYMENT_ACCOUNT=)[^&]*)i, '\1[FILTERED]').
311
+ gsub(%r((&?TAMPER_PROOF_SEAL=)[^&"]*)i, '\1[FILTERED]')
312
+ end
313
+
314
+ private
315
+
316
+ def commit(action, money, fields)
317
+ fields[:AMOUNT] = amount(money) unless(fields[:TRANS_TYPE] == 'VOID' || action == 'rebill')
318
+ fields[:MODE] = (test? ? 'TEST' : 'LIVE')
319
+ fields[:ACCOUNT_ID] = @options[:login]
320
+
321
+ if action == 'rebill'
322
+ url = rebilling_url
323
+ fields[:TAMPER_PROOF_SEAL] = calc_rebill_tps(fields)
324
+ else
325
+ url = live_url
326
+ fields[:TAMPER_PROOF_SEAL] = calc_tps(amount(money), fields)
327
+ end
328
+ parse(ssl_post(url, post_data(action, fields)))
329
+ end
330
+
331
+ def parse_recurring(response_fields, opts={}) # expected status?
332
+ parsed = {}
333
+ response_fields.each do |k, v|
334
+ mapped_key = REBILL_FIELD_MAP.include?(k) ? REBILL_FIELD_MAP[k] : k
335
+ parsed[mapped_key] = v
336
+ end
337
+
338
+ success = parsed[:status] != 'error'
339
+ message = parsed[:status]
340
+
341
+ Response.new(success, message, parsed,
342
+ :test => test?,
343
+ :authorization => parsed[:rebill_id])
344
+ end
345
+
346
+ def parse(body)
347
+ # The bp20api has max one value per form field.
348
+ response_fields = Hash[CGI::parse(body).map { |k, v| [k.upcase, v.first] }]
349
+
350
+ if response_fields.include? 'REBILL_ID'
351
+ return parse_recurring(response_fields)
352
+ end
353
+
354
+ parsed = {}
355
+ response_fields.each do |k, v|
356
+ mapped_key = FIELD_MAP.include?(k) ? FIELD_MAP[k] : k
357
+ parsed[mapped_key] = v
358
+ end
359
+
360
+ # normalize message
361
+ message = message_from(parsed)
362
+ success = parsed[:response_code] == '1'
363
+ Response.new(success, message, parsed,
364
+ :test => test?,
365
+ :authorization => (parsed[:rebid] && parsed[:rebid] != '' ? parsed[:rebid] : parsed[:transaction_id]),
366
+ :avs_result => { :code => parsed[:avs_result_code] },
367
+ :cvv_result => parsed[:card_code]
368
+ )
369
+ end
370
+
371
+ def message_from(parsed)
372
+ message = parsed[:message]
373
+ if(parsed[:response_code].to_i == 2)
374
+ if CARD_CODE_ERRORS.include?(parsed[:card_code])
375
+ message = CVVResult.messages[parsed[:card_code]]
376
+ elsif AVS_ERRORS.include?(parsed[:avs_result_code])
377
+ message = AVSResult.messages[parsed[:avs_result_code]]
378
+ else
379
+ message = message.chomp('.')
380
+ end
381
+ elsif message == 'Missing ACCOUNT_ID'
382
+ message = 'The merchant login ID or password is invalid'
383
+ elsif message =~ /Approved/
384
+ message = 'This transaction has been approved'
385
+ elsif message =~ /Expired/
386
+ message = 'The credit card has expired'
387
+ end
388
+ message
389
+ end
390
+
391
+ def add_invoice(post, options)
392
+ post[:ORDER_ID] = options[:order_id]
393
+ post[:INVOICE_ID] = options[:invoice]
394
+ post[:invoice_num] = options[:order_id]
395
+ post[:MEMO] = options[:description]
396
+ post[:description] = options[:description]
397
+ end
398
+
399
+ def add_payment_method(post, payment_object)
400
+ post[:MASTER_ID] = ''
401
+ case payment_object
402
+ when String
403
+ post[:MASTER_ID] = payment_object
404
+ when Check
405
+ add_check(post, payment_object)
406
+ else
407
+ add_creditcard(post, payment_object)
408
+ end
409
+ end
410
+
411
+ def add_creditcard(post, creditcard)
412
+ post[:PAYMENT_TYPE] = 'CREDIT'
413
+ post[:PAYMENT_ACCOUNT] = creditcard.number
414
+ post[:CARD_CVV2] = creditcard.verification_value
415
+ post[:CARD_EXPIRE] = expdate(creditcard)
416
+ post[:NAME1] = creditcard.first_name
417
+ post[:NAME2] = creditcard.last_name
418
+ end
419
+
420
+ CHECK_ACCOUNT_TYPES = {
421
+ 'checking' => 'C',
422
+ 'savings' => 'S'
423
+ }
424
+
425
+ def add_check(post, check)
426
+ post[:PAYMENT_TYPE] = 'ACH'
427
+ post[:PAYMENT_ACCOUNT] = [CHECK_ACCOUNT_TYPES[check.account_type], check.routing_number, check.account_number].join(':')
428
+ post[:NAME1] = check.first_name
429
+ post[:NAME2] = check.last_name
430
+ end
431
+
432
+ def add_customer_data(post, options)
433
+ post[:EMAIL] = options[:email]
434
+ post[:CUSTOM_ID] = options[:customer]
435
+ post[:CUSTOM_ID2] = options[:custom_id2]
436
+ end
437
+
438
+ def add_duplicate_override(post, options)
439
+ post[:DUPLICATE_OVERRIDE] = options[:duplicate_override]
440
+ end
441
+
442
+ def add_address(post, options)
443
+ if address = (options[:shipping_address] || options[:billing_address] || options[:address])
444
+ post[:ADDR1] = address[:address1]
445
+ post[:ADDR2] = address[:address2]
446
+ post[:COMPANY_NAME] = address[:company]
447
+ post[:PHONE] = address[:phone]
448
+ post[:CITY] = address[:city]
449
+ post[:STATE] = (address[:state].blank? ? 'n/a' : address[:state])
450
+ post[:ZIP] = address[:zip]
451
+ post[:COUNTRY] = address[:country]
452
+ end
453
+ end
454
+
455
+ def add_rebill(post, options)
456
+ post[:DO_REBILL] = '1'
457
+ post[:REB_AMOUNT] = amount(options[:rebill_amount])
458
+ post[:REB_FIRST_DATE] = options[:rebill_start_date]
459
+ post[:REB_EXPR] = options[:rebill_expression]
460
+ post[:REB_CYCLES] = options[:rebill_cycles]
461
+ end
462
+
463
+ def post_data(action, parameters = {})
464
+ post = {}
465
+ post[:version] = '1'
466
+ post[:login] = ''
467
+ post[:tran_key] = ''
468
+ post[:relay_response] = 'FALSE'
469
+ post[:type] = action
470
+ post[:delim_data] = 'TRUE'
471
+ post[:delim_char] = ','
472
+ post[:encap_char] = '$'
473
+ post[:card_num] = '4111111111111111'
474
+ post[:exp_date] = '1212'
475
+ post[:solution_ID] = application_id if application_id
476
+ post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
477
+ end
478
+
479
+ def expdate(creditcard)
480
+ year = format(creditcard.year, :two_digits)
481
+ month = format(creditcard.month, :two_digits)
482
+
483
+ "#{month}#{year}"
484
+ end
485
+
486
+ def calc_tps(amount, post)
487
+ post[:NAME1] ||= ''
488
+ Digest::MD5.hexdigest(
489
+ [
490
+ @options[:password],
491
+ @options[:login],
492
+ post[:TRANS_TYPE],
493
+ amount,
494
+ post[:MASTER_ID],
495
+ post[:NAME1],
496
+ post[:PAYMENT_ACCOUNT]
497
+ ].join('')
498
+ )
499
+ end
500
+
501
+ def calc_rebill_tps(post)
502
+ Digest::MD5.hexdigest(
503
+ [
504
+ @options[:password],
505
+ @options[:login],
506
+ post[:TRANS_TYPE],
507
+ post[:REBILL_ID]
508
+ ].join('')
509
+ )
510
+ end
511
+
512
+ def handle_response(response)
513
+ if ignore_http_status || (200...300).cover?(response.code.to_i)
514
+ return response.body
515
+ end
516
+ raise ResponseError.new(response)
517
+ end
518
+ end
519
+ end
520
+ end