activemerchant 1.38.0 → 1.78.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (397) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +1344 -3
  3. data/CONTRIBUTORS +154 -0
  4. data/README.md +157 -144
  5. data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
  6. data/lib/active_merchant/billing/base.rb +21 -17
  7. data/lib/active_merchant/billing/check.rb +32 -22
  8. data/lib/active_merchant/billing/compatibility.rb +120 -0
  9. data/lib/active_merchant/billing/credit_card.rb +215 -67
  10. data/lib/active_merchant/billing/credit_card_formatting.rb +4 -1
  11. data/lib/active_merchant/billing/credit_card_methods.rb +149 -52
  12. data/lib/active_merchant/billing/cvv_result.rb +15 -15
  13. data/lib/active_merchant/billing/gateway.rb +170 -24
  14. data/lib/active_merchant/billing/gateways/adyen.rb +284 -0
  15. data/lib/active_merchant/billing/gateways/allied_wallet.rb +206 -0
  16. data/lib/active_merchant/billing/gateways/authorize_net.rb +899 -606
  17. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +417 -0
  18. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +43 -18
  19. data/lib/active_merchant/billing/gateways/axcessms.rb +181 -0
  20. data/lib/active_merchant/billing/gateways/balanced.rb +134 -346
  21. data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
  22. data/lib/active_merchant/billing/gateways/banwire.rb +13 -2
  23. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +325 -0
  24. data/lib/active_merchant/billing/gateways/be2bill.rb +131 -0
  25. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +96 -15
  26. data/lib/active_merchant/billing/gateways/beanstream.rb +52 -9
  27. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +12 -8
  28. data/lib/active_merchant/billing/gateways/blue_pay.rb +520 -501
  29. data/lib/active_merchant/billing/gateways/blue_snap.rb +343 -0
  30. data/lib/active_merchant/billing/gateways/bogus.rb +94 -50
  31. data/lib/active_merchant/billing/gateways/borgun.rb +222 -0
  32. data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
  33. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +14 -2
  34. data/lib/active_merchant/billing/gateways/braintree.rb +2 -2
  35. data/lib/active_merchant/billing/gateways/braintree_blue.rb +372 -137
  36. data/lib/active_merchant/billing/gateways/braintree_orange.rb +4 -4
  37. data/lib/active_merchant/billing/gateways/bridge_pay.rb +245 -0
  38. data/lib/active_merchant/billing/gateways/cams.rb +230 -0
  39. data/lib/active_merchant/billing/gateways/card_connect.rb +286 -0
  40. data/lib/active_merchant/billing/gateways/card_stream.rb +269 -118
  41. data/lib/active_merchant/billing/gateways/cardknox.rb +328 -0
  42. data/lib/active_merchant/billing/gateways/cardprocess.rb +254 -0
  43. data/lib/active_merchant/billing/gateways/cashnet.rb +219 -0
  44. data/lib/active_merchant/billing/gateways/cc5.rb +45 -0
  45. data/lib/active_merchant/billing/gateways/cecabank.rb +239 -0
  46. data/lib/active_merchant/billing/gateways/cenpos.rb +327 -0
  47. data/lib/active_merchant/billing/gateways/checkout.rb +214 -0
  48. data/lib/active_merchant/billing/gateways/checkout_v2.rb +226 -0
  49. data/lib/active_merchant/billing/gateways/citrus_pay.rb +23 -0
  50. data/lib/active_merchant/billing/gateways/clearhaus.rb +222 -0
  51. data/lib/active_merchant/billing/gateways/commercegate.rb +143 -0
  52. data/lib/active_merchant/billing/gateways/conekta.rb +224 -0
  53. data/lib/active_merchant/billing/gateways/creditcall.rb +272 -0
  54. data/lib/active_merchant/billing/gateways/credorax.rb +345 -0
  55. data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
  56. data/lib/active_merchant/billing/gateways/cyber_source.rb +228 -98
  57. data/lib/active_merchant/billing/gateways/data_cash.rb +41 -314
  58. data/lib/active_merchant/billing/gateways/dibs.rb +205 -0
  59. data/lib/active_merchant/billing/gateways/digitzs.rb +292 -0
  60. data/lib/active_merchant/billing/gateways/ebanx.rb +296 -0
  61. data/lib/active_merchant/billing/gateways/efsnet.rb +3 -14
  62. data/lib/active_merchant/billing/gateways/elavon.rb +143 -142
  63. data/lib/active_merchant/billing/gateways/element.rb +356 -0
  64. data/lib/active_merchant/billing/gateways/epay.rb +23 -12
  65. data/lib/active_merchant/billing/gateways/eway.rb +12 -12
  66. data/lib/active_merchant/billing/gateways/eway_managed.rb +1 -1
  67. data/lib/active_merchant/billing/gateways/eway_rapid.rb +417 -204
  68. data/lib/active_merchant/billing/gateways/exact.rb +10 -1
  69. data/lib/active_merchant/billing/gateways/ezic.rb +196 -0
  70. data/lib/active_merchant/billing/gateways/fat_zebra.rb +65 -37
  71. data/lib/active_merchant/billing/gateways/federated_canada.rb +1 -8
  72. data/lib/active_merchant/billing/gateways/finansbank.rb +3 -2
  73. data/lib/active_merchant/billing/gateways/first_giving.rb +143 -0
  74. data/lib/active_merchant/billing/gateways/first_pay.rb +109 -124
  75. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +155 -29
  76. data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
  77. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
  78. data/lib/active_merchant/billing/gateways/forte.rb +256 -0
  79. data/lib/active_merchant/billing/gateways/garanti.rb +11 -5
  80. data/lib/active_merchant/billing/gateways/global_collect.rb +334 -0
  81. data/lib/active_merchant/billing/gateways/global_transport.rb +194 -0
  82. data/lib/active_merchant/billing/gateways/hps.rb +305 -0
  83. data/lib/active_merchant/billing/gateways/iats_payments.rb +271 -16
  84. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +2 -5
  85. data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +0 -0
  86. data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +1 -1
  87. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
  88. data/lib/active_merchant/billing/gateways/inspire.rb +8 -10
  89. data/lib/active_merchant/billing/gateways/instapay.rb +0 -0
  90. data/lib/active_merchant/billing/gateways/ipp.rb +175 -0
  91. data/lib/active_merchant/billing/gateways/iridium.rb +210 -4
  92. data/lib/active_merchant/billing/gateways/iveri.rb +251 -0
  93. data/lib/active_merchant/billing/gateways/jetpay.rb +176 -49
  94. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +437 -0
  95. data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
  96. data/lib/active_merchant/billing/gateways/kushki.rb +227 -0
  97. data/lib/active_merchant/billing/gateways/latitude19.rb +416 -0
  98. data/lib/active_merchant/billing/gateways/linkpoint.rb +17 -13
  99. data/lib/active_merchant/billing/gateways/litle.rb +329 -439
  100. data/lib/active_merchant/billing/gateways/mastercard.rb +268 -0
  101. data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
  102. data/lib/active_merchant/billing/gateways/mercado_pago.rb +262 -0
  103. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +15 -7
  104. data/lib/active_merchant/billing/gateways/merchant_one.rb +0 -1
  105. data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
  106. data/lib/active_merchant/billing/gateways/merchant_ware.rb +12 -15
  107. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +24 -13
  108. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +21 -14
  109. data/lib/active_merchant/billing/gateways/mercury.rb +74 -29
  110. data/lib/active_merchant/billing/gateways/metrics_global.rb +2 -21
  111. data/lib/active_merchant/billing/gateways/micropayment.rb +185 -0
  112. data/lib/active_merchant/billing/gateways/migs.rb +74 -13
  113. data/lib/active_merchant/billing/gateways/modern_payments.rb +1 -1
  114. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +1 -3
  115. data/lib/active_merchant/billing/gateways/monei.rb +307 -0
  116. data/lib/active_merchant/billing/gateways/moneris.rb +119 -36
  117. data/lib/active_merchant/billing/gateways/moneris_us.rb +146 -45
  118. data/lib/active_merchant/billing/gateways/money_movers.rb +152 -0
  119. data/lib/active_merchant/billing/gateways/nab_transact.rb +78 -53
  120. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +165 -0
  121. data/lib/active_merchant/billing/gateways/net_registry.rb +8 -3
  122. data/lib/active_merchant/billing/gateways/netbanx.rb +289 -0
  123. data/lib/active_merchant/billing/gateways/netbilling.rb +61 -26
  124. data/lib/active_merchant/billing/gateways/netpay.rb +1 -1
  125. data/lib/active_merchant/billing/gateways/network_merchants.rb +242 -0
  126. data/lib/active_merchant/billing/gateways/nmi.rb +265 -10
  127. data/lib/active_merchant/billing/gateways/ogone.rb +85 -27
  128. data/lib/active_merchant/billing/gateways/omise.rb +324 -0
  129. data/lib/active_merchant/billing/gateways/openpay.rb +227 -0
  130. data/lib/active_merchant/billing/gateways/opp.rb +372 -0
  131. data/lib/active_merchant/billing/gateways/optimal_payment.rb +59 -28
  132. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +22 -21
  133. data/lib/active_merchant/billing/gateways/orbital.rb +346 -56
  134. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +207 -0
  135. data/lib/active_merchant/billing/gateways/pagarme.rb +248 -0
  136. data/lib/active_merchant/billing/gateways/pago_facil.rb +122 -0
  137. data/lib/active_merchant/billing/gateways/pay_conex.rb +246 -0
  138. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +30 -14
  139. data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
  140. data/lib/active_merchant/billing/gateways/pay_junction.rb +19 -25
  141. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +190 -0
  142. data/lib/active_merchant/billing/gateways/pay_secure.rb +0 -7
  143. data/lib/active_merchant/billing/gateways/paybox_direct.rb +16 -12
  144. data/lib/active_merchant/billing/gateways/payeezy.rb +386 -0
  145. data/lib/active_merchant/billing/gateways/payex.rb +412 -0
  146. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +38 -17
  147. data/lib/active_merchant/billing/gateways/payflow.rb +100 -19
  148. data/lib/active_merchant/billing/gateways/payflow_express.rb +22 -22
  149. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +2 -2
  150. data/lib/active_merchant/billing/gateways/payflow_uk.rb +6 -6
  151. data/lib/active_merchant/billing/gateways/payment_express.rb +15 -3
  152. data/lib/active_merchant/billing/gateways/paymentez.rb +283 -0
  153. data/lib/active_merchant/billing/gateways/paymill.rb +237 -48
  154. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +41 -8
  155. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +4 -0
  156. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +18 -4
  157. data/lib/active_merchant/billing/gateways/paypal.rb +49 -20
  158. data/lib/active_merchant/billing/gateways/paypal_ca.rb +1 -1
  159. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +6 -5
  160. data/lib/active_merchant/billing/gateways/paypal_express.rb +32 -4
  161. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +3 -3
  162. data/lib/active_merchant/billing/gateways/payscout.rb +162 -0
  163. data/lib/active_merchant/billing/gateways/paystation.rb +22 -24
  164. data/lib/active_merchant/billing/gateways/payu_in.rb +248 -0
  165. data/lib/active_merchant/billing/gateways/payu_latam.rb +440 -0
  166. data/lib/active_merchant/billing/gateways/pin.rb +68 -13
  167. data/lib/active_merchant/billing/gateways/plugnpay.rb +1 -12
  168. data/lib/active_merchant/billing/gateways/pro_pay.rb +326 -0
  169. data/lib/active_merchant/billing/gateways/psigate.rb +3 -14
  170. data/lib/active_merchant/billing/gateways/psl_card.rb +3 -3
  171. data/lib/active_merchant/billing/gateways/qbms.rb +1 -1
  172. data/lib/active_merchant/billing/gateways/quantum.rb +2 -2
  173. data/lib/active_merchant/billing/gateways/quickbooks.rb +290 -0
  174. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +188 -0
  175. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +299 -0
  176. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +227 -0
  177. data/lib/active_merchant/billing/gateways/quickpay.rb +10 -319
  178. data/lib/active_merchant/billing/gateways/qvalent.rb +236 -0
  179. data/lib/active_merchant/billing/gateways/realex.rb +27 -25
  180. data/lib/active_merchant/billing/gateways/redsys.rb +212 -80
  181. data/lib/active_merchant/billing/gateways/s5.rb +247 -0
  182. data/lib/active_merchant/billing/gateways/safe_charge.rb +258 -0
  183. data/lib/active_merchant/billing/gateways/sage.rb +412 -119
  184. data/lib/active_merchant/billing/gateways/sage_pay.rb +176 -59
  185. data/lib/active_merchant/billing/gateways/secure_net.rb +35 -29
  186. data/lib/active_merchant/billing/gateways/secure_pay.rb +182 -9
  187. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +21 -7
  188. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +0 -7
  189. data/lib/active_merchant/billing/gateways/securion_pay.rb +267 -0
  190. data/lib/active_merchant/billing/gateways/skip_jack.rb +1 -3
  191. data/lib/active_merchant/billing/gateways/smart_ps.rb +13 -2
  192. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
  193. data/lib/active_merchant/billing/gateways/spreedly_core.rb +36 -11
  194. data/lib/active_merchant/billing/gateways/stripe.rb +461 -82
  195. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +156 -0
  196. data/lib/active_merchant/billing/gateways/telr.rb +275 -0
  197. data/lib/active_merchant/billing/gateways/tns.rb +22 -0
  198. data/lib/active_merchant/billing/gateways/trans_first.rb +142 -28
  199. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +608 -0
  200. data/lib/active_merchant/billing/gateways/transact_pro.rb +224 -0
  201. data/lib/active_merchant/billing/gateways/transnational.rb +2 -231
  202. data/lib/active_merchant/billing/gateways/trexle.rb +217 -0
  203. data/lib/active_merchant/billing/gateways/trust_commerce.rb +17 -11
  204. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +193 -75
  205. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +150 -63
  206. data/lib/active_merchant/billing/gateways/vanco.rb +294 -0
  207. data/lib/active_merchant/billing/gateways/verifi.rb +1 -8
  208. data/lib/active_merchant/billing/gateways/viaklix.rb +1 -15
  209. data/lib/active_merchant/billing/gateways/visanet_peru.rb +209 -0
  210. data/lib/active_merchant/billing/gateways/webpay.rb +45 -28
  211. data/lib/active_merchant/billing/gateways/wepay.rb +238 -0
  212. data/lib/active_merchant/billing/gateways/wirecard.rb +167 -49
  213. data/lib/active_merchant/billing/gateways/world_net.rb +344 -0
  214. data/lib/active_merchant/billing/gateways/worldpay.rb +131 -36
  215. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +218 -0
  216. data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
  217. data/lib/active_merchant/billing/gateways.rb +8 -11
  218. data/lib/active_merchant/billing/model.rb +30 -0
  219. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
  220. data/lib/active_merchant/billing/payment_token.rb +21 -0
  221. data/lib/active_merchant/billing/rails.rb +3 -0
  222. data/lib/active_merchant/billing/response.rb +24 -17
  223. data/lib/active_merchant/billing.rb +7 -1
  224. data/lib/active_merchant/connection.rb +177 -0
  225. data/lib/active_merchant/country.rb +334 -0
  226. data/lib/active_merchant/empty.rb +20 -0
  227. data/lib/active_merchant/errors.rb +35 -0
  228. data/lib/active_merchant/network_connection_retries.rb +79 -0
  229. data/lib/active_merchant/post_data.rb +24 -0
  230. data/lib/active_merchant/posts_data.rb +84 -0
  231. data/lib/active_merchant/version.rb +1 -1
  232. data/lib/active_merchant.rb +24 -21
  233. data/lib/certs/cacert.pem +3951 -0
  234. data/lib/support/gateway_support.rb +16 -10
  235. data/lib/support/outbound_hosts.rb +13 -10
  236. metadata +161 -306
  237. data/gem-public_cert.pem +0 -20
  238. data/lib/active_merchant/billing/expiry_date.rb +0 -34
  239. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +0 -314
  240. data/lib/active_merchant/billing/gateways/card_stream_modern.rb +0 -155
  241. data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -277
  242. data/lib/active_merchant/billing/gateways/orbital/avs_result.rb +0 -93
  243. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +0 -93
  244. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +0 -114
  245. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +0 -102
  246. data/lib/active_merchant/billing/gateways/samurai.rb +0 -118
  247. data/lib/active_merchant/billing/gateways/vindicia.rb +0 -361
  248. data/lib/active_merchant/billing/integrations/a1agregator/helper.rb +0 -31
  249. data/lib/active_merchant/billing/integrations/a1agregator/notification.rb +0 -186
  250. data/lib/active_merchant/billing/integrations/a1agregator/status.rb +0 -38
  251. data/lib/active_merchant/billing/integrations/a1agregator.rb +0 -26
  252. data/lib/active_merchant/billing/integrations/action_view_helper.rb +0 -73
  253. data/lib/active_merchant/billing/integrations/authorize_net_sim/helper.rb +0 -229
  254. data/lib/active_merchant/billing/integrations/authorize_net_sim/notification.rb +0 -340
  255. data/lib/active_merchant/billing/integrations/authorize_net_sim.rb +0 -38
  256. data/lib/active_merchant/billing/integrations/bogus/helper.rb +0 -17
  257. data/lib/active_merchant/billing/integrations/bogus/notification.rb +0 -11
  258. data/lib/active_merchant/billing/integrations/bogus/return.rb +0 -10
  259. data/lib/active_merchant/billing/integrations/bogus.rb +0 -23
  260. data/lib/active_merchant/billing/integrations/chronopay/helper.rb +0 -120
  261. data/lib/active_merchant/billing/integrations/chronopay/notification.rb +0 -158
  262. data/lib/active_merchant/billing/integrations/chronopay/return.rb +0 -10
  263. data/lib/active_merchant/billing/integrations/chronopay.rb +0 -23
  264. data/lib/active_merchant/billing/integrations/direc_pay/helper.rb +0 -200
  265. data/lib/active_merchant/billing/integrations/direc_pay/notification.rb +0 -76
  266. data/lib/active_merchant/billing/integrations/direc_pay/return.rb +0 -32
  267. data/lib/active_merchant/billing/integrations/direc_pay/status.rb +0 -37
  268. data/lib/active_merchant/billing/integrations/direc_pay.rb +0 -41
  269. data/lib/active_merchant/billing/integrations/directebanking/helper.rb +0 -90
  270. data/lib/active_merchant/billing/integrations/directebanking/notification.rb +0 -120
  271. data/lib/active_merchant/billing/integrations/directebanking/return.rb +0 -11
  272. data/lib/active_merchant/billing/integrations/directebanking.rb +0 -47
  273. data/lib/active_merchant/billing/integrations/dotpay/helper.rb +0 -77
  274. data/lib/active_merchant/billing/integrations/dotpay/notification.rb +0 -86
  275. data/lib/active_merchant/billing/integrations/dotpay/return.rb +0 -11
  276. data/lib/active_merchant/billing/integrations/dotpay.rb +0 -22
  277. data/lib/active_merchant/billing/integrations/dwolla/common.rb +0 -23
  278. data/lib/active_merchant/billing/integrations/dwolla/helper.rb +0 -43
  279. data/lib/active_merchant/billing/integrations/dwolla/notification.rb +0 -64
  280. data/lib/active_merchant/billing/integrations/dwolla/return.rb +0 -49
  281. data/lib/active_merchant/billing/integrations/dwolla.rb +0 -23
  282. data/lib/active_merchant/billing/integrations/e_payment_plans/helper.rb +0 -34
  283. data/lib/active_merchant/billing/integrations/e_payment_plans/notification.rb +0 -84
  284. data/lib/active_merchant/billing/integrations/e_payment_plans.rb +0 -48
  285. data/lib/active_merchant/billing/integrations/easy_pay/common.rb +0 -40
  286. data/lib/active_merchant/billing/integrations/easy_pay/helper.rb +0 -36
  287. data/lib/active_merchant/billing/integrations/easy_pay/notification.rb +0 -59
  288. data/lib/active_merchant/billing/integrations/easy_pay.rb +0 -30
  289. data/lib/active_merchant/billing/integrations/epay/helper.rb +0 -55
  290. data/lib/active_merchant/billing/integrations/epay/notification.rb +0 -110
  291. data/lib/active_merchant/billing/integrations/epay.rb +0 -21
  292. data/lib/active_merchant/billing/integrations/first_data/helper.rb +0 -61
  293. data/lib/active_merchant/billing/integrations/first_data/notification.rb +0 -56
  294. data/lib/active_merchant/billing/integrations/first_data.rb +0 -38
  295. data/lib/active_merchant/billing/integrations/gestpay/common.rb +0 -42
  296. data/lib/active_merchant/billing/integrations/gestpay/helper.rb +0 -70
  297. data/lib/active_merchant/billing/integrations/gestpay/notification.rb +0 -85
  298. data/lib/active_merchant/billing/integrations/gestpay/return.rb +0 -10
  299. data/lib/active_merchant/billing/integrations/gestpay.rb +0 -25
  300. data/lib/active_merchant/billing/integrations/helper.rb +0 -117
  301. data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +0 -58
  302. data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +0 -59
  303. data/lib/active_merchant/billing/integrations/hi_trust/return.rb +0 -68
  304. data/lib/active_merchant/billing/integrations/hi_trust.rb +0 -27
  305. data/lib/active_merchant/billing/integrations/ipay88/helper.rb +0 -114
  306. data/lib/active_merchant/billing/integrations/ipay88/return.rb +0 -95
  307. data/lib/active_merchant/billing/integrations/ipay88.rb +0 -19
  308. data/lib/active_merchant/billing/integrations/liqpay/helper.rb +0 -43
  309. data/lib/active_merchant/billing/integrations/liqpay/notification.rb +0 -89
  310. data/lib/active_merchant/billing/integrations/liqpay/return.rb +0 -83
  311. data/lib/active_merchant/billing/integrations/liqpay.rb +0 -30
  312. data/lib/active_merchant/billing/integrations/maksuturva/helper.rb +0 -119
  313. data/lib/active_merchant/billing/integrations/maksuturva/notification.rb +0 -48
  314. data/lib/active_merchant/billing/integrations/maksuturva.rb +0 -86
  315. data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +0 -75
  316. data/lib/active_merchant/billing/integrations/moneybookers/notification.rb +0 -129
  317. data/lib/active_merchant/billing/integrations/moneybookers.rb +0 -26
  318. data/lib/active_merchant/billing/integrations/nochex/helper.rb +0 -68
  319. data/lib/active_merchant/billing/integrations/nochex/notification.rb +0 -94
  320. data/lib/active_merchant/billing/integrations/nochex/return.rb +0 -10
  321. data/lib/active_merchant/billing/integrations/nochex.rb +0 -88
  322. data/lib/active_merchant/billing/integrations/notification.rb +0 -71
  323. data/lib/active_merchant/billing/integrations/paxum/common.rb +0 -24
  324. data/lib/active_merchant/billing/integrations/paxum/helper.rb +0 -42
  325. data/lib/active_merchant/billing/integrations/paxum/notification.rb +0 -33
  326. data/lib/active_merchant/billing/integrations/paxum.rb +0 -44
  327. data/lib/active_merchant/billing/integrations/pay_fast/common.rb +0 -42
  328. data/lib/active_merchant/billing/integrations/pay_fast/helper.rb +0 -50
  329. data/lib/active_merchant/billing/integrations/pay_fast/notification.rb +0 -134
  330. data/lib/active_merchant/billing/integrations/pay_fast/return.rb +0 -10
  331. data/lib/active_merchant/billing/integrations/pay_fast.rb +0 -70
  332. data/lib/active_merchant/billing/integrations/payflow_link/helper.rb +0 -116
  333. data/lib/active_merchant/billing/integrations/payflow_link/notification.rb +0 -78
  334. data/lib/active_merchant/billing/integrations/payflow_link.rb +0 -21
  335. data/lib/active_merchant/billing/integrations/paypal/helper.rb +0 -119
  336. data/lib/active_merchant/billing/integrations/paypal/notification.rb +0 -227
  337. data/lib/active_merchant/billing/integrations/paypal/return.rb +0 -10
  338. data/lib/active_merchant/billing/integrations/paypal.rb +0 -39
  339. data/lib/active_merchant/billing/integrations/paypal_payments_advanced/helper.rb +0 -15
  340. data/lib/active_merchant/billing/integrations/paypal_payments_advanced.rb +0 -20
  341. data/lib/active_merchant/billing/integrations/paysbuy/helper.rb +0 -15
  342. data/lib/active_merchant/billing/integrations/paysbuy/notification.rb +0 -28
  343. data/lib/active_merchant/billing/integrations/paysbuy.rb +0 -36
  344. data/lib/active_merchant/billing/integrations/payu_in/helper.rb +0 -74
  345. data/lib/active_merchant/billing/integrations/payu_in/notification.rb +0 -165
  346. data/lib/active_merchant/billing/integrations/payu_in/return.rb +0 -36
  347. data/lib/active_merchant/billing/integrations/payu_in.rb +0 -43
  348. data/lib/active_merchant/billing/integrations/platron/helper.rb +0 -32
  349. data/lib/active_merchant/billing/integrations/platron/notification.rb +0 -113
  350. data/lib/active_merchant/billing/integrations/platron.rb +0 -28
  351. data/lib/active_merchant/billing/integrations/pxpay/helper.rb +0 -112
  352. data/lib/active_merchant/billing/integrations/pxpay/notification.rb +0 -157
  353. data/lib/active_merchant/billing/integrations/pxpay/return.rb +0 -25
  354. data/lib/active_merchant/billing/integrations/pxpay.rb +0 -31
  355. data/lib/active_merchant/billing/integrations/quickpay/helper.rb +0 -74
  356. data/lib/active_merchant/billing/integrations/quickpay/notification.rb +0 -137
  357. data/lib/active_merchant/billing/integrations/quickpay.rb +0 -21
  358. data/lib/active_merchant/billing/integrations/rbkmoney/helper.rb +0 -23
  359. data/lib/active_merchant/billing/integrations/rbkmoney/notification.rb +0 -91
  360. data/lib/active_merchant/billing/integrations/rbkmoney.rb +0 -17
  361. data/lib/active_merchant/billing/integrations/return.rb +0 -42
  362. data/lib/active_merchant/billing/integrations/robokassa/common.rb +0 -19
  363. data/lib/active_merchant/billing/integrations/robokassa/helper.rb +0 -50
  364. data/lib/active_merchant/billing/integrations/robokassa/notification.rb +0 -55
  365. data/lib/active_merchant/billing/integrations/robokassa/return.rb +0 -17
  366. data/lib/active_merchant/billing/integrations/robokassa.rb +0 -49
  367. data/lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb +0 -33
  368. data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +0 -136
  369. data/lib/active_merchant/billing/integrations/sage_pay_form/notification.rb +0 -210
  370. data/lib/active_merchant/billing/integrations/sage_pay_form/return.rb +0 -31
  371. data/lib/active_merchant/billing/integrations/sage_pay_form.rb +0 -37
  372. data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +0 -91
  373. data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +0 -139
  374. data/lib/active_merchant/billing/integrations/two_checkout/return.rb +0 -17
  375. data/lib/active_merchant/billing/integrations/two_checkout.rb +0 -44
  376. data/lib/active_merchant/billing/integrations/valitor/helper.rb +0 -86
  377. data/lib/active_merchant/billing/integrations/valitor/notification.rb +0 -13
  378. data/lib/active_merchant/billing/integrations/valitor/response_fields.rb +0 -97
  379. data/lib/active_merchant/billing/integrations/valitor/return.rb +0 -13
  380. data/lib/active_merchant/billing/integrations/valitor.rb +0 -33
  381. data/lib/active_merchant/billing/integrations/verkkomaksut/helper.rb +0 -88
  382. data/lib/active_merchant/billing/integrations/verkkomaksut/notification.rb +0 -59
  383. data/lib/active_merchant/billing/integrations/verkkomaksut.rb +0 -20
  384. data/lib/active_merchant/billing/integrations/web_pay/common.rb +0 -50
  385. data/lib/active_merchant/billing/integrations/web_pay/helper.rb +0 -68
  386. data/lib/active_merchant/billing/integrations/web_pay/notification.rb +0 -51
  387. data/lib/active_merchant/billing/integrations/web_pay.rb +0 -45
  388. data/lib/active_merchant/billing/integrations/webmoney/common.rb +0 -17
  389. data/lib/active_merchant/billing/integrations/webmoney/helper.rb +0 -40
  390. data/lib/active_merchant/billing/integrations/webmoney/notification.rb +0 -47
  391. data/lib/active_merchant/billing/integrations/webmoney.rb +0 -43
  392. data/lib/active_merchant/billing/integrations/world_pay/helper.rb +0 -101
  393. data/lib/active_merchant/billing/integrations/world_pay/notification.rb +0 -160
  394. data/lib/active_merchant/billing/integrations/world_pay.rb +0 -34
  395. data/lib/active_merchant/billing/integrations.rb +0 -17
  396. data.tar.gz.sig +0 -0
  397. metadata.gz.sig +0 -0
