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
@@ -32,13 +32,13 @@ module ActiveMerchant #:nodoc:
32
32
  # == Usage
33
33
  #
34
34
  # gateway = ActiveMerchant::Billing::OgoneGateway.new(
35
- # :login => "my_ogone_psp_id",
36
- # :user => "my_ogone_user_id",
37
- # :password => "my_ogone_pswd",
38
- # :signature => "my_ogone_sha_signature", # Only if you configured your Ogone environment so.
39
- # :signature_encryptor => "sha512", # Can be "none" (default), "sha1", "sha256" or "sha512".
35
+ # :login => "my_ogone_psp_id",
36
+ # :user => "my_ogone_user_id",
37
+ # :password => "my_ogone_pswd",
38
+ # :signature => "my_ogone_sha_signature", # Only if you configured your Ogone environment so.
39
+ # :signature_encryptor => "sha512" # Can be "none" (default), "sha1", "sha256" or "sha512".
40
40
  # # Must be the same as the one configured in your Ogone account.
41
- # )
41
+ # )
42
42
  #
43
43
  # # set up credit card object as in main ActiveMerchant example
44
44
  # creditcard = ActiveMerchant::Billing::CreditCard.new(
@@ -75,7 +75,19 @@ module ActiveMerchant #:nodoc:
75
75
  #
76
76
  # # When using store, you can also let Ogone generate the alias for you
77
77
  # response = gateway.store(creditcard)
78
- # puts response.billing_id # Retrieve the generated alias
78
+ # puts response.billing_id # Retrieve the generated alias
79
+ #
80
+ # # By default, Ogone tries to authorize 0.01 EUR but you can change this
81
+ # # amount using the :store_amount option when creating the gateway object:
82
+ # gateway = ActiveMerchant::Billing::OgoneGateway.new(
83
+ # :login => "my_ogone_psp_id",
84
+ # :user => "my_ogone_user_id",
85
+ # :password => "my_ogone_pswd",
86
+ # :signature => "my_ogone_sha_signature",
87
+ # :signature_encryptor => "sha512",
88
+ # :store_amount => 100 # The store method will try to authorize 1 EUR instead of 0.01 EUR
89
+ # )
90
+ # response = gateway.store(creditcard) # authorize 1 EUR and void the authorization right away
79
91
  #
80
92
  # == 3-D Secure feature
81
93
  #
@@ -138,12 +150,13 @@ module ActiveMerchant #:nodoc:
138
150
  # Verify and reserve the specified amount on the account, without actually doing the transaction.
139
151
  def authorize(money, payment_source, options = {})
140
152
  post = {}
153
+ action = (payment_source.brand == "mastercard") ? "PAU" : "RES"
141
154
  add_invoice(post, options)
142
155
  add_payment_source(post, payment_source, options)
143
156
  add_address(post, payment_source, options)
144
157
  add_customer_data(post, options)
145
158
  add_money(post, money, options)
146
- commit('RES', post)
159
+ commit(action, post)
147
160
  end
148
161
 
149
162
  # Verify and transfer the specified amount.
@@ -179,7 +192,7 @@ module ActiveMerchant #:nodoc:
179
192
  # Credit the specified account by a specific amount.
180
193
  def credit(money, identification_or_credit_card, options = {})
181
194
  if reference_transaction?(identification_or_credit_card)
182
- deprecated CREDIT_DEPRECATION_MESSAGE
195
+ ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
183
196
  # Referenced credit: refund of a settled transaction
184
197
  refund(money, identification_or_credit_card, options)
185
198
  else # must be a credit card or card reference
@@ -192,14 +205,33 @@ module ActiveMerchant #:nodoc:
192
205
  perform_reference_credit(money, reference, options)
193
206
  end
194
207
 
208
+ def verify(credit_card, options={})
209
+ MultiResponse.run(:use_first_response) do |r|
210
+ r.process { authorize(100, credit_card, options) }
211
+ r.process(:ignore_result) { void(r.authorization, options) }
212
+ end
213
+ end
214
+
195
215
  # Store a credit card by creating an Ogone Alias
196
216
  def store(payment_source, options = {})
197
217
  options.merge!(:alias_operation => 'BYPSP') unless(options.has_key?(:billing_id) || options.has_key?(:store))
198
- response = authorize(1, payment_source, options)
218
+ response = authorize(@options[:store_amount] || 1, payment_source, options)
199
219
  void(response.authorization) if response.success?
200
220
  response
201
221
  end
202
222
 
