activemerchant 1.43.3 → 1.44.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 (326) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/CHANGELOG +133 -3
  5. data/CONTRIBUTORS +25 -0
  6. data/README.md +14 -39
  7. data/lib/active_merchant.rb +43 -2
  8. data/lib/active_merchant/billing.rb +3 -1
  9. data/lib/active_merchant/billing/base.rb +10 -2
  10. data/lib/active_merchant/billing/check.rb +29 -22
  11. data/lib/active_merchant/billing/compatibility.rb +120 -0
  12. data/lib/active_merchant/billing/credit_card.rb +129 -60
  13. data/lib/active_merchant/billing/credit_card_formatting.rb +4 -1
  14. data/lib/active_merchant/billing/credit_card_methods.rb +60 -43
  15. data/lib/active_merchant/billing/cvv_result.rb +15 -15
  16. data/lib/active_merchant/billing/gateway.rb +46 -11
  17. data/lib/active_merchant/billing/gateways/adyen.rb +205 -0
  18. data/lib/active_merchant/billing/gateways/app55.rb +1 -9
  19. data/lib/active_merchant/billing/gateways/authorize_net.rb +7 -391
  20. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +417 -0
  21. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +20 -4
  22. data/lib/active_merchant/billing/gateways/balanced.rb +127 -367
  23. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +1 -1
  24. data/lib/active_merchant/billing/gateways/beanstream.rb +25 -6
  25. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +3 -3
  26. data/lib/active_merchant/billing/gateways/blue_pay.rb +11 -3
  27. data/lib/active_merchant/billing/gateways/bogus.rb +1 -13
  28. data/lib/active_merchant/billing/gateways/borgun.rb +211 -0
  29. data/lib/active_merchant/billing/gateways/braintree_blue.rb +31 -13
  30. data/lib/active_merchant/billing/gateways/bridge_pay.rb +7 -0
  31. data/lib/active_merchant/billing/gateways/cashnet.rb +184 -0
  32. data/lib/active_merchant/billing/gateways/cc5.rb +45 -0
  33. data/lib/active_merchant/billing/gateways/certo_direct.rb +3 -2
  34. data/lib/active_merchant/billing/gateways/commercegate.rb +143 -0
  35. data/lib/active_merchant/billing/gateways/conekta.rb +56 -81
  36. data/lib/active_merchant/billing/gateways/cyber_source.rb +1 -0
  37. data/lib/active_merchant/billing/gateways/data_cash.rb +3 -1
  38. data/lib/active_merchant/billing/gateways/efsnet.rb +3 -14
  39. data/lib/active_merchant/billing/gateways/elavon.rb +45 -9
  40. data/lib/active_merchant/billing/gateways/epay.rb +2 -2
  41. data/lib/active_merchant/billing/gateways/eway.rb +1 -12
  42. data/lib/active_merchant/billing/gateways/eway_managed.rb +1 -1
  43. data/lib/active_merchant/billing/gateways/eway_rapid.rb +233 -202
  44. data/lib/active_merchant/billing/gateways/exact.rb +1 -1
  45. data/lib/active_merchant/billing/gateways/fat_zebra.rb +1 -1
  46. data/lib/active_merchant/billing/gateways/federated_canada.rb +1 -8
  47. data/lib/active_merchant/billing/gateways/finansbank.rb +2 -1
  48. data/lib/active_merchant/billing/gateways/first_pay.rb +108 -124
  49. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +43 -13
  50. data/lib/active_merchant/billing/gateways/garanti.rb +2 -2
  51. data/lib/active_merchant/billing/gateways/hps.rb +281 -0
  52. data/lib/active_merchant/billing/gateways/iats_payments.rb +2 -2
  53. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +1 -4
  54. data/lib/active_merchant/billing/gateways/inspire.rb +0 -8
  55. data/lib/active_merchant/billing/gateways/iridium.rb +25 -3
  56. data/lib/active_merchant/billing/gateways/jetpay.rb +1 -1
  57. data/lib/active_merchant/billing/gateways/linkpoint.rb +4 -13
  58. data/lib/active_merchant/billing/gateways/litle.rb +10 -4
  59. data/lib/active_merchant/billing/gateways/maxipago.rb +7 -0
  60. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +0 -6
  61. data/lib/active_merchant/billing/gateways/merchant_ware.rb +4 -11
  62. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +3 -10
  63. data/lib/active_merchant/billing/gateways/mercury.rb +0 -7
  64. data/lib/active_merchant/billing/gateways/metrics_global.rb +1 -20
  65. data/lib/active_merchant/billing/gateways/migs.rb +1 -1
  66. data/lib/active_merchant/billing/gateways/moneris.rb +29 -21
  67. data/lib/active_merchant/billing/gateways/moneris_us.rb +1 -11
  68. data/lib/active_merchant/billing/gateways/money_movers.rb +1 -8
  69. data/lib/active_merchant/billing/gateways/nab_transact.rb +16 -15
  70. data/lib/active_merchant/billing/gateways/net_registry.rb +1 -1
  71. data/lib/active_merchant/billing/gateways/netbilling.rb +0 -7
  72. data/lib/active_merchant/billing/gateways/network_merchants.rb +21 -18
  73. data/lib/active_merchant/billing/gateways/ogone.rb +3 -3
  74. data/lib/active_merchant/billing/gateways/openpay.rb +1 -8
  75. data/lib/active_merchant/billing/gateways/optimal_payment.rb +34 -23
  76. data/lib/active_merchant/billing/gateways/orbital.rb +121 -4
  77. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +22 -21
  78. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +2 -9
  79. data/lib/active_merchant/billing/gateways/pago_facil.rb +122 -0
  80. data/lib/active_merchant/billing/gateways/pay_junction.rb +3 -13
  81. data/lib/active_merchant/billing/gateways/pay_secure.rb +0 -7
  82. data/lib/active_merchant/billing/gateways/paybox_direct.rb +1 -9
  83. data/lib/active_merchant/billing/gateways/payex.rb +1 -1
  84. data/lib/active_merchant/billing/gateways/payflow.rb +7 -1
  85. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +15 -15
  86. data/lib/active_merchant/billing/gateways/payflow_express.rb +19 -19
  87. data/lib/active_merchant/billing/gateways/payment_express.rb +1 -1
  88. data/lib/active_merchant/billing/gateways/paymill.rb +7 -2
  89. data/lib/active_merchant/billing/gateways/paypal.rb +25 -14
  90. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +1 -1
  91. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +16 -2
  92. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +3 -2
  93. data/lib/active_merchant/billing/gateways/paypal_express.rb +25 -0
  94. data/lib/active_merchant/billing/gateways/payscout.rb +1 -8
  95. data/lib/active_merchant/billing/gateways/pin.rb +39 -7
  96. data/lib/active_merchant/billing/gateways/plugnpay.rb +1 -12
  97. data/lib/active_merchant/billing/gateways/psigate.rb +1 -12
  98. data/lib/active_merchant/billing/gateways/qbms.rb +1 -1
  99. data/lib/active_merchant/billing/gateways/quantum.rb +2 -2
  100. data/lib/active_merchant/billing/gateways/quickpay.rb +17 -15
  101. data/lib/active_merchant/billing/gateways/realex.rb +3 -12
  102. data/lib/active_merchant/billing/gateways/sage.rb +1 -1
  103. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +2 -8
  104. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +1 -1
  105. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +1 -1
  106. data/lib/active_merchant/billing/gateways/sage_pay.rb +93 -28
  107. data/lib/active_merchant/billing/gateways/secure_net.rb +1 -8
  108. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +3 -3
  109. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +0 -7
  110. data/lib/active_merchant/billing/gateways/skip_jack.rb +1 -2
  111. data/lib/active_merchant/billing/gateways/smart_ps.rb +8 -2
  112. data/lib/active_merchant/billing/gateways/spreedly_core.rb +2 -1
  113. data/lib/active_merchant/billing/gateways/stripe.rb +14 -15
  114. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +0 -1
  115. data/lib/active_merchant/billing/gateways/trust_commerce.rb +4 -9
  116. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +46 -43
  117. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +7 -0
  118. data/lib/active_merchant/billing/gateways/verifi.rb +1 -8
  119. data/lib/active_merchant/billing/gateways/viaklix.rb +0 -6
  120. data/lib/active_merchant/billing/gateways/vindicia.rb +68 -44
  121. data/lib/active_merchant/billing/gateways/webpay.rb +1 -9
  122. data/lib/active_merchant/billing/gateways/wirecard.rb +117 -11
  123. data/lib/active_merchant/billing/gateways/worldpay.rb +50 -22
  124. data/lib/active_merchant/billing/gateways/worldpay_us.rb +181 -0
  125. data/lib/active_merchant/billing/model.rb +30 -0
  126. data/lib/active_merchant/billing/rails.rb +3 -0
  127. data/lib/active_merchant/billing/response.rb +20 -15
  128. data/lib/active_merchant/country.rb +327 -0
  129. data/lib/active_merchant/empty.rb +20 -0
  130. data/lib/active_merchant/errors.rb +29 -0
  131. data/lib/active_merchant/offsite_payments_shim.rb +19 -0
  132. data/lib/active_merchant/version.rb +1 -1
  133. metadata +60 -243
  134. metadata.gz.sig +0 -0
  135. data/gem-public_cert.pem +0 -21
  136. data/lib/active_merchant/billing/expiry_date.rb +0 -34
  137. data/lib/active_merchant/billing/gateways/orbital/avs_result.rb +0 -93
  138. data/lib/active_merchant/billing/gateways/orbital/cvv_result.rb +0 -34
  139. data/lib/active_merchant/billing/integrations.rb +0 -17
  140. data/lib/active_merchant/billing/integrations/a1agregator.rb +0 -26
  141. data/lib/active_merchant/billing/integrations/a1agregator/helper.rb +0 -31
  142. data/lib/active_merchant/billing/integrations/a1agregator/notification.rb +0 -186
  143. data/lib/active_merchant/billing/integrations/a1agregator/status.rb +0 -38
  144. data/lib/active_merchant/billing/integrations/action_view_helper.rb +0 -78
  145. data/lib/active_merchant/billing/integrations/authorize_net_sim.rb +0 -38
  146. data/lib/active_merchant/billing/integrations/authorize_net_sim/helper.rb +0 -229
  147. data/lib/active_merchant/billing/integrations/authorize_net_sim/notification.rb +0 -340
  148. data/lib/active_merchant/billing/integrations/bit_pay.rb +0 -30
  149. data/lib/active_merchant/billing/integrations/bit_pay/helper.rb +0 -66
  150. data/lib/active_merchant/billing/integrations/bit_pay/notification.rb +0 -74
  151. data/lib/active_merchant/billing/integrations/bit_pay/return.rb +0 -10
  152. data/lib/active_merchant/billing/integrations/bogus.rb +0 -23
  153. data/lib/active_merchant/billing/integrations/bogus/helper.rb +0 -17
  154. data/lib/active_merchant/billing/integrations/bogus/notification.rb +0 -11
  155. data/lib/active_merchant/billing/integrations/bogus/return.rb +0 -10
  156. data/lib/active_merchant/billing/integrations/chronopay.rb +0 -23
  157. data/lib/active_merchant/billing/integrations/chronopay/helper.rb +0 -120
  158. data/lib/active_merchant/billing/integrations/chronopay/notification.rb +0 -158
  159. data/lib/active_merchant/billing/integrations/chronopay/return.rb +0 -10
  160. data/lib/active_merchant/billing/integrations/citrus.rb +0 -28
  161. data/lib/active_merchant/billing/integrations/citrus/helper.rb +0 -57
  162. data/lib/active_merchant/billing/integrations/citrus/notification.rb +0 -133
  163. data/lib/active_merchant/billing/integrations/citrus/return.rb +0 -40
  164. data/lib/active_merchant/billing/integrations/direc_pay.rb +0 -41
  165. data/lib/active_merchant/billing/integrations/direc_pay/helper.rb +0 -200
  166. data/lib/active_merchant/billing/integrations/direc_pay/notification.rb +0 -76
  167. data/lib/active_merchant/billing/integrations/direc_pay/return.rb +0 -32
  168. data/lib/active_merchant/billing/integrations/direc_pay/status.rb +0 -37
  169. data/lib/active_merchant/billing/integrations/directebanking.rb +0 -47
  170. data/lib/active_merchant/billing/integrations/directebanking/helper.rb +0 -90
  171. data/lib/active_merchant/billing/integrations/directebanking/notification.rb +0 -120
  172. data/lib/active_merchant/billing/integrations/directebanking/return.rb +0 -11
  173. data/lib/active_merchant/billing/integrations/doku.rb +0 -24
  174. data/lib/active_merchant/billing/integrations/doku/helper.rb +0 -102
  175. data/lib/active_merchant/billing/integrations/doku/notification.rb +0 -69
  176. data/lib/active_merchant/billing/integrations/doku/return.rb +0 -10
  177. data/lib/active_merchant/billing/integrations/dotpay.rb +0 -22
  178. data/lib/active_merchant/billing/integrations/dotpay/helper.rb +0 -77
  179. data/lib/active_merchant/billing/integrations/dotpay/notification.rb +0 -86
  180. data/lib/active_merchant/billing/integrations/dotpay/return.rb +0 -11
  181. data/lib/active_merchant/billing/integrations/dwolla.rb +0 -23
  182. data/lib/active_merchant/billing/integrations/dwolla/common.rb +0 -23
  183. data/lib/active_merchant/billing/integrations/dwolla/helper.rb +0 -43
  184. data/lib/active_merchant/billing/integrations/dwolla/notification.rb +0 -64
  185. data/lib/active_merchant/billing/integrations/dwolla/return.rb +0 -49
  186. data/lib/active_merchant/billing/integrations/e_payment_plans.rb +0 -48
  187. data/lib/active_merchant/billing/integrations/e_payment_plans/helper.rb +0 -34
  188. data/lib/active_merchant/billing/integrations/e_payment_plans/notification.rb +0 -84
  189. data/lib/active_merchant/billing/integrations/easy_pay.rb +0 -30
  190. data/lib/active_merchant/billing/integrations/easy_pay/common.rb +0 -40
  191. data/lib/active_merchant/billing/integrations/easy_pay/helper.rb +0 -36
  192. data/lib/active_merchant/billing/integrations/easy_pay/notification.rb +0 -59
  193. data/lib/active_merchant/billing/integrations/epay.rb +0 -21
  194. data/lib/active_merchant/billing/integrations/epay/helper.rb +0 -55
  195. data/lib/active_merchant/billing/integrations/epay/notification.rb +0 -110
  196. data/lib/active_merchant/billing/integrations/first_data.rb +0 -38
  197. data/lib/active_merchant/billing/integrations/first_data/helper.rb +0 -61
  198. data/lib/active_merchant/billing/integrations/first_data/notification.rb +0 -56
  199. data/lib/active_merchant/billing/integrations/gestpay.rb +0 -25
  200. data/lib/active_merchant/billing/integrations/gestpay/common.rb +0 -42
  201. data/lib/active_merchant/billing/integrations/gestpay/helper.rb +0 -70
  202. data/lib/active_merchant/billing/integrations/gestpay/notification.rb +0 -85
  203. data/lib/active_merchant/billing/integrations/gestpay/return.rb +0 -10
  204. data/lib/active_merchant/billing/integrations/helper.rb +0 -123
  205. data/lib/active_merchant/billing/integrations/hi_trust.rb +0 -27
  206. data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +0 -58
  207. data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +0 -59
  208. data/lib/active_merchant/billing/integrations/hi_trust/return.rb +0 -68
  209. data/lib/active_merchant/billing/integrations/ipay88.rb +0 -23
  210. data/lib/active_merchant/billing/integrations/ipay88/helper.rb +0 -118
  211. data/lib/active_merchant/billing/integrations/ipay88/notification.rb +0 -103
  212. data/lib/active_merchant/billing/integrations/ipay88/return.rb +0 -29
  213. data/lib/active_merchant/billing/integrations/klarna.rb +0 -71
  214. data/lib/active_merchant/billing/integrations/klarna/helper.rb +0 -123
  215. data/lib/active_merchant/billing/integrations/klarna/notification.rb +0 -103
  216. data/lib/active_merchant/billing/integrations/liqpay.rb +0 -30
  217. data/lib/active_merchant/billing/integrations/liqpay/helper.rb +0 -43
  218. data/lib/active_merchant/billing/integrations/liqpay/notification.rb +0 -89
  219. data/lib/active_merchant/billing/integrations/liqpay/return.rb +0 -83
  220. data/lib/active_merchant/billing/integrations/maksuturva.rb +0 -86
  221. data/lib/active_merchant/billing/integrations/maksuturva/helper.rb +0 -119
  222. data/lib/active_merchant/billing/integrations/maksuturva/notification.rb +0 -48
  223. data/lib/active_merchant/billing/integrations/mollie_ideal.rb +0 -98
  224. data/lib/active_merchant/billing/integrations/mollie_ideal/helper.rb +0 -67
  225. data/lib/active_merchant/billing/integrations/mollie_ideal/notification.rb +0 -69
  226. data/lib/active_merchant/billing/integrations/mollie_ideal/return.rb +0 -10
  227. data/lib/active_merchant/billing/integrations/moneybookers.rb +0 -26
  228. data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +0 -75
  229. data/lib/active_merchant/billing/integrations/moneybookers/notification.rb +0 -123
  230. data/lib/active_merchant/billing/integrations/nochex.rb +0 -88
  231. data/lib/active_merchant/billing/integrations/nochex/helper.rb +0 -68
  232. data/lib/active_merchant/billing/integrations/nochex/notification.rb +0 -94
  233. data/lib/active_merchant/billing/integrations/nochex/return.rb +0 -10
  234. data/lib/active_merchant/billing/integrations/notification.rb +0 -71
  235. data/lib/active_merchant/billing/integrations/pag_seguro.rb +0 -53
  236. data/lib/active_merchant/billing/integrations/pag_seguro/helper.rb +0 -121
  237. data/lib/active_merchant/billing/integrations/pag_seguro/notification.rb +0 -104
  238. data/lib/active_merchant/billing/integrations/paxum.rb +0 -44
  239. data/lib/active_merchant/billing/integrations/paxum/common.rb +0 -24
  240. data/lib/active_merchant/billing/integrations/paxum/helper.rb +0 -42
  241. data/lib/active_merchant/billing/integrations/paxum/notification.rb +0 -33
  242. data/lib/active_merchant/billing/integrations/pay_fast.rb +0 -70
  243. data/lib/active_merchant/billing/integrations/pay_fast/common.rb +0 -42
  244. data/lib/active_merchant/billing/integrations/pay_fast/helper.rb +0 -50
  245. data/lib/active_merchant/billing/integrations/pay_fast/notification.rb +0 -134
  246. data/lib/active_merchant/billing/integrations/pay_fast/return.rb +0 -10
  247. data/lib/active_merchant/billing/integrations/paydollar.rb +0 -59
  248. data/lib/active_merchant/billing/integrations/paydollar/helper.rb +0 -41
  249. data/lib/active_merchant/billing/integrations/paydollar/notification.rb +0 -64
  250. data/lib/active_merchant/billing/integrations/paydollar/return.rb +0 -15
  251. data/lib/active_merchant/billing/integrations/payflow_link.rb +0 -21
  252. data/lib/active_merchant/billing/integrations/payflow_link/helper.rb +0 -116
  253. data/lib/active_merchant/billing/integrations/payflow_link/notification.rb +0 -78
  254. data/lib/active_merchant/billing/integrations/paypal.rb +0 -39
  255. data/lib/active_merchant/billing/integrations/paypal/helper.rb +0 -119
  256. data/lib/active_merchant/billing/integrations/paypal/notification.rb +0 -227
  257. data/lib/active_merchant/billing/integrations/paypal/return.rb +0 -10
  258. data/lib/active_merchant/billing/integrations/paypal_payments_advanced.rb +0 -20
  259. data/lib/active_merchant/billing/integrations/paypal_payments_advanced/helper.rb +0 -15
  260. data/lib/active_merchant/billing/integrations/paysbuy.rb +0 -36
  261. data/lib/active_merchant/billing/integrations/paysbuy/helper.rb +0 -15
  262. data/lib/active_merchant/billing/integrations/paysbuy/notification.rb +0 -39
  263. data/lib/active_merchant/billing/integrations/payu_in.rb +0 -36
  264. data/lib/active_merchant/billing/integrations/payu_in/helper.rb +0 -76
  265. data/lib/active_merchant/billing/integrations/payu_in/notification.rb +0 -154
  266. data/lib/active_merchant/billing/integrations/payu_in/return.rb +0 -36
  267. data/lib/active_merchant/billing/integrations/payu_in_paisa.rb +0 -30
  268. data/lib/active_merchant/billing/integrations/payu_in_paisa/helper.rb +0 -19
  269. data/lib/active_merchant/billing/integrations/payu_in_paisa/notification.rb +0 -13
  270. data/lib/active_merchant/billing/integrations/payu_in_paisa/return.rb +0 -16
  271. data/lib/active_merchant/billing/integrations/platron.rb +0 -28
  272. data/lib/active_merchant/billing/integrations/platron/helper.rb +0 -32
  273. data/lib/active_merchant/billing/integrations/platron/notification.rb +0 -113
  274. data/lib/active_merchant/billing/integrations/pxpay.rb +0 -31
  275. data/lib/active_merchant/billing/integrations/pxpay/helper.rb +0 -113
  276. data/lib/active_merchant/billing/integrations/pxpay/notification.rb +0 -157
  277. data/lib/active_merchant/billing/integrations/pxpay/return.rb +0 -25
  278. data/lib/active_merchant/billing/integrations/quickpay.rb +0 -21
  279. data/lib/active_merchant/billing/integrations/quickpay/helper.rb +0 -96
  280. data/lib/active_merchant/billing/integrations/quickpay/notification.rb +0 -137
  281. data/lib/active_merchant/billing/integrations/rbkmoney.rb +0 -17
  282. data/lib/active_merchant/billing/integrations/rbkmoney/helper.rb +0 -23
  283. data/lib/active_merchant/billing/integrations/rbkmoney/notification.rb +0 -91
  284. data/lib/active_merchant/billing/integrations/return.rb +0 -42
  285. data/lib/active_merchant/billing/integrations/robokassa.rb +0 -49
  286. data/lib/active_merchant/billing/integrations/robokassa/common.rb +0 -19
  287. data/lib/active_merchant/billing/integrations/robokassa/helper.rb +0 -50
  288. data/lib/active_merchant/billing/integrations/robokassa/notification.rb +0 -55
  289. data/lib/active_merchant/billing/integrations/robokassa/return.rb +0 -17
  290. data/lib/active_merchant/billing/integrations/sage_pay_form.rb +0 -37
  291. data/lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb +0 -33
  292. data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +0 -136
  293. data/lib/active_merchant/billing/integrations/sage_pay_form/notification.rb +0 -210
  294. data/lib/active_merchant/billing/integrations/sage_pay_form/return.rb +0 -31
  295. data/lib/active_merchant/billing/integrations/two_checkout.rb +0 -44
  296. data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +0 -107
  297. data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +0 -171
  298. data/lib/active_merchant/billing/integrations/two_checkout/return.rb +0 -58
  299. data/lib/active_merchant/billing/integrations/universal.rb +0 -23
  300. data/lib/active_merchant/billing/integrations/universal/helper.rb +0 -76
  301. data/lib/active_merchant/billing/integrations/universal/notification.rb +0 -52
  302. data/lib/active_merchant/billing/integrations/universal/return.rb +0 -18
  303. data/lib/active_merchant/billing/integrations/valitor.rb +0 -33
  304. data/lib/active_merchant/billing/integrations/valitor/helper.rb +0 -86
  305. data/lib/active_merchant/billing/integrations/valitor/notification.rb +0 -13
  306. data/lib/active_merchant/billing/integrations/valitor/response_fields.rb +0 -97
  307. data/lib/active_merchant/billing/integrations/valitor/return.rb +0 -13
  308. data/lib/active_merchant/billing/integrations/verkkomaksut.rb +0 -20
  309. data/lib/active_merchant/billing/integrations/verkkomaksut/helper.rb +0 -88
  310. data/lib/active_merchant/billing/integrations/verkkomaksut/notification.rb +0 -59
  311. data/lib/active_merchant/billing/integrations/web_pay.rb +0 -45
  312. data/lib/active_merchant/billing/integrations/web_pay/common.rb +0 -50
  313. data/lib/active_merchant/billing/integrations/web_pay/helper.rb +0 -68
  314. data/lib/active_merchant/billing/integrations/web_pay/notification.rb +0 -51
  315. data/lib/active_merchant/billing/integrations/webmoney.rb +0 -43
  316. data/lib/active_merchant/billing/integrations/webmoney/common.rb +0 -17
  317. data/lib/active_merchant/billing/integrations/webmoney/helper.rb +0 -40
  318. data/lib/active_merchant/billing/integrations/webmoney/notification.rb +0 -47
  319. data/lib/active_merchant/billing/integrations/wirecard_checkout_page.rb +0 -39
  320. data/lib/active_merchant/billing/integrations/wirecard_checkout_page/common.rb +0 -104
  321. data/lib/active_merchant/billing/integrations/wirecard_checkout_page/helper.rb +0 -145
  322. data/lib/active_merchant/billing/integrations/wirecard_checkout_page/notification.rb +0 -101
  323. data/lib/active_merchant/billing/integrations/wirecard_checkout_page/return.rb +0 -35
  324. data/lib/active_merchant/billing/integrations/world_pay.rb +0 -34
  325. data/lib/active_merchant/billing/integrations/world_pay/helper.rb +0 -101
  326. data/lib/active_merchant/billing/integrations/world_pay/notification.rb +0 -160