@@ -1,141 +1,166 @@
1
+ require 'nokogiri'
2
+
1
3
  module ActiveMerchant #:nodoc:
2
4
  module Billing #:nodoc:
3
5
  class LitleGateway < Gateway
4
- # Specific to Litle options:
5
- # * <tt>:merchant_id</tt> - Merchant Id assigned by Litle
6
- # * <tt>:user</tt> - Username assigned by Litle
7
- # * <tt>:password</tt> - Password assigned by Litle
8
- # * <tt>:version</tt> - The version of the api you are using (eg, '8.10')
9
- # * <tt>:proxy_addr</tt> - Proxy address - nil if not needed
10
- # * <tt>:proxy_port</tt> - Proxy port - nil if not needed
11
- # * <tt>:url</tt> - URL assigned by Litle (for testing, use the sandbox)
12
- #
13
- # Standard Active Merchant options
14
- # * <tt>:order_id</tt> - The order number
15
- # * <tt>:ip</tt> - The IP address of the customer making the purchase
16
- # * <tt>:customer</tt> - The name, customer number, or other information that identifies the customer
17
- # * <tt>:invoice</tt> - The invoice number
18
- # * <tt>:merchant</tt> - The name or description of the merchant offering the product
19
- # * <tt>:description</tt> - A description of the transaction
20
- # * <tt>:email</tt> - The email address of the customer
21
- # * <tt>:currency</tt> - The currency of the transaction. Only important when you are using a currency that is not the default with a gateway that supports multiple currencies.
22
- # * <tt>:billing_address</tt> - A hash containing the billing address of the customer.
23
- # * <tt>:shipping_address</tt> - A hash containing the shipping address of the customer.
24
- #
25
- # The <tt>:billing_address</tt>, and <tt>:shipping_address</tt> hashes can have the following keys:
26
- #
27
- # * <tt>:name</tt> - The full name of the customer.
28
- # * <tt>:company</tt> - The company name of the customer.
29
- # * <tt>:address1</tt> - The primary street address of the customer.
30
- # * <tt>:address2</tt> - Additional line of address information.
31
- # * <tt>:city</tt> - The city of the customer.
32
- # * <tt>:state</tt> - The state of the customer. The 2 digit code for US and Canadian addresses. The full name of the state or province for foreign addresses.
33
- # * <tt>:country</tt> - The [ISO 3166-1-alpha-2 code](http://www.iso.org/iso/country_codes/iso_3166_code_lists/english_country_names_and_code_elements.htm) for the customer.
34
- # * <tt>:zip</tt> - The zip or postal code of the customer.
35
- # * <tt>:phone</tt> - The phone number of the customer.
36
-
37
- self.test_url = 'https://www.testlitle.com/sandbox/communicator/online'
38
- self.live_url = 'https://payments.litle.com/vap/communicator/online'
39
-
40
- LITLE_SCHEMA_VERSION = '8.13'
41
-
42
- # The countries the gateway supports merchants from as 2 digit ISO country codes
43
- self.supported_countries = ['US']
6
+ SCHEMA_VERSION = '9.12'
44
7
 
