swiss-crm-activemerchant 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (287) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +4033 -0
  3. data/CONTRIBUTORS +568 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.md +252 -0
  6. data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
  7. data/lib/active_merchant/billing/avs_result.rb +95 -0
  8. data/lib/active_merchant/billing/base.rb +48 -0
  9. data/lib/active_merchant/billing/check.rb +112 -0
  10. data/lib/active_merchant/billing/compatibility.rb +118 -0
  11. data/lib/active_merchant/billing/credit_card.rb +451 -0
  12. data/lib/active_merchant/billing/credit_card_formatting.rb +24 -0
  13. data/lib/active_merchant/billing/credit_card_methods.rb +512 -0
  14. data/lib/active_merchant/billing/cvv_result.rb +37 -0
  15. data/lib/active_merchant/billing/gateway.rb +332 -0
  16. data/lib/active_merchant/billing/gateways/adyen.rb +774 -0
  17. data/lib/active_merchant/billing/gateways/airwallex.rb +370 -0
  18. data/lib/active_merchant/billing/gateways/alelo.rb +256 -0
  19. data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
  20. data/lib/active_merchant/billing/gateways/authorize_net.rb +1125 -0
  21. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +424 -0
  22. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +977 -0
  23. data/lib/active_merchant/billing/gateways/axcessms.rb +242 -0
  24. data/lib/active_merchant/billing/gateways/balanced.rb +263 -0
  25. data/lib/active_merchant/billing/gateways/bambora_apac.rb +222 -0
  26. data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
  27. data/lib/active_merchant/billing/gateways/banwire.rb +116 -0
  28. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +397 -0
  29. data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +15 -0
  30. data/lib/active_merchant/billing/gateways/be2bill.rb +131 -0
  31. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +474 -0
  32. data/lib/active_merchant/billing/gateways/beanstream.rb +238 -0
  33. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +57 -0
  34. data/lib/active_merchant/billing/gateways/blue_pay.rb +549 -0
  35. data/lib/active_merchant/billing/gateways/blue_snap.rb +644 -0
  36. data/lib/active_merchant/billing/gateways/bogus.rb +190 -0
  37. data/lib/active_merchant/billing/gateways/borgun.rb +272 -0
  38. data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
  39. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +28 -0
  40. data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
  41. data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
  42. data/lib/active_merchant/billing/gateways/braintree_blue.rb +952 -0
  43. data/lib/active_merchant/billing/gateways/braintree_orange.rb +19 -0
  44. data/lib/active_merchant/billing/gateways/bridge_pay.rb +244 -0
  45. data/lib/active_merchant/billing/gateways/cams.rb +230 -0
  46. data/lib/active_merchant/billing/gateways/card_connect.rb +338 -0
  47. data/lib/active_merchant/billing/gateways/card_save.rb +21 -0
  48. data/lib/active_merchant/billing/gateways/card_stream.rb +394 -0
  49. data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
  50. data/lib/active_merchant/billing/gateways/cardprocess.rb +256 -0
  51. data/lib/active_merchant/billing/gateways/cashnet.rb +235 -0
  52. data/lib/active_merchant/billing/gateways/cc5.rb +198 -0
  53. data/lib/active_merchant/billing/gateways/cecabank.rb +249 -0
  54. data/lib/active_merchant/billing/gateways/cenpos.rb +328 -0
  55. data/lib/active_merchant/billing/gateways/checkout.rb +212 -0
  56. data/lib/active_merchant/billing/gateways/checkout_v2.rb +587 -0
  57. data/lib/active_merchant/billing/gateways/citrus_pay.rb +21 -0
  58. data/lib/active_merchant/billing/gateways/clearhaus.rb +219 -0
  59. data/lib/active_merchant/billing/gateways/commerce_hub.rb +366 -0
  60. data/lib/active_merchant/billing/gateways/commercegate.rb +142 -0
  61. data/lib/active_merchant/billing/gateways/conekta.rb +230 -0
  62. data/lib/active_merchant/billing/gateways/creditcall.rb +272 -0
  63. data/lib/active_merchant/billing/gateways/credorax.rb +526 -0
  64. data/lib/active_merchant/billing/gateways/ct_payment.rb +269 -0
  65. data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
  66. data/lib/active_merchant/billing/gateways/cyber_source/cyber_source_common.rb +36 -0
  67. data/lib/active_merchant/billing/gateways/cyber_source.rb +1148 -0
  68. data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +454 -0
  69. data/lib/active_merchant/billing/gateways/d_local.rb +343 -0
  70. data/lib/active_merchant/billing/gateways/data_cash.rb +302 -0
  71. data/lib/active_merchant/billing/gateways/decidir.rb +358 -0
  72. data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
  73. data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
  74. data/lib/active_merchant/billing/gateways/digitzs.rb +295 -0
  75. data/lib/active_merchant/billing/gateways/ebanx.rb +346 -0
  76. data/lib/active_merchant/billing/gateways/efsnet.rb +215 -0
  77. data/lib/active_merchant/billing/gateways/elavon.rb +475 -0
  78. data/lib/active_merchant/billing/gateways/element.rb +406 -0
  79. data/lib/active_merchant/billing/gateways/epay.rb +296 -0
  80. data/lib/active_merchant/billing/gateways/evo_ca.rb +307 -0
  81. data/lib/active_merchant/billing/gateways/eway.rb +226 -0
  82. data/lib/active_merchant/billing/gateways/eway_managed.rb +289 -0
  83. data/lib/active_merchant/billing/gateways/eway_rapid.rb +578 -0
  84. data/lib/active_merchant/billing/gateways/exact.rb +219 -0
  85. data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
  86. data/lib/active_merchant/billing/gateways/fat_zebra.rb +223 -0
  87. data/lib/active_merchant/billing/gateways/federated_canada.rb +158 -0
  88. data/lib/active_merchant/billing/gateways/finansbank.rb +22 -0
  89. data/lib/active_merchant/billing/gateways/first_giving.rb +143 -0
  90. data/lib/active_merchant/billing/gateways/first_pay.rb +182 -0
  91. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +452 -0
  92. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +505 -0
  93. data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
  94. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
  95. data/lib/active_merchant/billing/gateways/fluidpay.rb +275 -0
  96. data/lib/active_merchant/billing/gateways/forte.rb +286 -0
  97. data/lib/active_merchant/billing/gateways/garanti.rb +256 -0
  98. data/lib/active_merchant/billing/gateways/global_collect.rb +580 -0
  99. data/lib/active_merchant/billing/gateways/global_transport.rb +193 -0
  100. data/lib/active_merchant/billing/gateways/hdfc.rb +205 -0
  101. data/lib/active_merchant/billing/gateways/hps.rb +472 -0
  102. data/lib/active_merchant/billing/gateways/iats_payments.rb +312 -0
  103. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
  104. data/lib/active_merchant/billing/gateways/inspire.rb +213 -0
  105. data/lib/active_merchant/billing/gateways/instapay.rb +159 -0
  106. data/lib/active_merchant/billing/gateways/ipg.rb +420 -0
  107. data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
  108. data/lib/active_merchant/billing/gateways/iridium.rb +467 -0
  109. data/lib/active_merchant/billing/gateways/itransact.rb +448 -0
  110. data/lib/active_merchant/billing/gateways/iveri.rb +290 -0
  111. data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
  112. data/lib/active_merchant/billing/gateways/jetpay.rb +395 -0
  113. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +432 -0
  114. data/lib/active_merchant/billing/gateways/klarna.rb +317 -0
  115. data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
  116. data/lib/active_merchant/billing/gateways/kushki.rb +297 -0
  117. data/lib/active_merchant/billing/gateways/latitude19.rb +412 -0
  118. data/lib/active_merchant/billing/gateways/linkpoint.rb +448 -0
  119. data/lib/active_merchant/billing/gateways/litle.rb +643 -0
  120. data/lib/active_merchant/billing/gateways/mastercard.rb +286 -0
  121. data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
  122. data/lib/active_merchant/billing/gateways/mercado_pago.rb +348 -0
  123. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +228 -0
  124. data/lib/active_merchant/billing/gateways/merchant_one.rb +110 -0
  125. data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
  126. data/lib/active_merchant/billing/gateways/merchant_ware.rb +313 -0
  127. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +284 -0
  128. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +248 -0
  129. data/lib/active_merchant/billing/gateways/mercury.rb +352 -0
  130. data/lib/active_merchant/billing/gateways/metrics_global.rb +293 -0
  131. data/lib/active_merchant/billing/gateways/micropayment.rb +182 -0
  132. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
  133. data/lib/active_merchant/billing/gateways/migs.rb +329 -0
  134. data/lib/active_merchant/billing/gateways/mit.rb +260 -0
  135. data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
  136. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +215 -0
  137. data/lib/active_merchant/billing/gateways/moka.rb +290 -0
  138. data/lib/active_merchant/billing/gateways/monei.rb +424 -0
  139. data/lib/active_merchant/billing/gateways/moneris.rb +488 -0
  140. data/lib/active_merchant/billing/gateways/money_movers.rb +150 -0
  141. data/lib/active_merchant/billing/gateways/mundipagg.rb +366 -0
  142. data/lib/active_merchant/billing/gateways/nab_transact.rb +299 -0
  143. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +163 -0
  144. data/lib/active_merchant/billing/gateways/net_registry.rb +198 -0
  145. data/lib/active_merchant/billing/gateways/netaxept.rb +180 -0
  146. data/lib/active_merchant/billing/gateways/netbanx.rb +376 -0
  147. data/lib/active_merchant/billing/gateways/netbilling.rb +229 -0
  148. data/lib/active_merchant/billing/gateways/netpay.rb +223 -0
  149. data/lib/active_merchant/billing/gateways/network_merchants.rb +238 -0
  150. data/lib/active_merchant/billing/gateways/nmi.rb +396 -0
  151. data/lib/active_merchant/billing/gateways/ogone.rb +509 -0
  152. data/lib/active_merchant/billing/gateways/omise.rb +323 -0
  153. data/lib/active_merchant/billing/gateways/openpay.rb +246 -0
  154. data/lib/active_merchant/billing/gateways/opp.rb +394 -0
  155. data/lib/active_merchant/billing/gateways/optimal_payment.rb +331 -0
  156. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +45 -0
  157. data/lib/active_merchant/billing/gateways/orbital.rb +1267 -0
  158. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +206 -0
  159. data/lib/active_merchant/billing/gateways/pagarme.rb +239 -0
  160. data/lib/active_merchant/billing/gateways/pago_facil.rb +120 -0
  161. data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
  162. data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
  163. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +277 -0
  164. data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
  165. data/lib/active_merchant/billing/gateways/pay_junction.rb +390 -0
  166. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +206 -0
  167. data/lib/active_merchant/billing/gateways/pay_secure.rb +110 -0
  168. data/lib/active_merchant/billing/gateways/pay_trace.rb +450 -0
  169. data/lib/active_merchant/billing/gateways/paybox_direct.rb +224 -0
  170. data/lib/active_merchant/billing/gateways/payeezy.rb +513 -0
  171. data/lib/active_merchant/billing/gateways/payex.rb +409 -0
  172. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +235 -0
  173. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +42 -0
  174. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
  175. data/lib/active_merchant/billing/gateways/payflow.rb +473 -0
  176. data/lib/active_merchant/billing/gateways/payflow_express.rb +220 -0
  177. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +14 -0
  178. data/lib/active_merchant/billing/gateways/payflow_uk.rb +20 -0
  179. data/lib/active_merchant/billing/gateways/payment_express.rb +373 -0
  180. data/lib/active_merchant/billing/gateways/paymentez.rb +365 -0
  181. data/lib/active_merchant/billing/gateways/paymill.rb +369 -0
  182. data/lib/active_merchant/billing/gateways/paynetworx.rb +228 -0
  183. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +718 -0
  184. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +69 -0
  185. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -0
  186. data/lib/active_merchant/billing/gateways/paypal.rb +136 -0
  187. data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
  188. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +44 -0
  189. data/lib/active_merchant/billing/gateways/paypal_express.rb +272 -0
  190. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
  191. data/lib/active_merchant/billing/gateways/paypal_standard.rb +281 -0
  192. data/lib/active_merchant/billing/gateways/paysafe.rb +420 -0
  193. data/lib/active_merchant/billing/gateways/payscout.rb +159 -0
  194. data/lib/active_merchant/billing/gateways/paystation.rb +204 -0
  195. data/lib/active_merchant/billing/gateways/payu_in.rb +249 -0
  196. data/lib/active_merchant/billing/gateways/payu_latam.rb +482 -0
  197. data/lib/active_merchant/billing/gateways/payway.rb +207 -0
  198. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
  199. data/lib/active_merchant/billing/gateways/pin.rb +273 -0
  200. data/lib/active_merchant/billing/gateways/pixxels.rb +263 -0
  201. data/lib/active_merchant/billing/gateways/plexo.rb +308 -0
  202. data/lib/active_merchant/billing/gateways/plugnpay.rb +283 -0
  203. data/lib/active_merchant/billing/gateways/priority.rb +392 -0
  204. data/lib/active_merchant/billing/gateways/pro_pay.rb +325 -0
  205. data/lib/active_merchant/billing/gateways/psigate.rb +227 -0
  206. data/lib/active_merchant/billing/gateways/psl_card.rb +295 -0
  207. data/lib/active_merchant/billing/gateways/qbms.rb +302 -0
  208. data/lib/active_merchant/billing/gateways/quantum.rb +274 -0
  209. data/lib/active_merchant/billing/gateways/quickbooks.rb +377 -0
  210. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
  211. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +297 -0
  212. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
  213. data/lib/active_merchant/billing/gateways/quickpay.rb +24 -0
  214. data/lib/active_merchant/billing/gateways/qvalent.rb +305 -0
  215. data/lib/active_merchant/billing/gateways/rapyd.rb +319 -0
  216. data/lib/active_merchant/billing/gateways/reach.rb +277 -0
  217. data/lib/active_merchant/billing/gateways/realex.rb +400 -0
  218. data/lib/active_merchant/billing/gateways/redsys.rb +723 -0
  219. data/lib/active_merchant/billing/gateways/s5.rb +247 -0
  220. data/lib/active_merchant/billing/gateways/safe_charge.rb +298 -0
  221. data/lib/active_merchant/billing/gateways/sage.rb +446 -0
  222. data/lib/active_merchant/billing/gateways/sage_pay.rb +434 -0
  223. data/lib/active_merchant/billing/gateways/sallie_mae.rb +141 -0
  224. data/lib/active_merchant/billing/gateways/secure_net.rb +260 -0
  225. data/lib/active_merchant/billing/gateways/secure_pay.rb +191 -0
  226. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +290 -0
  227. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +103 -0
  228. data/lib/active_merchant/billing/gateways/securion_pay.rb +305 -0
  229. data/lib/active_merchant/billing/gateways/shift4.rb +345 -0
  230. data/lib/active_merchant/billing/gateways/simetrik.rb +368 -0
  231. data/lib/active_merchant/billing/gateways/skip_jack.rb +450 -0
  232. data/lib/active_merchant/billing/gateways/smart_ps.rb +274 -0
  233. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
  234. data/lib/active_merchant/billing/gateways/spreedly_core.rb +354 -0
  235. data/lib/active_merchant/billing/gateways/stripe.rb +866 -0
  236. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +602 -0
  237. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +151 -0
  238. data/lib/active_merchant/billing/gateways/telr.rb +273 -0
  239. data/lib/active_merchant/billing/gateways/tns.rb +23 -0
  240. data/lib/active_merchant/billing/gateways/trans_first.rb +240 -0
  241. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +612 -0
  242. data/lib/active_merchant/billing/gateways/transact_pro.rb +222 -0
  243. data/lib/active_merchant/billing/gateways/transax.rb +21 -0
  244. data/lib/active_merchant/billing/gateways/transnational.rb +9 -0
  245. data/lib/active_merchant/billing/gateways/trexle.rb +221 -0
  246. data/lib/active_merchant/billing/gateways/trust_commerce.rb +500 -0
  247. data/lib/active_merchant/billing/gateways/usa_epay.rb +24 -0
  248. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1612 -0
  249. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +367 -0
  250. data/lib/active_merchant/billing/gateways/vanco.rb +303 -0
  251. data/lib/active_merchant/billing/gateways/verifi.rb +224 -0
  252. data/lib/active_merchant/billing/gateways/viaklix.rb +171 -0
  253. data/lib/active_merchant/billing/gateways/visanet_peru.rb +250 -0
  254. data/lib/active_merchant/billing/gateways/vpos.rb +223 -0
  255. data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
  256. data/lib/active_merchant/billing/gateways/wepay.rb +235 -0
  257. data/lib/active_merchant/billing/gateways/wirecard.rb +430 -0
  258. data/lib/active_merchant/billing/gateways/wompi.rb +197 -0
  259. data/lib/active_merchant/billing/gateways/world_net.rb +345 -0
  260. data/lib/active_merchant/billing/gateways/worldpay.rb +1050 -0
  261. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +208 -0
  262. data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
  263. data/lib/active_merchant/billing/gateways.rb +14 -0
  264. data/lib/active_merchant/billing/model.rb +30 -0
  265. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
  266. data/lib/active_merchant/billing/payment_token.rb +21 -0
  267. data/lib/active_merchant/billing/rails.rb +3 -0
  268. data/lib/active_merchant/billing/response.rb +121 -0
  269. data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
  270. data/lib/active_merchant/billing.rb +16 -0
  271. data/lib/active_merchant/connection.rb +194 -0
  272. data/lib/active_merchant/country.rb +338 -0
  273. data/lib/active_merchant/empty.rb +20 -0
  274. data/lib/active_merchant/errors.rb +38 -0
  275. data/lib/active_merchant/net_http_ssl_connection.rb +11 -0
  276. data/lib/active_merchant/network_connection_retries.rb +78 -0
  277. data/lib/active_merchant/post_data.rb +26 -0
  278. data/lib/active_merchant/posts_data.rb +92 -0
  279. data/lib/active_merchant/version.rb +3 -0
  280. data/lib/active_merchant.rb +63 -0
  281. data/lib/activemerchant.rb +1 -0
  282. data/lib/certs/cacert.pem +3214 -0
  283. data/lib/support/gateway_support.rb +69 -0
  284. data/lib/support/outbound_hosts.rb +28 -0
  285. data/lib/support/ssl_verify.rb +88 -0
  286. data/lib/support/ssl_version.rb +86 -0
  287. metadata +506 -0
