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,406 @@
1
+ require 'nokogiri'
2
+ require 'securerandom'
3
+
4
+ module ActiveMerchant #:nodoc:
5
+ module Billing #:nodoc:
6
+ class ElementGateway < Gateway
7
+ self.test_url = 'https://certtransaction.elementexpress.com/express.asmx'
8
+ self.live_url = 'https://transaction.elementexpress.com/express.asmx'
9
+
10
+ self.supported_countries = ['US']
11
+ self.default_currency = 'USD'
12
+ self.supported_cardtypes = %i[visa master american_express discover diners_club jcb]
13
+
14
+ self.homepage_url = 'http://www.elementps.com'
15
+ self.display_name = 'Element'
16
+
17
+ SERVICE_TEST_URL = 'https://certservices.elementexpress.com/express.asmx'
18
+ SERVICE_LIVE_URL = 'https://services.elementexpress.com/express.asmx'
19
+
20
+ NETWORK_TOKEN_TYPE = {
21
+ apple_pay: '2',
22
+ google_pay: '1'
23
+ }
24
+
25
+ def initialize(options = {})
26
+ requires!(options, :account_id, :account_token, :application_id, :acceptor_id, :application_name, :application_version)
27
+ super
28
+ end
29
+
30
+ def purchase(money, payment, options = {})
31
+ action = payment.is_a?(Check) ? 'CheckSale' : 'CreditCardSale'
32
+
33
+ request = build_soap_request do |xml|
34
+ xml.send(action, xmlns: 'https://transaction.elementexpress.com') do
35
+ add_credentials(xml)
36
+ add_payment_method(xml, payment)
37
+ add_transaction(xml, money, options)
38
+ add_terminal(xml, options)
39
+ add_address(xml, options)
40
+ end
41
+ end
42
+
43
+ commit(action, request, money)
44
+ end
45
+
46
+ def authorize(money, payment, options = {})
47
+ request = build_soap_request do |xml|
48
+ xml.CreditCardAuthorization(xmlns: 'https://transaction.elementexpress.com') do
49
+ add_credentials(xml)
50
+ add_payment_method(xml, payment)
51
+ add_transaction(xml, money, options)
52
+ add_terminal(xml, options)
53
+ add_address(xml, options)
54
+ end
55
+ end
56
+
57
+ commit('CreditCardAuthorization', request, money)
58
+ end
59
+
60
+ def capture(money, authorization, options = {})
61
+ trans_id, = split_authorization(authorization)
62
+ options[:trans_id] = trans_id
63
+
64
+ request = build_soap_request do |xml|
65
+ xml.CreditCardAuthorizationCompletion(xmlns: 'https://transaction.elementexpress.com') do
66
+ add_credentials(xml)
67
+ add_transaction(xml, money, options)
68
+ add_terminal(xml, options)
69
+ end
70
+ end
71
+
72
+ commit('CreditCardAuthorizationCompletion', request, money)
73
+ end
74
+
75
+ def refund(money, authorization, options = {})
76
+ trans_id, = split_authorization(authorization)
77
+ options[:trans_id] = trans_id
78
+
79
+ request = build_soap_request do |xml|
80
+ xml.CreditCardReturn(xmlns: 'https://transaction.elementexpress.com') do
81
+ add_credentials(xml)
82
+ add_transaction(xml, money, options)
83
+ add_terminal(xml, options)
84
+ end
85
+ end
86
+
87
+ commit('CreditCardReturn', request, money)
88
+ end
89
+
90
+ def credit(money, payment, options = {})
91
+ request = build_soap_request do |xml|
92
+ xml.CreditCardCredit(xmlns: 'https://transaction.elementexpress.com') do
93
+ add_credentials(xml)
94
+ add_payment_method(xml, payment)
95
+ add_transaction(xml, money, options)
96
+ add_terminal(xml, options)
97
+ end
98
+ end
99
+
100
+ commit('CreditCardCredit', request, money)
101
+ end
102
+
103
+ def void(authorization, options = {})
104
+ trans_id, trans_amount = split_authorization(authorization)
105
+ options.merge!({ trans_id: trans_id, trans_amount: trans_amount, reversal_type: 'Full' })
106
+
107
+ request = build_soap_request do |xml|
108
+ xml.CreditCardReversal(xmlns: 'https://transaction.elementexpress.com') do
109
+ add_credentials(xml)
110
+ add_transaction(xml, trans_amount, options)
111
+ add_terminal(xml, options)
112
+ end
113
+ end
114
+
115
+ commit('CreditCardReversal', request, trans_amount)
116
+ end
117
+
118
+ def store(payment, options = {})
119
+ request = build_soap_request do |xml|
120
+ xml.PaymentAccountCreate(xmlns: 'https://services.elementexpress.com') do
121
+ add_credentials(xml)
122
+ add_payment_method(xml, payment)
123
+ add_payment_account(xml, payment, options[:payment_account_reference_number] || SecureRandom.hex(20))
124
+ add_address(xml, options)
125
+ end
126
+ end
127
+
128
+ commit('PaymentAccountCreate', request, nil)
129
+ end
130
+
131
+ def verify(credit_card, options = {})
132
+ request = build_soap_request do |xml|
133
+ xml.CreditCardAVSOnly(xmlns: 'https://transaction.elementexpress.com') do
134
+ add_credentials(xml)
135
+ add_payment_method(xml, credit_card)
136
+ add_transaction(xml, 0, options)
137
+ add_terminal(xml, options)
138
+ add_address(xml, options)
139
+ end
140
+ end
141
+
142
+ # send request with the transaction amount set to 0
143
+ commit('CreditCardAVSOnly', request, 0)
144
+ end
145
+
146
+ def supports_scrubbing?
147
+ true
148
+ end
149
+
150
+ def scrub(transcript)
151
+ transcript.
152
+ gsub(%r((<AccountToken>).+?(</AccountToken>))i, '\1[FILTERED]\2').
153
+ gsub(%r((<CardNumber>).+?(</CardNumber>))i, '\1[FILTERED]\2').
154
+ gsub(%r((<CVV>).+?(</CVV>))i, '\1[FILTERED]\2').
155
+ gsub(%r((<AccountNumber>).+?(</AccountNumber>))i, '\1[FILTERED]\2').
156
+ gsub(%r((<RoutingNumber>).+?(</RoutingNumber>))i, '\1[FILTERED]\2')
157
+ end
158
+
159
+ private
160
+
161
+ def add_credentials(xml)
162
+ xml.credentials do
163
+ xml.AccountID @options[:account_id]
164
+ xml.AccountToken @options[:account_token]
165
+ xml.AcceptorID @options[:acceptor_id]
166
+ end
167
+ xml.application do
168
+ xml.ApplicationID @options[:application_id]
169
+ xml.ApplicationName @options[:application_name]
170
+ xml.ApplicationVersion @options[:application_version]
171
+ end
172
+ end
173
+
174
+ def add_payment_method(xml, payment)
175
+ if payment.is_a?(String)
176
+ add_payment_account_id(xml, payment)
177
+ elsif payment.is_a?(Check)
178
+ add_echeck(xml, payment)
179
+ elsif payment.is_a?(NetworkTokenizationCreditCard)
180
+ add_network_tokenization_card(xml, payment)
181
+ else
182
+ add_credit_card(xml, payment)
183
+ end
184
+ end
185
+
186
+ def add_payment_account(xml, payment, payment_account_reference_number)
187
+ xml.paymentAccount do
188
+ xml.PaymentAccountType payment_account_type(payment)
189
+ xml.PaymentAccountReferenceNumber payment_account_reference_number
190
+ end
191
+ end
192
+
193
+ def add_payment_account_id(xml, payment)
194
+ xml.extendedParameters do
195
+ xml.ExtendedParameters do
196
+ xml.Key 'PaymentAccount'
197
+ xml.Value('xsi:type' => 'PaymentAccount') do
198
+ xml.PaymentAccountID payment
199
+ end
200
+ end
201
+ end
202
+ end
203
+
204
+ def add_transaction(xml, money, options = {})
205
+ xml.transaction do
206
+ xml.ReversalType options[:reversal_type] if options[:reversal_type]
207
+ xml.TransactionID options[:trans_id] if options[:trans_id]
208
+ xml.TransactionAmount amount(money.to_i) if money
209
+ xml.MarketCode market_code(money, options) if options[:market_code] || money
210
+ xml.ReferenceNumber options[:order_id].present? ? options[:order_id][0, 50] : SecureRandom.hex(20)
211
+ xml.TicketNumber options[:ticket_number] if options[:ticket_number]
212
+ xml.MerchantSuppliedTransactionId options[:merchant_supplied_transaction_id] if options[:merchant_supplied_transaction_id]
213
+ xml.PaymentType options[:payment_type] if options[:payment_type]
214
+ xml.SubmissionType options[:submission_type] if options[:submission_type]
215
+ xml.DuplicateCheckDisableFlag options[:duplicate_check_disable_flag].to_s == 'true' ? 'True' : 'False' unless options[:duplicate_check_disable_flag].nil?
216
+ xml.DuplicateOverrideFlag options[:duplicate_override_flag].to_s == 'true' ? 'True' : 'False' unless options[:duplicate_override_flag].nil?
217
+ xml.MerchantDescriptor options[:merchant_descriptor] if options[:merchant_descriptor]
218
+ end
219
+ end
220
+
221
+ def market_code(money, options)
222
+ options[:market_code] || 'Default'
223
+ end
224
+
225
+ def add_terminal(xml, options)
226
+ xml.terminal do
227
+ xml.TerminalID options[:terminal_id] || '01'
228
+ xml.CardPresentCode options[:card_present_code] || 'UseDefault'
229
+ xml.CardholderPresentCode 'UseDefault'
230
+ xml.CardInputCode 'UseDefault'
231
+ xml.CVVPresenceCode 'UseDefault'
232
+ xml.TerminalCapabilityCode 'UseDefault'
233
+ xml.TerminalEnvironmentCode 'UseDefault'
234
+ xml.MotoECICode 'NonAuthenticatedSecureECommerceTransaction'
235
+ end
236
+ end
237
+
238
+ def add_credit_card(xml, payment)
239
+ xml.card do
240
+ xml.CardNumber payment.number
241
+ xml.ExpirationMonth format(payment.month, :two_digits)
242
+ xml.ExpirationYear format(payment.year, :two_digits)
243
+ xml.CardholderName payment.first_name + ' ' + payment.last_name
244
+ xml.CVV payment.verification_value
245
+ end
246
+ end
247
+
248
+ def add_echeck(xml, payment)
249
+ xml.demandDepositAccount do
250
+ xml.AccountNumber payment.account_number
251
+ xml.RoutingNumber payment.routing_number
252
+ xml.DDAAccountType payment.account_type.capitalize
253
+ end
254
+ end
255
+
256
+ def add_network_tokenization_card(xml, payment)
257
+ xml.card do
258
+ xml.CardNumber payment.number
259
+ xml.ExpirationMonth format(payment.month, :two_digits)
260
+ xml.ExpirationYear format(payment.year, :two_digits)
261
+ xml.CardholderName "#{payment.first_name} #{payment.last_name}"
262
+ xml.Cryptogram payment.payment_cryptogram
263
+ xml.ElectronicCommerceIndicator payment.eci if payment.eci.present?
264
+ xml.WalletType NETWORK_TOKEN_TYPE.fetch(payment.source, '0')
265
+ end
266
+ end
267
+
268
+ def add_address(xml, options)
269
+ if address = options[:billing_address] || options[:address]
270
+ address[:email] ||= options[:email]
271
+ xml.address do
272
+ xml.BillingAddress1 address[:address1] if address[:address1]
273
+ xml.BillingAddress2 address[:address2] if address[:address2]
274
+ xml.BillingCity address[:city] if address[:city]
275
+ xml.BillingState address[:state] if address[:state]
276
+ xml.BillingZipcode address[:zip] if address[:zip]
277
+ xml.BillingEmail address[:email] if address[:email]
278
+ xml.BillingPhone address[:phone_number] if address[:phone_number]
279
+ end
280
+ end
281
+ if shipping_address = options[:shipping_address]
282
+ xml.address do
283
+ xml.ShippingAddress1 shipping_address[:address1] if shipping_address[:address1]
284
+ xml.ShippingAddress2 shipping_address[:address2] if shipping_address[:address2]
285
+ xml.ShippingCity shipping_address[:city] if shipping_address[:city]
286
+ xml.ShippingState shipping_address[:state] if shipping_address[:state]
287
+ xml.ShippingZipcode shipping_address[:zip] if shipping_address[:zip]
288
+ xml.ShippingEmail shipping_address[:email] if shipping_address[:email]
289
+ xml.ShippingPhone shipping_address[:phone_number] if shipping_address[:phone_number]
290
+ end
291
+ end
292
+ end
293
+
294
+ def parse(xml)
295
+ response = {}
296
+
297
+ doc = Nokogiri::XML(xml)
298
+ doc.remove_namespaces!
299
+ root = doc.root.xpath('//response/*')
300
+
301
+ root = doc.root.xpath('//Response/*') if root.empty?
302
+
303
+ root.each do |node|
304
+ if node.elements.empty?
305
+ response[node.name.downcase] = node.text
306
+ else
307
+ node_name = node.name.downcase
308
+ response[node_name] = Hash.new
309
+
310
+ node.elements.each do |childnode|
311
+ response[node_name][childnode.name.downcase] = childnode.text
312
+ end
313
+ end
314
+ end
315
+
316
+ response
317
+ end
318
+
319
+ def commit(action, xml, amount)
320
+ response = parse(ssl_post(url(action), xml, headers(action)))
321
+
322
+ Response.new(
323
+ success_from(response),
324
+ message_from(response),
325
+ response,
326
+ authorization: authorization_from(action, response, amount),
327
+ avs_result: success_from(response) ? avs_from(response) : nil,
328
+ cvv_result: success_from(response) ? cvv_from(response) : nil,
329
+ test: test?
330
+ )
331
+ end
332
+
333
+ def authorization_from(action, response, amount)
334
+ if action == 'PaymentAccountCreate'
335
+ response['paymentaccount']['paymentaccountid']
336
+ else
337
+ "#{response['transaction']['transactionid']}|#{amount}" if response['transaction']
338
+ end
339
+ end
340
+
341
+ def success_from(response)
342
+ response['expressresponsecode'] == '0'
343
+ end
344
+
345
+ def message_from(response)
346
+ response['expressresponsemessage']
347
+ end
348
+
349
+ def avs_from(response)
350
+ AVSResult.new(code: response['card']['avsresponsecode']) if response['card']
351
+ end
352
+
353
+ def cvv_from(response)
354
+ CVVResult.new(response['card']['cvvresponsecode']) if response['card']
355
+ end
356
+
357
+ def split_authorization(authorization)
358
+ authorization.split('|')
359
+ end
360
+
361
+ def build_soap_request
362
+ builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
363
+ xml['soap'].Envelope('xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
364
+ 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
365
+ 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/') do
366
+
367
+ xml['soap'].Body do
368
+ yield(xml)
369
+ end
370
+ end
371
+ end
372
+
373
+ builder.to_xml
374
+ end
375
+
376
+ def payment_account_type(payment)
377
+ if payment.is_a?(Check)
378
+ payment_account_type = payment.account_type
379
+ else
380
+ payment_account_type = 'CreditCard'
381
+ end
382
+ payment_account_type
383
+ end
384
+
385
+ def url(action)
386
+ if action == 'PaymentAccountCreate'
387
+ test? ? SERVICE_TEST_URL : SERVICE_LIVE_URL
388
+ else
389
+ test? ? test_url : live_url
390
+ end
391
+ end
392
+
393
+ def interface(action)
394
+ return 'transaction' if action != 'PaymentAccountCreate'
395
+ return 'services' if action == 'PaymentAccountCreate'
396
+ end
397
+
398
+ def headers(action)
399
+ {
400
+ 'Content-Type' => 'text/xml; charset=utf-8',
401
+ 'SOAPAction' => "https://#{interface(action)}.elementexpress.com/#{action}"
402
+ }
403
+ end
404
+ end
405
+ end
406
+ end
@@ -0,0 +1,296 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class EpayGateway < Gateway
4
+ self.live_url = 'https://ssl.ditonlinebetalingssystem.dk/'
5
+
6
+ self.default_currency = 'DKK'
7
+ self.money_format = :cents
8
+ self.supported_countries = %w[DK SE NO]
9
+ self.supported_cardtypes = %i[dankort forbrugsforeningen visa master
10
+ american_express diners_club jcb maestro]
11
+ self.homepage_url = 'http://epay.dk/'
12
+ self.display_name = 'ePay'
13
+
14
+ CURRENCY_CODES = {
15
+ ADP: '020', AED: '784', AFA: '004', ALL: '008', AMD: '051',
16
+ ANG: '532', AOA: '973', ARS: '032', AUD: '036', AWG: '533',
17
+ AZM: '031', BAM: '977', BBD: '052', BDT: '050', BGL: '100',
18
+ BGN: '975', BHD: '048', BIF: '108', BMD: '060', BND: '096',
19
+ BOB: '068', BOV: '984', BRL: '986', BSD: '044', BTN: '064',
20
+ BWP: '072', BYR: '974', BZD: '084', CAD: '124', CDF: '976',
21
+ CHF: '756', CLF: '990', CLP: '152', CNY: '156', COP: '170',
22
+ CRC: '188', CUP: '192', CVE: '132', CYP: '196', CZK: '203',
23
+ DJF: '262', DKK: '208', DOP: '214', DZD: '012', ECS: '218',
24
+ ECV: '983', EEK: '233', EGP: '818', ERN: '232', ETB: '230',
25
+ EUR: '978', FJD: '242', FKP: '238', GBP: '826', GEL: '981',
26
+ GHC: '288', GIP: '292', GMD: '270', GNF: '324', GTQ: '320',
27
+ GWP: '624', GYD: '328', HKD: '344', HNL: '340', HRK: '191',
28
+ HTG: '332', HUF: '348', IDR: '360', ILS: '376', INR: '356',
29
+ IQD: '368', IRR: '364', ISK: '352', JMD: '388', JOD: '400',
30
+ JPY: '392', KES: '404', KGS: '417', KHR: '116', KMF: '174',
31
+ KPW: '408', KRW: '410', KWD: '414', KYD: '136', KZT: '398',
32
+ LAK: '418', LBP: '422', LKR: '144', LRD: '430', LSL: '426',
33
+ LTL: '440', LVL: '428', LYD: '434', MAD: '504', MDL: '498',
34
+ MGF: '450', MKD: '807', MMK: '104', MNT: '496', MOP: '446',
35
+ MRO: '478', MTL: '470', MUR: '480', MVR: '462', MWK: '454',
36
+ MXN: '484', MXV: '979', MYR: '458', MZM: '508', NAD: '516',
37
+ NGN: '566', NIO: '558', NOK: '578', NPR: '524', NZD: '554',
38
+ OMR: '512', PAB: '590', PEN: '604', PGK: '598', PHP: '608',
39
+ PKR: '586', PLN: '985', PYG: '600', QAR: '634', ROL: '642',
40
+ RUB: '643', RUR: '810', RWF: '646', SAR: '682', SBD: '090',
41
+ SCR: '690', SDD: '736', SEK: '752', SGD: '702', SHP: '654',
42
+ SIT: '705', SKK: '703', SLL: '694', SOS: '706', SRG: '740',
43
+ STD: '678', SVC: '222', SYP: '760', SZL: '748', THB: '764',
44
+ TJS: '972', TMM: '795', TND: '788', TOP: '776', TPE: '626',
45
+ TRL: '792', TRY: '949', TTD: '780', TWD: '901', TZS: '834',
46
+ UAH: '980', UGX: '800', USD: '840', UYU: '858', UZS: '860',
47
+ VEB: '862', VND: '704', VUV: '548', XAF: '950', XCD: '951',
48
+ XOF: '952', XPF: '953', YER: '886', YUM: '891', ZAR: '710',
49
+ ZMK: '894', ZWD: '716'
50
+ }
51
+
52
+ # login: merchant number
53
+ # password: referrer url (for authorize authentication)
54
+ def initialize(options = {})
55
+ requires!(options, :login)
56
+ super
57
+ end
58
+
59
+ def authorize(money, credit_card_or_reference, options = {})
60
+ post = {}
61
+
62
+ add_amount(post, money, options)
63
+ add_invoice(post, options)
64
+ add_creditcard_or_reference(post, credit_card_or_reference)
65
+ add_instant_capture(post, false)
66
+ add_3ds_auth(post, options)
67
+
68
+ commit(:authorize, post)
69
+ end
70
+
71
+ def purchase(money, credit_card_or_reference, options = {})
72
+ post = {}
73
+
74
+ add_amount(post, money, options)
75
+ add_creditcard_or_reference(post, credit_card_or_reference)
76
+ add_invoice(post, options)
77
+ add_instant_capture(post, true)
78
+ add_3ds_auth(post, options)
79
+
80
+ commit(:authorize, post)
81
+ end
82
+
83
+ def capture(money, authorization, options = {})
84
+ post = {}
85
+
86
+ add_reference(post, authorization)
87
+ add_amount_without_currency(post, money)
88
+
89
+ commit(:capture, post)
90
+ end
91
+
92
+ def void(identification, options = {})
93
+ post = {}
94
+
95
+ add_reference(post, identification)
96
+
97
+ commit(:void, post)
98
+ end
99
+
100
+ def refund(money, identification, options = {})
101
+ post = {}
102
+
103
+ add_amount_without_currency(post, money)
104
+ add_reference(post, identification)
105
+
106
+ commit(:credit, post)
107
+ end
108
+
109
+ def credit(money, identification, options = {})
110
+ ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
111
+ refund(money, identification, options)
112
+ end
113
+
114
+ def supports_scrubbing
115
+ true
116
+ end
117
+
118
+ def scrub(transcript)
119
+ transcript.
120
+ gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
121
+ gsub(%r(((?:\?|&)cardno=)\d*(&?)), '\1[FILTERED]\2').
122
+ gsub(%r((&?cvc=)\d*(&?)), '\1[FILTERED]\2')
123
+ end
124
+
125
+ private
126
+
127
+ def add_amount(post, money, options)
128
+ post[:amount] = amount(money)
129
+ post[:currency] = CURRENCY_CODES[(options[:currency] || currency(money)).to_sym]
130
+ end
131
+
132
+ def add_amount_without_currency(post, money)
133
+ post[:amount] = amount(money)
134
+ end
135
+
136
+ def add_reference(post, identification)
137
+ post[:transaction] = identification
138
+ end
139
+
140
+ def add_invoice(post, options)
141
+ post[:orderid] = format_order_number(options[:order_id])
142
+ end
143
+
144
+ def add_creditcard(post, credit_card)
145
+ post[:cardno] = credit_card.number
146
+ post[:cvc] = credit_card.verification_value
147
+ post[:expmonth] = credit_card.month
148
+ post[:expyear] = credit_card.year
149
+ end
150
+
151
+ def add_creditcard_or_reference(post, credit_card_or_reference)
152
+ if credit_card_or_reference.respond_to?(:number)
153
+ add_creditcard(post, credit_card_or_reference)
154
+ else
155
+ add_reference(post, credit_card_or_reference.to_s)
156
+ end
157
+ end
158
+
159
+ def add_instant_capture(post, option)
160
+ post[:instantcapture] = option ? 1 : 0
161
+ end
162
+
163
+ def add_3ds_auth(post, options)
164
+ if options[:three_d_secure]
165
+ post[:eci] = options.dig(:three_d_secure, :eci)
166
+ post[:xid] = options.dig(:three_d_secure, :xid)
167
+ post[:cavv] = options.dig(:three_d_secure, :cavv)
168
+ post[:threeds_version] = options.dig(:three_d_secure, :version)
169
+ post[:ds_transaction_id] = options.dig(:three_d_secure, :ds_transaction_id)
170
+ end
171
+ end
172
+
173
+ def commit(action, params)
174
+ response = send("do_#{action}", params)
175
+
176
+ if action == :authorize
177
+ Response.new response['accept'].to_i == 1,
178
+ response['errortext'],
179
+ response,
180
+ test: test?,
181
+ authorization: response['tid']
182
+ else
183
+ Response.new response['result'] == 'true',
184
+ messages(response['epay'], response['pbs']),
185
+ response,
186
+ test: test?,
187
+ authorization: params[:transaction]
188
+ end
189
+ end
190
+
191
+ def messages(epay, pbs = nil)
192
+ response = "ePay: #{epay}"
193
+ response << " PBS: #{pbs}" if pbs
194
+ return response
195
+ end
196
+
197
+ def soap_post(method, params)
198
+ data = xml_builder(params, method)
199
+ headers = make_headers(data, method)
200
+ REXML::Document.new(ssl_post(live_url + 'remote/payment.asmx', data, headers))
201
+ end
202
+
203
+ def do_authorize(params)
204
+ headers = {}
205
+ headers['Referer'] = (options[:password] || 'activemerchant.org')
206
+
207
+ response = raw_ssl_request(:post, live_url + 'auth/default.aspx', authorize_post_data(params), headers)
208
+ # Authorize gives the response back by redirecting with the values in
209
+ # the URL query
210
+ if location = response['Location']
211
+ query = CGI::parse(URI.parse(location.gsub(' ', '%20').gsub('<', '%3C').gsub('>', '%3E')).query)
212
+ else
213
+ return {
214
+ 'accept' => '0',
215
+ 'errortext' => 'ePay did not respond as expected. Please try again.',
216
+ 'response_code' => response.code,
217
+ 'response_message' => response.message
218
+ }
219
+ end
220
+
221
+ result = {}
222
+ query.each_pair do |k, v|
223
+ result[k] = v.is_a?(Array) && v.size == 1 ? v[0] : v # make values like ['v'] into 'v'
224
+ end
225
+ result
226
+ end
227
+
228
+ def do_capture(params)
229
+ response = soap_post('capture', params)
230
+ {
231
+ 'result' => response.elements['//captureResponse/captureResult'].text,
232
+ 'pbs' => response.elements['//captureResponse/pbsResponse'].text,
233
+ 'epay' => response.elements['//captureResponse/epayresponse'].text
234
+ }
235
+ end
236
+
237
+ def do_credit(params)
238
+ response = soap_post('credit', params)
239
+ {
240
+ 'result' => response.elements['//creditResponse/creditResult'].text,
241
+ 'pbs' => response.elements['//creditResponse/pbsresponse'].text,
242
+ 'epay' => response.elements['//creditResponse/epayresponse'].text
243
+ }
244
+ end
245
+
246
+ def do_void(params)
247
+ response = soap_post('delete', params)
248
+ {
249
+ 'result' => response.elements['//deleteResponse/deleteResult'].text,
250
+ 'epay' => response.elements['//deleteResponse/epayresponse'].text
251
+ }
252
+ end
253
+
254
+ def make_headers(data, soap_call)
255
+ {
256
+ 'Content-Type' => 'text/xml; charset=utf-8',
257
+ 'Host' => 'ssl.ditonlinebetalingssystem.dk',
258
+ 'Content-Length' => data.size.to_s,
259
+ 'SOAPAction' => self.live_url + 'remote/payment/' + soap_call
260
+ }
261
+ end
262
+
263
+ def xml_builder(params, soap_call)
264
+ xml = Builder::XmlMarkup.new(indent: 2)
265
+ xml.instruct!
266
+ xml.tag! 'soap:Envelope', { 'xmlns:xsi' => 'http://schemas.xmlsoap.org/soap/envelope/',
267
+ 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
268
+ 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/' } do
269
+ xml.tag! 'soap:Body' do
270
+ xml.tag! soap_call, { 'xmlns' => "#{self.live_url}remote/payment" } do
271
+ xml.tag! 'merchantnumber', @options[:login]
272
+ xml.tag! 'transactionid', params[:transaction]
273
+ xml.tag! 'amount', params[:amount].to_s if soap_call != 'delete'
274
+ end
275
+ end
276
+ end
277
+ xml.target!
278
+ end
279
+
280
+ def authorize_post_data(params = {})
281
+ params[:language] = '2'
282
+ params[:cms] = 'activemerchant_3ds'
283
+ params[:accepturl] = live_url + 'auth/default.aspx?accept=1'
284
+ params[:declineurl] = live_url + 'auth/default.aspx?decline=1'
285
+ params[:merchantnumber] = @options[:login]
286
+
287
+ params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
288
+ end
289
+
290
+ # Limited to 20 digits max
291
+ def format_order_number(number)
292
+ number.to_s.gsub(/[^\w]/, '').rjust(4, '0')[0...20]
293
+ end
294
+ end
295
+ end
296
+ end