45
- # The card types supported by the payment gateway
46
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb]
8
+ self.test_url = 'https://www.testvantivcnp.com/sandbox/communicator/online'
9
+ self.live_url = 'https://payments.vantivcnp.com/vap/communicator/online'
47
10
 
48
- # The homepage URL of the gateway
49
- self.homepage_url = 'http://www.litle.com/'
11
+ self.supported_countries = ['US']
12
+ self.default_currency = 'USD'
13
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb]
50
14
 
51
- # The name of the gateway
52
- self.display_name = 'Litle & Co.'
15
+ self.homepage_url = 'http://www.vantiv.com/'
16
+ self.display_name = 'Vantiv eCommerce'
53
17
 
54
- self.default_currency = 'USD'
18
+ def initialize(options={})
19
+ requires!(options, :login, :password, :merchant_id)
20
+ super
21
+ end
55
22
 
56
- def initialize(options = {})
57
- begin
58
- require 'LitleOnline'
59
- rescue LoadError
60
- raise "Could not load the LitleOnline gem (> 08.15.0). Use `gem install LitleOnline` to install it."
23
+ def purchase(money, payment_method, options={})
24
+ request = build_xml_request do |doc|
25
+ add_authentication(doc)
26
+ if check?(payment_method)
27
+ doc.echeckSale(transaction_attributes(options)) do
28
+ add_echeck_purchase_params(doc, money, payment_method, options)
29
+ end
30
+ else
31
+ doc.sale(transaction_attributes(options)) do
32
+ add_auth_purchase_params(doc, money, payment_method, options)
33
+ end
34
+ end
61
35
  end
