active_accountability_merchant 1.97.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (259) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +2948 -0
  3. data/CONTRIBUTORS +568 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.md +246 -0
  6. data/lib/active_merchant.rb +63 -0
  7. data/lib/active_merchant/billing.rb +15 -0
  8. data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
  9. data/lib/active_merchant/billing/avs_result.rb +96 -0
  10. data/lib/active_merchant/billing/base.rb +61 -0
  11. data/lib/active_merchant/billing/check.rb +80 -0
  12. data/lib/active_merchant/billing/compatibility.rb +117 -0
  13. data/lib/active_merchant/billing/credit_card.rb +406 -0
  14. data/lib/active_merchant/billing/credit_card_formatting.rb +23 -0
  15. data/lib/active_merchant/billing/credit_card_methods.rb +343 -0
  16. data/lib/active_merchant/billing/cvv_result.rb +38 -0
  17. data/lib/active_merchant/billing/gateway.rb +330 -0
  18. data/lib/active_merchant/billing/gateways.rb +14 -0
  19. data/lib/active_merchant/billing/gateways/adyen.rb +503 -0
  20. data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
  21. data/lib/active_merchant/billing/gateways/authorize_net.rb +1055 -0
  22. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +417 -0
  23. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +980 -0
  24. data/lib/active_merchant/billing/gateways/axcessms.rb +181 -0
  25. data/lib/active_merchant/billing/gateways/balanced.rb +256 -0
  26. data/lib/active_merchant/billing/gateways/bambora_apac.rb +226 -0
  27. data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
  28. data/lib/active_merchant/billing/gateways/banwire.rb +116 -0
  29. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +384 -0
  30. data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +15 -0
  31. data/lib/active_merchant/billing/gateways/be2bill.rb +131 -0
  32. data/lib/active_merchant/billing/gateways/beanstream.rb +217 -0
  33. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +473 -0
  34. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +57 -0
  35. data/lib/active_merchant/billing/gateways/blue_pay.rb +522 -0
  36. data/lib/active_merchant/billing/gateways/blue_snap.rb +522 -0
  37. data/lib/active_merchant/billing/gateways/bogus.rb +186 -0
  38. data/lib/active_merchant/billing/gateways/borgun.rb +220 -0
  39. data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
  40. data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
  41. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +22 -0
  42. data/lib/active_merchant/billing/gateways/braintree_blue.rb +740 -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 +316 -0
  47. data/lib/active_merchant/billing/gateways/card_save.rb +22 -0
  48. data/lib/active_merchant/billing/gateways/card_stream.rb +367 -0
  49. data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
  50. data/lib/active_merchant/billing/gateways/cardprocess.rb +254 -0
  51. data/lib/active_merchant/billing/gateways/cashnet.rb +219 -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 +327 -0
  55. data/lib/active_merchant/billing/gateways/checkout.rb +214 -0
  56. data/lib/active_merchant/billing/gateways/checkout_v2.rb +270 -0
  57. data/lib/active_merchant/billing/gateways/citrus_pay.rb +22 -0
  58. data/lib/active_merchant/billing/gateways/clearhaus.rb +220 -0
  59. data/lib/active_merchant/billing/gateways/commercegate.rb +142 -0
  60. data/lib/active_merchant/billing/gateways/conekta.rb +228 -0
  61. data/lib/active_merchant/billing/gateways/creditcall.rb +271 -0
  62. data/lib/active_merchant/billing/gateways/credorax.rb +382 -0
  63. data/lib/active_merchant/billing/gateways/ct_payment.rb +268 -0
  64. data/lib/active_merchant/billing/gateways/culqi.rb +277 -0
  65. data/lib/active_merchant/billing/gateways/cyber_source.rb +828 -0
  66. data/lib/active_merchant/billing/gateways/d_local.rb +226 -0
  67. data/lib/active_merchant/billing/gateways/data_cash.rb +305 -0
  68. data/lib/active_merchant/billing/gateways/decidir.rb +233 -0
  69. data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
  70. data/lib/active_merchant/billing/gateways/digitzs.rb +292 -0
  71. data/lib/active_merchant/billing/gateways/ebanx.rb +296 -0
  72. data/lib/active_merchant/billing/gateways/efsnet.rb +215 -0
  73. data/lib/active_merchant/billing/gateways/elavon.rb +320 -0
  74. data/lib/active_merchant/billing/gateways/element.rb +356 -0
  75. data/lib/active_merchant/billing/gateways/epay.rb +285 -0
  76. data/lib/active_merchant/billing/gateways/evo_ca.rb +308 -0
  77. data/lib/active_merchant/billing/gateways/eway.rb +226 -0
  78. data/lib/active_merchant/billing/gateways/eway_managed.rb +290 -0
  79. data/lib/active_merchant/billing/gateways/eway_rapid.rb +563 -0
  80. data/lib/active_merchant/billing/gateways/exact.rb +224 -0
  81. data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
  82. data/lib/active_merchant/billing/gateways/fat_zebra.rb +218 -0
  83. data/lib/active_merchant/billing/gateways/federated_canada.rb +159 -0
  84. data/lib/active_merchant/billing/gateways/finansbank.rb +22 -0
  85. data/lib/active_merchant/billing/gateways/first_giving.rb +142 -0
  86. data/lib/active_merchant/billing/gateways/first_pay.rb +182 -0
  87. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +451 -0
  88. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +485 -0
  89. data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
  90. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
  91. data/lib/active_merchant/billing/gateways/forte.rb +270 -0
  92. data/lib/active_merchant/billing/gateways/garanti.rb +259 -0
  93. data/lib/active_merchant/billing/gateways/global_collect.rb +336 -0
  94. data/lib/active_merchant/billing/gateways/global_transport.rb +194 -0
  95. data/lib/active_merchant/billing/gateways/hdfc.rb +206 -0
  96. data/lib/active_merchant/billing/gateways/hps.rb +350 -0
  97. data/lib/active_merchant/billing/gateways/iats_payments.rb +290 -0
  98. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
  99. data/lib/active_merchant/billing/gateways/inspire.rb +218 -0
  100. data/lib/active_merchant/billing/gateways/instapay.rb +162 -0
  101. data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
  102. data/lib/active_merchant/billing/gateways/iridium.rb +468 -0
  103. data/lib/active_merchant/billing/gateways/itransact.rb +447 -0
  104. data/lib/active_merchant/billing/gateways/iveri.rb +251 -0
  105. data/lib/active_merchant/billing/gateways/jetpay.rb +402 -0
  106. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +437 -0
  107. data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
  108. data/lib/active_merchant/billing/gateways/kushki.rb +219 -0
  109. data/lib/active_merchant/billing/gateways/latitude19.rb +411 -0
  110. data/lib/active_merchant/billing/gateways/linkpoint.rb +449 -0
  111. data/lib/active_merchant/billing/gateways/litle.rb +507 -0
  112. data/lib/active_merchant/billing/gateways/mastercard.rb +267 -0
  113. data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
  114. data/lib/active_merchant/billing/gateways/mercado_pago.rb +277 -0
  115. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +194 -0
  116. data/lib/active_merchant/billing/gateways/merchant_one.rb +113 -0
  117. data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
  118. data/lib/active_merchant/billing/gateways/merchant_ware.rb +319 -0
  119. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +286 -0
  120. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +210 -0
  121. data/lib/active_merchant/billing/gateways/mercury.rb +356 -0
  122. data/lib/active_merchant/billing/gateways/metrics_global.rb +303 -0
  123. data/lib/active_merchant/billing/gateways/micropayment.rb +183 -0
  124. data/lib/active_merchant/billing/gateways/migs.rb +332 -0
  125. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
  126. data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
  127. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +217 -0
  128. data/lib/active_merchant/billing/gateways/monei.rb +338 -0
  129. data/lib/active_merchant/billing/gateways/moneris.rb +377 -0
  130. data/lib/active_merchant/billing/gateways/moneris_us.rb +352 -0
  131. data/lib/active_merchant/billing/gateways/money_movers.rb +151 -0
  132. data/lib/active_merchant/billing/gateways/mundipagg.rb +293 -0
  133. data/lib/active_merchant/billing/gateways/nab_transact.rb +301 -0
  134. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +165 -0
  135. data/lib/active_merchant/billing/gateways/net_registry.rb +199 -0
  136. data/lib/active_merchant/billing/gateways/netaxept.rb +180 -0
  137. data/lib/active_merchant/billing/gateways/netbanx.rb +294 -0
  138. data/lib/active_merchant/billing/gateways/netbilling.rb +232 -0
  139. data/lib/active_merchant/billing/gateways/netpay.rb +222 -0
  140. data/lib/active_merchant/billing/gateways/network_merchants.rb +241 -0
  141. data/lib/active_merchant/billing/gateways/nmi.rb +324 -0
  142. data/lib/active_merchant/billing/gateways/ogone.rb +478 -0
  143. data/lib/active_merchant/billing/gateways/omise.rb +324 -0
  144. data/lib/active_merchant/billing/gateways/openpay.rb +228 -0
  145. data/lib/active_merchant/billing/gateways/opp.rb +388 -0
  146. data/lib/active_merchant/billing/gateways/optimal_payment.rb +332 -0
  147. data/lib/active_merchant/billing/gateways/orbital.rb +1006 -0
  148. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +47 -0
  149. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +206 -0
  150. data/lib/active_merchant/billing/gateways/pagarme.rb +246 -0
  151. data/lib/active_merchant/billing/gateways/pago_facil.rb +122 -0
  152. data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
  153. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +280 -0
  154. data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
  155. data/lib/active_merchant/billing/gateways/pay_junction.rb +390 -0
  156. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +188 -0
  157. data/lib/active_merchant/billing/gateways/pay_secure.rb +111 -0
  158. data/lib/active_merchant/billing/gateways/paybox_direct.rb +200 -0
  159. data/lib/active_merchant/billing/gateways/payeezy.rb +410 -0
  160. data/lib/active_merchant/billing/gateways/payex.rb +410 -0
  161. data/lib/active_merchant/billing/gateways/payflow.rb +383 -0
  162. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +235 -0
  163. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +43 -0
  164. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
  165. data/lib/active_merchant/billing/gateways/payflow_express.rb +220 -0
  166. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +14 -0
  167. data/lib/active_merchant/billing/gateways/payflow_uk.rb +20 -0
  168. data/lib/active_merchant/billing/gateways/payment_express.rb +369 -0
  169. data/lib/active_merchant/billing/gateways/paymentez.rb +300 -0
  170. data/lib/active_merchant/billing/gateways/paymill.rb +371 -0
  171. data/lib/active_merchant/billing/gateways/paypal.rb +128 -0
  172. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +717 -0
  173. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +65 -0
  174. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -0
  175. data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
  176. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +44 -0
  177. data/lib/active_merchant/billing/gateways/paypal_express.rb +269 -0
  178. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
  179. data/lib/active_merchant/billing/gateways/payscout.rb +160 -0
  180. data/lib/active_merchant/billing/gateways/paystation.rb +207 -0
  181. data/lib/active_merchant/billing/gateways/payu_in.rb +248 -0
  182. data/lib/active_merchant/billing/gateways/payu_latam.rb +449 -0
  183. data/lib/active_merchant/billing/gateways/payway.rb +207 -0
  184. data/lib/active_merchant/billing/gateways/pin.rb +234 -0
  185. data/lib/active_merchant/billing/gateways/plugnpay.rb +284 -0
  186. data/lib/active_merchant/billing/gateways/pro_pay.rb +326 -0
  187. data/lib/active_merchant/billing/gateways/psigate.rb +227 -0
  188. data/lib/active_merchant/billing/gateways/psl_card.rb +296 -0
  189. data/lib/active_merchant/billing/gateways/qbms.rb +303 -0
  190. data/lib/active_merchant/billing/gateways/quantum.rb +276 -0
  191. data/lib/active_merchant/billing/gateways/quickbooks.rb +290 -0
  192. data/lib/active_merchant/billing/gateways/quickpay.rb +25 -0
  193. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
  194. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +301 -0
  195. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
  196. data/lib/active_merchant/billing/gateways/qvalent.rb +289 -0
  197. data/lib/active_merchant/billing/gateways/realex.rb +374 -0
  198. data/lib/active_merchant/billing/gateways/redsys.rb +534 -0
  199. data/lib/active_merchant/billing/gateways/s5.rb +246 -0
  200. data/lib/active_merchant/billing/gateways/safe_charge.rb +262 -0
  201. data/lib/active_merchant/billing/gateways/sage.rb +448 -0
  202. data/lib/active_merchant/billing/gateways/sage_pay.rb +434 -0
  203. data/lib/active_merchant/billing/gateways/sallie_mae.rb +142 -0
  204. data/lib/active_merchant/billing/gateways/secure_net.rb +267 -0
  205. data/lib/active_merchant/billing/gateways/secure_pay.rb +200 -0
  206. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +292 -0
  207. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +104 -0
  208. data/lib/active_merchant/billing/gateways/securion_pay.rb +264 -0
  209. data/lib/active_merchant/billing/gateways/skip_jack.rb +450 -0
  210. data/lib/active_merchant/billing/gateways/smart_ps.rb +280 -0
  211. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
  212. data/lib/active_merchant/billing/gateways/spreedly_core.rb +306 -0
  213. data/lib/active_merchant/billing/gateways/stripe.rb +790 -0
  214. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +267 -0
  215. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +152 -0
  216. data/lib/active_merchant/billing/gateways/telr.rb +274 -0
  217. data/lib/active_merchant/billing/gateways/tns.rb +22 -0
  218. data/lib/active_merchant/billing/gateways/trans_first.rb +239 -0
  219. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +608 -0
  220. data/lib/active_merchant/billing/gateways/transact_pro.rb +224 -0
  221. data/lib/active_merchant/billing/gateways/transax.rb +22 -0
  222. data/lib/active_merchant/billing/gateways/transnational.rb +9 -0
  223. data/lib/active_merchant/billing/gateways/trexle.rb +218 -0
  224. data/lib/active_merchant/billing/gateways/trust_commerce.rb +490 -0
  225. data/lib/active_merchant/billing/gateways/usa_epay.rb +25 -0
  226. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1620 -0
  227. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +355 -0
  228. data/lib/active_merchant/billing/gateways/vanco.rb +294 -0
  229. data/lib/active_merchant/billing/gateways/verifi.rb +225 -0
  230. data/lib/active_merchant/billing/gateways/viaklix.rb +176 -0
  231. data/lib/active_merchant/billing/gateways/visanet_peru.rb +245 -0
  232. data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
  233. data/lib/active_merchant/billing/gateways/wepay.rb +237 -0
  234. data/lib/active_merchant/billing/gateways/wirecard.rb +432 -0
  235. data/lib/active_merchant/billing/gateways/world_net.rb +344 -0
  236. data/lib/active_merchant/billing/gateways/worldpay.rb +634 -0
  237. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +215 -0
  238. data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
  239. data/lib/active_merchant/billing/model.rb +30 -0
  240. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
  241. data/lib/active_merchant/billing/payment_token.rb +21 -0
  242. data/lib/active_merchant/billing/rails.rb +3 -0
  243. data/lib/active_merchant/billing/response.rb +92 -0
  244. data/lib/active_merchant/connection.rb +195 -0
  245. data/lib/active_merchant/country.rb +336 -0
  246. data/lib/active_merchant/empty.rb +20 -0
  247. data/lib/active_merchant/errors.rb +35 -0
  248. data/lib/active_merchant/net_http_ssl_connection.rb +10 -0
  249. data/lib/active_merchant/network_connection_retries.rb +80 -0
  250. data/lib/active_merchant/post_data.rb +25 -0
  251. data/lib/active_merchant/posts_data.rb +92 -0
  252. data/lib/active_merchant/version.rb +3 -0
  253. data/lib/activemerchant.rb +1 -0
  254. data/lib/certs/cacert.pem +3988 -0
  255. data/lib/support/gateway_support.rb +69 -0
  256. data/lib/support/outbound_hosts.rb +28 -0
  257. data/lib/support/ssl_verify.rb +92 -0
  258. data/lib/support/ssl_version.rb +87 -0
  259. metadata +435 -0
