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,182 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class MicropaymentGateway < Gateway
4
+ self.display_name = 'micropayment'
5
+ self.homepage_url = 'https://www.micropayment.de/'
6
+
7
+ self.test_url = self.live_url = 'https://sipg.micropayment.de/public/creditcardpsp/v1/nvp/'
8
+
9
+ self.supported_countries = %w(DE)
10
+ self.default_currency = 'EUR'
11
+ self.money_format = :cents
12
+ self.supported_cardtypes = %i[visa master american_express]
13
+
14
+ def initialize(options = {})
15
+ requires!(options, :access_key)
16
+ super
17
+ end
18
+
19
+ def purchase(amount, payment_method, options = {})
20
+ post = {}
21
+ add_invoice(post, amount, options)
22
+ add_payment_method(post, payment_method, options)
23
+ add_customer_data(post, options)
24
+ add_address(post, options)
25
+ commit('purchase', post)
26
+ end
27
+
28
+ def authorize(amount, payment_method, options = {})
29
+ post = {}
30
+ add_invoice(post, amount, options)
31
+ add_payment_method(post, payment_method, options)
32
+ add_customer_data(post, options)
33
+ add_address(post, options)
34
+ commit('authorize', post)
35
+ end
36
+
37
+ def capture(amount, authorization, options = {})
38
+ post = {}
39
+ add_reference(post, authorization)
40
+ add_invoice(post, amount, options)
41
+ commit('capture', post)
42
+ end
43
+
44
+ def void(authorization, options = {})
45
+ post = {}
46
+ add_reference(post, authorization)
47
+ commit('void', post)
48
+ end
49
+
50
+ def refund(amount, authorization, options = {})
51
+ post = {}
52
+ add_reference(post, authorization)
53
+ add_invoice(post, amount, options)
54
+ commit('refund', post)
55
+ end
56
+
57
+ def verify(credit_card, options = {})
58
+ MultiResponse.run(:use_first_response) do |r|
59
+ r.process { authorize(250, credit_card, options) }
60
+ r.process(:ignore_result) { void(r.authorization, options) }
61
+ end
62
+ end
63
+
64
+ def supports_scrubbing?
65
+ true
66
+ end
67
+
68
+ def scrub(transcript)
69
+ transcript.
70
+ gsub(%r((accessKey=)\w+), '\1[FILTERED]').
71
+ gsub(%r((number=)\d+), '\1[FILTERED]').
72
+ gsub(%r((cvc2=)\d+), '\1[FILTERED]')
73
+ end
74
+
75
+ private
76
+
77
+ def add_invoice(post, money, options)
78
+ if money
79
+ post[:amount] = amount(money)
80
+ post[:currency] = options[:currency] || currency(money)
81
+ end
82
+ post[:project] = options[:project] if options[:project]
83
+ post['params[title]'] = options[:description] if options[:description]
84
+ end
85
+
86
+ def add_payment_method(post, payment_method, options = {})
87
+ post[:number] = payment_method.number
88
+ post[:recurring] = 1 if options[:recurring] == true
89
+ post[:cvc2] = payment_method.verification_value
90
+ post[:expiryYear] = format(payment_method.year, :four_digits)
91
+ post[:expiryMonth] = format(payment_method.month, :two_digits)
92
+
93
+ post['params[firstname]'] = payment_method.first_name
94
+ post['params[surname]'] = payment_method.last_name
95
+ end
96
+
97
+ def add_customer_data(post, options)
98
+ post['params[email]'] = options[:email] if options[:email]
99
+ post['params[ip]'] = options[:ip] || '1.1.1.1'
100
+ post['params[sendMail]'] = options[:send_mail] || 'false'
101
+ end
102
+
103
+ def add_address(post, options)
104
+ address = options[:billing_address]
105
+ return unless address
106
+
107
+ post['params[address]'] = address[:address1] if address[:address1]
108
+ post['params[zipcode]'] = address[:zip] if address[:zip]
109
+ post['params[town]'] = address[:city] if address[:city]
110
+ post['params[country]'] = address[:country] if address[:country]
111
+ end
112
+
113
+ def add_reference(post, authorization)
114
+ session_id, transaction_id = split_authorization(authorization)
115
+ post[:sessionId] = session_id
116
+ post[:transactionId] = transaction_id
117
+ end
118
+
119
+ def commit(action, params)
120
+ params[:testMode] = 1 if test?
121
+ params[:accessKey] = @options[:access_key]
122
+ params[:apiKey] = @options[:api_key] || 'af1fd841af792f4c50131414ff76e004'
123
+
124
+ response = parse(ssl_post(url(action), post_data(action, params), headers))
125
+
126
+ Response.new(
127
+ succeeded = success_from(response),
128
+ message_from(succeeded, response),
129
+ response,
130
+ authorization: authorization_from(response, params),
131
+ avs_result: AVSResult.new(code: response['some_avs_result_key']),
132
+ cvv_result: CVVResult.new(response['some_cvv_result_key']),
133
+ test: test?
134
+ )
135
+ end
136
+
137
+ def headers
138
+ { 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8' }
139
+ end
140
+
141
+ def post_data(action, params)
142
+ params.map { |k, v| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}" }.join('&')
143
+ end
144
+
145
+ def url(action)
146
+ action_url = test? ? test_url : live_url
147
+ "#{action_url}?action=#{action}"
148
+ end
149
+
150
+ def parse(body)
151
+ body.split(/\r?\n/).inject({}) do |acc, pair|
152
+ key, value = pair.split('=')
153
+ acc[key] = CGI.unescape(value)
154
+ acc
155
+ end
156
+ end
157
+
158
+ def success_from(response)
159
+ response['error'] == '0' &&
160
+ response['transactionResultCode'] == '00' &&
161
+ response['transactionStatus'] == 'SUCCESS'
162
+ end
163
+
164
+ def message_from(succeeded, response)
165
+ if succeeded
166
+ 'Succeeded'
167
+ else
168
+ response['errorMessage'] || response['transactionResultMessage']
169
+ end
170
+ end
171
+
172
+ def split_authorization(authorization)
173
+ authorization.split('|')
174
+ end
175
+
176
+ def authorization_from(response, request_params)
177
+ session_id = response['sessionId'] || request_params[:sessionId]
178
+ "#{session_id}|#{response['transactionId']}"
179
+ end
180
+ end
181
+ end
182
+ end
@@ -0,0 +1,100 @@
1
+ module ActiveMerchant
2
+ module Billing
3
+ module MigsCodes
4
+ TXN_RESPONSE_CODES = {
5
+ '?' => 'Response Unknown',
6
+ '0' => 'Transaction Successful',
7
+ '1' => 'Transaction Declined - Bank Error',
8
+ '2' => 'Bank Declined Transaction',
9
+ '3' => 'Transaction Declined - No Reply from Bank',
10
+ '4' => 'Transaction Declined - Expired Card',
11
+ '5' => 'Transaction Declined - Insufficient funds',
12
+ '6' => 'Transaction Declined - Error Communicating with Bank',
13
+ '7' => 'Payment Server Processing Error - Typically caused by invalid input data such as an invalid credit card number. Processing errors can also occur',
14
+ '8' => 'Transaction Declined - Transaction Type Not Supported',
15
+ '9' => 'Bank Declined Transaction (Do not contact Bank)',
16
+ 'A' => 'Transaction Aborted',
17
+ 'C' => 'Transaction Cancelled',
18
+ 'D' => 'Deferred Transaction',
19
+ 'E' => 'Issuer Returned a Referral Response',
20
+ 'F' => '3D Secure Authentication Failed',
21
+ 'I' => 'Card Security Code Failed',
22
+ 'L' => 'Shopping Transaction Locked (This indicates that there is another transaction taking place using the same shopping transaction number)',
23
+ 'N' => 'Cardholder is not enrolled in 3D Secure (Authentication Only)',
24
+ 'P' => 'Transaction is Pending',
25
+ 'R' => 'Retry Limits Exceeded, Transaction Not Processed',
26
+ 'S' => 'Duplicate OrderInfo used. (This is only relevant for Payment Servers that enforce the uniqueness of this field)',
27
+ 'U' => 'Card Security Code Failed'
28
+ }
29
+
30
+ ISSUER_RESPONSE_CODES = {
31
+ '00' => 'Approved',
32
+ '01' => 'Refer to Card Issuer',
33
+ '02' => 'Refer to Card Issuer',
34
+ '03' => 'Invalid Merchant',
35
+ '04' => 'Pick Up Card',
36
+ '05' => 'Do Not Honor',
37
+ '07' => 'Pick Up Card',
38
+ '12' => 'Invalid Transaction',
39
+ '14' => 'Invalid Card Number (No such Number)',
40
+ '15' => 'No Such Issuer',
41
+ '33' => 'Expired Card',
42
+ '34' => 'Suspected Fraud',
43
+ '36' => 'Restricted Card',
44
+ '39' => 'No Credit Account',
45
+ '41' => 'Card Reported Lost',
46
+ '43' => 'Stolen Card',
47
+ '51' => 'Insufficient Funds',
48
+ '54' => 'Expired Card',
49
+ '57' => 'Transaction Not Permitted',
50
+ '59' => 'Suspected Fraud',
51
+ '62' => 'Restricted Card',
52
+ '65' => 'Exceeds withdrawal frequency limit',
53
+ '91' => 'Cannot Contact Issuer'
54
+ }
55
+
56
+ VERIFIED_3D_CODES = {
57
+ 'Y' => 'The cardholder was successfully authenticated.',
58
+ 'E' => 'The cardholder is not enrolled.',
59
+ 'N' => 'The cardholder was not verified.',
60
+ 'U' => 'The cardholder\'s Issuer was unable to authenticate due to a system error at the Issuer.',
61
+ 'F' => 'An error exists in the format of the request from the merchant. For example, the request did not contain all required fields, or the format of some fields was invalid.',
62
+ 'A' => 'Authentication of your Merchant ID and Password to the Directory Server Failed (see "What does a Payment Authentication Status of "A" mean?" on page 85).',
63
+ 'D' => 'Error communicating with the Directory Server, for example, the Payment Server could not connect to the directory server or there was a versioning mismatch.',
64
+ 'C' => 'The card type is not supported for authentication.',
65
+ 'M' => 'This indicates that attempts processing was used. Verification is marked with status M - ACS attempts processing used. Payment is performed with authentication. Attempts is when a cardholder has successfully passed the directory server but decides not to continue with the authentication process and cancels.',
66
+ 'S' => 'The signature on the response received from the Issuer could not be validated. This should be considered a failure.',
67
+ 'T' => 'ACS timed out. The Issuer\'s ACS did not respond to the Authentication request within the time out period.',
68
+ 'P' => 'Error parsing input from Issuer.',
69
+ 'I' => 'Internal Payment Server system error. This could be caused by a temporary DB failure or an error in the security module or by some error in an internal system.'
70
+ }
71
+
72
+ class CreditCardType
73
+ attr_accessor :am_code, :migs_code, :migs_long_code, :name
74
+ def initialize(am_code, migs_code, migs_long_code, name)
75
+ @am_code = am_code
76
+ @migs_code = migs_code
77
+ @migs_long_code = migs_long_code
78
+ @name = name
79
+ end
80
+ end
81
+
82
+ CARD_TYPES = [
83
+ # The following are 4 different representations of credit card types
84
+ # am_code: The active merchant code
85
+ # migs_code: Used in response for purchase/authorize/status
86
+ # migs_long_code: Used to pre-select card for server_purchase_url
87
+ # name: The nice display name
88
+ %w(american_express AE Amex American\ Express),
89
+ %w(diners_club DC Dinersclub Diners\ Club),
90
+ %w(jcb JC JCB JCB\ Card),
91
+ %w(maestro MS Maestro Maestro\ Card),
92
+ %w(master MC Mastercard MasterCard),
93
+ %w(na PL PrivateLabelCard Private\ Label\ Card),
94
+ %w(visa VC Visa Visa\ Card)
95
+ ].map do |am_code, migs_code, migs_long_code, name|
96
+ CreditCardType.new(am_code, migs_code, migs_long_code, name)
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,329 @@
1
+ require 'active_merchant/billing/gateways/migs/migs_codes'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ class MigsGateway < Gateway
6
+ include MigsCodes
7
+
8
+ API_VERSION = 1
9
+
10
+ class_attribute :server_hosted_url, :merchant_hosted_url
11
+
12
+ self.server_hosted_url = 'https://migs.mastercard.com.au/vpcpay'
13
+ self.merchant_hosted_url = 'https://migs.mastercard.com.au/vpcdps'
14
+
15
+ self.live_url = self.server_hosted_url
16
+
17
+ # MiGS is supported throughout Asia Pacific, Middle East and Africa
18
+ # MiGS is used in Australia (AU) by ANZ (eGate), CBA (CommWeb) and more
19
+ # Source of Country List: http://www.scribd.com/doc/17811923
20
+ self.supported_countries = %w(AU AE BD BN EG HK ID JO KW LB LK MU MV MY NZ OM PH QA SA SG TT VN)
21
+
22
+ # The card types supported by the payment gateway
23
+ self.supported_cardtypes = %i[visa master american_express diners_club jcb]
24
+
25
+ self.money_format = :cents
26
+ self.currencies_without_fractions = %w(IDR)
27
+
28
+ # The homepage URL of the gateway
29
+ self.homepage_url = 'http://mastercard.com/mastercardsps'
30
+
31
+ # The name of the gateway
32
+ self.display_name = 'MasterCard Internet Gateway Service (MiGS)'
33
+
34
+ # Creates a new MigsGateway
35
+ # The advanced_login/advanced_password fields are needed for
36
+ # advanced methods such as the capture, refund and status methods
37
+ #
38
+ # ==== Options
39
+ #
40
+ # * <tt>:login</tt> -- The MiGS Merchant ID (REQUIRED)
41
+ # * <tt>:password</tt> -- The MiGS Access Code (REQUIRED)
42
+ # * <tt>:secure_hash</tt> -- The MiGS Secure Hash
43
+ # (Required for Server Hosted payments)
44
+ # * <tt>:advanced_login</tt> -- The MiGS AMA User
45
+ # * <tt>:advanced_password</tt> -- The MiGS AMA User's password
46
+ def initialize(options = {})
47
+ requires!(options, :login, :password)
48
+ super
49
+ end
50
+
51
+ # ==== Options
52
+ #
53
+ # * <tt>:order_id</tt> -- A reference for tracking the order (REQUIRED)
54
+ # * <tt>:unique_id</tt> -- A unique id for this request (Max 40 chars).
55
+ # If not supplied one will be generated.
56
+ def purchase(money, creditcard, options = {})
57
+ requires!(options, :order_id)
58
+
59
+ post = {}
60
+
61
+ add_amount(post, money, options)
62
+ add_invoice(post, options)
63
+ add_creditcard(post, creditcard)
64
+ add_standard_parameters('pay', post, options[:unique_id])
65
+ add_3ds(post, options)
66
+ add_tx_source(post, options)
67
+
68
+ commit(post)
69
+ end
70
+
71
+ # MiGS works by merchants being either purchase only or authorize/capture
72
+ # So authorize is the same as purchase when in authorize mode
73
+ alias authorize purchase
74
+
75
+ # ==== Options
76
+ #
77
+ # * <tt>:unique_id</tt> -- A unique id for this request (Max 40 chars).
78
+ # If not supplied one will be generated.
79
+ def capture(money, authorization, options = {})
80
+ requires!(@options, :advanced_login, :advanced_password)
81
+
82
+ post = options.merge(TransNo: authorization)
83
+
84
+ add_amount(post, money, options)
85
+ add_advanced_user(post)
86
+ add_standard_parameters('capture', post, options[:unique_id])
87
+ add_tx_source(post, options)
88
+
89
+ commit(post)
90
+ end
91
+
92
+ # ==== Options
93
+ #
94
+ # * <tt>:unique_id</tt> -- A unique id for this request (Max 40 chars).
95
+ # If not supplied one will be generated.
96
+ def refund(money, authorization, options = {})
97
+ requires!(@options, :advanced_login, :advanced_password)
98
+
99
+ post = options.merge(TransNo: authorization)
100
+
101
+ add_amount(post, money, options)
102
+ add_advanced_user(post)
103
+ add_standard_parameters('refund', post, options[:unique_id])
104
+ add_tx_source(post, options)
105
+
106
+ commit(post)
107
+ end
108
+
109
+ def void(authorization, options = {})
110
+ requires!(@options, :advanced_login, :advanced_password)
111
+
112
+ post = options.merge(TransNo: authorization)
113
+
114
+ add_advanced_user(post)
115
+ add_standard_parameters('voidAuthorisation', post, options[:unique_id])
116
+ add_tx_source(post, options)
117
+
118
+ commit(post)
119
+ end
120
+
121
+ def credit(money, authorization, options = {})
122
+ ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
123
+ refund(money, authorization, options)
124
+ end
125
+
126
+ def verify(credit_card, options = {})
127
+ MultiResponse.run do |r|
128
+ r.process { authorize(100, credit_card, options) }
129
+ r.process(:ignore_result) { void(r.authorization, options) }
130
+ end
131
+ end
132
+
133
+ # Checks the status of a previous transaction
134
+ # This can be useful when a response is not received due to network issues
135
+ #
136
+ # ==== Parameters
137
+ #
138
+ # * <tt>unique_id</tt> -- Unique id of transaction to find.
139
+ # This is the value of the option supplied in other methods or
140
+ # if not supplied is returned with key :MerchTxnRef
141
+ def status(unique_id)
142
+ requires!(@options, :advanced_login, :advanced_password)
143
+
144
+ post = {}
145
+ add_advanced_user(post)
146
+ add_standard_parameters('queryDR', post, unique_id)
147
+
148
+ commit(post)
149
+ end
150
+
151
+ # Generates a URL to redirect user to MiGS to process payment
152
+ # Once user is finished MiGS will redirect back to specified URL
153
+ # With a response hash which can be turned into a Response object
154
+ # with purchase_offsite_response
155
+ #
156
+ # ==== Options
157
+ #
158
+ # * <tt>:order_id</tt> -- A reference for tracking the order (REQUIRED)
159
+ # * <tt>:locale</tt> -- Change the language of the redirected page
160
+ # Values are 2 digit locale, e.g. en, es
161
+ # * <tt>:return_url</tt> -- the URL to return to once the payment is complete
162
+ # * <tt>:card_type</tt> -- Providing this skips the card type step.
163
+ # Values are ActiveMerchant formats: e.g. master, visa, american_express, diners_club
164
+ # * <tt>:unique_id</tt> -- Unique id of transaction to find.
165
+ # If not supplied one will be generated.
166
+ def purchase_offsite_url(money, options = {})
167
+ requires!(options, :order_id, :return_url)
168
+ requires!(@options, :secure_hash)
169
+
170
+ post = {}
171
+
172
+ add_amount(post, money, options)
173
+ add_invoice(post, options)
174
+ add_creditcard_type(post, options[:card_type]) if options[:card_type]
175
+
176
+ post[:Locale] = options[:locale] || 'en'
177
+ post[:ReturnURL] = options[:return_url]
178
+
179
+ add_standard_parameters('pay', post, options[:unique_id])
180
+
181
+ add_secure_hash(post)
182
+
183
+ self.server_hosted_url + '?' + post_data(post)
184
+ end
185
+
186
+ # Parses a response from purchase_offsite_url once user is redirected back
187
+ #
188
+ # ==== Parameters
189
+ #
190
+ # * <tt>data</tt> -- All params when offsite payment returns
191
+ # e.g. returns to http://company.com/return?a=1&b=2, then input "a=1&b=2"
192
+ def purchase_offsite_response(data)
193
+ requires!(@options, :secure_hash)
194
+
195
+ response_hash = parse(data)
196
+
197
+ expected_secure_hash = calculate_secure_hash(response_hash, @options[:secure_hash])
198
+ raise SecurityError, 'Secure Hash mismatch, response may be tampered with' unless response_hash[:SecureHash] == expected_secure_hash
199
+
200
+ response_object(response_hash)
201
+ end
202
+
203
+ def test?
204
+ @options[:login].start_with?('TEST')
205
+ end
206
+
207
+ def supports_scrubbing?
208
+ true
209
+ end
210
+
211
+ def scrub(transcript)
212
+ transcript.
213
+ gsub(%r((&?CardNum=)\d*(&?)), '\1[FILTERED]\2').
214
+ gsub(%r((&?CardSecurityCode=)\d*(&?)), '\1[FILTERED]\2').
215
+ gsub(%r((&?AccessCode=)[^&]*(&?)), '\1[FILTERED]\2').
216
+ gsub(%r((&?Password=)[^&]*(&?)), '\1[FILTERED]\2').
217
+ gsub(%r((&?3DSXID=)[^&]*(&?)), '\1[FILTERED]\2').
218
+ gsub(%r((&?VerToken=)[^&]*(&?)), '\1[FILTERED]\2')
219
+ end
220
+
221
+ private
222
+
223
+ def add_amount(post, money, options)
224
+ post[:Amount] = localized_amount(money, options[:currency])
225
+ post[:Currency] = options[:currency] if options[:currency]
226
+ end
227
+
228
+ def add_advanced_user(post)
229
+ post[:User] = @options[:advanced_login]
230
+ post[:Password] = @options[:advanced_password]
231
+ end
232
+
233
+ def add_invoice(post, options)
234
+ post[:OrderInfo] = options[:order_id]
235
+ end
236
+
237
+ def add_3ds(post, options)
238
+ post[:VerType] = options[:ver_type] if options[:ver_type]
239
+ post[:VerToken] = options[:ver_token] if options[:ver_token]
240
+ post['3DSXID'] = options[:three_ds_xid] if options[:three_ds_xid]
241
+ post['3DSECI'] = options[:three_ds_eci] if options[:three_ds_eci]
242
+ post['3DSenrolled'] = options[:three_ds_enrolled] if options[:three_ds_enrolled]
243
+ post['3DSstatus'] = options[:three_ds_status] if options[:three_ds_status]
244
+ end
245
+
246
+ def add_tx_source(post, options)
247
+ post[:TxSource] = options[:tx_source] if options[:tx_source]
248
+ end
249
+
250
+ def add_creditcard(post, creditcard)
251
+ post[:CardNum] = creditcard.number
252
+ post[:CardSecurityCode] = creditcard.verification_value if creditcard.verification_value?
253
+ post[:CardExp] = format(creditcard.year, :two_digits) + format(creditcard.month, :two_digits)
254
+ end
255
+
256
+ def add_creditcard_type(post, card_type)
257
+ post[:Gateway] = 'ssl'
258
+ post[:card] = CARD_TYPES.detect { |ct| ct.am_code == card_type }.migs_long_code
259
+ end
260
+
261
+ def parse(body)
262
+ params = CGI::parse(body)
263
+ hash = {}
264
+ params.each do |key, value|
265
+ hash[key.gsub('vpc_', '').to_sym] = value[0]
266
+ end
267
+ hash
268
+ end
269
+
270
+ def commit(post)
271
+ add_secure_hash(post) if @options[:secure_hash]
272
+ data = ssl_post self.merchant_hosted_url, post_data(post)
273
+ response_hash = parse(data)
274
+ response_object(response_hash)
275
+ end
276
+
277
+ def response_object(response)
278
+ avs_response_code = response[:AVSResultCode]
279
+ avs_response_code = 'S' if avs_response_code == 'Unsupported'
280
+
281
+ cvv_result_code = response[:CSCResultCode]
282
+ cvv_result_code = 'P' if cvv_result_code == 'Unsupported'
283
+
284
+ Response.new(success?(response), response[:Message], response,
285
+ test: test?,
286
+ authorization: response[:TransactionNo],
287
+ fraud_review: fraud_review?(response),
288
+ avs_result: { code: avs_response_code },
289
+ cvv_result: cvv_result_code)
290
+ end
291
+
292
+ def success?(response)
293
+ response[:TxnResponseCode] == '0'
294
+ end
295
+
296
+ def fraud_review?(response)
297
+ ISSUER_RESPONSE_CODES[response[:AcqResponseCode]] == 'Suspected Fraud'
298
+ end
299
+
300
+ def add_standard_parameters(action, post, unique_id = nil)
301
+ post.merge!(
302
+ Version: API_VERSION,
303
+ Merchant: @options[:login],
304
+ AccessCode: @options[:password],
305
+ Command: action,
306
+ MerchTxnRef: unique_id || generate_unique_id.slice(0, 40)
307
+ )
308
+ end
309
+
310
+ def post_data(post)
311
+ post.collect { |key, value| "vpc_#{key}=#{CGI.escape(value.to_s)}" }.join('&')
312
+ end
313
+
314
+ def add_secure_hash(post)
315
+ post[:SecureHash] = calculate_secure_hash(post, @options[:secure_hash])
316
+ post[:SecureHashType] = 'SHA256'
317
+ end
318
+
319
+ def calculate_secure_hash(post, secure_hash)
320
+ input = post.
321
+ reject { |k| %i[SecureHash SecureHashType].include?(k) }.
322
+ sort.
323
+ map { |(k, v)| "vpc_#{k}=#{v}" }.
324
+ join('&')
325
+ OpenSSL::HMAC.hexdigest('SHA256', [secure_hash].pack('H*'), input).upcase
326
+ end
327
+ end
328
+ end
329
+ end