archetype2142_activemerchant 1.124.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (271) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +3640 -0
  3. data/CONTRIBUTORS +568 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.md +249 -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 +80 -0
  10. data/lib/active_merchant/billing/compatibility.rb +118 -0
  11. data/lib/active_merchant/billing/credit_card.rb +414 -0
  12. data/lib/active_merchant/billing/credit_card_formatting.rb +24 -0
  13. data/lib/active_merchant/billing/credit_card_methods.rb +444 -0
  14. data/lib/active_merchant/billing/cvv_result.rb +37 -0
  15. data/lib/active_merchant/billing/gateway.rb +331 -0
  16. data/lib/active_merchant/billing/gateways/adyen.rb +712 -0
  17. data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
  18. data/lib/active_merchant/billing/gateways/authorize_net.rb +1107 -0
  19. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +424 -0
  20. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +977 -0
  21. data/lib/active_merchant/billing/gateways/axcessms.rb +179 -0
  22. data/lib/active_merchant/billing/gateways/balanced.rb +263 -0
  23. data/lib/active_merchant/billing/gateways/bambora_apac.rb +222 -0
  24. data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
  25. data/lib/active_merchant/billing/gateways/banwire.rb +116 -0
  26. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +396 -0
  27. data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +15 -0
  28. data/lib/active_merchant/billing/gateways/be2bill.rb +131 -0
  29. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +474 -0
  30. data/lib/active_merchant/billing/gateways/beanstream.rb +220 -0
  31. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +57 -0
  32. data/lib/active_merchant/billing/gateways/blue_pay.rb +549 -0
  33. data/lib/active_merchant/billing/gateways/blue_snap.rb +613 -0
  34. data/lib/active_merchant/billing/gateways/bogus.rb +186 -0
  35. data/lib/active_merchant/billing/gateways/borgun.rb +231 -0
  36. data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
  37. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +23 -0
  38. data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
  39. data/lib/active_merchant/billing/gateways/braintree_blue.rb +832 -0
  40. data/lib/active_merchant/billing/gateways/braintree_orange.rb +19 -0
  41. data/lib/active_merchant/billing/gateways/bridge_pay.rb +244 -0
  42. data/lib/active_merchant/billing/gateways/cams.rb +230 -0
  43. data/lib/active_merchant/billing/gateways/card_connect.rb +320 -0
  44. data/lib/active_merchant/billing/gateways/card_save.rb +21 -0
  45. data/lib/active_merchant/billing/gateways/card_stream.rb +371 -0
  46. data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
  47. data/lib/active_merchant/billing/gateways/cardprocess.rb +256 -0
  48. data/lib/active_merchant/billing/gateways/cashnet.rb +225 -0
  49. data/lib/active_merchant/billing/gateways/cc5.rb +198 -0
  50. data/lib/active_merchant/billing/gateways/cecabank.rb +249 -0
  51. data/lib/active_merchant/billing/gateways/cenpos.rb +328 -0
  52. data/lib/active_merchant/billing/gateways/checkout.rb +212 -0
  53. data/lib/active_merchant/billing/gateways/checkout_v2.rb +311 -0
  54. data/lib/active_merchant/billing/gateways/citrus_pay.rb +21 -0
  55. data/lib/active_merchant/billing/gateways/clearhaus.rb +219 -0
  56. data/lib/active_merchant/billing/gateways/commercegate.rb +142 -0
  57. data/lib/active_merchant/billing/gateways/conekta.rb +230 -0
  58. data/lib/active_merchant/billing/gateways/creditcall.rb +272 -0
  59. data/lib/active_merchant/billing/gateways/credorax.rb +496 -0
  60. data/lib/active_merchant/billing/gateways/ct_payment.rb +269 -0
  61. data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
  62. data/lib/active_merchant/billing/gateways/cyber_source.rb +1074 -0
  63. data/lib/active_merchant/billing/gateways/d_local.rb +253 -0
  64. data/lib/active_merchant/billing/gateways/data_cash.rb +302 -0
  65. data/lib/active_merchant/billing/gateways/decidir.rb +331 -0
  66. data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
  67. data/lib/active_merchant/billing/gateways/digitzs.rb +295 -0
  68. data/lib/active_merchant/billing/gateways/ebanx.rb +333 -0
  69. data/lib/active_merchant/billing/gateways/efsnet.rb +215 -0
  70. data/lib/active_merchant/billing/gateways/elavon.rb +472 -0
  71. data/lib/active_merchant/billing/gateways/element.rb +386 -0
  72. data/lib/active_merchant/billing/gateways/epay.rb +296 -0
  73. data/lib/active_merchant/billing/gateways/evo_ca.rb +307 -0
  74. data/lib/active_merchant/billing/gateways/eway.rb +226 -0
  75. data/lib/active_merchant/billing/gateways/eway_managed.rb +289 -0
  76. data/lib/active_merchant/billing/gateways/eway_rapid.rb +578 -0
  77. data/lib/active_merchant/billing/gateways/exact.rb +219 -0
  78. data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
  79. data/lib/active_merchant/billing/gateways/fat_zebra.rb +223 -0
  80. data/lib/active_merchant/billing/gateways/federated_canada.rb +158 -0
  81. data/lib/active_merchant/billing/gateways/finansbank.rb +22 -0
  82. data/lib/active_merchant/billing/gateways/first_giving.rb +143 -0
  83. data/lib/active_merchant/billing/gateways/first_pay.rb +182 -0
  84. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +452 -0
  85. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +505 -0
  86. data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
  87. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
  88. data/lib/active_merchant/billing/gateways/forte.rb +286 -0
  89. data/lib/active_merchant/billing/gateways/garanti.rb +256 -0
  90. data/lib/active_merchant/billing/gateways/global_collect.rb +463 -0
  91. data/lib/active_merchant/billing/gateways/global_transport.rb +193 -0
  92. data/lib/active_merchant/billing/gateways/hdfc.rb +205 -0
  93. data/lib/active_merchant/billing/gateways/hps.rb +472 -0
  94. data/lib/active_merchant/billing/gateways/iats_payments.rb +312 -0
  95. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
  96. data/lib/active_merchant/billing/gateways/inspire.rb +213 -0
  97. data/lib/active_merchant/billing/gateways/instapay.rb +159 -0
  98. data/lib/active_merchant/billing/gateways/ipg.rb +390 -0
  99. data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
  100. data/lib/active_merchant/billing/gateways/iridium.rb +467 -0
  101. data/lib/active_merchant/billing/gateways/itransact.rb +448 -0
  102. data/lib/active_merchant/billing/gateways/iveri.rb +254 -0
  103. data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
  104. data/lib/active_merchant/billing/gateways/jetpay.rb +395 -0
  105. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +432 -0
  106. data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
  107. data/lib/active_merchant/billing/gateways/kushki.rb +270 -0
  108. data/lib/active_merchant/billing/gateways/latitude19.rb +412 -0
  109. data/lib/active_merchant/billing/gateways/linkpoint.rb +448 -0
  110. data/lib/active_merchant/billing/gateways/litle.rb +531 -0
  111. data/lib/active_merchant/billing/gateways/mastercard.rb +293 -0
  112. data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
  113. data/lib/active_merchant/billing/gateways/mercado_pago.rb +329 -0
  114. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +194 -0
  115. data/lib/active_merchant/billing/gateways/merchant_one.rb +110 -0
  116. data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
  117. data/lib/active_merchant/billing/gateways/merchant_ware.rb +313 -0
  118. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +284 -0
  119. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +248 -0
  120. data/lib/active_merchant/billing/gateways/mercury.rb +352 -0
  121. data/lib/active_merchant/billing/gateways/metrics_global.rb +293 -0
  122. data/lib/active_merchant/billing/gateways/micropayment.rb +182 -0
  123. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
  124. data/lib/active_merchant/billing/gateways/migs.rb +329 -0
  125. data/lib/active_merchant/billing/gateways/mit.rb +260 -0
  126. data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
  127. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +215 -0
  128. data/lib/active_merchant/billing/gateways/moka.rb +290 -0
  129. data/lib/active_merchant/billing/gateways/monei.rb +422 -0
  130. data/lib/active_merchant/billing/gateways/moneris.rb +446 -0
  131. data/lib/active_merchant/billing/gateways/money_movers.rb +150 -0
  132. data/lib/active_merchant/billing/gateways/mundipagg.rb +363 -0
  133. data/lib/active_merchant/billing/gateways/nab_transact.rb +299 -0
  134. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +163 -0
  135. data/lib/active_merchant/billing/gateways/net_registry.rb +198 -0
  136. data/lib/active_merchant/billing/gateways/netaxept.rb +180 -0
  137. data/lib/active_merchant/billing/gateways/netbanx.rb +376 -0
  138. data/lib/active_merchant/billing/gateways/netbilling.rb +229 -0
  139. data/lib/active_merchant/billing/gateways/netpay.rb +223 -0
  140. data/lib/active_merchant/billing/gateways/network_merchants.rb +238 -0
  141. data/lib/active_merchant/billing/gateways/nmi.rb +356 -0
  142. data/lib/active_merchant/billing/gateways/ogone.rb +481 -0
  143. data/lib/active_merchant/billing/gateways/omise.rb +323 -0
  144. data/lib/active_merchant/billing/gateways/openpay.rb +229 -0
  145. data/lib/active_merchant/billing/gateways/opp.rb +394 -0
  146. data/lib/active_merchant/billing/gateways/optimal_payment.rb +331 -0
  147. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +45 -0
  148. data/lib/active_merchant/billing/gateways/orbital.rb +1209 -0
  149. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +206 -0
  150. data/lib/active_merchant/billing/gateways/pagarme.rb +239 -0
  151. data/lib/active_merchant/billing/gateways/pago_facil.rb +120 -0
  152. data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
  153. data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
  154. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +277 -0
  155. data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
  156. data/lib/active_merchant/billing/gateways/pay_junction.rb +390 -0
  157. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +206 -0
  158. data/lib/active_merchant/billing/gateways/pay_secure.rb +110 -0
  159. data/lib/active_merchant/billing/gateways/pay_trace.rb +404 -0
  160. data/lib/active_merchant/billing/gateways/paybox_direct.rb +224 -0
  161. data/lib/active_merchant/billing/gateways/payeezy.rb +458 -0
  162. data/lib/active_merchant/billing/gateways/payex.rb +409 -0
  163. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +235 -0
  164. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +42 -0
  165. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
  166. data/lib/active_merchant/billing/gateways/payflow.rb +411 -0
  167. data/lib/active_merchant/billing/gateways/payflow_express.rb +220 -0
  168. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +14 -0
  169. data/lib/active_merchant/billing/gateways/payflow_uk.rb +20 -0
  170. data/lib/active_merchant/billing/gateways/payment_express.rb +373 -0
  171. data/lib/active_merchant/billing/gateways/paymentez.rb +327 -0
  172. data/lib/active_merchant/billing/gateways/paymill.rb +369 -0
  173. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +718 -0
  174. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +65 -0
  175. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -0
  176. data/lib/active_merchant/billing/gateways/paypal.rb +136 -0
  177. data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
  178. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +44 -0
  179. data/lib/active_merchant/billing/gateways/paypal_express.rb +270 -0
  180. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
  181. data/lib/active_merchant/billing/gateways/paysafe.rb +412 -0
  182. data/lib/active_merchant/billing/gateways/payscout.rb +159 -0
  183. data/lib/active_merchant/billing/gateways/paystation.rb +204 -0
  184. data/lib/active_merchant/billing/gateways/payu_in.rb +249 -0
  185. data/lib/active_merchant/billing/gateways/payu_latam.rb +469 -0
  186. data/lib/active_merchant/billing/gateways/payu_polska.rb +178 -0
  187. data/lib/active_merchant/billing/gateways/payway.rb +207 -0
  188. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
  189. data/lib/active_merchant/billing/gateways/pin.rb +246 -0
  190. data/lib/active_merchant/billing/gateways/plugnpay.rb +283 -0
  191. data/lib/active_merchant/billing/gateways/priority.rb +390 -0
  192. data/lib/active_merchant/billing/gateways/pro_pay.rb +325 -0
  193. data/lib/active_merchant/billing/gateways/psigate.rb +227 -0
  194. data/lib/active_merchant/billing/gateways/psl_card.rb +295 -0
  195. data/lib/active_merchant/billing/gateways/qbms.rb +302 -0
  196. data/lib/active_merchant/billing/gateways/quantum.rb +274 -0
  197. data/lib/active_merchant/billing/gateways/quickbooks.rb +377 -0
  198. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
  199. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +297 -0
  200. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
  201. data/lib/active_merchant/billing/gateways/quickpay.rb +24 -0
  202. data/lib/active_merchant/billing/gateways/qvalent.rb +305 -0
  203. data/lib/active_merchant/billing/gateways/realex.rb +400 -0
  204. data/lib/active_merchant/billing/gateways/redsys.rb +718 -0
  205. data/lib/active_merchant/billing/gateways/s5.rb +247 -0
  206. data/lib/active_merchant/billing/gateways/safe_charge.rb +301 -0
  207. data/lib/active_merchant/billing/gateways/sage.rb +446 -0
  208. data/lib/active_merchant/billing/gateways/sage_pay.rb +434 -0
  209. data/lib/active_merchant/billing/gateways/sallie_mae.rb +141 -0
  210. data/lib/active_merchant/billing/gateways/secure_net.rb +260 -0
  211. data/lib/active_merchant/billing/gateways/secure_pay.rb +191 -0
  212. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +290 -0
  213. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +103 -0
  214. data/lib/active_merchant/billing/gateways/securion_pay.rb +265 -0
  215. data/lib/active_merchant/billing/gateways/skip_jack.rb +450 -0
  216. data/lib/active_merchant/billing/gateways/smart_ps.rb +274 -0
  217. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
  218. data/lib/active_merchant/billing/gateways/spreedly_core.rb +312 -0
  219. data/lib/active_merchant/billing/gateways/stripe.rb +813 -0
  220. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +463 -0
  221. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +151 -0
  222. data/lib/active_merchant/billing/gateways/telr.rb +273 -0
  223. data/lib/active_merchant/billing/gateways/tns.rb +26 -0
  224. data/lib/active_merchant/billing/gateways/trans_first.rb +240 -0
  225. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +612 -0
  226. data/lib/active_merchant/billing/gateways/transact_pro.rb +222 -0
  227. data/lib/active_merchant/billing/gateways/transax.rb +21 -0
  228. data/lib/active_merchant/billing/gateways/transnational.rb +9 -0
  229. data/lib/active_merchant/billing/gateways/trexle.rb +221 -0
  230. data/lib/active_merchant/billing/gateways/trust_commerce.rb +489 -0
  231. data/lib/active_merchant/billing/gateways/usa_epay.rb +24 -0
  232. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1612 -0
  233. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +353 -0
  234. data/lib/active_merchant/billing/gateways/vanco.rb +294 -0
  235. data/lib/active_merchant/billing/gateways/verifi.rb +224 -0
  236. data/lib/active_merchant/billing/gateways/viaklix.rb +171 -0
  237. data/lib/active_merchant/billing/gateways/visanet_peru.rb +246 -0
  238. data/lib/active_merchant/billing/gateways/vpos.rb +220 -0
  239. data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
  240. data/lib/active_merchant/billing/gateways/wepay.rb +235 -0
  241. data/lib/active_merchant/billing/gateways/wirecard.rb +430 -0
  242. data/lib/active_merchant/billing/gateways/wompi.rb +153 -0
  243. data/lib/active_merchant/billing/gateways/world_net.rb +345 -0
  244. data/lib/active_merchant/billing/gateways/worldpay.rb +923 -0
  245. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +208 -0
  246. data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
  247. data/lib/active_merchant/billing/gateways.rb +14 -0
  248. data/lib/active_merchant/billing/model.rb +30 -0
  249. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
  250. data/lib/active_merchant/billing/payment_token.rb +21 -0
  251. data/lib/active_merchant/billing/rails.rb +3 -0
  252. data/lib/active_merchant/billing/response.rb +97 -0
  253. data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
  254. data/lib/active_merchant/billing.rb +16 -0
  255. data/lib/active_merchant/connection.rb +196 -0
  256. data/lib/active_merchant/country.rb +337 -0
  257. data/lib/active_merchant/empty.rb +20 -0
  258. data/lib/active_merchant/errors.rb +35 -0
  259. data/lib/active_merchant/net_http_ssl_connection.rb +11 -0
  260. data/lib/active_merchant/network_connection_retries.rb +78 -0
  261. data/lib/active_merchant/post_data.rb +26 -0
  262. data/lib/active_merchant/posts_data.rb +92 -0
  263. data/lib/active_merchant/version.rb +3 -0
  264. data/lib/active_merchant.rb +63 -0
  265. data/lib/activemerchant.rb +1 -0
  266. data/lib/certs/cacert.pem +3214 -0
  267. data/lib/support/gateway_support.rb +69 -0
  268. data/lib/support/outbound_hosts.rb +28 -0
  269. data/lib/support/ssl_verify.rb +88 -0
  270. data/lib/support/ssl_version.rb +86 -0
  271. metadata +463 -0