36
+ check?(payment_method) ? commit(:echeckSales, request, money) : commit(:sale, request, money)
37
+ end
62
38
 
63
- if wiredump_device
64
- LitleOnline::Configuration.logger = ((Logger === wiredump_device) ? wiredump_device : Logger.new(wiredump_device))
65
- LitleOnline::Configuration.logger.level = Logger::DEBUG
66
- else
67
- LitleOnline::Configuration.logger = Logger.new(STDOUT)
68
- LitleOnline::Configuration.logger.level = Logger::WARN
39
+ def authorize(money, payment_method, options={})
40
+ request = build_xml_request do |doc|
41
+ add_authentication(doc)
42
+ if check?(payment_method)
43
+ doc.echeckVerification(transaction_attributes(options)) do
44
+ add_echeck_purchase_params(doc, money, payment_method, options)
45
+ end
46
+ else
47
+ doc.authorization(transaction_attributes(options)) do
48
+ add_auth_purchase_params(doc, money, payment_method, options)
49
+ end
50
+ end
69
51
  end
52
+ check?(payment_method) ? commit(:echeckVerification, request, money) : commit(:authorization, request, money)
53
+ end
70
54
 
71
- @litle = LitleOnline::LitleOnlineRequest.new
72
-
73
- options[:version] ||= LITLE_SCHEMA_VERSION
74
- options[:merchant] ||= 'Default Report Group'
75
- options[:user] ||= options[:login]
55
+ def capture(money, authorization, options={})
56
+ transaction_id, _, _ = split_authorization(authorization)
76
57
 