223
+ def supports_scrubbing?
224
+ true
225
+ end
226
+
227
+ def scrub(transcript)
228
+ transcript.
229
+ gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
230
+ gsub(%r((&?cardno=)[^&]*)i, '\1[FILTERED]').
231
+ gsub(%r((&?cvc=)[^&]*)i, '\1[FILTERED]').
232
+ gsub(%r((&?pswd=)[^&]*)i, '\1[FILTERED]')
233
+ end
234
+
203
235
  private
204
236
 
205
237
  def reference_from(authorization)
@@ -231,17 +263,18 @@ module ActiveMerchant #:nodoc:
231
263
  end
232
264
 
233
265
  def add_payment_source(post, payment_source, options)
266
+ add_d3d(post, options) if options[:d3d]
267
+
234
268
  if payment_source.is_a?(String)
235
269
  add_alias(post, payment_source, options[:alias_operation])
236
270
  add_eci(post, options[:eci] || '9')
237
271
  else
238
272
  if options.has_key?(:store)
239
- deprecated OGONE_STORE_OPTION_DEPRECATION_MESSAGE
273
+ ActiveMerchant.deprecated OGONE_STORE_OPTION_DEPRECATION_MESSAGE
240
274
  options[:billing_id] ||= options[:store]
241
275
  end
242
276
  add_alias(post, options[:billing_id], options[:alias_operation])
243
277
  add_eci(post, options[:eci] || '7')
244
- add_d3d(post, options) if options[:d3d]
245
278
  add_creditcard(post, payment_source)
246
279
  end
247
280
  end
@@ -258,6 +291,8 @@ module ActiveMerchant #:nodoc:
258
291
  add_pair post, 'ACCEPTURL', options[:accept_url] if options[:accept_url]
259
292
  add_pair post, 'DECLINEURL', options[:decline_url] if options[:decline_url]
260
293
  add_pair post, 'EXCEPTIONURL', options[:exception_url] if options[:exception_url]
294
+ add_pair post, 'CANCELURL', options[:cancel_url] if options[:cancel_url]
295
+ add_pair post, 'PARAMVAR', options[:paramvar] if options[:paramvar]
261
296
  add_pair post, 'PARAMPLUS', options[:paramplus] if options[:paramplus]
262
297
  add_pair post, 'COMPLUS', options[:complus] if options[:complus]
263
298
  add_pair post, 'LANGUAGE', options[:language] if options[:language]
@@ -298,6 +333,7 @@ module ActiveMerchant #:nodoc:
298
333
  def add_invoice(post, options)
299
334
  add_pair post, 'orderID', options[:order_id] || generate_unique_id[0...30]
300
335
  add_pair post, 'COM', options[:description]
336
+ add_pair post, 'ORIG', options[:origin] if options[:origin]
301
337
  end
302
338
 
303
339
  def add_creditcard(post, creditcard)
@@ -321,6 +357,7 @@ module ActiveMerchant #:nodoc:
321
357
  end
322
358
 
323
359
  def commit(action, parameters)
360
+ add_pair parameters, 'RTIMEOUT', @options[:timeout] if @options[:timeout]
324
361
  add_pair parameters, 'PSPID', @options[:login]
325
362
  add_pair parameters, 'USERID', @options[:user]
326
363
  add_pair parameters, 'PSWD', @options[:password]
@@ -372,27 +409,48 @@ module ActiveMerchant #:nodoc:
372
409
 
373
410
  def add_signature(parameters)
374
411
  if @options[:signature].blank?
375
- deprecated(OGONE_NO_SIGNATURE_DEPRECATION_MESSAGE) unless(@options[:signature_encryptor] == "none")
412
+ ActiveMerchant.deprecated(OGONE_NO_SIGNATURE_DEPRECATION_MESSAGE) unless(@options[:signature_encryptor] == "none")
376
413
  return
377
414
  end
378
415
 
379
- sha_encryptor = case @options[:signature_encryptor]
380
- when 'sha256'
381
- Digest::SHA256
382
- when 'sha512'
383
- Digest::SHA512
384
- else
385
- Digest::SHA1
386
- end
387
-
388
- string_to_digest = if @options[:signature_encryptor]
389
- parameters.sort { |a, b| a[0].upcase <=> b[0].upcase }.map { |k, v| "#{k.upcase}=#{v}" }.join(@options[:signature])
416
+ add_pair parameters, 'SHASign', calculate_signature(parameters, @options[:signature_encryptor], @options[:signature])
417
+ end
418
+
419
+ def calculate_signature(signed_parameters, algorithm, secret)
420
+ return legacy_calculate_signature(signed_parameters, secret) unless algorithm
421
+
422
+ sha_encryptor = case algorithm
423
+ when 'sha256'
424
+ Digest::SHA256
425
+ when 'sha512'
426
+ Digest::SHA512
427
+ when 'sha1'
428
+ Digest::SHA1
390
429
  else
