swiss-crm-activemerchant-v2 1.0.20

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 (288) 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/finix.rb +348 -0
  90. data/lib/active_merchant/billing/gateways/first_giving.rb +143 -0
  91. data/lib/active_merchant/billing/gateways/first_pay.rb +182 -0
  92. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +452 -0
  93. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +505 -0
  94. data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
  95. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
  96. data/lib/active_merchant/billing/gateways/fluidpay.rb +275 -0
  97. data/lib/active_merchant/billing/gateways/forte.rb +286 -0
  98. data/lib/active_merchant/billing/gateways/garanti.rb +256 -0
  99. data/lib/active_merchant/billing/gateways/global_collect.rb +580 -0
  100. data/lib/active_merchant/billing/gateways/global_transport.rb +193 -0
  101. data/lib/active_merchant/billing/gateways/hdfc.rb +205 -0
  102. data/lib/active_merchant/billing/gateways/hps.rb +472 -0
  103. data/lib/active_merchant/billing/gateways/iats_payments.rb +312 -0
  104. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
  105. data/lib/active_merchant/billing/gateways/inspire.rb +213 -0
  106. data/lib/active_merchant/billing/gateways/instapay.rb +159 -0
  107. data/lib/active_merchant/billing/gateways/ipg.rb +420 -0
  108. data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
  109. data/lib/active_merchant/billing/gateways/iridium.rb +467 -0
  110. data/lib/active_merchant/billing/gateways/itransact.rb +448 -0
  111. data/lib/active_merchant/billing/gateways/iveri.rb +290 -0
  112. data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
  113. data/lib/active_merchant/billing/gateways/jetpay.rb +395 -0
  114. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +432 -0
  115. data/lib/active_merchant/billing/gateways/klarna.rb +317 -0
  116. data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
  117. data/lib/active_merchant/billing/gateways/kushki.rb +297 -0
  118. data/lib/active_merchant/billing/gateways/latitude19.rb +412 -0
  119. data/lib/active_merchant/billing/gateways/linkpoint.rb +448 -0
  120. data/lib/active_merchant/billing/gateways/litle.rb +643 -0
  121. data/lib/active_merchant/billing/gateways/mastercard.rb +286 -0
  122. data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
  123. data/lib/active_merchant/billing/gateways/mercado_pago.rb +348 -0
  124. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +228 -0
  125. data/lib/active_merchant/billing/gateways/merchant_one.rb +110 -0
  126. data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
  127. data/lib/active_merchant/billing/gateways/merchant_ware.rb +313 -0
  128. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +284 -0
  129. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +248 -0
  130. data/lib/active_merchant/billing/gateways/mercury.rb +352 -0
  131. data/lib/active_merchant/billing/gateways/metrics_global.rb +293 -0
  132. data/lib/active_merchant/billing/gateways/micropayment.rb +182 -0
  133. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
  134. data/lib/active_merchant/billing/gateways/migs.rb +329 -0
  135. data/lib/active_merchant/billing/gateways/mit.rb +260 -0
  136. data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
  137. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +215 -0
  138. data/lib/active_merchant/billing/gateways/moka.rb +290 -0
  139. data/lib/active_merchant/billing/gateways/monei.rb +424 -0
  140. data/lib/active_merchant/billing/gateways/moneris.rb +488 -0
  141. data/lib/active_merchant/billing/gateways/money_movers.rb +150 -0
  142. data/lib/active_merchant/billing/gateways/mundipagg.rb +366 -0
  143. data/lib/active_merchant/billing/gateways/nab_transact.rb +299 -0
  144. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +163 -0
  145. data/lib/active_merchant/billing/gateways/net_registry.rb +198 -0
  146. data/lib/active_merchant/billing/gateways/netaxept.rb +180 -0
  147. data/lib/active_merchant/billing/gateways/netbanx.rb +376 -0
  148. data/lib/active_merchant/billing/gateways/netbilling.rb +229 -0
  149. data/lib/active_merchant/billing/gateways/netpay.rb +223 -0
  150. data/lib/active_merchant/billing/gateways/network_merchants.rb +238 -0
  151. data/lib/active_merchant/billing/gateways/nmi.rb +405 -0
  152. data/lib/active_merchant/billing/gateways/ogone.rb +509 -0
  153. data/lib/active_merchant/billing/gateways/omise.rb +323 -0
  154. data/lib/active_merchant/billing/gateways/openpay.rb +246 -0
  155. data/lib/active_merchant/billing/gateways/opp.rb +394 -0
  156. data/lib/active_merchant/billing/gateways/optimal_payment.rb +331 -0
  157. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +45 -0
  158. data/lib/active_merchant/billing/gateways/orbital.rb +1267 -0
  159. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +206 -0
  160. data/lib/active_merchant/billing/gateways/pagarme.rb +239 -0
  161. data/lib/active_merchant/billing/gateways/pago_facil.rb +120 -0
  162. data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
  163. data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
  164. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +277 -0
  165. data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
  166. data/lib/active_merchant/billing/gateways/pay_junction.rb +390 -0
  167. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +206 -0
  168. data/lib/active_merchant/billing/gateways/pay_secure.rb +110 -0
  169. data/lib/active_merchant/billing/gateways/pay_trace.rb +450 -0
  170. data/lib/active_merchant/billing/gateways/paybox_direct.rb +224 -0
  171. data/lib/active_merchant/billing/gateways/payeezy.rb +513 -0
  172. data/lib/active_merchant/billing/gateways/payex.rb +409 -0
  173. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +235 -0
  174. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +42 -0
  175. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
  176. data/lib/active_merchant/billing/gateways/payflow.rb +473 -0
  177. data/lib/active_merchant/billing/gateways/payflow_express.rb +220 -0
  178. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +14 -0
  179. data/lib/active_merchant/billing/gateways/payflow_uk.rb +20 -0
  180. data/lib/active_merchant/billing/gateways/payment_express.rb +373 -0
  181. data/lib/active_merchant/billing/gateways/paymentez.rb +365 -0
  182. data/lib/active_merchant/billing/gateways/paymill.rb +369 -0
  183. data/lib/active_merchant/billing/gateways/paynetworx.rb +228 -0
  184. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +718 -0
  185. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +69 -0
  186. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -0
  187. data/lib/active_merchant/billing/gateways/paypal.rb +136 -0
  188. data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
  189. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +44 -0
  190. data/lib/active_merchant/billing/gateways/paypal_express.rb +272 -0
  191. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
  192. data/lib/active_merchant/billing/gateways/paypal_standard.rb +281 -0
  193. data/lib/active_merchant/billing/gateways/paysafe.rb +420 -0
  194. data/lib/active_merchant/billing/gateways/payscout.rb +159 -0
  195. data/lib/active_merchant/billing/gateways/paystation.rb +204 -0
  196. data/lib/active_merchant/billing/gateways/payu_in.rb +249 -0
  197. data/lib/active_merchant/billing/gateways/payu_latam.rb +482 -0
  198. data/lib/active_merchant/billing/gateways/payway.rb +207 -0
  199. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
  200. data/lib/active_merchant/billing/gateways/pin.rb +273 -0
  201. data/lib/active_merchant/billing/gateways/pixxels.rb +263 -0
  202. data/lib/active_merchant/billing/gateways/plexo.rb +308 -0
  203. data/lib/active_merchant/billing/gateways/plugnpay.rb +283 -0
  204. data/lib/active_merchant/billing/gateways/priority.rb +392 -0
  205. data/lib/active_merchant/billing/gateways/pro_pay.rb +325 -0
  206. data/lib/active_merchant/billing/gateways/psigate.rb +227 -0
  207. data/lib/active_merchant/billing/gateways/psl_card.rb +295 -0
  208. data/lib/active_merchant/billing/gateways/qbms.rb +302 -0
  209. data/lib/active_merchant/billing/gateways/quantum.rb +274 -0
  210. data/lib/active_merchant/billing/gateways/quickbooks.rb +377 -0
  211. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
  212. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +297 -0
  213. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
  214. data/lib/active_merchant/billing/gateways/quickpay.rb +24 -0
  215. data/lib/active_merchant/billing/gateways/qvalent.rb +305 -0
  216. data/lib/active_merchant/billing/gateways/rapyd.rb +319 -0
  217. data/lib/active_merchant/billing/gateways/reach.rb +277 -0
  218. data/lib/active_merchant/billing/gateways/realex.rb +400 -0
  219. data/lib/active_merchant/billing/gateways/redsys.rb +723 -0
  220. data/lib/active_merchant/billing/gateways/s5.rb +247 -0
  221. data/lib/active_merchant/billing/gateways/safe_charge.rb +298 -0
  222. data/lib/active_merchant/billing/gateways/sage.rb +446 -0
  223. data/lib/active_merchant/billing/gateways/sage_pay.rb +434 -0
  224. data/lib/active_merchant/billing/gateways/sallie_mae.rb +141 -0
  225. data/lib/active_merchant/billing/gateways/secure_net.rb +260 -0
  226. data/lib/active_merchant/billing/gateways/secure_pay.rb +191 -0
  227. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +290 -0
  228. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +103 -0
  229. data/lib/active_merchant/billing/gateways/securion_pay.rb +305 -0
  230. data/lib/active_merchant/billing/gateways/shift4.rb +345 -0
  231. data/lib/active_merchant/billing/gateways/simetrik.rb +368 -0
  232. data/lib/active_merchant/billing/gateways/skip_jack.rb +450 -0
  233. data/lib/active_merchant/billing/gateways/smart_ps.rb +274 -0
  234. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
  235. data/lib/active_merchant/billing/gateways/spreedly_core.rb +359 -0
  236. data/lib/active_merchant/billing/gateways/stripe.rb +866 -0
  237. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +602 -0
  238. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +151 -0
  239. data/lib/active_merchant/billing/gateways/telr.rb +273 -0
  240. data/lib/active_merchant/billing/gateways/tns.rb +23 -0
  241. data/lib/active_merchant/billing/gateways/trans_first.rb +240 -0
  242. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +612 -0
  243. data/lib/active_merchant/billing/gateways/transact_pro.rb +222 -0
  244. data/lib/active_merchant/billing/gateways/transax.rb +21 -0
  245. data/lib/active_merchant/billing/gateways/transnational.rb +9 -0
  246. data/lib/active_merchant/billing/gateways/trexle.rb +221 -0
  247. data/lib/active_merchant/billing/gateways/trust_commerce.rb +500 -0
  248. data/lib/active_merchant/billing/gateways/usa_epay.rb +24 -0
  249. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1612 -0
  250. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +367 -0
  251. data/lib/active_merchant/billing/gateways/vanco.rb +303 -0
  252. data/lib/active_merchant/billing/gateways/verifi.rb +224 -0
  253. data/lib/active_merchant/billing/gateways/viaklix.rb +171 -0
  254. data/lib/active_merchant/billing/gateways/visanet_peru.rb +250 -0
  255. data/lib/active_merchant/billing/gateways/vpos.rb +223 -0
  256. data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
  257. data/lib/active_merchant/billing/gateways/wepay.rb +235 -0
  258. data/lib/active_merchant/billing/gateways/wirecard.rb +430 -0
  259. data/lib/active_merchant/billing/gateways/wompi.rb +197 -0
  260. data/lib/active_merchant/billing/gateways/world_net.rb +345 -0
  261. data/lib/active_merchant/billing/gateways/worldpay.rb +1050 -0
  262. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +208 -0
  263. data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
  264. data/lib/active_merchant/billing/gateways.rb +14 -0
  265. data/lib/active_merchant/billing/model.rb +30 -0
  266. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
  267. data/lib/active_merchant/billing/payment_token.rb +21 -0
  268. data/lib/active_merchant/billing/rails.rb +3 -0
  269. data/lib/active_merchant/billing/response.rb +121 -0
  270. data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
  271. data/lib/active_merchant/billing.rb +16 -0
  272. data/lib/active_merchant/connection.rb +194 -0
  273. data/lib/active_merchant/country.rb +338 -0
  274. data/lib/active_merchant/empty.rb +20 -0
  275. data/lib/active_merchant/errors.rb +38 -0
  276. data/lib/active_merchant/net_http_ssl_connection.rb +11 -0
  277. data/lib/active_merchant/network_connection_retries.rb +78 -0
  278. data/lib/active_merchant/post_data.rb +26 -0
  279. data/lib/active_merchant/posts_data.rb +92 -0
  280. data/lib/active_merchant/version.rb +3 -0
  281. data/lib/active_merchant.rb +63 -0
  282. data/lib/activemerchant.rb +1 -0
  283. data/lib/certs/cacert.pem +3214 -0
  284. data/lib/support/gateway_support.rb +69 -0
  285. data/lib/support/outbound_hosts.rb +28 -0
  286. data/lib/support/ssl_verify.rb +88 -0
  287. data/lib/support/ssl_version.rb +86 -0
  288. metadata +507 -0