77
- requires!(options, :merchant_id, :user, :password, :merchant, :version)
58
+ request = build_xml_request do |doc|
59
+ add_authentication(doc)
60
+ add_descriptor(doc, options)
61
+ doc.capture_(transaction_attributes(options)) do
62
+ doc.litleTxnId(transaction_id)
63
+ doc.amount(money) if money
64
+ end
65
+ end
78
66
 
79
- super
67
+ commit(:capture, request, money)
80
68
  end
81
69
 
82
- def authorize(money, creditcard_or_token, options = {})
83
- to_pass = build_authorize_request(money, creditcard_or_token, options)
84
- build_response(:authorization, @litle.authorization(to_pass))
70
+ def credit(money, authorization, options = {})
71
+ ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
72
+ refund(money, authorization, options)
85
73
  end
86
74
 
87
- def purchase(money, creditcard_or_token, options = {})
88
- to_pass = build_purchase_request(money, creditcard_or_token, options)
89
- build_response(:sale, @litle.sale(to_pass))
75
+ def refund(money, payment, options={})
76
+ request = build_xml_request do |doc|
77
+ add_authentication(doc)
78
+ add_descriptor(doc, options)
79
+ doc.send(refund_type(payment), transaction_attributes(options)) do
80
+ if payment.is_a?(String)
81
+ transaction_id, kind, _ = split_authorization(payment)
82
+ doc.litleTxnId(transaction_id)
83
+ doc.amount(money) if money
84
+ elsif check?(payment)
85
+ add_echeck_purchase_params(doc, money, payment, options)
86
+ else
87
+ add_auth_purchase_params(doc, money, payment, options)
88
+ end
89
+ end
90
+ end
91
+
92
+ commit(refund_type(payment), request)
90
93
  end
91
94
 
92
- def capture(money, authorization, options = {})
93
- transaction_id, kind = split_authorization(authorization)
94
- to_pass = create_capture_hash(money, transaction_id, options)
95
- build_response(:capture, @litle.capture(to_pass))
95
+ def verify(creditcard, options = {})
96
+ MultiResponse.run(:use_first_response) do |r|
97
+ r.process { authorize(0, creditcard, options) }
98
+ r.process(:ignore_result) { void(r.authorization, options) }
99
+ end
96
100
  end
97
101
 
98
- # Note: Litle requires that authorization requests be voided via auth_reversal
99
- # and other requests via void. To maintain the same interface as the other
100
- # gateways the transaction_id and the kind of transaction are concatenated
101
- # together with a ; separator (e.g. 1234;authorization)
102
- #
103
- # A partial auth_reversal can be accomplished by passing :amount as an option
104
- def void(identification, options = {})
105
- transaction_id, kind = split_authorization(identification)
106
- if(kind == 'authorization')
107
- to_pass = create_auth_reversal_hash(transaction_id, options[:amount], options)
108
- build_response(:authReversal, @litle.auth_reversal(to_pass))
109
- else
110
- to_pass = create_void_hash(transaction_id, options)
111
- build_response(:void, @litle.void(to_pass))
102
+ def void(authorization, options={})
103
+ transaction_id, kind, money = split_authorization(authorization)
104
+
105
+ request = build_xml_request do |doc|
106
+ add_authentication(doc)
107
+ doc.send(void_type(kind), transaction_attributes(options)) do
108
+ doc.litleTxnId(transaction_id)
109
+ doc.amount(money) if void_type(kind) == :authReversal
110
+ end
112
111
  end
112
+
113
+ commit(void_type(kind), request)
113
114
  end
114
115
 
115
- def refund(money, authorization, options = {})
116
- to_pass = build_credit_request(money, authorization, options)
117
- build_response(:credit, @litle.credit(to_pass))
116
+ def store(payment_method, options = {})
117
+ request = build_xml_request do |doc|
118
+ add_authentication(doc)
119
+ doc.registerTokenRequest(transaction_attributes(options)) do
120
+ doc.orderId(truncate(options[:order_id], 24))
121
+ if payment_method.is_a?(String)
122
+ doc.paypageRegistrationId(payment_method)
123
+ elsif check?(payment_method)
124
+ doc.echeckForToken do
125
+ doc.accNum(payment_method.account_number)
126
+ doc.routingNum(payment_method.routing_number)
127
+ end
128
+ else
129
+ doc.accountNumber(payment_method.number)
130
+ doc.cardValidationNum(payment_method.verification_value) if payment_method.verification_value
131
+ end
132
+ end
133
+ end
134
+
135
+ commit(:registerToken, request)
118
136
  end
119
137
 
120
- def credit(money, authorization, options = {})
121
- deprecated CREDIT_DEPRECATION_MESSAGE
122
- refund(money, authorization, options)
138
+ def supports_scrubbing?
139
+ true
123
140
  end
124
141
 
125
- def store(creditcard_or_paypage_registration_id, options = {})
126
- to_pass = create_token_hash(creditcard_or_paypage_registration_id, options)
127
- build_response(:registerToken, @litle.register_token_request(to_pass), %w(000 801 802))
142
+ def scrub(transcript)
143
+ transcript.
144
+ gsub(%r((<user>).+(</user>)), '\1[FILTERED]\2').
145
+ gsub(%r((<password>).+(</password>)), '\1[FILTERED]\2').
146
+ gsub(%r((<number>).+(</number>)), '\1[FILTERED]\2').
147
+ gsub(%r((<accNum>).+(</accNum>)), '\1[FILTERED]\2').
148
+ gsub(%r((<routingNum>).+(</routingNum>)), '\1[FILTERED]\2').
149
+ gsub(%r((<cardValidationNum>).+(</cardValidationNum>)), '\1[FILTERED]\2').
150
+ gsub(%r((<accountNumber>).+(</accountNumber>)), '\1[FILTERED]\2').
151
+ gsub(%r((<paypageRegistrationId>).+(</paypageRegistrationId>)), '\1[FILTERED]\2').
152
+ gsub(%r((<authenticationValue>).+(</authenticationValue>)), '\1[FILTERED]\2')
128
153
  end