391
- %w[orderID amount currency CARDNO PSPID Operation ALIAS].map { |key| parameters[key] }.join
430
+ raise "Unknown signature algorithm #{algorithm}"
392
431
  end
393
- string_to_digest << @options[:signature]
394
432
 
395
- add_pair parameters, 'SHASign', sha_encryptor.hexdigest(string_to_digest).upcase
433
+ filtered_params = signed_parameters.select{|k,v| !v.blank?}
434
+ sha_encryptor.hexdigest(
435
+ filtered_params.sort_by{|k,v| k.upcase}.map{|k, v| "#{k.upcase}=#{v}#{secret}"}.join("")
436
+ ).upcase
437
+ end
438
+
439
+ def legacy_calculate_signature(parameters, secret)
440
+ Digest::SHA1.hexdigest(
441
+ (
442
+ %w(
443
+ orderID
444
+ amount
445
+ currency
446
+ CARDNO
447
+ PSPID
448
+ Operation
449
+ ALIAS
450
+ ).map{|key| parameters[key]} +
451
+ [secret]
452
+ ).join("")
453
+ ).upcase
396
454
  end
397
455
 
398
456
  def add_pair(post, key, value)
@@ -0,0 +1,324 @@
1
+ require 'active_merchant/billing/rails'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ class OmiseGateway < Gateway
6
+ API_URL = 'https://api.omise.co/'
7
+ VAULT_URL = 'https://vault.omise.co/'
8
+
9
+ STANDARD_ERROR_CODE_MAPPING = {
10
+ 'invalid_security_code' => STANDARD_ERROR_CODE[:invalid_cvc],
11
+ 'failed_capture' => STANDARD_ERROR_CODE[:card_declined]
12
+ }
13
+
14
+ self.live_url = self.test_url = API_URL
15
+
16
+ # Currency supported by Omise
17
+ # * Thai Baht with Satang, 50000 (THB500.00)
18
+ # * Japanese Yen, 500 (JPY500)
19
+ self.default_currency = 'THB'
20
+ self.money_format = :cents
21
+
22
+ #Country supported by Omise
23
+ # * Thailand
24
+ self.supported_countries = %w( TH JP )
25
+
26
+ # Credit cards supported by Omise
27
+ # * VISA
28
+ # * MasterCard
29
+ # * JCB
30
+ self.supported_cardtypes = [:visa, :master, :jcb]
31
+
32
+ # Omise main page
33
+ self.homepage_url = 'https://www.omise.co/'
34
+ self.display_name = 'Omise'
35
+
36
+ # Creates a new OmiseGateway.
37
+ #
38
+ # Omise requires public_key for token creation.
39
+ # And it requires secret_key for other transactions.
40
+ # These keys can be found in https://dashboard.omise.co/test/api-keys
41
+ #
42
+ # ==== Options
43
+ #
44
+ # * <tt>:public_key</tt> -- Omise's public key (REQUIRED).
45
+ # * <tt>:secret_key</tt> -- Omise's secret key (REQUIRED).
46
+ # * <tt>:api_version</tt> -- Omise's API Version (OPTIONAL), default version is '2014-07-27'
47
+ # See version at page https://dashboard.omise.co/api-version/edit
48
+
49
+ def initialize(options={})
50
+ requires!(options, :public_key, :secret_key)
51
+ @public_key = options[:public_key]
52
+ @secret_key = options[:secret_key]
53
+ @api_version = options[:api_version]
54
+ super
55
+ end
56
+
57
+ # Perform a purchase (with auto capture)
58
+ #
59
+ # ==== Parameters
60
+ #
61
+ # * <tt>money</tt> -- The purchasing amount in Thai Baht Satang
62
+ # * <tt>payment_method</tt> -- The CreditCard object
63
+ # * <tt>options</tt> -- An optional parameters, such as token from Omise.js
64
+ #
65
+ # ==== Options
66
+ # * <tt>token_id</tt> -- token id, use Omise.js library to retrieve a token id
67
+ # if this is passed as an option, it will ignore tokenizing via Omisevaultgateway object
68
+ #
69
+ # === Example
70
+ # To create a charge on a card
71
+ #
72
+ # purchase(money, Creditcard_object)
73
+ #
74
+ # To create a charge on a token
75
+ #
76
+ # purchase(money, nil, { :token_id => token_id, ... })
77
+ #
78
+ # To create a charge on a customer
79
+ #
80
+ # purchase(money, nil, { :customer_id => customer_id })
81
+
82
+ def purchase(money, payment_method, options={})
83
+ create_charge(money, payment_method, options)
84
+ end
85
+
86
+ # Authorize a charge.
87
+ #
88
+ # ==== Parameters
89
+ #
90
+ # * <tt>money</tt> -- The purchasing amount in Thai Baht Satang
91
+ # * <tt>payment_method</tt> -- The CreditCard object
92
+ # * <tt>options</tt> -- An optional parameters, such as token or capture
93
+
94
+ def authorize(money, payment_method, options={})
95
+ options[:capture] = 'false'
96
+ create_charge(money, payment_method, options)
97
+ end
98
+
99
+ # Capture an authorized charge.
100
+ #
101
+ # ==== Parameters
102
+ #
103
+ # * <tt>money</tt> -- An amount in Thai Baht Satang
104
+ # * <tt>charge_id</tt> -- The CreditCard object
105
+ # * <tt>options</tt> -- An optional parameters, such as token or capture
106
+
107
+ def capture(money, charge_id, options={})
108
+ post = {}
109
+ add_amount(post, money, options)
110
+ commit(:post, "charges/#{CGI.escape(charge_id)}/capture", post, options)
111
+ end
112
+
113
+ # Refund a charge.
114
+ #
115
+ # ==== Parameters
116
+ #
117
+ # * <tt>money</tt> -- An amount of money to charge in Satang.
118
+ # * <tt>charge_id</tt> -- The CreditCard object
119
+ # * <tt>options</tt> -- An optional parameters, such as token or capture
120
+
121
+ def refund(money, charge_id, options={})
122
+ options[:amount] = money if money
123
+ commit(:post, "charges/#{CGI.escape(charge_id)}/refunds", options)
124
+ end
125
+
126
+ # Store a card details as customer
127
+ #
128
+ # ==== Parameters
129
+ #
130
+ # * <tt>payment_method</tt> -- The CreditCard.
131
+ # * <tt>options</tt> -- Optional Customer information:
132
+ # 'email' (A customer email)
133
+ # 'description' (A customer description)
134
+
135
+ def store(payment_method, options={})
136
+ post, card_params = {}, {}
137
+ add_customer_data(post, options)
138
+ add_token(card_params, payment_method, options)
139
+ commit(:post, 'customers', post.merge(card_params), options)
140
+ end
141
+
142
+ # Delete a customer and all associated credit cards.
143
+ #
144
+ # ==== Parameters
145
+ #
146
+ # * <tt>customer_id</tt> -- The Customer identifier (REQUIRED).
147
+
148
+ def unstore(customer_id, options={})
149
+ commit(:delete, "customers/#{CGI.escape(customer_id)}")
150
+ end
151
+
152
+ # Enable scrubbing sensitive information
153
+ def supports_scrubbing?
154
+ true
155
+ end
156
+
157
+ # Scrub sensitive information out of HTTP transcripts
158
+ #
159
+ # ==== Parameters
160
+ #
161
+ # * <tt>transcript</tt> -- The HTTP transcripts
162
+
163
+ def scrub(transcript)
164
+ transcript.
165
+ gsub(/(Authorization: Basic )\w+/i, '\1[FILTERED]').
166
+ gsub(/(\\"number\\":)\\"\d+\\"/, '\1[FILTERED]').
167
+ gsub(/(\\"security_code\\":)\\"\d+\\"/,'\1[FILTERED]')
168
+ end
169
+
170
+ private
171
+
172
+ def create_charge(money, payment_method, options)
173
+ post = {}
174
+ add_token(post, payment_method, options)
175
+ add_amount(post, money, options)
176
+ add_customer(post, options)
177
+ post[:capture] = options[:capture] if options[:capture]
178
+ commit(:post, 'charges', post, options)
179
+ end
180
+
181
+ def headers(options={})
182
+ key = options[:key] || @secret_key
183
+ {
184
+ 'Content-Type' => 'application/json;utf-8',
185
+ 'Omise-Version' => @api_version || "2014-07-27",
186
+ 'User-Agent' => "ActiveMerchantBindings/#{ActiveMerchant::VERSION} Ruby/#{RUBY_VERSION}",
187
+ 'Authorization' => 'Basic ' + Base64.encode64(key.to_s + ':').strip,
188
+ 'Accept-Encoding' => 'utf-8'
189
+ }
190
+ end
191
+
192
+ def url_for(endpoint)
193
+ (endpoint == 'tokens' ? VAULT_URL : API_URL) + endpoint
194
+ end
195
+
196
+ def post_data(parameters)
197
+ parameters.present? ? parameters.to_json : nil
198
+ end
199
+
200
+ def https_request(method, endpoint, parameters=nil, options={})
201
+ raw_response = response = nil
202
+ begin
203
+ raw_response = ssl_request(method, url_for(endpoint), post_data(parameters), headers(options))
204
+ response = parse(raw_response)
205
+ rescue ResponseError => e
206
+ raw_response = e.response.body
207
+ response = parse(raw_response)
208
+ rescue JSON::ParserError
209
+ response = json_error(raw_response)
210
+ end
211
+ response
212
+ end
213
+
214
+ def parse(body)
215
+ JSON.parse(body)
216
+ end
217
+
218
+ def json_error(raw_response)
219
+ msg = "Invalid response received from Omise API. Please contact support@omise.co if you continue to receive this message."
220
+ msg += "The raw response returned by the API was #{raw_response.inspect})"
221
+ { message: msg }
222
+ end
223
+
224
+ def commit(method, endpoint, params=nil, options={})
225
+ response = https_request(method, endpoint, params, options)
226
+ Response.new(
227
+ successful?(response),
228
+ message_from(response),
229
+ response,
230
+ {
231
+ authorization: authorization_from(response),
232
+ test: test?,
233
+ error_code: successful?(response) ? nil : standard_error_code_mapping(response)
234
+ }
235
+ )
236
+ end
237
+
238
+ def standard_error_code_mapping(response)
239
+ STANDARD_ERROR_CODE_MAPPING[error_code_from(response)] || message_to_standard_error_code_from(response)
240
+ end
241
+
242
+ def error_code_from(response)
243
+ error?(response) ? response['code'] : response['failure_code']
244
+ end
245
+
246
+ def message_to_standard_error_code_from(response)
247
+ message = response['message'] if response['code'] == 'invalid_card'
248
+ case message
249
+ when /brand not supported/
250
+ STANDARD_ERROR_CODE[:invalid_number]
251
+ when /number is invalid/
252
+ STANDARD_ERROR_CODE[:incorrect_number]
253
+ when /expiration date cannot be in the past/
254
+ STANDARD_ERROR_CODE[:expired_card]
255
+ when /expiration \w+ is invalid/
256
+ STANDARD_ERROR_CODE[:invalid_expiry_date]
257
+ else
258
+ STANDARD_ERROR_CODE[:processing_error]
259
+ end
260
+ end
261
+
262
+ def message_from(response)
263
+ if successful?(response)
264
+ 'Success'
265
+ else
266
+ (response['message'] ? response['message'] : response['failure_message'])
267
+ end
268
+ end
269
+
270
+ def authorization_from(response)
271
+ response['id'] if successful?(response)
272
+ end
273
+
274
+ def successful?(response)
275
+ !error?(response) && response['failure_code'].nil?
276
+ end
277
+
278
+ def error?(response)
279
+ response.key?('object') && (response['object'] == 'error')
280
+ end
281
+
282
+ def get_token(post, credit_card)
283
+ add_creditcard(post, credit_card) if credit_card
284
+ commit(:post, 'tokens', post, { key: @public_key })
285
+ end
286
+
287
+ def add_token(post, credit_card, options={})
288
+ if options[:token_id].present?
289
+ post[:card] = options[:token_id]
290
+ else
291
+ response = get_token(post, credit_card)
292
+ response.authorization ? (post[:card] = response.authorization) : response
293
+ end
294
+ end
295
+
296
+ def add_creditcard(post, payment_method)
297
+ card = {
298
+ number: payment_method.number,
299
+ name: payment_method.name,
300
+ security_code: payment_method.verification_value,
301
+ expiration_month: payment_method.month,
302
+ expiration_year: payment_method.year
303
+ }
304
+ post[:card] = card
305
+ end
306
+
307
+ def add_customer(post, options={})
308
+ post[:customer] = options[:customer_id] if options[:customer_id]
309
+ end
310
+
311
+ def add_customer_data(post, options={})
312
+ post[:description] = options[:description] if options[:description]
313
+ post[:email] = options[:email] if options[:email]
314
+ end
315
+
316
+ def add_amount(post, money, options)
317
+ post[:amount] = amount(money)
318
+ post[:currency] = (options[:currency] || currency(money))
319
+ post[:description] = options[:description] if options.key?(:description)
320
+ end
321
+
322
+ end
323
+ end
324
+ end