@@ -0,0 +1,233 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class DecidirGateway < Gateway
4
+ self.test_url = 'https://developers.decidir.com/api/v2'
5
+ self.live_url = 'https://live.decidir.com/api/v2'
6
+
7
+ self.supported_countries = ['AR']
8
+ self.money_format = :cents
9
+ self.default_currency = 'ARS'
10
+ self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :naranja, :cabal]
11
+
12
+ self.homepage_url = 'http://www.decidir.com'
13
+ self.display_name = 'Decidir'
14
+
15
+ STANDARD_ERROR_CODE_MAPPING = {
16
+ 1 => STANDARD_ERROR_CODE[:call_issuer],
17
+ 2 => STANDARD_ERROR_CODE[:call_issuer],
18
+ 3 => STANDARD_ERROR_CODE[:config_error],
19
+ 4 => STANDARD_ERROR_CODE[:pickup_card],
20
+ 5 => STANDARD_ERROR_CODE[:card_declined],
21
+ 7 => STANDARD_ERROR_CODE[:pickup_card],
22
+ 12 => STANDARD_ERROR_CODE[:processing_error],
23
+ 14 => STANDARD_ERROR_CODE[:invalid_number],
24
+ 28 => STANDARD_ERROR_CODE[:processing_error],
25
+ 38 => STANDARD_ERROR_CODE[:incorrect_pin],
26
+ 39 => STANDARD_ERROR_CODE[:invalid_number],
27
+ 43 => STANDARD_ERROR_CODE[:pickup_card],
28
+ 45 => STANDARD_ERROR_CODE[:card_declined],
29
+ 46 => STANDARD_ERROR_CODE[:invalid_number],
30
+ 47 => STANDARD_ERROR_CODE[:card_declined],
31
+ 48 => STANDARD_ERROR_CODE[:card_declined],
32
+ 49 => STANDARD_ERROR_CODE[:invalid_expiry_date],
33
+ 51 => STANDARD_ERROR_CODE[:card_declined],
34
+ 53 => STANDARD_ERROR_CODE[:card_declined],
35
+ 54 => STANDARD_ERROR_CODE[:expired_card],
36
+ 55 => STANDARD_ERROR_CODE[:incorrect_pin],
37
+ 56 => STANDARD_ERROR_CODE[:card_declined],
38
+ 57 => STANDARD_ERROR_CODE[:card_declined],
39
+ 76 => STANDARD_ERROR_CODE[:call_issuer],
40
+ 96 => STANDARD_ERROR_CODE[:processing_error],
41
+ 97 => STANDARD_ERROR_CODE[:processing_error],
42
+ }
43
+
44
+ def initialize(options={})
45
+ requires!(options, :api_key)
46
+ super
47
+ @options[:preauth_mode] ||= false
48
+ end
49
+
50
+ def purchase(money, payment, options={})
51
+ raise ArgumentError, 'Purchase is not supported on Decidir gateways configured with the preauth_mode option' if @options[:preauth_mode]
52
+
53
+ post = {}
54
+ add_auth_purchase_params(post, money, payment, options)
55
+ commit(:post, 'payments', post)
56
+ end
57
+
58
+ def authorize(money, payment, options={})
59
+ raise ArgumentError, 'Authorize is not supported on Decidir gateways unless the preauth_mode option is enabled' unless @options[:preauth_mode]
60
+
61
+ post = {}
62
+ add_auth_purchase_params(post, money, payment, options)
63
+ commit(:post, 'payments', post)
64
+ end
65
+
66
+ def capture(money, authorization, options={})
67
+ raise ArgumentError, 'Capture is not supported on Decidir gateways unless the preauth_mode option is enabled' unless @options[:preauth_mode]
68
+
69
+ post = {}
70
+ add_amount(post, money, options)
71
+ commit(:put, "payments/#{authorization}", post)
72
+ end
73
+
74
+ def refund(money, authorization, options={})
75
+ post = {}
76
+ add_amount(post, money, options)
77
+ commit(:post, "payments/#{authorization}/refunds", post)
78
+ end
79
+
80
+ def void(authorization, options={})
81
+ post = {}
82
+ commit(:post, "payments/#{authorization}/refunds", post)
83
+ end
84
+
85
+ def verify(credit_card, options={})
86
+ raise ArgumentError, 'Verify is not supported on Decidir gateways unless the preauth_mode option is enabled' unless @options[:preauth_mode]
87
+
88
+ MultiResponse.run(:use_first_response) do |r|
89
+ r.process { authorize(100, credit_card, options) }
90
+ r.process(:ignore_result) { void(r.authorization, options) }
91
+ end
92
+ end
93
+
94
+ def supports_scrubbing?
95
+ true
96
+ end
97
+
98
+ def scrub(transcript)
99
+ transcript.
100
+ gsub(%r((apikey: )\w+)i, '\1[FILTERED]').
101
+ gsub(%r((\"card_number\\\":\\\")\d+), '\1[FILTERED]').
102
+ gsub(%r((\"security_code\\\":\\\")\d+), '\1[FILTERED]').
103
+ gsub(%r((\"emv_issuer_data\\\":\\\")\d+), '\1[FILTERED]')
104
+ end
105
+
106
+ private
107
+
108
+ def add_auth_purchase_params(post, money, credit_card, options)
109
+ post[:payment_method_id] = options[:payment_method_id] ? options[:payment_method_id].to_i : 1
110
+ post[:site_transaction_id] = options[:order_id]
111
+ post[:bin] = credit_card.number[0..5]
112
+ post[:payment_type] = options[:payment_type] || 'single'
113
+ post[:installments] = options[:installments] ? options[:installments].to_i : 1
114
+ post[:description] = options[:description] if options[:description]
115
+ post[:email] = options[:email] if options[:email]
116
+ post[:sub_payments] = []
117
+
118
+ add_invoice(post, money, options)
119
+ add_payment(post, credit_card, options)
120
+ end
121
+
122
+ def add_invoice(post, money, options)
123
+ add_amount(post, money, options)
124
+ post[:currency] = (options[:currency] || currency(money))
125
+ end
126
+
127
+ def add_amount(post, money, options)
128
+ currency = (options[:currency] || currency(money))
129
+ post[:amount] = localized_amount(money, currency).to_i
130
+ end
131
+
132
+ def add_payment(post, credit_card, options)
133
+ card_data = {}
134
+ card_data[:card_number] = credit_card.number
135
+ card_data[:card_expiration_month] = format(credit_card.month, :two_digits)
136
+ card_data[:card_expiration_year] = format(credit_card.year, :two_digits)
137
+ card_data[:security_code] = credit_card.verification_value if credit_card.verification_value?
138
+ card_data[:card_holder_name] = credit_card.name if credit_card.name
139
+
140
+ # additional data used for Visa transactions
141
+ card_data[:card_holder_door_number] = options[:card_holder_door_number].to_i if options[:card_holder_door_number]
142
+ card_data[:card_holder_birthday] = options[:card_holder_birthday] if options[:card_holder_birthday]
143
+
144
+ card_data[:card_holder_identification] = {}
145
+ card_data[:card_holder_identification][:type] = options[:card_holder_identification_type] if options[:card_holder_identification_type]
146
+ card_data[:card_holder_identification][:number] = options[:card_holder_identification_number] if options[:card_holder_identification_number]
147
+
148
+ post[:card_data] = card_data
149
+ end
150
+
151
+ def headers(options = {})
152
+ {
153
+ 'apikey' => @options[:api_key],
154
+ 'Content-type' => 'application/json',
155
+ 'Cache-Control' => 'no-cache'
156
+ }
157
+ end
158
+
159
+ def commit(method, endpoint, parameters, options={})
160
+ url = "#{(test? ? test_url : live_url)}/#{endpoint}"
161
+
162
+ begin
163
+ raw_response = ssl_request(method, url, post_data(parameters), headers(options))
164
+ response = parse(raw_response)
165
+ rescue ResponseError => e
166
+ raw_response = e.response.body
167
+ response = parse(raw_response)
168
+ end
169
+
170
+ success = success_from(response)
171
+ Response.new(
172
+ success,
173
+ message_from(success, response),
174
+ response,
175
+ authorization: authorization_from(response),
176
+ test: test?,
177
+ error_code: success ? nil : error_code_from(response)
178
+ )
179
+ end
180
+
181
+ def post_data(parameters = {})
182
+ parameters.to_json
183
+ end
184
+
185
+ def parse(body)
186
+ JSON.parse(body)
187
+ rescue JSON::ParserError
188
+ {
189
+ 'message' => "A non-JSON response was received from Decidir where one was expected. The raw response was:\n\n#{body}"
190
+ }
191
+ end
192
+
193
+ def message_from(success, response)
194
+ return response['status'] if success
195
+ return response['message'] if response['message']
196
+
197
+ message = nil
198
+
199
+ if error = response.dig('status_details', 'error')
200
+ message = error.dig('reason', 'description')
201
+ elsif response['error_type']
202
+ if response['validation_errors']
203
+ message = response['validation_errors'].map { |errors| "#{errors['code']}: #{errors['param']}" }.join(', ')
204
+ end
205
+ message ||= response['error_type']
206
+ end
207
+
208
+ message
209
+ end
210
+
211
+ def success_from(response)
212
+ response['status'] == 'approved' || response['status'] == 'pre_approved'
213
+ end
214
+
215
+ def authorization_from(response)
216
+ response['id']
217
+ end
218
+
219
+ def error_code_from(response)
220
+ error_code = nil
221
+ if error = response.dig('status_details', 'error')
222
+ code = error.dig('reason', 'id')
223
+ error_code = STANDARD_ERROR_CODE_MAPPING[code]
224
+ error_code ||= error['type']
225
+ elsif response['error_type']
226
+ error_code = response['error_type'] if response['validation_errors']
227
+ end
228
+
229
+ error_code || STANDARD_ERROR_CODE[:processing_error]
230
+ end
231
+ end
232
+ end
233
+ end
@@ -0,0 +1,199 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class DibsGateway < Gateway
4
+ self.display_name = 'DIBS'
5
+ self.homepage_url = 'http://www.dibspayment.com/'
6
+
7
+ self.live_url = 'https://api.dibspayment.com/merchant/v1/JSON/Transaction/'
8
+
9
+ self.supported_countries = ['US', 'FI', 'NO', 'SE', 'GB']
10
+ self.default_currency = 'USD'
11
+ self.money_format = :cents
12
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover]
13
+
14
+ def initialize(options={})
15
+ requires!(options, :merchant_id, :secret_key)
16
+ super
17
+ end
18
+
19
+ def purchase(amount, payment_method, options={})
20
+ MultiResponse.run(false) do |r|
21
+ r.process { authorize(amount, payment_method, options) }
22
+ r.process { capture(amount, r.authorization, options) }
23
+ end
24
+ end
25
+
26
+ def authorize(amount, payment_method, options={})
27
+ post = {}
28
+ add_amount(post, amount)
29
+ add_invoice(post, amount, options)
30
+ if payment_method.respond_to?(:number)
31
+ add_payment_method(post, payment_method, options)
32
+ commit(:authorize, post)
33
+ else
34
+ add_ticket_id(post, payment_method)
35
+ commit(:authorize_ticket, post)
36
+ end
37
+ end
38
+
39
+ def capture(amount, authorization, options={})
40
+ post = {}
41
+ add_amount(post, amount)
42
+ add_reference(post, authorization)
43
+
44
+ commit(:capture, post)
45
+ end
46
+
47
+ def void(authorization, options={})
48
+ post = {}
49
+ add_reference(post, authorization)
50
+
51
+ commit(:void, post)
52
+ end
53
+
54
+ def refund(amount, authorization, options={})
55
+ post = {}
56
+ add_amount(post, amount)
57
+ add_reference(post, authorization)
58
+
59
+ commit(:refund, post)
60
+ end
61
+
62
+ def verify(credit_card, options={})
63
+ MultiResponse.run(:use_first_response) do |r|
64
+ r.process { authorize(100, credit_card, options) }
65
+ r.process(:ignore_result) { void(r.authorization, options) }
66
+ end
67
+ end
68
+
69
+ def store(payment_method, options = {})
70
+ post = {}
71
+
72
+ add_invoice(post, 0, options)
73
+ add_payment_method(post, payment_method, options)
74
+
75
+ commit(:store, post)
76
+ end
77
+
78
+ def supports_scrubbing?
79
+ true
80
+ end
81
+
82
+ def scrub(transcript)
83
+ transcript.
84
+ gsub(%r(("cardNumber\\?":\\?")[^"]*)i, '\1[FILTERED]').
85
+ gsub(%r(("cvc\\?":\\?")[^"]*)i, '\1[FILTERED]')
86
+ end
87
+
88
+ private
89
+
90
+ CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency: #{k}") }
91
+ CURRENCY_CODES['USD'] = '840'
92
+ CURRENCY_CODES['DKK'] = '208'
93
+ CURRENCY_CODES['NOK'] = '578'
94
+ CURRENCY_CODES['SEK'] = '752'
95
+ CURRENCY_CODES['GBP'] = '826'
96
+ CURRENCY_CODES['EUR'] = '978'
97
+
98
+ def add_invoice(post, money, options)
99
+ post[:orderId] = options[:order_id] || generate_unique_id
100
+ post[:currency] = CURRENCY_CODES[options[:currency] || currency(money)]
101
+ end
102
+
103
+ def add_ticket_id(post, payment_method)
104
+ post[:ticketId] = payment_method
105
+ end
106
+
107
+ def add_payment_method(post, payment_method, options)
108
+ post[:cardNumber] = payment_method.number
109
+ post[:cvc] = payment_method.verification_value if payment_method.verification_value
110
+ post[:expYear] = format(payment_method.year, :two_digits)
111
+ post[:expMonth] = payment_method.month
112
+ post[:clientIp] = options[:ip] || '127.0.0.1'
113
+ post[:test] = true if test?
114
+ end
115
+
116
+ def add_reference(post, authorization)
117
+ post[:transactionId] = authorization
118
+ end
119
+
120
+ def add_amount(post, amount)
121
+ post[:amount] = amount
122
+ end
123
+
124
+ ACTIONS = {
125
+ authorize: 'AuthorizeCard',
126
+ authorize_ticket: 'AuthorizeTicket',
127
+ capture: 'CaptureTransaction',
128
+ void: 'CancelTransaction',
129
+ refund: 'RefundTransaction',
130
+ store: 'CreateTicket'
131
+ }
132
+
133
+ def commit(action, post)
134
+ post[:merchantId] = @options[:merchant_id]
135
+
136
+ data = build_request(post)
137
+ raw = parse(ssl_post(url(action), "request=#{data}", headers))
138
+ succeeded = success_from(raw)
139
+ Response.new(
140
+ succeeded,
141
+ message_from(succeeded, raw),
142
+ raw,
143
+ authorization: authorization_from(post, raw),
144
+ test: test?
145
+ )
146
+ rescue JSON::ParserError
147
+ unparsable_response(raw)
148
+ end
149
+
150
+ def headers
151
+ {
152
+ 'Content-Type' => 'application/x-www-form-urlencoded'
153
+ }
154
+ end
155
+
156
+ def build_request(post)
157
+ add_hmac(post)
158
+ post.to_json
159
+ end
160
+
161
+ def add_hmac(post)
162
+ data = post.sort.collect { |key, value| "#{key}=#{value}" }.join('&')
163
+ digest = OpenSSL::Digest.new('sha256')
164
+ key = [@options[:secret_key]].pack('H*')
165
+ post[:MAC] = OpenSSL::HMAC.hexdigest(digest, key, data)
166
+ end
167
+
168
+ def url(action)
169
+ live_url + ACTIONS[action]
170
+ end
171
+
172
+ def parse(body)
173
+ JSON.parse(body)
174
+ end
175
+
176
+ def success_from(raw_response)
177
+ raw_response['status'] == 'ACCEPT'
178
+ end
179
+
180
+ def message_from(succeeded, response)
181
+ if succeeded
182
+ 'Succeeded'
183
+ else
184
+ response['status'] + ': ' + response['declineReason'] || 'Unable to read error message'
185
+ end
186
+ end
187
+
188
+ def authorization_from(request, response)
189
+ response['transactionId'] || response['ticketId'] || request[:transactionId]
190
+ end
191
+
192
+ def unparsable_response(raw_response)
193
+ message = 'Invalid JSON response received from Dibs. Please contact Dibs if you continue to receive this message.'
194
+ message += " (The raw response returned by the API was #{raw_response.inspect})"
195
+ return Response.new(false, message)
196
+ end
197
+ end
198
+ end
199
+ end
@@ -0,0 +1,292 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class DigitzsGateway < Gateway
4
+ include Empty
5
+
6
+ self.test_url = 'https://beta.digitzsapi.com/sandbox'
7
+ self.live_url = 'https://beta.digitzsapi.com/v3'
8
+
9
+ self.supported_countries = ['US']
10
+ self.default_currency = 'USD'
11
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover]
12
+ self.money_format = :cents
13
+
14
+ self.homepage_url = 'https://digitzs.com'
15
+ self.display_name = 'Digitzs'
16
+
17
+ def initialize(options={})
18
+ requires!(options, :app_key, :api_key)
19
+ super
20
+ end
21
+
22
+ def purchase(money, payment, options={})
23
+ MultiResponse.run do |r|
24
+ r.process { commit('auth/token', app_token_request(options)) }
25
+ r.process { commit('payments', purchase_request(money, payment, options), options.merge({ app_token: app_token_from(r) })) }
26
+ end
27
+ end
28
+
29
+ def refund(money, authorization, options={})
30
+ MultiResponse.run do |r|
31
+ r.process { commit('auth/token', app_token_request(options)) }
32
+ r.process { commit('payments', refund_request(money, authorization, options), options.merge({ app_token: app_token_from(r) })) }
33
+ end
34
+ end
35
+
36
+ def store(payment, options = {})
37
+ MultiResponse.run do |r|
38
+ r.process { commit('auth/token', app_token_request(options)) }
39
+ options[:app_token] = app_token_from(r)
40
+
41
+ if options[:customer_id].present?
42
+ customer_id = check_customer_exists(options)
43
+
44
+ if customer_id
45
+ r.process { add_credit_card_to_customer(payment, options) }
46
+ else
47
+ r.process { add_customer_with_credit_card(payment, options) }
48
+ end
49
+ else
50
+ r.process { add_customer_with_credit_card(payment, options) }
51
+ end
52
+ end
53
+ end
54
+
55
+ def supports_scrubbing?
56
+ true
57
+ end
58
+
59
+ def scrub(transcript)
60
+ transcript.
61
+ gsub(%r((Authorization: Bearer ).+), '\1[FILTERED]').
62
+ gsub(%r((X-Api-Key: )\w+), '\1[FILTERED]').
63
+ gsub(%r((\"id\\\":\\\").+), '\1[FILTERED]').
64
+ gsub(%r((\"appKey\\\":\\\").+), '\1[FILTERED]').
65
+ gsub(%r((\"appToken\\\":\\\").+), '\1[FILTERED]').
66
+ gsub(%r((\"code\\\":\\\")\d+), '\1[FILTERED]').
67
+ gsub(%r((\"number\\\":\\\")\d+), '\1[FILTERED]')
68
+ end
69
+
70
+ private
71
+
72
+ def new_post
73
+ {
74
+ data: {
75
+ attributes: {}
76
+ }
77
+ }
78
+ end
79
+
80
+ def add_split(post, options)
81
+ return unless options[:payment_type] == 'card_split' || options[:payment_type] == 'token_split'
82
+
83
+ post[:data][:attributes][:split] = {
84
+ merchantId: options[:split_merchant_id],
85
+ amount: amount(options[:split_amount])
86
+ }
87
+ end
88
+
89
+ def add_payment(post, payment, options)
90
+ if payment.is_a? String
91
+ customer_id, token = split_authorization(payment)
92
+ post[:data][:attributes][:token] = {
93
+ customerId: customer_id,
94
+ tokenId: token
95
+ }
96
+ else
97
+ post[:data][:attributes][:card] = {
98
+ type: payment.brand,
99
+ holder: payment.name,
100
+ number: payment.number,
101
+ expiry: expdate(payment),
102
+ code: payment.verification_value
103
+ }
104
+ end
105
+ end
106
+
107
+ def add_transaction(post, money, options)
108
+ post[:data][:attributes][:transaction] = {
109
+ amount: amount(money),
110
+ currency: (options[:currency] || currency(money)),
111
+ invoice: options[:order_id] || generate_unique_id
112
+ }
113
+ end
114
+
115
+ def add_address(post, options)
116
+ if address = options[:billing_address] || options[:address]
117
+ post[:data][:attributes][:billingAddress] = {
118
+ line1: address[:address1] || '',
119
+ line2: address[:address2] || '',
120
+ city: address[:city] || '',
121
+ state: address[:state] || '',
122
+ zip: address[:zip] || '',
123
+ country: address['country'] || 'USA'
124
+ }
125
+ end
126
+ end
127
+
128
+ def app_token_request(options)
129
+ post = new_post
130
+ post[:data][:type] = 'auth'
131
+ post[:data][:attributes] = { appKey: @options[:app_key] }
132
+
133
+ post
134
+ end
135
+
136
+ def purchase_request(money, payment, options)
137
+ post = new_post
138
+ post[:data][:type] = 'payments'
139
+ post[:data][:attributes][:merchantId] = options[:merchant_id]
140
+ post[:data][:attributes][:paymentType] = determine_payment_type(payment, options)
141
+ add_split(post, options)
142
+ add_payment(post, payment, options)
143
+ add_transaction(post, money, options)
144
+ add_address(post, options)
145
+
146
+ post
147
+ end
148
+
149
+ def refund_request(money, authorization, options)
150
+ post = new_post
151
+ post[:data][:type] = 'payments'
152
+ post[:data][:attributes][:merchantId] = options[:merchant_id]
153
+ post[:data][:attributes][:paymentType] = 'cardRefund'
154
+ post[:data][:attributes][:originalTransaction] = {id: authorization}
155
+ add_transaction(post, money, options)
156
+
157
+ post
158
+ end
159
+
160
+ def create_customer_request(payment, options)
161
+ post = new_post
162
+ post[:data][:type] = 'customers'
163
+ post[:data][:attributes] = {
164
+ merchantId: options[:merchant_id],
165
+ name: payment.name,
166
+ externalId: SecureRandom.hex(16)
167
+ }
168
+
169
+ post
170
+ end
171
+
172
+ def create_token_request(payment, options)
173
+ post = new_post
174
+ post[:data][:type] = 'tokens'
175
+ post[:data][:attributes] = {
176
+ tokenType: 'card',
177
+ customerId: options[:customer_id],
178
+ label: 'Credit Card',
179
+ }
180
+ add_payment(post, payment, options)
181
+ add_address(post, options)
182
+
183
+ post
184
+ end
185
+
186
+ def check_customer_exists(options = {})
187
+ url = (test? ? test_url : live_url)
188
+ response = parse(ssl_get(url + "/customers/#{options[:customer_id]}", headers(options)))
189
+
190
+ return response.try(:[], 'data').try(:[], 'customerId') if success_from(response)
191
+ return nil
192
+ end
193
+
194
+ def add_credit_card_to_customer(payment, options = {})
195
+ commit('tokens', create_token_request(payment, options), options)
196
+ end
197
+
198
+ def add_customer_with_credit_card(payment, options = {})
199
+ customer_response = commit('customers', create_customer_request(payment, options), options)
200
+ options[:customer_id] = customer_response.authorization
201
+ commit('tokens', create_token_request(payment, options), options)
202
+ end
203
+
204
+ def parse(body)
205
+ JSON.parse(body)
206
+ end
207
+
208
+ def commit(action, parameters, options={})
209
+ url = (test? ? test_url : live_url)
210
+ response = parse(ssl_post(url + "/#{action}", parameters.to_json, headers(options)))
211
+
212
+ Response.new(
213
+ success_from(response),
214
+ message_from(response),
215
+ response,
216
+ authorization: authorization_from(response),
217
+ avs_result: AVSResult.new(code: avs_result_from(response)),
218
+ cvv_result: CVVResult.new(cvv_result_from(response)),
219
+ test: test?,
220
+ error_code: error_code_from(response)
221
+ )
222
+ end
223
+
224
+ def success_from(response)
225
+ response['errors'].nil? && response['message'].nil?
226
+ end
227
+
228
+ def message_from(response)
229
+ return response['message'] if response['message']
230
+ return 'Success' if success_from(response)
231
+ response['errors'].map { |error_hash| error_hash['detail'] }.join(', ')
232
+ end
233
+
234
+ def authorization_from(response)
235
+ if customer_id = response.try(:[], 'data').try(:[], 'attributes').try(:[], 'customerId')
236
+ "#{customer_id}|#{response.try(:[], "data").try(:[], "id")}"
237
+ else
238
+ response.try(:[], 'data').try(:[], 'id')
239
+ end
240
+ end
241
+
242
+ def avs_result_from(response)
243
+ response.try(:[], 'data').try(:[], 'attributes').try(:[], 'transaction').try(:[], 'avsResult')
244
+ end
245
+
246
+ def cvv_result_from(response)
247
+ response.try(:[], 'data').try(:[], 'attributes').try(:[], 'transaction').try(:[], 'codeResult')
248
+ end
249
+
250
+ def app_token_from(response)
251
+ response.params.try(:[], 'data').try(:[], 'attributes').try(:[], 'appToken')
252
+ end
253
+
254
+ def headers(options)
255
+ headers = {
256
+ 'Content-Type' => 'application/json',
257
+ 'x-api-key' => @options[:api_key]
258
+ }
259
+
260
+ headers['Authorization'] = "Bearer #{options[:app_token]}" if options[:app_token]
261
+ headers
262
+ end
263
+
264
+ def error_code_from(response)
265
+ unless success_from(response)
266
+ response['errors'].nil? ? response['message'] : response['errors'].map { |error_hash| error_hash['code'] }.join(', ')
267
+ end
268
+ end
269
+
270
+ def split_authorization(authorization)
271
+ customer_id, token = authorization.split('|')
272
+ [customer_id, token]
273
+ end
274
+
275
+ def determine_payment_type(payment, options)
276
+ return 'cardSplit' if options[:payment_type] == 'card_split'
277
+ return 'tokenSplit' if options[:payment_type] == 'token_split'
278
+ return 'token' if payment.is_a? String
279
+ 'card'
280
+ end
281
+
282
+ def handle_response(response)
283
+ case response.code.to_i
284
+ when 200..499
285
+ response.body
286
+ else
287
+ raise ResponseError.new(response)
288
+ end
289
+ end
290
+ end
291
+ end
292
+ end