@@ -4,29 +4,29 @@ module ActiveMerchant
4
4
  # http://www.bbbonline.org/eExport/doc/MerchantGuide_cvv2.pdf
5
5
  # Check additional codes from cybersource website
6
6
  class CVVResult
7
-
7
+
8
8
  MESSAGES = {
9
- 'D' => 'Suspicious transaction',
10
- 'I' => 'Failed data validation check',
11
- 'M' => 'Match',
12
- 'N' => 'No Match',
13
- 'P' => 'Not Processed',
14
- 'S' => 'Should have been present',
15
- 'U' => 'Issuer unable to process request',
16
- 'X' => 'Card does not support verification'
9
+ 'D' => 'CVV check flagged transaction as suspicious',
10
+ 'I' => 'CVV failed data validation check',
11
+ 'M' => 'CVV matches',
12
+ 'N' => 'CVV does not match',
13
+ 'P' => 'CVV not processed',
14
+ 'S' => 'CVV should have been present',
15
+ 'U' => 'CVV request unable to be processed by issuer',
16
+ 'X' => 'CVV check not supported for card'
17
17
  }
18
-
18
+
19
19
  def self.messages
20
20
  MESSAGES
21
21
  end
22
-
22
+
23
23
  attr_reader :code, :message
24
-
24
+
25
25
  def initialize(code)