129
154
 
130
155
  private
131
156
 
132
157
  CARD_TYPE = {
133
- 'visa' => 'VI',
134
- 'master' => 'MC',
135
- 'american_express' => 'AX',
136
- 'discover' => 'DI',
137
- 'jcb' => 'DI',
138
- 'diners_club' => 'DI'
158
+ 'visa' => 'VI',
159
+ 'master' => 'MC',
160
+ 'american_express' => 'AX',
161
+ 'discover' => 'DI',
162
+ 'jcb' => 'JC',
163
+ 'diners_club' => 'DC'
139
164
  }
140
165
 
141
166
  AVS_RESPONSE_CODE = {
@@ -156,403 +181,268 @@ module ActiveMerchant #:nodoc:
156
181
  '40' => 'E'
157
182
  }
158
183
 
159
- def url
160
- return @options[:url] if @options[:url].present?
161
-
162
- test? ? self.test_url : self.live_url
163
- end
164
-
165
- def build_response(kind, litle_response, valid_responses=%w(000))
166
- response = Hash.from_xml(litle_response.raw_xml.to_s)['litleOnlineResponse']
167
-
168
- if response['response'] == "0"
169
- detail = response["#{kind}Response"]
170
- fraud = fraud_result(detail)
171
- Response.new(
172
- valid_responses.include?(detail['response']),
173
- detail['message'],
174
- { :litleOnlineResponse => response },
175
- :authorization => authorization_from(detail, kind),
176
- :avs_result => { :code => fraud['avs'] },
177
- :cvv_result => fraud['cvv'],
178
- :test => test?
179
- )
184
+ def void_type(kind)
185
+ if kind == 'authorization'
186
+ :authReversal
187
+ elsif kind == 'echeckSales'
188
+ :echeckVoid
180
189
  else
181
- Response.new(false, response['message'], :litleOnlineResponse => response, :test => test?)
190
+ :void
182
191
  end
183
192
  end
184
193
 
185
- # Generates an authorization string of the appropriate id and the kind of transaction
186
- # See #void for how the kind is used
187
- def authorization_from(litle_response, kind)
188
- case kind
189
- when :registerToken
190
- authorization = litle_response['litleToken']
194
+ def refund_type(payment)
195
+ transaction_id, kind, _ = split_authorization(payment)
196
+ if check?(payment) || kind == 'echeckSales'
197
+ :echeckCredit
191
198
  else
192
- authorization = [litle_response['litleTxnId'], kind.to_s].join(";")
199
+ :credit
193
200
  end
194
201
  end
195
202
 
196
- def split_authorization(authorization)
197
- transaction_id, kind = authorization.to_s.split(';')
198
- [transaction_id, kind]
203
+ def check?(payment_method)
204
+ return false if payment_method.is_a?(String)
205
+ card_brand(payment_method) == 'check'
199
206
  end
200
207
 
201
- def build_authorize_request(money, creditcard_or_token, options)
202
- payment_method = build_payment_method(creditcard_or_token, options)
203
-
204
- hash = create_hash(money, options)
205
-
206
- add_creditcard_or_cardtoken_hash(hash, payment_method)
207
-
208
- hash
208
+ def add_authentication(doc)
209
+ doc.authentication do
210
+ doc.user(@options[:login])
211
+ doc.password(@options[:password])
212
+ end
209
213
  end
210
214
 
211
- def build_purchase_request(money, creditcard_or_token, options)
212
- payment_method = build_payment_method(creditcard_or_token, options)
213
-
214
- hash = create_hash(money, options)
215
-
216
- add_creditcard_or_cardtoken_hash(hash, payment_method)
217
-
218
- hash
215
+ def add_auth_purchase_params(doc, money, payment_method, options)
216
+ doc.orderId(truncate(options[:order_id], 24))
217
+ doc.amount(money)
218
+ add_order_source(doc, payment_method, options)
219
+ add_billing_address(doc, payment_method, options)
220
+ add_shipping_address(doc, payment_method, options)
221
+ add_payment_method(doc, payment_method, options)
222
+ add_pos(doc, payment_method)
223
+ add_descriptor(doc, options)
224
+ add_merchant_data(doc, options)
225
+ add_debt_repayment(doc, options)
219
226
  end
220
227
 
221
- def build_credit_request(money, identification_or_token, options)
222
- payment_method = build_payment_method(identification_or_token, options)
223
-
224
- hash = create_hash(money, options)
225
-
226
- add_identification_or_cardtoken_hash(hash, payment_method)
227
-
228
- unless payment_method.is_a?(LitleCardToken)
229
- hash['orderSource'] = nil
230
- hash['orderId'] = nil
228
+ def add_merchant_data(doc, options={})
229
+ if options[:affiliate] || options[:campaign] || options[:merchant_grouping_id]
230
+ doc.merchantData do
231
+ doc.affiliate(options[:affiliate]) if options[:affiliate]
232
+ doc.campaign(options[:campaign]) if options[:campaign]
233
+ doc.merchantGroupingId(options[:merchant_grouping_id]) if options[:merchant_grouping_id]
234
+ end
231
235
  end
232
-
233
- hash
234
236
  end
235
237
 
236
- def build_payment_method(payment_method, options)
237
- result = payment_method
238
+ def add_echeck_purchase_params(doc, money, payment_method, options)
239
+ doc.orderId(truncate(options[:order_id], 24))
240
+ doc.amount(money)
241
+ add_order_source(doc, payment_method, options)
242
+ add_billing_address(doc, payment_method, options)
243
+ add_payment_method(doc, payment_method, options)
244
+ add_descriptor(doc, options)
245
+ end
238
246
 
239
- # Build instance of the LitleCardToken class for internal use if this is a token request.
240
- if payment_method.is_a?(String) && options.has_key?(:token)
241
- result = LitleCardToken.new(:token => payment_method)
242
- result.month = options[:token][:month]
243
- result.year = options[:token][:year]
244
- result.verification_value = options[:token][:verification_value]
245
- result.brand = options[:token][:brand]
247
+ def add_descriptor(doc, options)
248
+ if options[:descriptor_name] || options[:descriptor_phone]
249
+ doc.customBilling do
250
+ doc.phone(options[:descriptor_phone]) if options[:descriptor_phone]
251
+ doc.descriptor(options[:descriptor_name]) if options[:descriptor_name]
252
+ end
246
253
  end
247
-
248
- result
249
254
  end
250
255
 
251
- def add_creditcard_or_cardtoken_hash(hash, creditcard_or_cardtoken)
252
- if creditcard_or_cardtoken.is_a?(LitleCardToken)
253
- add_cardtoken_hash(hash, creditcard_or_cardtoken)
254
- else
255
- add_creditcard_hash(hash, creditcard_or_cardtoken)
256
- end
256
+ def add_debt_repayment(doc, options)
257
+ doc.debtRepayment(true) if options[:debt_repayment] == true
257
258
  end
258
259
 
259
- def add_identification_or_cardtoken_hash(hash, identification_or_cardtoken)
260
- if identification_or_cardtoken.is_a?(LitleCardToken)
261
- add_cardtoken_hash(hash, identification_or_cardtoken)
260
+ def add_payment_method(doc, payment_method, options)
261
+ if payment_method.is_a?(String)
262
+ doc.token do
263
+ doc.litleToken(payment_method)
264
+ end
265
+ elsif payment_method.respond_to?(:track_data) && payment_method.track_data.present?
266
+ doc.card do
267
+ doc.track(payment_method.track_data)
268
+ end
269
+ elsif check?(payment_method)
270
+ doc.echeck do
271
+ doc.accType(payment_method.account_type)
272
+ doc.accNum(payment_method.account_number)
273
+ doc.routingNum(payment_method.routing_number)
274
+ doc.checkNum(payment_method.number)
275
+ end
262
276
  else