@@ -0,0 +1,256 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class CardprocessGateway < Gateway
4
+ self.test_url = 'https://test.vr-pay-ecommerce.de/v1/payments'
5
+ self.live_url = 'https://vr-pay-ecommerce.de/v1/payments'
6
+
7
+ self.supported_countries = %w[ BE BG CZ DK DE EE IE ES FR HR IT CY LV LT LU
8
+ MT HU NL AT PL PT RO SI SK FI SE GB IS LI NO
9
+ CH ME MK AL RS TR BA ]
10
+ self.default_currency = 'EUR'
11
+ self.supported_cardtypes = %i[visa master american_express diners_club jcb]
12
+
13
+ self.homepage_url = 'https://vr-pay-ecommerce.docs.oppwa.com/'
14
+ self.display_name = 'CardProcess VR-Pay'
15
+ self.money_format = :dollars
16
+
17
+ STANDARD_ERROR_CODE_MAPPING = {}
18
+
19
+ # Creates a new CardProcess Gateway
20
+ #
21
+ # The gateway requires a valid login, password, and entity ID
22
+ # to be passed in the +options+ hash.
23
+ #
24
+ # === Options
25
+ #
26
+ # * <tt>:user_id</tt> -- The CardProcess user ID
27
+ # * <tt>:password</tt> -- The CardProcess password
28
+ # * <tt>:entity_id</tt> -- The CardProcess channel or entity ID for any transactions
29
+ def initialize(options = {})
30
+ requires!(options, :user_id, :password, :entity_id)
31
+ super
32
+ # This variable exists purely to allow remote tests to force error codes;
33
+ # the lack of a setter despite its usage is intentional.
34
+ @test_options = {}
35
+ end
36
+
37
+ def purchase(money, payment, options = {})
38
+ post = {}
39
+ add_invoice(post, money, options)
40
+ add_payment(post, payment)
41
+ add_address(post, payment, options)
42
+ add_customer_data(post, options)
43
+
44
+ commit('DB', post)
45
+ end
46
+
47
+ def authorize(money, payment, options = {})
48
+ post = {}
49
+ add_invoice(post, money, options)
50
+ add_payment(post, payment)
51
+ add_address(post, payment, options)
52
+ add_customer_data(post, options)
53
+
54
+ commit('PA', post)
55
+ end
56
+
57
+ def capture(money, authorization, options = {})
58
+ post = {
59
+ id: authorization
60
+ }
61
+ add_invoice(post, money, options)
62
+ commit('CP', post)
63
+ end
64
+
65
+ def refund(money, authorization, options = {})
66
+ post = {
67
+ id: authorization
68
+ }
69
+ add_invoice(post, money, options)
70
+ commit('RF', post)
71
+ end
72
+
73
+ def credit(money, payment, options = {})
74
+ post = {}
75
+ add_invoice(post, money, options)
76
+ add_payment(post, payment)
77
+ add_address(post, payment, options)
78
+ add_customer_data(post, options)
79
+
80
+ commit('CD', post)
81
+ end
82
+
83
+ def void(authorization, _options = {})
84
+ post = {
85
+ id: authorization
86
+ }
87
+ commit('RV', post)
88
+ end
89
+
90
+ def verify(credit_card, options = {})
91
+ MultiResponse.run do |r|
92
+ r.process { authorize(100, credit_card, options) }
93
+ r.process { void(r.authorization, options) }
94
+ end
95
+ end
96
+
97
+ def supports_scrubbing?
98
+ true
99
+ end
100
+
101
+ def scrub(transcript)
102
+ transcript.
103
+ gsub(%r{(authentication\.[^=]+=)[^&]+}, '\1[FILTERED]').
104
+ gsub(%r{(card\.number=)\d+}, '\1[FILTERED]').
105
+ gsub(%r{(cvv=)\d{3,4}}, '\1[FILTERED]\2')
106
+ end
107
+
108
+ private
109
+
110
+ def add_customer_data(post, options)
111
+ post['customer.ip'] = options[:ip] if options[:ip]
112
+ end
113
+
114
+ def add_address(post, _card, options)
115
+ if (address = options[:billing_address] || options[:address])
116
+ post[:billing] = hashify_address(address)
117
+ end
118
+
119
+ if (shipping = options[:shipping_address])
120
+ post[:shipping] = hashify_address(shipping)
121
+ end
122
+ end
123
+
124
+ def add_invoice(post, money, options)
125
+ return if money.nil?
126
+
127
+ post[:amount] = amount(money)
128
+ post[:currency] = (options[:currency] || currency(money))
129
+ post[:merchantInvoiceId] = options[:merchant_invoice_id] if options[:merchant_invoice_id]
130
+ post[:merchantTransactionId] = options[:merchant_transaction_id] if options[:merchant_transaction_id]
131
+ post[:transactionCategory] = options[:transaction_category] if options[:transaction_category]
132
+ end
133
+
134
+ def add_payment(post, payment)
135
+ return if payment.is_a?(String)
136
+
137
+ post[:paymentBrand] = payment.brand.upcase if payment.brand
138
+ post[:card] ||= {}
139
+ post[:card][:number] = payment.number
140
+ post[:card][:holder] = payment.name
141
+ post[:card][:expiryMonth] = sprintf('%02d', payment.month)
142
+ post[:card][:expiryYear] = sprintf('%02d', payment.year)
143
+ post[:card][:cvv] = payment.verification_value
144
+ end
145
+
146
+ def parse(body)
147
+ JSON.parse(body)
148
+ end
149
+
150
+ def commit(action, parameters)
151
+ url = (test? ? test_url : live_url)
152
+ if (id = parameters.delete(:id))
153
+ url += "/#{id}"
154
+ end
155
+
156
+ begin
157
+ raw_response = ssl_post(url, post_data(action, parameters.merge(@test_options)))
158
+ rescue ResponseError => e
159
+ raw_response = e.response.body
160
+ end
161
+ response = parse(raw_response)
162
+
163
+ Response.new(
164
+ success_from(response),
165
+ message_from(response),
166
+ response,
167
+ authorization: authorization_from(response),
168
+ avs_result: AVSResult.new(code: response['result']['avsResponse']),
169
+ cvv_result: CVVResult.new(response['result']['cvvResponse']),
170
+ test: test?,
171
+ error_code: error_code_from(response)
172
+ )
173
+ end
174
+
175
+ def success_from(response)
176
+ !(response['result']['code'] =~ /^(000\.000\.|000\.100\.1|000\.[36])/).nil?
177
+ end
178
+
179
+ def message_from(response)
180
+ response['result']['description']
181
+ end
182
+
183
+ def authorization_from(response)
184
+ response['id']
185
+ end
186
+
187
+ def post_data(action, parameters = {})
188
+ post = parameters.clone
189
+ post[:authentication] ||= {}
190
+ post[:authentication][:userId] = @options[:user_id]
191
+ post[:authentication][:password] = @options[:password]
192
+ post[:authentication][:entityId] = @options[:entity_id]
193
+ post[:paymentType] = action
194
+ dot_flatten_hash(post).map { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
195
+ end
196
+
197
+ def error_code_from(response)
198
+ unless success_from(response)
199
+ case response['result']['code']
200
+ when '100.100.101'
201
+ STANDARD_ERROR_CODE[:incorrect_number]
202
+ when '100.100.303'
203
+ STANDARD_ERROR_CODE[:expired_card]
204
+ when /100\.100\.(201|301|305)/
205
+ STANDARD_ERROR_CODE[:invalid_expiry_date]
206
+ when /100.100.60[01]/
207
+ STANDARD_ERROR_CODE[:invalid_cvc]
208
+ when '800.100.151'
209
+ STANDARD_ERROR_CODE[:invalid_number]
210
+ when '800.100.153'
211
+ STANDARD_ERROR_CODE[:incorrect_cvc]
212
+ when /800.800.(102|302)/
213
+ STANDARD_ERROR_CODE[:incorrect_address]
214
+ when '800.800.202'
215
+ STANDARD_ERROR_CODE[:invalid_zip]
216
+ when '800.100.166'
217
+ STANDARD_ERROR_CODE[:incorrect_pin]
218
+ when '800.100.171'
219
+ STANDARD_ERROR_CODE[:pickup_card]
220
+ when /^(200|700)\./
221
+ STANDARD_ERROR_CODE[:config_error]
222
+ when /^(800\.[17]00|800\.800\.[123])/
223
+ STANDARD_ERROR_CODE[:card_declined]
224
+ when /^(900\.[1234]00)/
225
+ STANDARD_ERROR_CODE[:processing_error]
226
+ else
227
+ STANDARD_ERROR_CODE[:processing_error]
228
+ end
229
+ end
230
+ end
231
+
232
+ def hashify_address(address)
233
+ hash = {}
234
+ hash[:street1] = address[:address1] if address[:address1]
235
+ hash[:street2] = address[:address2] if address[:address2]
236
+ hash[:city] = address[:city] if address[:city]
237
+ hash[:state] = address[:state] if address[:state]
238
+ hash[:postcode] = address[:zip] if address[:zip]
239
+ hash[:country] = address[:country] if address[:country]
240
+ hash
241
+ end
242
+
243
+ def dot_flatten_hash(hash, prefix = '')
244
+ h = {}
245
+ hash.each_pair do |k, v|
246
+ if v.is_a?(Hash)
247
+ h.merge!(dot_flatten_hash(v, prefix + k.to_s + '.'))
248
+ else
249
+ h[prefix + k.to_s] = v
250
+ end
251
+ end
252
+ h
253
+ end
254
+ end
255
+ end
256
+ end
@@ -0,0 +1,225 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class CashnetGateway < Gateway
4
+ include Empty
5
+
6
+ self.live_url = 'https://commerce.cashnet.com/'
7
+ self.test_url = 'https://train.cashnet.com/'
8
+
9
+ self.supported_countries = ['US']
10
+ self.supported_cardtypes = %i[visa master american_express discover diners_club jcb]
11
+ self.homepage_url = 'https://transactcampus.com'
12
+ self.display_name = 'Cashnet'
13
+ self.money_format = :dollars
14
+ self.max_retries = 0
15
+
16
+ # Creates a new CashnetGateway
17
+ #
18
+ # ==== Options
19
+ #
20
+ # * <tt>:merchant</tt> -- Gateway Merchant (REQUIRED)
21
+ # * <tt>:operator</tt> -- Operator (REQUIRED)
22
+ # * <tt>:password</tt> -- Password (REQUIRED)
23
+ # * <tt>:merchant_gateway_name</tt> -- Site name (REQUIRED)
24
+ # * <tt>:station</tt> -- Station (defaults to "WEB")
25
+ # * <tt>:custcode</tt> -- Customer code (defaults to
26
+ # "ActiveMerchant/#{ActiveMerchant::VERSION}")
27
+ # * <tt>:default_item_code</tt> -- Default item code (defaults to "FEE",
28
+ # can be overridden on a per-transaction basis with options[:item_code])
29
+ def initialize(options = {})
30
+ requires!(
31
+ options,
32
+ :merchant,
33
+ :operator,
34
+ :password,
35
+ :merchant_gateway_name
36
+ )
37
+ options[:default_item_code] ||= 'FEE'
38
+ super
39
+ end
40
+
41
+ def purchase(money, payment_object, options = {})
42
+ post = {}
43
+ add_creditcard(post, payment_object)
44
+ add_invoice(post, options)
45
+ add_address(post, options)
46
+ add_customer_data(post, options)
47
+ commit('SALE', money, post)
48
+ end
49
+
50
+ def refund(money, identification, options = {})
51
+ post = {}
52
+ post[:origtx] = identification
53
+ add_invoice(post, options)
54
+ add_customer_data(post, options)
55
+ commit('REFUND', money, post)
56
+ end
57
+
58
+ def supports_scrubbing?
59
+ true
60
+ end
61
+
62
+ def scrub(transcript)
63
+ transcript.
64
+ gsub(%r{(password=)[^&]+}, '\1[FILTERED]').
65
+ gsub(%r{(cardno=)[^&]+}, '\1[FILTERED]').
66
+ gsub(%r{(cid=)[^&]+}, '\1[FILTERED]')
67
+ end
68
+
69
+ private
70
+
71
+ def commit(action, money, fields)
72
+ fields[:amount] = amount(money)
73
+ url = (test? ? test_url : live_url) + CGI.escape(@options[:merchant_gateway_name])
74
+ raw_response = ssl_post(url, post_data(action, fields))
75
+ parsed_response = parse(raw_response)
76
+
77
+ return unparsable_response(raw_response) unless parsed_response
78
+
79
+ success = success?(parsed_response)
80
+ Response.new(
81
+ success,
82
+ CASHNET_CODES[parsed_response[:result]],
83
+ parsed_response,
84
+ test: test?,
85
+ authorization: (success ? parsed_response[:tx] : '')
86
+ )
87
+ end
88
+
89
+ def success?(response)
90
+ response[:result] == '0'
91
+ end
92
+
93
+ def post_data(action, parameters = {})
94
+ post = {}
95
+ post[:command] = action
96
+ post[:merchant] = @options[:merchant]
97
+ post[:operator] = @options[:operator]
98
+ post[:password] = @options[:password]
99
+ post[:station] = (@options[:station] || 'WEB')
100
+ post[:custcode] = (@options[:custcode] || "ActiveMerchant/#{ActiveMerchant::VERSION}")
101
+ post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
102
+ end
103
+
104
+ def add_creditcard(post, creditcard)
105
+ post[:cardno] = creditcard.number
106
+ post[:cid] = creditcard.verification_value
107
+ post[:expdate] = expdate(creditcard)
108
+ post[:card_name_g] = creditcard.name
109
+ post[:fname] = creditcard.first_name
110
+ post[:lname] = creditcard.last_name
111
+ end
112
+
113
+ def add_invoice(post, options)
114
+ post[:order_number] = options[:order_id] if options[:order_id].present?
115
+ post[:itemcode] = (options[:item_code] || @options[:default_item_code])
116
+ end
117
+
118
+ def add_address(post, options)
119
+ if address = (options[:shipping_address] || options[:billing_address] || options[:address])
120
+ post[:addr_g] = String(address[:address1]) + ',' + String(address[:address2])
121
+ post[:city_g] = address[:city]
122
+ post[:state_g] = address[:state]
123
+ post[:zip_g] = address[:zip]
124
+ end
125
+ end
126
+
127
+ def add_customer_data(post, options)
128
+ post[:email_g] = options[:email]
129
+ post[:custcode] = options[:custcode] unless empty?(options[:custcode])
130
+ end
131
+
132
+ def expdate(creditcard)
133
+ year = format(creditcard.year, :two_digits)
134
+ month = format(creditcard.month, :two_digits)
135
+
136
+ "#{month}#{year}"
137
+ end
138
+
139
+ def parse(body)
140
+ match = body.match(/<cngateway>(.*)<\/cngateway>/)
141
+ return nil unless match
142
+
143
+ Hash[CGI::parse(match[1]).map { |k, v| [k.to_sym, v.first] }]
144
+ end
145
+
146
+ def handle_response(response)
147
+ if (200...300).cover?(response.code.to_i)
148
+ return response.body
149
+ elsif response.code.to_i == 302
150
+ return ssl_get(URI.parse(response['location']))
151
+ end
152
+
153
+ raise ResponseError.new(response)
154
+ end
155
+
156
+ def unparsable_response(raw_response)
157
+ message = 'Unparsable response received from Cashnet. Please contact Cashnet if you continue to receive this message.'
158
+ message += " (The raw response returned by the API was #{raw_response.inspect})"
159
+ return Response.new(false, message)
160
+ end
161
+
162
+ CASHNET_CODES = {
163
+ '0' => 'Success',
164
+ '1' => 'Invalid customer code, no customer code specified',
165
+ '2' => 'Invalid operator code, no operator specified',
166
+ '3' => 'Invalid workstation code, no station specified',
167
+ '4' => 'Invalid item code, no code specified',
168
+ '5' => 'Negative amount is not allowed',
169
+ '6' => 'Invalid credit card number, no credit card number provided',
170
+ '7' => 'Invalid expiration date, no expiration date provided',
171
+ '8' => 'Please only provide either ACH or credit card information',
172
+ '9' => 'Invalid ACH account number, no account number provided',
173
+ '10' => 'Invalid routing/transit number, no routing/transit number provided',
174
+ '11' => 'Invalid account type, no account type provided',
175
+ '12' => 'Invalid check digit for routing/transit number',
176
+ '13' => 'No ACH merchant account set up for the location of the station being used',
177
+ '21' => 'Invalid merchant code, no merchant code provided',
178
+ '22' => 'Invalid client code, no client code provided',
179
+ '23' => 'Invalid password, no password provided',
180
+ '24' => 'Invalid transaction type, no transaction type provided',
181
+ '25' => 'Invalid amount, amount not provided',
182
+ '26' => 'Invalid payment code provided',
183
+ '27' => 'Invalid version number, version not found',
184
+ '31' => 'Application amount exceeds account balance',
185
+ '150' => 'Invalid payment information, no payment information provided',
186
+ '200' => 'Invalid command',
187
+ '201' => 'Customer not on file',
188
+ '205' => 'Invalid operator or password',
189
+ '206' => 'Operator is not authorized for this function',
190
+ '208' => 'Customer/PIN authentication unsuccessful',
191
+ '209' => 'Credit card error',
192
+ '211' => 'Credit card error',
193
+ '212' => 'Customer/PIN not on file',
194
+ '213' => 'Customer information not on file',
195
+ '215' => 'Old PIN does not validate ',
196
+ '221' => 'Invalid credit card processor type specified in location or payment code',
197
+ '222' => 'Credit card processor error',
198
+ '230' => 'Host Error (USE VOID OR REVERSAL TO REFUND UNSETTLED TRANSACTIONS)',
199
+ '280' => 'SmartPay transaction not posted',
200
+ '301' => 'Original transaction not found for this customer',
201
+ '302' => 'Amount to refund exceeds original payment amount or is missing',
202
+ '304' => 'Original credit card payment not found or corrupted',
203
+ '305' => 'Refund amounts should be expressed as positive amounts',
204
+ '306' => 'Original ACH payment not found',
205
+ '307' => 'Original electronic payment not found',
206
+ '308' => 'Invalid original transaction number, original transaction number not found',
207
+ '310' => 'Refund amount exceeds amount still available for a refund',
208
+ '321' => 'Store has not been implemented',
209
+ '501' => 'Unable to roll over batch',
210
+ '502' => 'Batch not found',
211
+ '503' => 'Batch information not available',
212
+ '650' => 'Invalid quick code',
213
+ '651' => 'Transaction amount does not match amount specified in quick code',
214
+ '652' => 'Invalid item code in the detail of the quick code',
215
+ '701' => 'This website has been disabled. Please contact the system administrator.',
216
+ '702' => 'Improper merchant code. Please contact the system administrator.',
217
+ '703' => 'This site is temporarily down for maintenance. We regret the inconvenience. Please try again later.',
218
+ '704' => 'Duplicate item violation. Please contact the system administrator.',
219
+ '705' => 'An invalid reference type has been passed into the system. Please contact the system administrator',
220
+ '706' => 'Items violating unique selection have been passed in. Please contact the system administrator.',
221
+ '999' => 'An unexpected error has occurred. Please consult the event log.'
222
+ }
223
+ end
224
+ end
225
+ end
@@ -0,0 +1,198 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ # CC5 API is used by many banks in Turkey. Extend this base class to provide
4
+ # concrete implementations.
5
+ class CC5Gateway < Gateway
6
+ self.default_currency = 'TRY'
7
+
8
+ CURRENCY_CODES = {
9
+ 'TRY' => 949,
10
+ 'YTL' => 949,
11
+ 'TRL' => 949,
12
+ 'TL' => 949,
13
+ 'USD' => 840,
14
+ 'EUR' => 978,
15
+ 'GBP' => 826,
16
+ 'JPY' => 392
17
+ }
18
+
19
+ def initialize(options = {})
20
+ requires!(options, :login, :password, :client_id)
21
+ super
22
+ end
23
+
24
+ def purchase(money, creditcard, options = {})
25
+ commit(build_sale_request('Auth', money, creditcard, options))
26
+ end
27
+
28
+ def authorize(money, creditcard, options = {})
29
+ commit(build_sale_request('PreAuth', money, creditcard, options))
30
+ end
31
+
32
+ def capture(money, authorization, options = {})
33
+ commit(build_capture_request(money, authorization, options))
34
+ end
35
+
36
+ def void(authorization, options = {})
37
+ commit(build_void_request(authorization, options))
38
+ end
39
+
40
+ def refund(money, authorization, options = {})
41
+ commit(build_authorization_credit_request(money, authorization, options))
42
+ end
43
+
44
+ def credit(money, creditcard, options = {})
45
+ commit(build_creditcard_credit_request(money, creditcard, options))
46
+ end
47
+
48
+ protected
49
+
50
+ def build_sale_request(type, money, creditcard, options = {})
51
+ requires!(options, :order_id)
52
+
53
+ xml = Builder::XmlMarkup.new indent: 2
54
+
55
+ xml.tag! 'CC5Request' do
56
+ add_login_tags(xml)
57
+ xml.tag! 'OrderId', options[:order_id]
58
+ xml.tag! 'Type', type
59
+ xml.tag! 'Number', creditcard.number
60
+ xml.tag! 'Expires', [format(creditcard.month, :two_digits), format(creditcard.year, :two_digits)].join('/')
61
+ xml.tag! 'Cvv2Val', creditcard.verification_value
62
+ add_amount_tags(money, options, xml)
63
+ xml.tag! 'Email', options[:email] if options[:email]
64
+
65
+ if (address = (options[:billing_address] || options[:address]))
66
+ xml.tag! 'BillTo' do
67
+ add_address(xml, address)
68
+ end
69
+ xml.tag! 'ShipTo' do
70
+ add_address(xml, address)
71
+ end
72
+ end
73
+ end
74
+
75
+ xml.target!
76
+ end
77
+
78
+ def build_capture_request(money, authorization, options = {})
79
+ xml = Builder::XmlMarkup.new indent: 2
80
+
81
+ xml.tag! 'CC5Request' do
82
+ add_login_tags(xml)
83
+ xml.tag! 'OrderId', authorization
84
+ xml.tag! 'Type', 'PostAuth'
85
+ add_amount_tags(money, options, xml)
86
+ end
87
+ end
88
+
89
+ def build_void_request(authorization, options = {})
90
+ xml = Builder::XmlMarkup.new indent: 2
91
+
92
+ xml.tag! 'CC5Request' do
93
+ add_login_tags(xml)
94
+ xml.tag! 'OrderId', authorization
95
+ xml.tag! 'Type', 'Void'
96
+ end
97
+ end
98
+
99
+ def build_authorization_credit_request(money, authorization, options = {})
100
+ xml = Builder::XmlMarkup.new indent: 2
101
+
102
+ xml.tag! 'CC5Request' do
103
+ add_login_tags(xml)
104
+ xml.tag! 'OrderId', authorization
105
+ xml.tag! 'Type', 'Credit'
106
+ add_amount_tags(money, options, xml)
107
+ end
108
+ end
109
+
110
+ def build_creditcard_credit_request(money, creditcard, options = {})
111
+ xml = Builder::XmlMarkup.new indent: 2
112
+
113
+ xml.tag! 'CC5Request' do
114
+ add_login_tags(xml)
115
+ xml.tag! 'Type', 'Credit'
116
+ xml.tag! 'Number', creditcard.number
117
+
118
+ add_amount_tags(money, options, xml)
119
+ end
120
+ end
121
+
122
+ def add_address(xml, address)
123
+ xml.tag! 'Name', normalize(address[:name])
124
+ xml.tag! 'Street1', normalize(address[:address1])
125
+ xml.tag! 'Street2', normalize(address[:address2]) if address[:address2]
126
+ xml.tag! 'City', normalize(address[:city])
127
+ xml.tag! 'PostalCode', address[:zip]
128
+ xml.tag! 'Country', normalize(address[:country])
129
+ xml.tag! 'Company', normalize(address[:company])
130
+ xml.tag! 'TelVoice', address[:phone].to_s.gsub(/[^0-9]/, '') if address[:phone]
131
+ end
132
+
133
+ def add_login_tags(xml)
134
+ xml.tag! 'Name', @options[:login]
135
+ xml.tag! 'Password', @options[:password]
136
+ xml.tag! 'ClientId', @options[:client_id]
137
+ xml.tag! 'Mode', (test? ? 'T' : 'P')
138
+ end
139
+
140
+ def add_amount_tags(money, options, xml)
141
+ xml.tag! 'Total', amount(money)
142
+ xml.tag! 'Currency', currency_code(options[:currency] || currency(money))
143
+ end
144
+
145
+ def currency_code(currency)
146
+ (CURRENCY_CODES[currency] || CURRENCY_CODES[default_currency])
147
+ end
148
+
149
+ def commit(request)
150
+ raw_response = ssl_post((test? ? self.test_url : self.live_url), 'DATA=' + request)
151
+
152
+ response = parse(raw_response)
153
+
154
+ success = success?(response)
155
+
156
+ Response.new(
157
+ success,
158
+ (success ? 'Approved' : "Declined (Reason: #{response[:proc_return_code]} - #{response[:err_msg]})"),
159
+ response,
160
+ test: test?,
161
+ authorization: response[:order_id]
162
+ )
163
+ end
164
+
165
+ def parse(body)
166
+ xml = REXML::Document.new(body)
167
+
168
+ response = {}
169
+ xml.root.elements.to_a.each do |node|
170
+ parse_element(response, node)
171
+ end
172
+ response
173
+ end
174
+
175
+ def parse_element(response, node)
176
+ if node.has_elements?
177
+ node.elements.each { |element| parse_element(response, element) }
178
+ else
179
+ response[node.name.underscore.to_sym] = node.text
180
+ end
181
+ end
182
+
183
+ def success?(response)
184
+ (response[:response] == 'Approved')
185
+ end
186
+
187
+ def normalize(text)
188
+ return unless text
189
+
190
+ if ActiveSupport::Inflector.method(:transliterate).arity == -2
191
+ ActiveSupport::Inflector.transliterate(text, '')
192
+ else
193
+ text.gsub(/[^\x00-\x7F]+/, '')
194
+ end
195
+ end
196
+ end
197
+ end
198
+ end