@@ -0,0 +1,290 @@
1
+ require 'nokogiri'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ class IveriGateway < Gateway
6
+ class_attribute :iveri_url
7
+
8
+ self.live_url = self.test_url = 'https://portal.nedsecure.co.za/iVeriWebService/Service.asmx'
9
+ self.iveri_url = 'https://portal.host.iveri.com/iVeriWebService/Service.asmx'
10
+
11
+ self.supported_countries = %w[US ZA GB]
12
+ self.default_currency = 'ZAR'
13
+ self.money_format = :cents
14
+ self.supported_cardtypes = %i[visa master american_express]
15
+
16
+ self.homepage_url = 'http://www.iveri.com'
17
+ self.display_name = 'iVeri'
18
+
19
+ def initialize(options = {})
20
+ requires!(options, :app_id, :cert_id)
21
+ super
22
+ end
23
+
24
+ def purchase(money, payment_method, options = {})
25
+ post = build_vxml_request('Debit', options) do |xml|
26
+ add_auth_purchase_params(xml, money, payment_method, options)
27
+ end
28
+
29
+ commit(post)
30
+ end
31
+
32
+ def authorize(money, payment_method, options = {})
33
+ post = build_vxml_request('Authorisation', options) do |xml|
34
+ add_auth_purchase_params(xml, money, payment_method, options)
35
+ end
36
+
37
+ commit(post)
38
+ end
39
+
40
+ def capture(money, authorization, options = {})
41
+ post = build_vxml_request('Debit', options) do |xml|
42
+ add_authorization(xml, authorization, options)
43
+ end
44
+
45
+ commit(post)
46
+ end
47
+
48
+ def refund(money, authorization, options = {})
49
+ post = build_vxml_request('Credit', options) do |xml|
50
+ add_amount(xml, money, options)
51
+ add_authorization(xml, authorization, options)
52
+ end
53
+
54
+ commit(post)
55
+ end
56
+
57
+ def void(authorization, options = {})
58
+ post = build_vxml_request('Void', options) do |xml|
59
+ add_authorization(xml, authorization, options)
60
+ end
61
+
62
+ commit(post)
63
+ end
64
+
65
+ def verify(credit_card, options = {})
66
+ MultiResponse.run(:use_first_response) do |r|
67
+ r.process { authorize(100, credit_card, options) }
68
+ r.process(:ignore_result) { void(r.authorization, options) }
69
+ end
70
+ end
71
+
72
+ def verify_credentials
73
+ void = void('', options)
74
+ return true if void.message == 'Missing OriginalMerchantTrace'
75
+
76
+ false
77
+ end
78
+
79
+ def supports_scrubbing?
80
+ true
81
+ end
82
+
83
+ def scrub(transcript)
84
+ transcript.
85
+ gsub(%r((CertificateID=\\\")[^\\]*), '\1[FILTERED]').
86
+ gsub(%r((&lt;PAN&gt;)[^&]*), '\1[FILTERED]').
87
+ gsub(%r((&lt;CardSecurityCode&gt;)[^&]*), '\1[FILTERED]')
88
+ end
89
+
90
+ private
91
+
92
+ def build_xml_envelope(vxml)
93
+ builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
94
+ xml[:soap].Envelope 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/' do
95
+ xml[:soap].Body do
96
+ xml.Execute 'xmlns' => 'http://iveri.com/' do
97
+ xml.validateRequest('false')
98
+ xml.protocol 'V_XML'
99
+ xml.protocolVersion '2.0'
100
+ xml.request vxml
101
+ end
102
+ end
103
+ end
104
+ end
105
+
106
+ builder.to_xml
107
+ end
108
+
109
+ def build_vxml_request(action, options)
110
+ builder = Nokogiri::XML::Builder.new do |xml|
111
+ xml.V_XML('Version' => '2.0', 'CertificateID' => @options[:cert_id], 'Direction' => 'Request') do
112
+ xml.Transaction('ApplicationID' => @options[:app_id], 'Command' => action, 'Mode' => mode) do
113
+ yield(xml)
114
+ end
115
+ end
116
+ end
117
+
118
+ builder.doc.root.to_xml
119
+ end
120
+
121
+ def add_auth_purchase_params(post, money, payment_method, options)
122
+ add_card_holder_authentication(post, options)
123
+ add_amount(post, money, options)
124
+ add_electronic_commerce_indicator(post, options) unless options[:three_d_secure]
125
+ add_payment_method(post, payment_method, options)
126
+ add_three_ds(post, options)
127
+ end
128
+
129
+ def add_amount(post, money, options)
130
+ post.Amount(amount(money))
131
+ post.Currency(options[:currency] || default_currency)
132
+ end
133
+
134
+ def add_electronic_commerce_indicator(post, options)
135
+ post.ElectronicCommerceIndicator(options[:eci]) if options[:eci]
136
+ end
137
+
138
+ def add_authorization(post, authorization, options)
139
+ post.MerchantReference(split_auth(authorization)[2])
140
+ post.TransactionIndex(split_auth(authorization)[1])
141
+ post.OriginalRequestID(split_auth(authorization)[0])
142
+ end
143
+
144
+ def add_payment_method(post, payment_method, options)
145
+ post.ExpiryDate("#{format(payment_method.month, :two_digits)}#{payment_method.year}")
146
+ add_new_reference(post, options)
147
+ post.CardSecurityCode(payment_method.verification_value)
148
+ post.PAN(payment_method.number)
149
+ end
150
+
151
+ def add_new_reference(post, options)
152
+ post.MerchantReference(options[:order_id] || generate_unique_id)
153
+ end
154
+
155
+ def add_card_holder_authentication(post, options)
156
+ post.CardHolderAuthenticationID(options[:xid]) if options[:xid]
157
+ post.CardHolderAuthenticationData(options[:cavv]) if options[:cavv]
158
+ end
159
+
160
+ def commit(post)
161
+ raw_response =
162
+ begin
163
+ ssl_post(url, build_xml_envelope(post), headers(post))
164
+ rescue ActiveMerchant::ResponseError => e
165
+ e.response.body
166
+ end
167
+
168
+ parsed = parse(raw_response)
169
+ succeeded = success_from(parsed)
170
+
171
+ Response.new(
172
+ succeeded,
173
+ message_from(parsed, succeeded),
174
+ parsed,
175
+ authorization: authorization_from(parsed),
176
+ error_code: error_code_from(parsed, succeeded),
177
+ test: test?
178
+ )
179
+ end
180
+
181
+ def mode
182
+ test? ? 'Test' : 'Live'
183
+ end
184
+
185
+ def url
186
+ @options[:url_override].to_s == 'iveri' ? iveri_url : live_url
187
+ end
188
+
189
+ def headers(post)
190
+ {
191
+ 'Content-Type' => 'text/xml; charset=utf-8',
192
+ 'Content-Length' => post.size.to_s,
193
+ 'SOAPAction' => 'http://iveri.com/Execute'
194
+ }
195
+ end
196
+
197
+ def parse(body)
198
+ parsed = {}
199
+
200
+ vxml = Nokogiri::XML(body).remove_namespaces!.xpath('//Envelope/Body/ExecuteResponse/ExecuteResult').inner_text
201
+ doc = Nokogiri::XML(vxml)
202
+ doc.xpath('*').each do |node|
203
+ if node.elements.empty?
204
+ parsed[underscore(node.name)] = node.text
205
+ else
206
+ node.elements.each do |childnode|
207
+ parse_element(parsed, childnode)
208
+ end
209
+ end
210
+ end
211
+ parsed
212
+ end
213
+
214
+ def parse_element(parsed, node)
215
+ if !node.attributes.empty?
216
+ node.attributes.each do |a|
217
+ parsed[underscore(node.name) + '_' + underscore(a[1].name)] = a[1].value
218
+ end
219
+ end
220
+
221
+ if !node.elements.empty?
222
+ node.elements.each { |e| parse_element(parsed, e) }
223
+ else
224
+ parsed[underscore(node.name)] = node.text
225
+ end
226
+ end
227
+
228
+ def success_from(response)
229
+ response['result_status'] == '0'
230
+ end
231
+
232
+ def message_from(response, succeeded)
233
+ if succeeded
234
+ 'Succeeded'
235
+ else
236
+ response['result_description'] || response['result_acquirer_description']
237
+ end
238
+ end
239
+
240
+ def authorization_from(response)
241
+ "#{response['transaction_request_id']}|#{response['transaction_index']}|#{response['merchant_reference']}"
242
+ end
243
+
244
+ def split_auth(authorization)
245
+ request_id, transaction_index, merchant_reference = authorization.to_s.split('|')
246
+ [request_id, transaction_index, merchant_reference]
247
+ end
248
+
249
+ def error_code_from(response, succeeded)
250
+ response['result_code'] unless succeeded
251
+ end
252
+
253
+ def underscore(camel_cased_word)
254
+ camel_cased_word.to_s.gsub(/::/, '/').
255
+ gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
256
+ gsub(/([a-z\d])([A-Z])/, '\1_\2').
257
+ tr('-', '_').
258
+ downcase
259
+ end
260
+
261
+ def add_three_ds(post, options)
262
+ return unless three_d_secure = options[:three_d_secure]
263
+
264
+ post.ElectronicCommerceIndicator(formatted_three_ds_eci(three_d_secure[:eci])) if three_d_secure[:eci]
265
+ post.CardHolderAuthenticationID(three_d_secure[:xid]) if three_d_secure[:xid]
266
+ post.CardHolderAuthenticationData(three_d_secure[:cavv]) if three_d_secure[:cavv]
267
+ post.ThreeDSecure_ProtocolVersion(three_d_secure[:version]) if three_d_secure[:version]
268
+ post.ThreeDSecure_DSTransID(three_d_secure[:ds_transaction_id]) if three_d_secure[:ds_transaction_id]
269
+ post.ThreeDSecure_VEResEnrolled(formatted_enrollment(three_d_secure[:enrolled])) if three_d_secure[:enrolled]
270
+ end
271
+
272
+ def formatted_enrollment(val)
273
+ case val
274
+ when 'Y', 'N', 'U' then val
275
+ when true, 'true' then 'Y'
276
+ when false, 'false' then 'N'
277
+ end
278
+ end
279
+
280
+ def formatted_three_ds_eci(val)
281
+ case val
282
+ when '05', '02' then 'ThreeDSecure'
283
+ when '06', '01' then 'ThreeDSecureAttempted'
284
+ when '07' then 'SecureChannel'
285
+ else val
286
+ end
287
+ end
288
+ end
289
+ end
290
+ end
@@ -0,0 +1,320 @@
1
+ require 'nokogiri'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ class IxopayGateway < Gateway
6
+ self.test_url = 'https://secure.ixopay.com/transaction'
7
+ self.live_url = 'https://secure.ixopay.com/transaction'
8
+
9
+ self.supported_countries = %w(AO AQ AR AS AT AU AW AX AZ BA BB BD BE BF BG BH BI BJ BL BM BN BO BQ BQ BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ DE DJ DK DM DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IQ IR IS IT JE JM JO JP KE KG KH KI KM KN KP KR KW KY KZ LA LB LC LI LK LR LS LT LU LV LY MA MC MD ME MF MG MH MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM PN PR PS PT PW PY QA RE RO RS RU RW SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR SS ST SV SX SY SZ TC TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS YE YT ZA ZM ZW)
10
+ self.default_currency = 'EUR'
11
+ self.currencies_with_three_decimal_places = %w(BHD IQD JOD KWD LWD OMR TND)
12
+ self.supported_cardtypes = %i[visa master american_express discover diners_club jcb maestro]
13
+
14
+ self.homepage_url = 'https://www.ixopay.com'
15
+ self.display_name = 'Ixopay'
16
+
17
+ def initialize(options = {})
18
+ requires!(options, :username, :password, :secret, :api_key)
19
+ @secret = options[:secret]
20
+ super
21
+ end
22
+
23
+ def purchase(money, payment_method, options = {})
24
+ request = build_xml_request do |xml|
25
+ add_card_data(xml, payment_method)
26
+ add_debit(xml, money, options)
27
+ end
28
+
29
+ commit(request)
30
+ end
31
+
32
+ def authorize(money, payment_method, options = {})
33
+ request = build_xml_request do |xml|
34
+ add_card_data(xml, payment_method)
35
+ add_preauth(xml, money, options)
36
+ end
37
+
38
+ commit(request)
39
+ end
40
+
41
+ def capture(money, authorization, options = {})
42
+ request = build_xml_request do |xml|
43
+ add_capture(xml, money, authorization, options)
44
+ end
45
+
46
+ commit(request)
47
+ end
48
+
49
+ def refund(money, authorization, options = {})
50
+ request = build_xml_request do |xml|
51
+ add_refund(xml, money, authorization, options)
52
+ end
53
+
54
+ commit(request)
55
+ end
56
+
57
+ def void(authorization, options = {})
58
+ request = build_xml_request do |xml|
59
+ add_void(xml, authorization)
60
+ end
61
+
62
+ commit(request)
63
+ end
64
+
65
+ def verify(credit_card, options = {})
66
+ MultiResponse.run(:use_first_response) do |r|
67
+ r.process { authorize(100, credit_card, options) }
68
+ r.process(:ignore_result) { void(r.authorization, options) }
69
+ end
70
+ end
71
+
72
+ def supports_scrubbing?
73
+ true
74
+ end
75
+
76
+ def scrub(transcript)
77
+ clean_transcript = remove_invalid_utf_8_byte_sequences(transcript)
78
+
79
+ clean_transcript.
80
+ gsub(%r((Authorization: Gateway )(.*)(:)), '\1[FILTERED]\3').
81
+ gsub(%r((<password>)(.*)(</password>)), '\1[FILTERED]\3').
82
+ gsub(%r((<pan>)(.*)(</pan>)), '\1[FILTERED]\3').
83
+ gsub(%r((<cvv>)\d+(</cvv>)), '\1[FILTERED]\2')
84
+ end
85
+
86
+ private
87
+
88
+ def remove_invalid_utf_8_byte_sequences(text)
89
+ text.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
90
+ end
91
+
92
+ def headers(xml)
93
+ timestamp = Time.now.httpdate
94
+ signature = generate_signature('POST', xml, timestamp)
95
+
96
+ {
97
+ 'Authorization' => "Gateway #{options[:api_key]}:#{signature}",
98
+ 'Date' => timestamp,
99
+ 'Content-Type' => 'text/xml; charset=utf-8'
100
+ }
101
+ end
102
+
103
+ def generate_signature(http_method, xml, timestamp)
104
+ content_type = 'text/xml; charset=utf-8'
105
+ message = "#{http_method}\n#{Digest::MD5.hexdigest(xml)}\n#{content_type}\n#{timestamp}\n\n/transaction"
106
+ digest = OpenSSL::Digest.new('sha512')
107
+ hmac = OpenSSL::HMAC.digest(digest, @secret, message)
108
+
109
+ Base64.encode64(hmac).delete("\n")
110
+ end
111
+
112
+ def parse(body)
113
+ xml = Nokogiri::XML(body)
114
+ response = Hash.from_xml(xml.to_s)['result']
115
+
116
+ response.deep_transform_keys(&:underscore).transform_keys(&:to_sym)
117
+ end
118
+
119
+ def build_xml_request
120
+ builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
121
+ xml.transactionWithCard 'xmlns' => 'http://secure.ixopay.com/Schema/V2/TransactionWithCard' do
122
+ xml.username @options[:username]
123
+ xml.password Digest::SHA1.hexdigest(@options[:password])
124
+ yield(xml)
125
+ end
126
+ end
127
+
128
+ builder.to_xml
129
+ end
130
+
131
+ def add_card_data(xml, payment_method)
132
+ xml.cardData do
133
+ xml.cardHolder payment_method.name
134
+ xml.pan payment_method.number
135
+ xml.cvv payment_method.verification_value
136
+ xml.expirationMonth format(payment_method.month, :two_digits)
137
+ xml.expirationYear format(payment_method.year, :four_digits)
138
+ end
139
+ end
140
+
141
+ def add_debit(xml, money, options)
142
+ currency = options[:currency] || currency(money)
143
+ description = options[:description].blank? ? 'Purchase' : options[:description]
144
+
145
+ xml.debit do
146
+ xml.transactionId new_transaction_id
147
+
148
+ add_customer_data(xml, options)
149
+ add_extra_data(xml, options[:extra_data]) if options[:extra_data]
150
+
151
+ xml.amount localized_amount(money, currency)
152
+ xml.currency currency
153
+ xml.description description
154
+ xml.callbackUrl(options[:callback_url])
155
+ add_stored_credentials(xml, options)
156
+ end
157
+ end
158
+
159
+ def add_preauth(xml, money, options)
160
+ description = options[:description].blank? ? 'Preauthorize' : options[:description]
161
+ currency = options[:currency] || currency(money)
162
+ callback_url = options[:callback_url]
163
+
164
+ xml.preauthorize do
165
+ xml.transactionId new_transaction_id
166
+
167
+ add_customer_data(xml, options)
168
+ add_extra_data(xml, options[:extra_data]) if options[:extra_data]
169
+
170
+ xml.amount localized_amount(money, currency)
171
+ xml.currency currency
172
+ xml.description description
173
+ xml.callbackUrl callback_url
174
+ add_stored_credentials(xml, options)
175
+ end
176
+ end
177
+
178
+ def add_refund(xml, money, authorization, options)
179
+ currency = options[:currency] || currency(money)
180
+
181
+ xml.refund do
182
+ xml.transactionId new_transaction_id
183
+ add_extra_data(xml, options[:extra_data]) if options[:extra_data]
184
+ xml.referenceTransactionId authorization&.split('|')&.first
185
+ xml.amount localized_amount(money, currency)
186
+ xml.currency currency
187
+ end
188
+ end
189
+
190
+ def add_void(xml, authorization)
191
+ xml.void do
192
+ xml.transactionId new_transaction_id
193
+ add_extra_data(xml, options[:extra_data]) if options[:extra_data]
194
+ xml.referenceTransactionId authorization&.split('|')&.first
195
+ end
196
+ end
197
+
198
+ def add_capture(xml, money, authorization, options)
199
+ currency = options[:currency] || currency(money)
200
+
201
+ xml.capture_ do
202
+ xml.transactionId new_transaction_id
203
+ add_extra_data(xml, options[:extra_data]) if options[:extra_data]
204
+ xml.referenceTransactionId authorization&.split('|')&.first
205
+ xml.amount localized_amount(money, currency)
206
+ xml.currency currency
207
+ end
208
+ end
209
+
210
+ def add_customer_data(xml, options)
211
+ # Ixopay returns an error if the elements are not added in the order used here.
212
+ xml.customer do
213
+ add_billing_address(xml, options[:billing_address]) if options[:billing_address]
214
+ add_shipping_address(xml, options[:shipping_address]) if options[:shipping_address]
215
+
216
+ xml.company options[:billing_address][:company] if options.dig(:billing_address, :company)
217
+ xml.email options[:email]
218
+ xml.ipAddress(options[:ip] || '127.0.0.1')
219
+ end
220
+ end
221
+
222
+ def add_billing_address(xml, address)
223
+ if address[:name]
224
+ xml.firstName split_names(address[:name])[0]
225
+ xml.lastName split_names(address[:name])[1]
226
+ end
227
+
228
+ xml.billingAddress1 address[:address1]
229
+ xml.billingAddress2 address[:address2]
230
+ xml.billingCity address[:city]
231
+ xml.billingPostcode address[:zip]
232
+ xml.billingState address[:state]
233
+ xml.billingCountry address[:country]
234
+ xml.billingPhone address[:phone]
235
+ end
236
+
237
+ def add_shipping_address(xml, address)
238
+ if address[:name]
239
+ xml.shippingFirstName split_names(address[:name])[0]
240
+ xml.shippingLastName split_names(address[:name])[1]
241
+ end
242
+
243
+ xml.shippingCompany address[:company]
244
+ xml.shippingAddress1 address[:address1]
245
+ xml.shippingAddress2 address[:address2]
246
+ xml.shippingCity address[:city]
247
+ xml.shippingPostcode address[:zip]
248
+ xml.shippingState address[:state]
249
+ xml.shippingCountry address[:country]
250
+ xml.shippingPhone address[:phone]
251
+ end
252
+
253
+ def new_transaction_id
254
+ SecureRandom.uuid
255
+ end
256
+
257
+ # Ixopay does not pass any parameters for cardholder/merchant initiated.
258
+ # Ixopay also doesn't support installment transactions, only recurring
259
+ # ("RECURRING") and unscheduled ("CARDONFILE").
260
+ #
261
+ # Furthermore, Ixopay is slightly unusual in its application of stored
262
+ # credentials in that the gateway does not return a true
263
+ # network_transaction_id that can be sent on subsequent transactions.
264
+ def add_stored_credentials(xml, options)
265
+ return unless stored_credential = options[:stored_credential]
266
+
267
+ if stored_credential[:initial_transaction]
268
+ xml.transactionIndicator 'INITIAL'
269
+ elsif stored_credential[:reason_type] == 'recurring'
270
+ xml.transactionIndicator 'RECURRING'
271
+ elsif stored_credential[:reason_type] == 'unscheduled'
272
+ xml.transactionIndicator 'CARDONFILE'
273
+ end
274
+ end
275
+
276
+ def add_extra_data(xml, extra_data)
277
+ extra_data.each do |k, v|
278
+ xml.extraData(v, key: k)
279
+ end
280
+ end
281
+
282
+ def commit(request)
283
+ url = (test? ? test_url : live_url)
284
+
285
+ # ssl_post raises an exception for any non-2xx HTTP status from the gateway
286
+ response =
287
+ begin
288
+ parse(ssl_post(url, request, headers(request)))
289
+ rescue StandardError => error
290
+ parse(error.response.body)
291
+ end
292
+
293
+ Response.new(
294
+ success_from(response),
295
+ message_from(response),
296
+ response,
297
+ authorization: authorization_from(response),
298
+ test: test?,
299
+ error_code: error_code_from(response)
300
+ )
301
+ end
302
+
303
+ def success_from(response)
304
+ response[:success] == 'true'
305
+ end
306
+
307
+ def message_from(response)
308
+ response.dig(:errors, 'error', 'message') || response[:return_type]
309
+ end
310
+
311
+ def authorization_from(response)
312
+ response[:reference_id] ? "#{response[:reference_id]}|#{response[:purchase_id]}" : nil
313
+ end
314
+
315
+ def error_code_from(response)
316
+ response.dig(:errors, 'error', 'code') unless success_from(response)
317
+ end
318
+ end
319
+ end
320
+ end