26
- @code = code.upcase unless code.blank?
26
+ @code = (code.blank? ? nil : code.upcase)
27
27
  @message = MESSAGES[@code]
28
28
  end
29
-
29
+
30
30
  def to_hash
31
31
  {
32
32
  'code' => code,
@@ -35,4 +35,4 @@ module ActiveMerchant
35
35
  end
36
36
  end
37
37
  end
38
- end
38
+ end
@@ -10,19 +10,16 @@ module ActiveMerchant #:nodoc:
10
10
  #
11
11
  # The standard list of gateway functions that most concrete gateway subclasses implement is:
12
12
  #
13
- # * <tt>purchase(money, creditcard, options = {})</tt>
14
- # * <tt>authorize(money, creditcard, options = {})</tt>
13
+ # * <tt>purchase(money, credit_card, options = {})</tt>
14
+ # * <tt>authorize(money, credit_card, options = {})</tt>
15
15
  # * <tt>capture(money, authorization, options = {})</tt>
16
16
  # * <tt>void(identification, options = {})</tt>
17
- # * <tt>credit(money, identification, options = {})</tt>
18
- #
19
- # Some gateways include features for recurring billing
20
- #
21
- # * <tt>recurring(money, creditcard, options = {})</tt>
17
+ # * <tt>refund(money, identification, options = {})</tt>
18
+ # * <tt>verify(credit_card, options = {})</tt>
22
19
  #
23
20
  # Some gateways also support features for storing credit cards:
24
21
  #
25
- # * <tt>store(creditcard, options = {})</tt>
22
+ # * <tt>store(credit_card, options = {})</tt>
26
23
  # * <tt>unstore(identification, options = {})</tt>
27
24
  #
28
25
  # === Gateway Options
@@ -57,13 +54,12 @@ module ActiveMerchant #:nodoc:
57
54
  #
58
55
  class Gateway
59
56
  include PostsData
60
- include RequiresParameters
61
57
  include CreditCardFormatting
62
- include Utils
63
58
 
64
59
  DEBIT_CARDS = [ :switch, :solo ]
65
60
  CURRENCIES_WITHOUT_FRACTIONS = [ 'BIF', 'BYR', 'CLP', 'CVE', 'DJF', 'GNF', 'HUF', 'ISK', 'JPY', 'KMF', 'KRW', 'PYG', 'RWF', 'TWD', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF' ]
66
61
  CREDIT_DEPRECATION_MESSAGE = "Support for using credit to refund existing transactions is deprecated and will be removed from a future release of ActiveMerchant. Please use the refund method instead."
62
+ RECURRING_DEPRECATION_MESSAGE = "Recurring functionality in ActiveMerchant is deprecated and will be removed in a future version. Please contact the ActiveMerchant maintainers if you have an interest in taking ownership of a separate gem that continues support for it."
67
63
 
68
64
  cattr_reader :implementations
69
65
  @@implementations = []
@@ -73,6 +69,10 @@ module ActiveMerchant #:nodoc:
73
69
  @@implementations << subclass
74
70
  end
75
71
 
72
+ def generate_unique_id
73
+ SecureRandom.hex(16)
74
+ end
75
+
76
76
  # The format of the amounts used by the gateway
77
77
  # :dollars => '12.50'
78
78
  # :cents => '1250'
@@ -146,6 +146,28 @@ module ActiveMerchant #:nodoc:
146
146
  (@options.has_key?(:test) ? @options[:test] : Base.test?)
147
147
  end
148
148
 
149
+ protected # :nodoc: all
150
+
151
+ def normalize(field)
152
+ case field
153
+ when "true" then true
154
+ when "false" then false
155
+ when "" then nil
156
+ when "null" then nil
157
+ else field
158
+ end
159
+ end
160
+
161
+ def user_agent
162
+ @@ua ||= JSON.dump({
163
+ :bindings_version => ActiveMerchant::VERSION,
164
+ :lang => 'ruby',
165
+ :lang_version => "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})",
166
+ :platform => RUBY_PLATFORM,
167
+ :publisher => 'active_merchant'
168
+ })
169
+ end
170
+
149
171
  private # :nodoc: all
150
172
 
151
173
  def name
@@ -155,7 +177,7 @@ module ActiveMerchant #:nodoc:
155
177
  def amount(money)
156
178
  return nil if money.nil?
157
179
  cents = if money.respond_to?(:cents)
158
- deprecated "Support for Money objects is deprecated and will be removed from a future release of ActiveMerchant. Please use an Integer value in cents"
180
+ ActiveMerchant.deprecated "Support for Money objects is deprecated and will be removed from a future release of ActiveMerchant. Please use an Integer value in cents"
159
181
  money.cents
160
182
  else
161
183
  money
@@ -196,6 +218,19 @@ module ActiveMerchant #:nodoc:
196
218
  return false if card_brand(credit_card).blank?
197
219
  DEBIT_CARDS.include?(card_brand(credit_card).to_sym)
198
220
  end
221
+
222
+ def requires!(hash, *params)
223
+ params.each do |param|
224
+ if param.is_a?(Array)
225
+ raise ArgumentError.new("Missing required parameter: #{param.first}") unless hash.has_key?(param.first)
226
+
227
+ valid_options = param[1..-1]
228
+ raise ArgumentError.new("Parameter: #{param.first} must be one of #{valid_options.to_sentence(:words_connector => 'or')}") unless valid_options.include?(hash[param.first])
229
+ else
230
+ raise ArgumentError.new("Missing required parameter: #{param}") unless hash.has_key?(param)
231
+ end
232
+ end
233
+ end
199
234
  end
200
235
  end
201
236
  end
@@ -0,0 +1,205 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class AdyenGateway < Gateway
4
+ self.test_url = 'https://pal-test.adyen.com/pal/adapter/httppost'
5
+ self.live_url = 'https://pal-live.adyen.com/pal/adapter/httppost'
6
+
7
+ self.supported_countries = ['AR', 'AT', 'BE', 'BR', 'CA', 'CH', 'CL', 'CN', 'CO', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'HK', 'ID', 'IE', 'IL', 'IN', 'IT', 'JP', 'KR', 'LU', 'MX', 'MY', 'NL', 'NO', 'PA', 'PE', 'PH', 'PL', 'PT', 'RU', 'SE', 'SG', 'TH', 'TR', 'TW', 'US', 'VN', 'ZA']
8
+ self.default_currency = 'EUR'
9
+ self.money_format = :cents
10
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :dankort, :maestro]
11
+
12
+ self.homepage_url = 'https://www.adyen.com/'
13
+ self.display_name = 'Adyen'
14
+
15
+ def initialize(options = {})
16
+ requires!(options, :company, :merchant, :password)
17
+ super
18
+ end
19
+
20
+ def purchase(money, creditcard, options = {})
21
+ requires!(options, :order_id)
22
+
23
+ MultiResponse.run do |r|
24
+ r.process { authorize(money, creditcard, options) }
25
+ r.process { capture(money, r.authorization, options) }
26
+ end
27
+ end
28
+
29
+ def authorize(money, creditcard, options = {})
30
+ requires!(options, :order_id)
31
+
32
+ post = {}
33
+ post[:paymentRequest] = payment_request(money, options)
34
+ post[:paymentRequest][:amount] = amount_hash(money, options[:currency])
35
+ post[:paymentRequest][:card] = credit_card_hash(creditcard)
36
+
37
+ if address = (options[:billing_address] || options[:address])
38
+ post[:paymentRequest][:billingAddress] = address_hash(address)
39
+ end
40
+
41
+ if options[:shipping_address]
42
+ post[:paymentRequest][:deliveryAddress] = address_hash(options[:shipping_address])
43
+ end
44
+
45
+ commit('Payment.authorise', post)
46
+ end
47
+
48
+ def capture(money, authorization, options = {})
49
+ requires!(options, :order_id)
50
+
51
+ post = {}
52
+ post[:modificationRequest] = modification_request(authorization, options)
53
+ post[:modificationRequest][:modificationAmount] = amount_hash(money, options[:currency])
54
+
55
+ commit('Payment.capture', post)
56
+ end
57
+
58
+ def refund(money, authorization, options = {})
59
+ requires!(options, :order_id)
60
+
61
+ post = {}
62
+ post[:modificationRequest] = modification_request(authorization, options)
63
+ post[:modificationRequest][:modificationAmount] = amount_hash(money, options[:currency])
64
+
65
+ commit('Payment.refund', post)
66
+ end
67
+
68
+ def void(identification, options = {})
69
+ requires!(options, :order_id)
70
+
71
+ post = {}
72
+ post[:modificationRequest] = modification_request(identification, options)
73
+
74
+ commit('Payment.cancel', post)
75
+ end
76
+
77
+ private
78
+
79
+ def commit(action, post)
80
+ request = post_data(flatten_hash(post.merge(:action => action)))
81
+ raw_response = ssl_post(url, request, headers)
82
+ response = parse(raw_response)
83
+
84
+ Response.new(
85
+ success_from(response),
86
+ message_from(response),
87
+ response,
88
+ test: test?,
89
+ authorization: response['pspReference']
90
+ )
91
+
92
+ rescue ResponseError => e
93
+ case e.response.code
94
+ when '401'
95
+ return Response.new(false, 'Invalid credentials', {}, :test => test?)
96
+ when '500'
97
+ if e.response.body.split(' ')[0] == 'validation'
98
+ return Response.new(false, e.response.body.split(' ', 3)[2], {}, :test => test?)
99
+ end
100
+ end
101
+ raise
102
+ end
103
+
104
+ def flatten_hash(hash, prefix = nil)
105
+ flat_hash = {}
106
+ hash.each_pair do |key, val|
107
+ conc_key = prefix.nil? ? key : "#{prefix}.#{key}"
108
+ if val.is_a?(Hash)
109
+ flat_hash.merge!(flatten_hash(val, conc_key))
110
+ else
111
+ flat_hash[conc_key] = val
112
+ end
113
+ end
114
+ flat_hash
115
+ end
116
+
117
+ def headers
118
+ {
119
+ 'Authorization' => 'Basic ' + Base64.encode64("ws@Company.#{@options[:company]}:#{@options[:password]}").strip
120
+ }
121
+ end
122
+
123
+ def parse(response)
124
+ Hash[
125
+ response.split('&').map do |x|
126
+ key, val = x.split('=', 2)
127
+ [key.split('.').last, CGI.unescape(val)]
128
+ end
129
+ ]
130
+ end
131
+
132
+ def post_data(data)
133
+ data.map do |key, val|
134
+ "#{key}=#{CGI.escape(val.to_s)}"
135
+ end.reduce do |x, y|
136
+ "#{x}&#{y}"
137
+ end
138
+ end
139
+
140
+ def message_from(response)
141
+ return response['resultCode'] if response.has_key?('resultCode') # Payment request
142
+ return response['response'] if response['response'] # Modification request
143
+ "Failure" # Negative fallback in case of error
144
+ end
145
+
146
+ def success_from(response)
147
+ return true if response.has_key?('authCode')
148
+
149
+ successful_responses = %w([capture-received] [cancel-received] [refund-received])
150
+ successful_responses.include?(response['response'])
151
+ end
152
+
153
+ def url
154
+ test? ? self.test_url : self.live_url
155
+ end
156
+
157
+ def address_hash(address)
158
+ full_address = "#{address[:address1]} #{address[:address2]}"
159
+
160
+ {
161
+ :city => address[:city],
162
+ :street => full_address.split(/\s+/).keep_if { |x| x !~ /\d/ }.join(' '),
163
+ :houseNumberOrName => full_address.split(/\s+/).keep_if { |x| x =~ /\d/ }.join(' '),
164
+ :postalCode => address[:zip],
165
+ :stateOrProvince => address[:state],
166
+ :country => address[:country]
167
+ }
168
+ end
169
+
170
+ def amount_hash(money, currency)
171
+ {
172
+ :currency => (currency || currency(money)),
173
+ :value => amount(money)
174
+ }
175
+ end
176
+
177
+ def credit_card_hash(creditcard)
178
+ {
179
+ :cvc => creditcard.verification_value,
180
+ :expiryMonth => format(creditcard.month, :two_digits),
181
+ :expiryYear => format(creditcard.year, :four_digits),
182
+ :holderName => creditcard.name,
183
+ :number => creditcard.number
184
+ }
185
+ end
186
+
187
+ def modification_request(reference, options)
188
+ {
189
+ :merchantAccount => @options[:merchant],
190
+ :originalReference => reference
191
+ }.keep_if { |_, v| v }
192
+ end
193
+
194
+ def payment_request(money, options)
195
+ {
196
+ :merchantAccount => @options[:merchant],
197
+ :reference => options[:order_id],
198
+ :shopperEmail => options[:email],
199
+ :shopperIP => options[:ip],
200
+ :shopperReference => options[:customer]
201
+ }.keep_if { |_, v| v }
202
+ end
203
+ end
204
+ end
205
+ end
@@ -166,17 +166,9 @@ module ActiveMerchant #:nodoc:
166
166
  end
167
167
 
168
168
  def headers
169
- @@ua ||= JSON.dump(
170
- :bindings_version => ActiveMerchant::VERSION,
171
- :lang => 'ruby',
172
- :lang_version => "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})",
173
- :platform => RUBY_PLATFORM,
174
- :publisher => 'active_merchant'
175
- )
176
-
177
169
  {
178
170
  "Authorization" => "Basic " + Base64.strict_encode64(@options[:api_key].to_s + ":" + @options[:api_secret].to_s),
179
- "User-Agent" => "ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
171
+ "User-Agent" => user_agent,
180
172
  }
181
173
  end
182
174
  end
@@ -15,25 +15,12 @@ module ActiveMerchant #:nodoc:
15
15
  # 4. Type in the answer to the secret question configured on setup
16
16
  # 5. Click Submit
17
17
  #
18
- # ==== Automated Recurring Billing (ARB)
19
- #
20
- # Automated Recurring Billing (ARB) is an optional service for submitting and managing recurring, or subscription-based, transactions.
21
- #
22
- # To use recurring, update_recurring, cancel_recurring and status_recurring ARB must be enabled for your account.
23
- #
24
- # Information about ARB is available on the {Authorize.Net website}[http://www.authorize.net/solutions/merchantsolutions/merchantservices/automatedrecurringbilling/].
25
- # Information about the ARB API is available at the {Authorize.Net Integration Center}[http://developer.authorize.net/]
26
18
  class AuthorizeNetGateway < Gateway
27
19
  API_VERSION = '3.1'
28
20
 
29
- class_attribute :arb_test_url, :arb_live_url
30
-
31
21
  self.test_url = "https://test.authorize.net/gateway/transact.dll"
32
22
  self.live_url = "https://secure.authorize.net/gateway/transact.dll"
33
23
 
34
- self.arb_test_url = 'https://apitest.authorize.net/xml/v1/request.api'
35
- self.arb_live_url = 'https://api.authorize.net/xml/v1/request.api'
36
-
37
24
  class_attribute :duplicate_window
38
25
 
39
26
  APPROVED, DECLINED, ERROR, FRAUD_REVIEW = 1, 2, 3, 4
@@ -44,7 +31,7 @@ module ActiveMerchant #:nodoc:
44
31
  self.default_currency = 'USD'
45
32
 
46
33
  self.supported_countries = %w(AD AT AU BE BG CA CH CY CZ DE DK ES FI FR GB GB GI GR HU IE IT LI LU MC MT NL NO PL PT RO SE SI SK SM TR US VA)
47
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb]
34
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro]
48
35
  self.homepage_url = 'http://www.authorize.net/'