263
- transaction_id, kind = split_authorization(identification_or_cardtoken)
264
- hash['litleTxnId'] = transaction_id
277
+ doc.card do
278
+ doc.type_(CARD_TYPE[payment_method.brand])
279
+ doc.number(payment_method.number)
280
+ doc.expDate(exp_date(payment_method))
281
+ doc.cardValidationNum(payment_method.verification_value)
282
+ end
283
+ if payment_method.is_a?(NetworkTokenizationCreditCard)
284
+ doc.cardholderAuthentication do
285
+ doc.authenticationValue(payment_method.payment_cryptogram)
286
+ end
287
+ elsif options[:order_source] && options[:order_source].start_with?('3ds')
288
+ doc.cardholderAuthentication do
289
+ doc.authenticationValue(options[:cavv]) if options[:cavv]
290
+ doc.authenticationTransactionId(options[:xid]) if options[:xid]
291
+ end
292
+ end
265
293
  end
266
294
  end
267
295
 
268
- def add_cardtoken_hash(hash, cardtoken)
269
- token_info = {}
270
- token_info['litleToken'] = cardtoken.token
271
- token_info['expDate'] = cardtoken.exp_date if cardtoken.exp_date?
272
- token_info['cardValidationNum'] = cardtoken.verification_value unless cardtoken.verification_value.blank?
273
- token_info['type'] = cardtoken.type unless cardtoken.type.blank?
296
+ def add_billing_address(doc, payment_method, options)
297
+ return if payment_method.is_a?(String)
274
298
 
275
- hash['token'] = token_info
276
- hash
277
- end
299
+ doc.billToAddress do
300
+ if check?(payment_method)
301
+ doc.name(payment_method.name)
302
+ doc.firstName(payment_method.first_name)
303
+ doc.lastName(payment_method.last_name)
304
+ else
305
+ doc.name(payment_method.name)
306
+ end
307
+ doc.email(options[:email]) if options[:email]
278
308
 
279
- def add_creditcard_hash(hash, creditcard)
280
- cc_type = CARD_TYPE[creditcard.brand]
281
- exp_date_yr = creditcard.year.to_s[2..3]
282
- exp_date_mo = '%02d' % creditcard.month.to_i
283
- exp_date = exp_date_mo + exp_date_yr
309
+ add_address(doc, options[:billing_address])
310
+ end
311
+ end
284
312
 
285
- card_info = {
286
- 'type' => cc_type,
287
- 'number' => creditcard.number,
288
- 'expDate' => exp_date,
289
- 'cardValidationNum' => creditcard.verification_value
290
- }
313
+ def add_shipping_address(doc, payment_method, options)
314
+ return if payment_method.is_a?(String)
291
315
 
292
- hash['card'] = card_info
293
- hash
316
+ doc.shipToAddress do
317
+ add_address(doc, options[:shipping_address])
318
+ end
294
319
  end
295
320
 
296
- def create_capture_hash(money, authorization, options)
297
- hash = create_hash(money, options)
298
- hash['litleTxnId'] = authorization
299
- hash
321
+ def add_address(doc, address)
322
+ return unless address
323
+
324
+ doc.companyName(address[:company]) unless address[:company].blank?
325
+ doc.addressLine1(address[:address1]) unless address[:address1].blank?
326
+ doc.addressLine2(address[:address2]) unless address[:address2].blank?
327
+ doc.city(address[:city]) unless address[:city].blank?
328
+ doc.state(address[:state]) unless address[:state].blank?
329
+ doc.zip(address[:zip]) unless address[:zip].blank?
330
+ doc.country(address[:country]) unless address[:country].blank?
331
+ doc.phone(address[:phone]) unless address[:phone].blank?
300
332
  end
301
333
 
302
- def create_token_hash(creditcard_or_paypage_registration_id, options)
303
- hash = create_hash(0, options)
304
-
305
- if creditcard_or_paypage_registration_id.is_a?(String)
306
- hash['paypageRegistrationId'] = creditcard_or_paypage_registration_id
334
+ def add_order_source(doc, payment_method, options)
335
+ if options[:order_source]
336
+ doc.orderSource(options[:order_source])
337
+ elsif payment_method.is_a?(NetworkTokenizationCreditCard) && payment_method.source == :apple_pay
338
+ doc.orderSource('applepay')
339
+ elsif payment_method.is_a?(NetworkTokenizationCreditCard) && payment_method.source == :android_pay
340
+ doc.orderSource('androidpay')
341
+ elsif payment_method.respond_to?(:track_data) && payment_method.track_data.present?
342
+ doc.orderSource('retail')
307
343
  else
308
- hash['accountNumber'] = creditcard_or_paypage_registration_id.number
344
+ doc.orderSource('ecommerce')
309
345
  end
310
-
311
- hash
312
346
  end
313
347
 
314
- def create_void_hash(identification, options)
315
- hash = create_hash(nil, options)
316
- hash['litleTxnId'] = identification
317
- hash
348
+ def add_pos(doc, payment_method)
349
+ return unless payment_method.respond_to?(:track_data) && payment_method.track_data.present?
350
+
351
+ doc.pos do
352
+ doc.capability('magstripe')
353
+ doc.entryMode('completeread')
354
+ doc.cardholderId('signature')
355
+ end
318
356
  end
319
357
 
320
- def create_auth_reversal_hash(identification, money, options)
321
- hash = create_hash(money, options)
322
- hash['litleTxnId'] = identification
323
- hash
358
+ def exp_date(payment_method)
359
+ "#{format(payment_method.month, :two_digits)}#{format(payment_method.year, :two_digits)}"
324
360
  end
325
361
 
326
- def create_hash(money, options)
327
- fraud_check_type = {}
328
- if options[:ip]
329
- fraud_check_type['customerIpAddress'] = options[:ip]
362
+ def parse(kind, xml)
363
+ parsed = {}
364
+
365
+ doc = Nokogiri::XML(xml).remove_namespaces!
366
+ doc.xpath("//litleOnlineResponse/#{kind}Response/*").each do |node|
367
+ if (node.elements.empty?)
368
+ parsed[node.name.to_sym] = node.text
369
+ else
370
+ node.elements.each do |childnode|
371
+ name = "#{node.name}_#{childnode.name}"
372
+ parsed[name.to_sym] = childnode.text
373
+ end
374
+ end
330
375
  end
331
376
 
332
- enhanced_data = {}
333
- if options[:invoice]
334
- enhanced_data['invoiceReferenceNumber'] = options[:invoice]
377
+ if parsed.empty?
378
+ %w(response message).each do |attribute|
379
+ parsed[attribute.to_sym] = doc.xpath("//litleOnlineResponse").attribute(attribute).value
380
+ end
335
381
  end
336
382
 
337
- if options[:description]
338
- enhanced_data['customerReference'] = options[:description]
339
- end
383
+ parsed
384
+ end
340
385
 
341
- if options[:billing_address]
342
- bill_to_address = {
343
- 'name' => options[:billing_address][:name],
344
- 'companyName' => options[:billing_address][:company],
345
- 'addressLine1' => options[:billing_address][:address1],
346
- 'addressLine2' => options[:billing_address][:address2],
347
- 'city' => options[:billing_address][:city],
348
- 'state' => options[:billing_address][:state],
349
- 'zip' => options[:billing_address][:zip],
350
- 'country' => options[:billing_address][:country],
351
- 'email' => options[:email],
352
- 'phone' => options[:billing_address][:phone]
353
- }
354
- end
355
- if options[:shipping_address]
356
- ship_to_address = {
357
- 'name' => options[:shipping_address][:name],
358
- 'companyName' => options[:shipping_address][:company],
359
- 'addressLine1' => options[:shipping_address][:address1],
360
- 'addressLine2' => options[:shipping_address][:address2],
361
- 'city' => options[:shipping_address][:city],
362
- 'state' => options[:shipping_address][:state],
363
- 'zip' => options[:shipping_address][:zip],
364
- 'country' => options[:shipping_address][:country],
365
- 'email' => options[:email],
366
- 'phone' => options[:shipping_address][:phone]
367
- }
368
- end
386
+ def commit(kind, request, money=nil)
387
+ parsed = parse(kind, ssl_post(url, request, headers))
369
388
 