@@ -0,0 +1,158 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class FederatedCanadaGateway < Gateway
4
+ # Same URL for both test and live, testing is done by using the test username (demo) and password (password).
5
+ self.live_url = self.test_url = 'https://secure.federatedgateway.com/api/transact.php'
6
+
7
+ APPROVED, DECLINED, ERROR = 1, 2, 3
8
+
9
+ # The countries the gateway supports merchants from as 2 digit ISO country codes
10
+ self.supported_countries = ['CA']
11
+
12
+ self.default_currency = 'CAD'
13
+
14
+ # The card types supported by the payment gateway
15
+ self.supported_cardtypes = %i[visa master american_express discover]
16
+
17
+ # The homepage URL of the gateway
18
+ self.homepage_url = 'http://www.federatedcanada.com/'
19
+
20
+ # The name of the gateway
21
+ self.display_name = 'Federated Canada'
22
+
23
+ def initialize(options = {})
24
+ requires!(options, :login, :password)
25
+ super
26
+ end
27
+
28
+ def purchase(money, creditcard, options = {})
29
+ post = {}
30
+ add_invoice(post, options)
31
+ add_creditcard(post, creditcard)
32
+ add_address(post, options)
33
+ add_customer_data(post, options)
34
+ commit('sale', money, post)
35
+ end
36
+
37
+ def authorize(money, creditcard, options = {})
38
+ post = {}
39
+ add_invoice(post, options)
40
+ add_creditcard(post, creditcard)
41
+ add_address(post, options)
42
+ add_customer_data(post, options)
43
+ commit('auth', money, post)
44
+ end
45
+
46
+ def capture(money, authorization, options = {})
47
+ options[:transactionid] = authorization
48
+ commit('capture', money, options)
49
+ end
50
+
51
+ def void(authorization, options = {})
52
+ options[:transactionid] = authorization
53
+ commit('void', nil, options)
54
+ end
55
+
56
+ def refund(money, authorization, options = {})
57
+ commit('refund', money, options.merge(transactionid: authorization))
58
+ end
59
+
60
+ def credit(money, authorization, options = {})
61
+ ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
62
+ refund(money, authorization, options)
63
+ end
64
+
65
+ private
66
+
67
+ def add_customer_data(post, options)
68
+ post[:firstname] = options[:first_name]
69
+ post[:lastname] = options[:last_name]
70
+
71
+ post[:email] = options[:email]
72
+ end
73
+
74
+ def add_address(post, options)
75
+ if address = (options[:billing_address] || options[:address])
76
+ post[:company] = address[:company]
77
+ post[:address1] = address[:address1]
78
+ post[:address2] = address[:address2]
79
+ post[:city] = address[:city]
80
+ post[:state] = address[:state]
81
+ post[:zip] = address[:zip]
82
+ post[:country] = address[:country]
83
+ post[:phone] = address[:phone]
84
+ end
85
+ if address = options[:shipping_address]
86
+ post[:shipping_firstname] = address[:first_name]
87
+ post[:shipping_lastname] = address[:last_name]
88
+ post[:shipping_company] = address[:company]
89
+ post[:shipping_address1] = address[:address1]
90
+ post[:shipping_address2] = address[:address2]
91
+ post[:shipping_city] = address[:city]
92
+ post[:shipping_state] = address[:state]
93
+ post[:shipping_zip] = address[:zip]
94
+ post[:shipping_country] = address[:country]
95
+ post[:shipping_email] = address[:email]
96
+ end
97
+ end
98
+
99
+ def add_invoice(post, options)
100
+ post[:orderid] = options[:order_id]
101
+ post[:orderdescription] = options[:description]
102
+ end
103
+
104
+ def add_creditcard(post, creditcard)
105
+ post[:ccnumber] = creditcard.number
106
+ post[:ccexp] = expdate(creditcard)
107
+ post[:cvv] = creditcard.verification_value
108
+ end
109
+
110
+ def parse(body)
111
+ body.split('&').inject({}) do |memo, x|
112
+ k, v = x.split('=')
113
+ memo[k] = v
114
+ memo
115
+ end
116
+ end
117
+
118
+ def commit(action, money, parameters)
119
+ parameters[:amount] = amount(money)
120
+ data = ssl_post(self.live_url, post_data(action, parameters))
121
+ response = parse(data)
122
+ message = message_from(response)
123
+
124
+ Response.new(success?(response), message, response,
125
+ test: test?,
126
+ authorization: response['transactionid'],
127
+ avs_result: { code: response['avsresponse'] },
128
+ cvv_result: response['cvvresponse'])
129
+ end
130
+
131
+ def success?(response)
132
+ response['response'] == '1'
133
+ end
134
+
135
+ def test?
136
+ @options[:login].eql?('demo') && @options[:password].eql?('password')
137
+ end
138
+
139
+ def message_from(response)
140
+ case response['response'].to_i
141
+ when APPROVED
142
+ 'Transaction Approved'
143
+ when DECLINED
144
+ 'Transaction Declined'
145
+ else
146
+ 'Error in transaction data or system error'
147
+ end
148
+ end
149
+
150
+ def post_data(action, parameters = {})
151
+ parameters[:type] = action
152
+ parameters[:username] = @options[:login]
153
+ parameters[:password] = @options[:password]
154
+ parameters.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
155
+ end
156
+ end
157
+ end
158
+ end
@@ -0,0 +1,22 @@
1
+ require 'active_merchant/billing/gateways/cc5'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ class FinansbankGateway < CC5Gateway
6
+ self.live_url = 'https://www.fbwebpos.com/servlet/cc5ApiServer'
7
+ self.test_url = 'https://entegrasyon.asseco-see.com.tr/fim/api'
8
+
9
+ # The countries the gateway supports merchants from as 2 digit ISO country codes
10
+ self.supported_countries = %w[US TR]
11
+
12
+ # The card types supported by the payment gateway
13
+ self.supported_cardtypes = %i[visa master]
14
+
15
+ # The homepage URL of the gateway
16
+ self.homepage_url = 'https://www.fbwebpos.com/'
17
+
18
+ # The name of the gateway
19
+ self.display_name = 'Finansbank WebPOS'
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,348 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class FinixGateway < Gateway
4
+ include Empty
5
+
6
+ SUCCESS_CODES = [200, 201].freeze
7
+
8
+ SOFT_DECLINE_CODES = %w[
9
+ INSUFFICIENT_FUNDS
10
+ EXCEEDS_APPROVAL_LIMIT
11
+ CARD_VELOCITY_EXCEEDED
12
+ PROCESSOR_TIMEOUT
13
+ TRANSACTION_NOT_ALLOWED
14
+ ].freeze
15
+
16
+ COUNTRY_CODE = { 'US' => 'USA', 'CA' => 'CAN' }.freeze
17
+
18
+ API_VERSION = '2018-01-01'.freeze
19
+ BASIC_AUTH_PREFIX = 'Basic '.freeze
20
+ CONTENT_TYPE = 'application/json'.freeze
21
+
22
+ self.test_url = 'https://finix.sandbox-payments-api.com'
23
+ self.live_url = 'https://finix.live-payments-api.com'
24
+ self.supported_countries = %w[US CA]
25
+ self.supported_cardtypes = %i[visa master american_express discover]
26
+ self.default_currency = 'USD'
27
+ self.money_format = :cents
28
+ self.homepage_url = 'https://finixpayments.com'
29
+ self.display_name = 'Finix'
30
+
31
+ def initialize(options = {})
32
+ requires!(options, :username, :password, :merchant_id)
33
+ super
34
+ @username = options[:username]
35
+ @password = options[:password]
36
+ @merchant_id = options[:merchant_id]
37
+ end
38
+
39
+ def purchase(amount, payment_source, options = {})
40
+ post = {}
41
+ add_invoice(post, amount, options)
42
+ add_payment_source(post, payment_source, options)
43
+ add_idempotency_id(post, options)
44
+
45
+ verification_data = options[:verification_data] || {}
46
+ commit('transaction', post, verification_data, options)
47
+ end
48
+
49
+ def refund(amount, authorization, options = {})
50
+ post = {}
51
+ add_refund_data(post, amount, authorization, options)
52
+
53
+ commit('reversals', post, options)
54
+ end
55
+
56
+ private
57
+
58
+ def add_payment_source(post, payment_source, options)
59
+ return attach_existing_instrument(post, payment_source, options) if existing_customer?(options)
60
+
61
+ identity = create_new_identity(options)
62
+ return identity unless identity.success?
63
+
64
+ attach_new_instrument(post, identity.authorization, payment_source, options)
65
+ end
66
+
67
+ def existing_customer?(options)
68
+ options[:customer_identity].present?
69
+ end
70
+
71
+ def attach_existing_instrument(post, payment_source, options)
72
+ instrument_id = payment_source[:finix_payment_instrument_id]
73
+
74
+ if instrument_id.present?
75
+ attach_existing_instrument_data(post, instrument_id, options)
76
+ else
77
+ create_and_attach_new_instrument(post, payment_source, options)
78
+ end
79
+ end
80
+
81
+ def attach_existing_instrument_data(post, instrument_id, options)
82
+ payment_instrument = fetch_payment_instrument(instrument_id)
83
+
84
+ options[:verification_data] = {
85
+ avs_result: payment_instrument.dig('address_verification'),
86
+ cvv_result: payment_instrument.dig('security_code_verification')
87
+ }
88
+
89
+ post[:instrument_id] = instrument_id
90
+ end
91
+
92
+ def create_and_attach_new_instrument(post, payment_source, options)
93
+ instrument = create_payment_instrument(options[:customer_identity], payment_source, options)
94
+
95
+ return instrument unless instrument.success?
96
+
97
+ post[:instrument_id] = instrument.params['id']
98
+ end
99
+
100
+ def create_new_identity(options)
101
+ identity = create_identity(options)
102
+ options[:identity_id] = identity.authorization if identity.success?
103
+ identity
104
+ end
105
+
106
+ def attach_new_instrument(post, identity_id, payment_source, options)
107
+ instrument = create_payment_instrument(identity_id, payment_source, options)
108
+ return instrument unless instrument.success?
109
+
110
+ options[:verification_data] = {
111
+ avs_result: instrument.params['address_verification'],
112
+ cvv_result: instrument.params['security_code_verification']
113
+ }
114
+
115
+ post[:instrument_id] = instrument.params['id']
116
+ end
117
+
118
+ def create_identity(options)
119
+ post = {}
120
+ add_identity_data(post, options)
121
+
122
+ commit('identities', post, nil, options)
123
+ end
124
+
125
+ def create_payment_instrument(identity_id, payment_source, options)
126
+ post = {}
127
+ post[:identity] = identity_id
128
+ add_payment_method(post, payment_source, options)
129
+ add_address(post, options)
130
+ commit('payment_instruments', post, nil, options)
131
+ end
132
+
133
+ def fetch_payment_instrument(payment_instrument_id)
134
+ raw_response = ssl_get("#{url}/payment_instruments/#{payment_instrument_id}", headers)
135
+ response = parse(raw_response)
136
+ end
137
+
138
+ def add_refund_data(post, amount, authorization, options)
139
+ post[:amount] = amount
140
+ post[:transaction_id] = authorization
141
+ add_idempotency_id(post, options) if options['idempotency_id'].present?
142
+ end
143
+
144
+ def add_idempotency_id(post, options)
145
+ post[:idempotency_id] = options['idempotency_id']
146
+ end
147
+
148
+ def add_identity_data(post, options)
149
+ billing = options[:billing_address] || {}
150
+ first_name, last_name = split_names(billing[:name])
151
+
152
+ post[:type] = 'BUSINESS'
153
+ post[:identity_roles] = ['BUYER']
154
+ post[:entity] = {
155
+ first_name: first_name,
156
+ last_name: last_name,
157
+ email: options[:email],
158
+ phone: billing[:phone],
159
+ personal_address: build_address(billing)
160
+ }
161
+ end
162
+
163
+ def add_payment_method(post, payment_source, options)
164
+ billing = options[:billing_address] || {}
165
+ post[:type] = 'PAYMENT_CARD'
166
+ post[:name] = billing[:name]
167
+ post[:number] = payment_source.number
168
+ post[:expiration_month] = payment_source.month
169
+ post[:expiration_year] = payment_source.year
170
+ post[:security_code] = payment_source.verification_value
171
+ end
172
+
173
+ def add_invoice(post, amount, options)
174
+ post[:amount] = amount
175
+ post[:currency] = options[:currency] || default_currency
176
+ post[:merchant] = @merchant_id
177
+ post[:tags] = {
178
+ purpose: 'sale',
179
+ order_id: options[:order_id],
180
+ customer_id: options[:customer_id]
181
+ }.compact
182
+ end
183
+
184
+ def add_address(post, options)
185
+ billing = options[:billing_address] || {}
186
+ post[:address] = build_address(billing)
187
+ end
188
+
189
+ def add_reference(post, authorization)
190
+ post[:transaction_id] = authorization
191
+ end
192
+
193
+ def build_address(data)
194
+ {
195
+ line1: data[:address1],
196
+ city: data[:city],
197
+ region: data[:state],
198
+ postal_code: data[:zip].to_s.gsub(/\s+/, ''),
199
+ country: COUNTRY_CODE[data[:country]] || data[:country]
200
+ }
201
+ end
202
+
203
+ def commit(action, params, verification_data = nil, options = {})
204
+ request_url = build_request_url(action, params)
205
+ payload = build_payload(action, params)
206
+ raw_response = ssl_post(request_url, payload.to_json, headers)
207
+ response = parse(raw_response).merge('customer_identity' => options[:identity_id]).compact
208
+ succeeded = ['identities', 'payment_instruments'].include?(action) ?
209
+ profile_created_successful?(response) :
210
+ success_from(response)
211
+
212
+ Response.new(
213
+ succeeded,
214
+ message_from(succeeded, response),
215
+ response,
216
+ error_code: error_code_from(succeeded, response),
217
+ authorization: authorization_from(response),
218
+ avs_result: AVSResult.new(code: verification_data&.dig(:avs_result)),
219
+ cvv_result: CVVResult.new(verification_data&.dig(:cvv_result)),
220
+ test: test?,
221
+ response_type: response_type(response['state']),
222
+ response_http_code: @response_http_code,
223
+ request_endpoint: request_url,
224
+ request_method: :post,
225
+ request_body: payload
226
+ )
227
+ end
228
+
229
+ def build_request_url(action, params)
230
+ case action
231
+ when 'identities'
232
+ "#{url}/identities"
233
+ when 'payment_instruments'
234
+ "#{url}/payment_instruments"
235
+ when 'transaction'
236
+ "#{url}/transfers"
237
+ when 'reversals'
238
+ "#{url}/transfers/#{params[:transaction_id]}/reversals"
239
+ end
240
+ end
241
+
242
+ def build_payload(action, params)
243
+ case action
244
+ when 'reversals'
245
+ {
246
+ amount: params[:amount],
247
+ idempotency_id: params[:idempotency_id],
248
+ tags: params[:tags]
249
+ }
250
+ when 'transaction'
251
+ {
252
+ amount: params[:amount],
253
+ currency: params[:currency] || default_currency,
254
+ merchant: @merchant_id,
255
+ source: params[:instrument_id],
256
+ idempotency_id: params[:idempotency_id],
257
+ tags: params[:tags]
258
+ }
259
+ else
260
+ params
261
+ end
262
+ end
263
+
264
+ def headers
265
+ {
266
+ 'Content-Type' => CONTENT_TYPE,
267
+ 'Authorization' => basic_auth_header,
268
+ 'Finix-Version' => API_VERSION
269
+ }
270
+ end
271
+
272
+ def basic_auth_header
273
+ BASIC_AUTH_PREFIX + Base64.strict_encode64("#{@username}:#{@password}")
274
+ end
275
+
276
+ def url
277
+ test? ? test_url : live_url
278
+ end
279
+
280
+ def parse(body)
281
+ JSON.parse(body)
282
+ end
283
+
284
+ def success_from(response)
285
+ response['state'] == 'SUCCEEDED'
286
+ end
287
+
288
+ def profile_created_successful?(response)
289
+ return true if response['id'].present?
290
+
291
+ errors = response.dig('_embedded', 'errors')
292
+ if errors.present?
293
+ return false
294
+ end
295
+
296
+ false
297
+ end
298
+
299
+ def message_from(succeeded, response)
300
+ state = response["state"]
301
+
302
+ case state
303
+ when "FAILED"
304
+ response['failure_message']
305
+ when "PENDING", "SUCCEEDED", "CANCELED"
306
+ state.capitalize
307
+ else
308
+ response.dig('_embedded', 'errors', 0, 'message')
309
+ end
310
+ end
311
+
312
+ def error_code_from(succeeded, response)
313
+ return nil if succeeded
314
+
315
+ if response['_embedded'] && response['_embedded']['errors']
316
+ response['_embedded']['errors'].first['code']
317
+ else
318
+ response['failure_code']
319
+ end
320
+ end
321
+
322
+ def authorization_from(response)
323
+ response['id']
324
+ end
325
+
326
+ def response_type(state)
327
+ case state
328
+ when 'SUCCEEDED' then 0
329
+ when 'FAILED' then 2
330
+ when 'CANCELED', 'DECLINED' then 1
331
+ else 1
332
+ end
333
+ end
334
+
335
+ def split_names(name)
336
+ name_parts = name.to_s.split
337
+ first_name = name_parts.first || ''
338
+ last_name = name_parts[1..]&.join(' ') || ''
339
+ [first_name, last_name]
340
+ end
341
+
342
+ def handle_response(response)
343
+ @response_http_code = response.code.to_i
344
+ response.body
345
+ end
346
+ end
347
+ end
348
+ end
@@ -0,0 +1,143 @@
1
+ require 'nokogiri'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ class FirstGivingGateway < Gateway
6
+ self.test_url = 'http://usapisandbox.fgdev.net'
7
+ self.live_url = 'https://api.firstgiving.com'
8
+
9
+ self.supported_countries = ['US']
10
+ self.supported_cardtypes = %i[visa master american_express discover]
11
+ self.homepage_url = 'http://www.firstgiving.com/'
12
+ self.default_currency = 'USD'
13
+ self.display_name = 'FirstGiving'
14
+
15
+ def initialize(options = {})
16
+ requires!(options, :application_key, :security_token, :charity_id)
17
+ super
18
+ end
19
+
20
+ def purchase(money, creditcard, options = {})
21
+ post = {}
22
+ add_invoice(post, options)
23
+ add_creditcard(post, creditcard)
24
+ add_address(post, options)
25
+ add_customer_data(post, options)
26
+ add_donation_data(post, money, options)
27
+ commit('/donation/creditcard', post)
28
+ end
29
+
30
+ def refund(money, identifier, options = {})
31
+ get = {}
32
+ get[:transactionId] = identifier
33
+ get[:tranType] = 'REFUNDREQUEST'
34
+ commit('/transaction/refundrequest?' + encode(get))
35
+ end
36
+
37
+ private
38
+
39
+ def add_donation_data(post, money, options)
40
+ post[:amount] = amount(money)
41
+ post[:charityId] = @options[:charity_id]
42
+ post[:description] = (options[:description] || 'Purchase')
43
+ post[:currencyCode] = (options[:currency] || currency(money))
44
+ end
45
+
46
+ def add_customer_data(post, options)
47
+ post[:billToEmail] = (options[:email] || 'activemerchant@example.com')
48
+ post[:remoteAddr] = (options[:ip] || '127.0.0.1')
49
+ end
50
+
51
+ def add_address(post, options)
52
+ if (billing_address = (options[:billing_address] || options[:address]))
53
+ post[:billToAddressLine1] = billing_address[:address1]
54
+ post[:billToCity] = billing_address[:city]
55
+ post[:billToState] = billing_address[:state]
56
+ post[:billToZip] = billing_address[:zip]
57
+ post[:billToCountry] = billing_address[:country]
58
+ end
59
+ end
60
+
61
+ def add_invoice(post, options)
62
+ post[:orderId] = options[:order_id]
63
+ end
64
+
65
+ def add_creditcard(post, creditcard)
66
+ post[:billToFirstName] = creditcard.first_name
67
+ post[:billToLastName] = creditcard.last_name
68
+ post[:ccNumber] = creditcard.number
69
+ post[:ccType] = creditcard_brand(creditcard.brand)
70
+ post[:ccExpDateMonth] = creditcard.month
71
+ post[:ccExpDateYear] = creditcard.year
72
+ post[:ccCardValidationNum] = creditcard.verification_value
73
+ end
74
+
75
+ def parse(body)
76
+ response = {}
77
+
78
+ xml = Nokogiri::XML(body)
79
+ element = xml.xpath('//firstGivingDonationApi/firstGivingResponse').first
80
+
81
+ element.attributes.each do |name, attribute|
82
+ response[name] = attribute.content
83
+ end
84
+ element.children.each do |child|
85
+ next if child.text?
86
+
87
+ response[child.name] = child.text
88
+ end
89
+
90
+ response
91
+ end
92
+
93
+ def commit(action, post = nil)
94
+ url = (test? ? self.test_url : self.live_url) + action
95
+
96
+ begin
97
+ if post
98
+ response = parse(ssl_post(url, post_data(post), headers))
99
+ else
100
+ response = parse(ssl_get(url, headers))
101
+ end
102
+ rescue ResponseError => e
103
+ response = parse(e.response.body)
104
+ end
105
+
106
+ Response.new(
107
+ (response['acknowledgement'] == 'Success'),
108
+ (response['friendlyErrorMessage'] || response['verboseErrorMessage'] || response['acknowledgement']),
109
+ response,
110
+ authorization: response['transactionId'],
111
+ test: test?
112
+ )
113
+ end
114
+
115
+ def post_data(post)
116
+ post.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
117
+ end
118
+
119
+ def encode(hash)
120
+ hash.collect { |(k, v)| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}" }.join('&')
121
+ end
122
+
123
+ def creditcard_brand(brand)
124
+ case brand
125
+ when 'visa' then 'VI'
126
+ when 'master' then 'MC'
127
+ when 'discover' then 'DI'
128
+ when 'american_express' then 'AX'
129
+ else
130
+ raise "Unhandled credit card brand #{brand}"
131
+ end
132
+ end
133
+
134
+ def headers
135
+ {
136
+ 'User-Agent' => "ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
137
+ 'JG_APPLICATIONKEY' => @options[:application_key].to_s,
138
+ 'JG_SECURITYTOKEN' => @options[:security_token].to_s
139
+ }
140
+ end
141
+ end
142
+ end
143
+ end