49
36
  self.display_name = 'Authorize.Net'
50
37
 
@@ -53,15 +40,6 @@ module ActiveMerchant #:nodoc:
53
40
  AVS_REASON_CODES = %w(27 45)
54
41
  TRANSACTION_ALREADY_ACTIONED = %w(310 311)
55
42
 
56
- AUTHORIZE_NET_ARB_NAMESPACE = 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'
57
-
58
- RECURRING_ACTIONS = {
59
- :create => 'ARBCreateSubscription',
60
- :update => 'ARBUpdateSubscription',
61
- :cancel => 'ARBCancelSubscription',
62
- :status => 'ARBGetSubscriptionStatus'
63
- }
64
-
65
43
  # Creates a new AuthorizeNetGateway
66
44
  #
67
45
  # The gateway requires that a valid login and password be passed
@@ -177,89 +155,15 @@ module ActiveMerchant #:nodoc:
177
155
  end
178
156
 
179
157
  def credit(money, identification, options = {})
180
- deprecated CREDIT_DEPRECATION_MESSAGE
158
+ ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
181
159
  refund(money, identification, options)
182
160
  end
183
161
 
184
- # Create a recurring payment.
185
- #
186
- # This transaction creates a new Automated Recurring Billing (ARB) subscription. Your account must have ARB enabled.
187
- #
188
- # ==== Parameters
189
- #
190
- # * <tt>money</tt> -- The amount to be charged to the customer at each interval as an Integer value in cents.
191
- # * <tt>creditcard</tt> -- The CreditCard details for the transaction.
192
- # * <tt>options</tt> -- A hash of parameters.
193
- #
194
- # ==== Options
195
- #
196
- # * <tt>:interval</tt> -- A hash containing information about the interval of time between payments. Must
197
- # contain the keys <tt>:length</tt> and <tt>:unit</tt>. <tt>:unit</tt> can be either <tt>:months</tt> or <tt>:days</tt>.
198
- # If <tt>:unit</tt> is <tt>:months</tt> then <tt>:length</tt> must be an integer between 1 and 12 inclusive.
199
- # If <tt>:unit</tt> is <tt>:days</tt> then <tt>:length</tt> must be an integer between 7 and 365 inclusive.
200
- # For example, to charge the customer once every three months the hash would be
201
- # +:interval => { :unit => :months, :length => 3 }+ (REQUIRED)
202
- # * <tt>:duration</tt> -- A hash containing keys for the <tt>:start_date</tt> the subscription begins (also the date the
203
- # initial billing occurs) and the total number of billing <tt>:occurrences</tt> or payments for the subscription. (REQUIRED)
204
- def recurring(money, creditcard, options={})
205
- requires!(options, :interval, :duration, :billing_address)
206
- requires!(options[:interval], :length, [:unit, :days, :months])
207
- requires!(options[:duration], :start_date, :occurrences)
208
- requires!(options[:billing_address], :first_name, :last_name)
209
-
210
- options[:credit_card] = creditcard
211
- options[:amount] = money
212
-
213
- request = build_recurring_request(:create, options)
214
- recurring_commit(:create, request)
215
- end
216
-
217
- # Update a recurring payment's details.
218
- #
219
- # This transaction updates an existing Automated Recurring Billing (ARB) subscription. Your account must have ARB enabled
220
- # and the subscription must have already been created previously by calling +recurring()+. The ability to change certain
221
- # details about a recurring payment is dependent on transaction history and cannot be determined until after calling
222
- # +update_recurring()+. See the ARB XML Guide for such conditions.
223
- #
224
- # ==== Parameters
225
- #
226
- # * <tt>options</tt> -- A hash of parameters.
227
- #
228
- # ==== Options
229
- #
230
- # * <tt>:subscription_id</tt> -- A string containing the <tt>:subscription_id</tt> of the recurring payment already in place
231
- # for a given credit card. (REQUIRED)
232
- def update_recurring(options={})
233
- requires!(options, :subscription_id)
234
- request = build_recurring_request(:update, options)
235
- recurring_commit(:update, request)
236
- end
237
-
238
- # Cancel a recurring payment.
239
- #
240
- # This transaction cancels an existing Automated Recurring Billing (ARB) subscription. Your account must have ARB enabled
241
- # and the subscription must have already been created previously by calling recurring()
242
- #
243
- # ==== Parameters
244
- #
245
- # * <tt>subscription_id</tt> -- A string containing the +subscription_id+ of the recurring payment already in place
246
- # for a given credit card. (REQUIRED)
247
- def cancel_recurring(subscription_id)
248
- request = build_recurring_request(:cancel, :subscription_id => subscription_id)
249
- recurring_commit(:cancel, request)
250
- end
251
-
252
- # Get Subscription Status of a recurring payment.
253
- #
254
- # This transaction gets the status of an existing Automated Recurring Billing (ARB) subscription. Your account must have ARB enabled.
255
- #
256
- # ==== Parameters
257
- #
258
- # * <tt>subscription_id</tt> -- A string containing the +subscription_id+ of the recurring payment already in place
259
- # for a given credit card. (REQUIRED)
260
- def status_recurring(subscription_id)
261
- request = build_recurring_request(:status, :subscription_id => subscription_id)
262
- recurring_commit(:status, request)
162
+ def verify(credit_card, options = {})
163
+ MultiResponse.run(:use_first_response) do |r|
164
+ r.process { authorize(100, credit_card, options) }
165
+ r.process(:ignore_result) { void(r.authorization, options) }
166
+ end
263
167
  end