370
- hash = {
371
- 'billToAddress' => bill_to_address,
372
- 'shipToAddress' => ship_to_address,
373
- 'orderId' => (options[:order_id] || @options[:order_id]),
374
- 'customerId' => options[:customer],
375
- 'reportGroup' => (options[:merchant] || @options[:merchant]),
376
- 'merchantId' => (options[:merchant_id] || @options[:merchant_id]),
377
- 'orderSource' => (options[:order_source] || 'ecommerce'),
378
- 'enhancedData' => enhanced_data,
379
- 'fraudCheckType' => fraud_check_type,
380
- 'user' => (options[:user] || @options[:user]),
381
- 'password' => (options[:password] || @options[:password]),
382
- 'version' => (options[:version] || @options[:version]),
383
- 'url' => (options[:url] || url),
384
- 'proxy_addr' => (options[:proxy_addr] || @options[:proxy_addr]),
385
- 'proxy_port' => (options[:proxy_port] || @options[:proxy_port]),
386
- 'id' => (options[:id] || options[:order_id] || @options[:order_id])
389
+ options = {
390
+ authorization: authorization_from(kind, parsed, money),
391
+ test: test?,
392
+ :avs_result => { :code => AVS_RESPONSE_CODE[parsed[:fraudResult_avsResult]] },
393
+ :cvv_result => parsed[:fraudResult_cardValidationResult]
387
394
  }
388
395
 
389
- if (!money.nil? && money.to_s.length > 0)
390
- hash.merge!({ 'amount' => money })
391
- end
392
- hash
396
+ Response.new(success_from(kind, parsed), parsed[:message], parsed, options)
393
397
  end
394
398
 
395
- def fraud_result(authorization_response)
396
- if result = authorization_response['fraudResult']
397
- if result.key?('cardValidationResult')
398
- cvv_to_pass = result['cardValidationResult'].blank? ? "P" : result['cardValidationResult']
399
- end
400
-
401
- avs_to_pass = AVS_RESPONSE_CODE[result['avsResult']] unless result['avsResult'].blank?
402
- end
403
- { 'cvv' => cvv_to_pass, 'avs' => avs_to_pass }
404
- end
405
-
406
- # A +LitleCardToken+ object represents a tokenized credit card, and is capable of validating the various
407
- # data associated with these.
408
- #
409
- # == Example Usage
410
- # token = LitleCardToken.new(
411
- # :token => '1234567890123456',
412
- # :month => '9',
413
- # :year => '2010',
414
- # :brand => 'visa',
415
- # :verification_value => '123'
416
- # )
417
- #
418
- # token.valid? # => true
419
- # cc.exp_date # => 0910
420
- #
421
- class LitleCardToken
422
- include Validateable
423
-
424
- # Returns or sets the token. (required)
425
- #
426
- # @return [String]
427
- attr_accessor :token
428
-
429
- # Returns or sets the expiry month for the card associated with token. (optional)
430
- #
431
- # @return [Integer]
432
- attr_accessor :month
433
-
434
- # Returns or sets the expiry year for the card associated with token. (optional)
435
- #
436
- # @return [Integer]
437
- attr_accessor :year
438
-
439
- # Returns or sets the card verification value. (optional)
440
- #
441
- # @return [String] the verification value
442
- attr_accessor :verification_value
443
-
444
- # Returns or sets the credit card brand. (optional)
445
- #
446
- # Valid card types are
447
- #
448
- # * +'visa'+
449
- # * +'master'+
450
- # * +'discover'+
451
- # * +'american_express'+
452
- # * +'diners_club'+
453
- # * +'jcb'+
454
- # * +'switch'+
455
- # * +'solo'+
456
- # * +'dankort'+
457
- # * +'maestro'+
458
- # * +'forbrugsforeningen'+
459
- # * +'laser'+
460
- #
461
- # @return (String) the credit card brand
462
- attr_accessor :brand
463
-
464
- # Returns the Litle credit card type identifier.
465
- #
466
- # @return (String) the credit card type identifier
467
- def type
468
- CARD_TYPE[brand] unless brand.blank?
469
- end
470
-
471
- # Returns true if the expiration date is set.
472
- #
473
- # @return (Boolean)
474
- def exp_date?
475
- !month.to_i.zero? && !year.to_i.zero?
476
- end
477
-
478
- # Returns the card token expiration date in MMYY format.
479
- #
480
- # @return (String) the expiration date in MMYY format
481
- def exp_date
482
- result = ''
483
- if exp_date?
484
- exp_date_yr = year.to_s[2..3]
485
- exp_date_mo = '%02d' % month.to_i
486
-
487
- result = exp_date_mo + exp_date_yr
488
- end
489
- result
490
- end
399
+ def success_from(kind, parsed)
400
+ return (parsed[:response] == '000') unless kind == :registerToken
401
+ %w(000 801 802).include?(parsed[:response])
402
+ end
491
403
 
492
- # Validates the card token details.
493
- #
494
- # Any validation errors are added to the {#errors} attribute.
495
- def validate
496
- validate_card_token
497
- validate_expiration_date
498
- validate_card_brand
499
- end
404
+ def authorization_from(kind, parsed, money)
405
+ (kind == :registerToken) ? parsed[:litleToken] : "#{parsed[:litleTxnId]};#{kind};#{money}"
406
+ end
500
407
 
501
- def check?
502
- false
503
- end
408
+ def split_authorization(authorization)
409
+ transaction_id, kind, money = authorization.to_s.split(';')
410
+ [transaction_id, kind, money]
411
+ end
504
412
 
505
- private
413
+ def transaction_attributes(options)
414
+ attributes = {}
415
+ attributes[:id] = truncate(options[:id] || options[:order_id], 24)
416
+ attributes[:reportGroup] = options[:merchant] || 'Default Report Group'
417
+ attributes[:customerId] = options[:customer]
418
+ attributes.delete_if { |key, value| value == nil }
419
+ attributes
420
+ end
506
421
 
507
- CARD_TYPE = {
508
- 'visa' => 'VI',
509
- 'master' => 'MC',
510
- 'american_express' => 'AX',
511
- 'discover' => 'DI',
512
- 'jcb' => 'DI',
513
- 'diners_club' => 'DI'
422
+ def root_attributes
423
+ {
424
+ merchantId: @options[:merchant_id],
425
+ version: SCHEMA_VERSION,
426
+ xmlns: "http://www.litle.com/schema"
514
427
  }
428
+ end
515
429
 
516
- def before_validate #:nodoc:
517
- self.month = month.to_i
518
- self.year = year.to_i
519
- end
520
-
521
- # Litle XML Reference Guide 1.8.2
522
- #
523
- # The length of the original card number is reflected in the token, so a
524
- # submitted 16-digit number results in a 16-digit token. Also, all tokens
525
- # use only numeric characters, so you do not have to change your
526
- # systems to accept alpha-numeric characters.
527
- #
528
- # The credit card token numbers themselves have two parts.
529
- # The last four digits match the last four digits of the card number.
530
- # The remaining digits (length can vary based upon original card number
531
- # length) are a randomly generated.
532
- def validate_card_token #:nodoc:
533
- if token.to_s.length < 12 || token.to_s.match(/\A\d+\Z/).nil?
534
- errors.add :token, "is not a valid card token"
535
- end
536
- end
537
-
538
- def validate_expiration_date #:nodoc:
539
- if !month.to_i.zero? || !year.to_i.zero?
540
- errors.add :month, "is not a valid month" unless valid_month?(month)
541
- errors.add :year, "is not a valid year" unless valid_expiry_year?(year)
542
- end
543
- end
544
-
545
- def validate_card_brand #:nodoc:
546
- errors.add :brand, "is invalid" unless brand.blank? || CreditCard.card_companies.keys.include?(brand)
430
+ def build_xml_request
431
+ builder = Nokogiri::XML::Builder.new
432
+ builder.__send__('litleOnlineRequest', root_attributes) do |doc|
433
+ yield(doc)
547
434
  end
435
+ builder.doc.root.to_xml
436
+ end
548
437
 
549
- def valid_month?(month)
550
- (1..12).include?(month.to_i)
551
- end
438
+ def url
439
+ test? ? test_url : live_url
440
+ end
552
441
 
553
- def valid_expiry_year?(year)
554
- year.to_s =~ /\A\d{4}\Z/ && year.to_i > 1987
555
- end
442
+ def headers
443
+ {
444
+ 'Content-Type' => 'text/xml'
445
+ }
556
446
  end
557
447
  end
558
448
  end