264
168
 
265
169
  private
@@ -419,17 +323,6 @@ module ActiveMerchant #:nodoc:
419
323
  end
420
324
  end
421
325
 
422
- # Make a ruby type out of the response string
423
- def normalize(field)
424
- case field
425
- when "true" then true
426
- when "false" then false
427
- when "" then nil
428
- when "null" then nil
429
- else field
430
- end
431
- end
432
-
433
326
  def message_from(results)
434
327
  if results[:response_code] == DECLINED
435
328
  return CVVResult.messages[ results[:card_code] ] if CARD_CODE_ERRORS.include?(results[:card_code])
@@ -441,286 +334,9 @@ module ActiveMerchant #:nodoc:
441
334
  (results[:response_reason_text] ? results[:response_reason_text].chomp('.') : '')
442
335
  end
443
336
 
444
- def expdate(creditcard)
445
- year = sprintf("%.4i", creditcard.year)
446
- month = sprintf("%.2i", creditcard.month)
447
-
448
- "#{month}#{year[-2..-1]}"
449
- end
450
-
451
337
  def split(response)
452
338
  response[1..-2].split(/\$,\$/)
453
339
  end
454
-
455
- # ARB
456
-
457
- # Builds recurring billing request
458
- def build_recurring_request(action, options = {})
459
- unless RECURRING_ACTIONS.include?(action)
460
- raise StandardError, "Invalid Automated Recurring Billing Action: #{action}"
461
- end
462
-
463
- xml = Builder::XmlMarkup.new(:indent => 2)
464
- xml.instruct!(:xml, :version => '1.0', :encoding => 'utf-8')
465
- xml.tag!("#{RECURRING_ACTIONS[action]}Request", :xmlns => AUTHORIZE_NET_ARB_NAMESPACE) do
466
- add_arb_merchant_authentication(xml)
467
- # Merchant-assigned reference ID for the request
468
- xml.tag!('refId', options[:ref_id]) if options[:ref_id]
469
- send("build_arb_#{action}_subscription_request", xml, options)
470
- end
471
- end
472
-
473
- # Contains the merchant’s payment gateway account authentication information
474
- def add_arb_merchant_authentication(xml)
475
- xml.tag!('merchantAuthentication') do
476
- xml.tag!('name', @options[:login])
477
- xml.tag!('transactionKey', @options[:password])
478
- end
479
- end
480
-
481
- # Builds body for ARBCreateSubscriptionRequest
482
- def build_arb_create_subscription_request(xml, options)
483
- # Subscription
484
- add_arb_subscription(xml, options)
485
-
486
- xml.target!
487
- end
488
-
489
- # Builds body for ARBUpdateSubscriptionRequest
490
- def build_arb_update_subscription_request(xml, options)
491
- xml.tag!('subscriptionId', options[:subscription_id])
492
- # Adds Subscription
493
- add_arb_subscription(xml, options)
494
-
495
- xml.target!
496
- end
497
-
498
- # Builds body for ARBCancelSubscriptionRequest
499
- def build_arb_cancel_subscription_request(xml, options)
500
- xml.tag!('subscriptionId', options[:subscription_id])
501
-
502
- xml.target!
503
- end
504
-
505
- # Builds body for ARBGetSubscriptionStatusRequest
506
- def build_arb_status_subscription_request(xml, options)
507
- xml.tag!('subscriptionId', options[:subscription_id])
508
-
509
- xml.target!
510
- end
511
-
512
- # Adds subscription information
513
- def add_arb_subscription(xml, options)
514
- xml.tag!('subscription') do
515
- # Merchant-assigned name for the subscription (optional)
516
- xml.tag!('name', options[:subscription_name]) if options[:subscription_name]
517
- # Contains information about the payment schedule
518
- add_arb_payment_schedule(xml, options)
519
- # The amount to be billed to the customer
520
- # for each payment in the subscription
521
- xml.tag!('amount', amount(options[:amount])) if options[:amount]
522
- if trial = options[:trial]
523
- # The amount to be charged for each payment during a trial period (conditional)
524
- xml.tag!('trialAmount', amount(trial[:amount])) if trial[:amount]
525
- end
526
- # Contains either the customer’s credit card
527
- # or bank account payment information
528
- add_arb_payment(xml, options)
529
- # Contains order information (optional)
530
- add_arb_order(xml, options)
531
- # Contains information about the customer
532
- add_arb_customer(xml, options)
533
- # Contains the customer's billing address information
534
- add_arb_address(xml, 'billTo', options[:billing_address])
535
- # Contains the customer's shipping address information (optional)
536
- add_arb_address(xml, 'shipTo', options[:shipping_address])
537
- end
538
- end
539
-
540
- # Adds information about the interval of time between payments
541
- def add_arb_interval(xml, options)
542
- interval = options[:interval]
543
- return unless interval
544
- xml.tag!('interval') do
545
- # The measurement of time, in association with the Interval Unit,
546
- # that is used to define the frequency of the billing occurrences
547
- xml.tag!('length', interval[:length])
548
- # The unit of time, in association with the Interval Length,
549
- # between each billing occurrence
550
- xml.tag!('unit', interval[:unit].to_s)
551
- end
552
- end
553
-
554
- # Adds information about the subscription duration
555
- def add_arb_duration(xml, options)
556
- duration = options[:duration]
557
- return unless duration
558
- # The date the subscription begins
559
- # (also the date the initial billing occurs)
560
- xml.tag!('startDate', duration[:start_date]) if duration[:start_date]
561
- # Number of billing occurrences or payments for the subscription
562
- xml.tag!('totalOccurrences', duration[:occurrences]) if duration[:occurrences]
563
- end
564
-
565
- def add_arb_payment_schedule(xml, options)
566
- return unless options[:interval] || options[:duration]
567
- xml.tag!('paymentSchedule') do
568
- # Contains information about the interval of time between payments
569
- add_arb_interval(xml, options)
570
- add_arb_duration(xml, options)
571
- if trial = options[:trial]
572
- # Number of billing occurrences or payments in the trial period (optional)
573
- xml.tag!('trialOccurrences', trial[:occurrences]) if trial[:occurrences]
574
- end
575
- end
576
- end
577
-
578
- # Adds customer's credit card or bank account payment information
579
- def add_arb_payment(xml, options)
580
- return unless options[:credit_card] || options[:bank_account]
581
- xml.tag!('payment') do
582
- # Contains the customer’s credit card information
583
- add_arb_credit_card(xml, options)
584
- # Contains the customer’s bank account information
585
- add_arb_bank_account(xml, options)
586
- end
587
- end
588
-
589
- # Adds customer’s credit card information
590
- # Note: This element should only be included
591
- # when the payment method is credit card.
592
- def add_arb_credit_card(xml, options)
593
- credit_card = options[:credit_card]
594
- return unless credit_card
595
- xml.tag!('creditCard') do
596
- # The credit card number used for payment of the subscription
597
- xml.tag!('cardNumber', credit_card.number)
598
- # The expiration date of the credit card used for the subscription
599
- xml.tag!('expirationDate', arb_expdate(credit_card))
600
- end
601
- end
602
-
603
- # Adds customer’s bank account information
604
- # Note: This element should only be included
605
- # when the payment method is bank account.
606
- def add_arb_bank_account(xml, options)
607
- bank_account = options[:bank_account]
608
- return unless bank_account
609
- xml.tag!('bankAccount') do
610
- # The type of bank account used for payment of the subscription
611
- xml.tag!('accountType', bank_account[:account_type])
612
- # The routing number of the customer’s bank
613
- xml.tag!('routingNumber', bank_account[:routing_number])
614
- # The bank account number used for payment of the subscription
615
- xml.tag!('accountNumber', bank_account[:account_number])
616
- # The full name of the individual associated
617
- # with the bank account number
618
- xml.tag!('nameOfAccount', bank_account[:name_of_account])
619
- # The full name of the individual associated
620
- # with the bank account number (optional)
621
- xml.tag!('bankName', bank_account[:bank_name]) if bank_account[:bank_name]
622
- # The type of electronic check transaction used for the subscription
623
- xml.tag!('echeckType', bank_account[:echeck_type])
624
- end
625
- end
626
-
627
- # Adds order information (optional)
628
- def add_arb_order(xml, options)
629
- order = options[:order]
630
- return unless order
631
- xml.tag!('order') do
632
- # Merchant-assigned invoice number for the subscription (optional)
633
- xml.tag!('invoiceNumber', order[:invoice_number])
634
- # Description of the subscription (optional)
635
- xml.tag!('description', order[:description])
636
- end
637
- end
638
-
639
- # Adds information about the customer
640
- def add_arb_customer(xml, options)
641
- customer = options[:customer]
642
- return unless customer
643
- xml.tag!('customer') do
644
- xml.tag!('type', customer[:type]) if customer[:type]
645
- xml.tag!('id', customer[:id]) if customer[:id]
646
- xml.tag!('email', customer[:email]) if customer[:email]
647
- xml.tag!('phoneNumber', customer[:phone_number]) if customer[:phone_number]
648
- xml.tag!('faxNumber', customer[:fax_number]) if customer[:fax_number]
649
- add_arb_drivers_license(xml, options)
650
- xml.tag!('taxId', customer[:tax_id]) if customer[:tax_id]
651
- end
652
- end
653
-
654
- # Adds the customer's driver's license information (conditional)
655
- def add_arb_drivers_license(xml, options)
656
- return unless customer = options[:customer]
657
- return unless drivers_license = customer[:drivers_license]
658
- xml.tag!('driversLicense') do
659
- # The customer's driver's license number
660
- xml.tag!('number', drivers_license[:number])
661
- # The customer's driver's license state
662
- xml.tag!('state', drivers_license[:state])
663
- # The customer's driver's license date of birth
664
- xml.tag!('dateOfBirth', drivers_license[:date_of_birth])
665
- end
666
- end
667
-
668
- # Adds address information
669
- def add_arb_address(xml, container_name, address)
670
- return if address.blank?
671
- xml.tag!(container_name) do
672
- xml.tag!('firstName', address[:first_name])
673
- xml.tag!('lastName', address[:last_name])
674
- xml.tag!('company', address[:company])
675
- xml.tag!('address', address[:address1])
676
- xml.tag!('city', address[:city])
677
- xml.tag!('state', address[:state])
678
- xml.tag!('zip', address[:zip])
679
- xml.tag!('country', address[:country])
680
- end
681
- end
682
-
683
- def arb_expdate(credit_card)
684
- sprintf('%04d-%02d', credit_card.year, credit_card.month)
685
- end
686
-
687
- def recurring_commit(action, request)
688
- url = test? ? arb_test_url : arb_live_url
689
- xml = ssl_post(url, request, "Content-Type" => "text/xml")
690
-
691
- response = recurring_parse(action, xml)
692
-
693
- message = response[:message] || response[:text]
694
- test_mode = test? || message =~ /Test Mode/
695
- success = response[:result_code] == 'Ok'
696
-
697
- Response.new(success, message, response,
698
- :test => test_mode,
699
- :authorization => response[:subscription_id]
700
- )
701
- end
702
-
703
- def recurring_parse(action, xml)
704
- response = {}
705
- xml = REXML::Document.new(xml)
706
- root = REXML::XPath.first(xml, "//#{RECURRING_ACTIONS[action]}Response") ||
707
- REXML::XPath.first(xml, "//ErrorResponse")
708
- if root
709
- root.elements.to_a.each do |node|
710
- recurring_parse_element(response, node)
711
- end
712
- end
713
-
714
- response
715
- end
716
-
717
- def recurring_parse_element(response, node)
718
- if node.has_elements?
719
- node.elements.each{|e| recurring_parse_element(response, e) }
720
- else
721
- response[node.name.underscore.to_sym] = node.text
722
- end
723
- end
724
340
  end
725
341
  end
726
342
  end