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,224 @@
1
+ require 'rexml/document'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ class VerifiGateway < Gateway
6
+ class VerifiPostData < PostData
7
+ # Fields that will be sent even if they are blank
8
+ self.required_fields = %i[amount type ccnumber ccexp firstname lastname
9
+ company address1 address2 city state zip country phone]
10
+ end
11
+
12
+ self.live_url = self.test_url = 'https://secure.verifi.com/gw/api/transact.php'
13
+
14
+ RESPONSE_CODE_MESSAGES = {
15
+ '100' => 'Transaction was Approved',
16
+ '200' => 'Transaction was Declined by Processor',
17
+ '201' => 'Do Not Honor',
18
+ '202' => 'Insufficient Funds',
19
+ '203' => 'Over Limit',
20
+ '204' => 'Transaction not allowed',
21
+ '220' => 'Incorrect payment Data',
22
+ '221' => 'No Such Card Issuer',
23
+ '222' => 'No Card Number on file with Issuer',
24
+ '223' => 'Expired Card',
25
+ '224' => 'Invalid Expiration Date',
26
+ '225' => 'Invalid Card Security Code',
27
+ '240' => 'Call Issuer for Further Information',
28
+ '250' => 'Pick Up Card',
29
+ '251' => 'Lost Card',
30
+ '252' => 'Stolen Card',
31
+ '253' => 'Fraudulent Card',
32
+ '260' => 'Declined With further Instructions Available (see response text)',
33
+ '261' => 'Declined - Stop All Recurring Payments',
34
+ '262' => 'Declined - Stop this Recurring Program',
35
+ '263' => 'Declined - Update Cardholder Data Available',
36
+ '264' => 'Declined - Retry in a few days',
37
+ '300' => 'Transaction was Rejected by Gateway',
38
+ '400' => 'Transaction Error Returned by Processor',
39
+ '410' => 'Invalid Merchant Configuration',
40
+ '411' => 'Merchant Account is Inactive',
41
+ '420' => 'Communication Error',
42
+ '421' => 'Communication Error with Issuer',
43
+ '430' => 'Duplicate Transaction at Processor',
44
+ '440' => 'Processor Format Error',
45
+ '441' => 'Invalid Transaction Information',
46
+ '460' => 'Processor Feature Not Available',
47
+ '461' => 'Unsupported Card Type'
48
+ }
49
+
50
+ SUCCESS = 1
51
+
52
+ TRANSACTIONS = {
53
+ authorization: 'auth',
54
+ purchase: 'sale',
55
+ capture: 'capture',
56
+ void: 'void',
57
+ credit: 'credit',
58
+ refund: 'refund'
59
+ }
60
+
61
+ self.supported_countries = ['US']
62
+ self.supported_cardtypes = %i[visa master american_express discover]
63
+ self.homepage_url = 'http://www.verifi.com/'
64
+ self.display_name = 'Verifi'
65
+
66
+ def initialize(options = {})
67
+ requires!(options, :login, :password)
68
+ super
69
+ end
70
+
71
+ def purchase(money, credit_card, options = {})
72
+ sale_authorization_or_credit_template(:purchase, money, credit_card, options)
73
+ end
74
+
75
+ def authorize(money, credit_card, options = {})
76
+ sale_authorization_or_credit_template(:authorization, money, credit_card, options)
77
+ end
78
+
79
+ def capture(money, authorization, options = {})
80
+ capture_void_or_refund_template(:capture, money, authorization, options)
81
+ end
82
+
83
+ def void(authorization, options = {})
84
+ capture_void_or_refund_template(:void, 0, authorization, options)
85
+ end
86
+
87
+ def credit(money, credit_card_or_authorization, options = {})
88
+ if credit_card_or_authorization.is_a?(String)
89
+ ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
90
+ refund(money, credit_card_or_authorization, options)
91
+ else
92
+ sale_authorization_or_credit_template(:credit, money, credit_card_or_authorization, options)
93
+ end
94
+ end
95
+
96
+ def refund(money, reference, options = {})
97
+ capture_void_or_refund_template(:refund, money, reference, options)
98
+ end
99
+
100
+ private
101
+
102
+ def sale_authorization_or_credit_template(trx_type, money, credit_card, options = {})
103
+ post = VerifiPostData.new
104
+ add_security_key_data(post, options, money)
105
+ add_credit_card(post, credit_card)
106
+ add_addresses(post, options)
107
+ add_customer_data(post, options)
108
+ add_invoice_data(post, options)
109
+ add_optional_data(post, options)
110
+ commit(trx_type, money, post)
111
+ end
112
+
113
+ def capture_void_or_refund_template(trx_type, money, authorization, options)
114
+ post = VerifiPostData.new
115
+ post[:transactionid] = authorization
116
+
117
+ commit(trx_type, money, post)
118
+ end
119
+
120
+ def add_credit_card(post, credit_card)
121
+ post[:ccnumber] = credit_card.number
122
+ post[:ccexp] = expdate(credit_card)
123
+ post[:firstname] = credit_card.first_name
124
+ post[:lastname] = credit_card.last_name
125
+ post[:cvv] = credit_card.verification_value
126
+ end
127
+
128
+ def add_addresses(post, options)
129
+ if billing_address = options[:billing_address] || options[:address]
130
+ post[:company] = billing_address[:company]
131
+ post[:address1] = billing_address[:address1]
132
+ post[:address2] = billing_address[:address2]
133
+ post[:city] = billing_address[:city]
134
+ post[:state] = billing_address[:state]
135
+ post[:zip] = billing_address[:zip]
136
+ post[:country] = billing_address[:country]
137
+ post[:phone] = billing_address[:phone]
138
+ post[:fax] = billing_address[:fax]
139
+ end
140
+
141
+ if shipping_address = options[:shipping_address]
142
+ post[:shipping_firstname] = shipping_address[:first_name]
143
+ post[:shipping_lastname] = shipping_address[:last_name]
144
+ post[:shipping_company] = shipping_address[:company]
145
+ post[:shipping_address1] = shipping_address[:address1]
146
+ post[:shipping_address2] = shipping_address[:address2]
147
+ post[:shipping_city] = shipping_address[:city]
148
+ post[:shipping_state] = shipping_address[:state]
149
+ post[:shipping_zip] = shipping_address[:zip]
150
+ post[:shipping_country] = shipping_address[:country]
151
+ post[:shipping_email] = shipping_address[:email]
152
+ end
153
+ end
154
+
155
+ def add_customer_data(post, options)
156
+ post[:email] = options[:email]
157
+ post[:ipaddress] = options[:ip]
158
+ end
159
+
160
+ def add_invoice_data(post, options)
161
+ post[:orderid] = options[:order_id]
162
+ post[:ponumber] = options[:invoice]
163
+ post[:orderdescription] = options[:description]
164
+ post[:tax] = options[:tax]
165
+ post[:shipping] = options[:shipping]
166
+ end
167
+
168
+ def add_optional_data(post, options)
169
+ post[:billing_method] = options[:billing_method]
170
+ post[:website] = options[:website]
171
+ post[:descriptor] = options[:descriptor]
172
+ post[:descriptor_phone] = options[:descriptor_phone]
173
+ post[:cardholder_auth] = options[:cardholder_auth]
174
+ post[:cavv] = options[:cavv]
175
+ post[:xid] = options[:xid]
176
+ post[:customer_receipt] = options[:customer_receipt]
177
+ end
178
+
179
+ def add_security_key_data(post, options, money)
180
+ # MD5(username|password|orderid|amount|time)
181
+ now = Time.now.to_i.to_s
182
+ md5 = Digest::MD5.new
183
+ md5 << @options[:login].to_s + '|'
184
+ md5 << @options[:password].to_s + '|'
185
+ md5 << options[:order_id].to_s + '|'
186
+ md5 << amount(money).to_s + '|'
187
+ md5 << now
188
+ post[:key] = md5.hexdigest
189
+ post[:time] = now
190
+ end
191
+
192
+ def commit(trx_type, money, post)
193
+ post[:amount] = amount(money)
194
+
195
+ response = parse(ssl_post(self.live_url, post_data(trx_type, post)))
196
+
197
+ Response.new(response[:response].to_i == SUCCESS, message_from(response), response,
198
+ test: test?,
199
+ authorization: response[:transactionid],
200
+ avs_result: { code: response[:avsresponse] },
201
+ cvv_result: response[:cvvresponse])
202
+ end
203
+
204
+ def message_from(response)
205
+ response[:response_code_message] || ''
206
+ end
207
+
208
+ def parse(body)
209
+ results = {}
210
+ CGI.parse(body).each { |key, value| results[key.intern] = value[0] }
211
+ results[:response_code_message] = RESPONSE_CODE_MESSAGES[results[:response_code]] if results[:response_code]
212
+ results
213
+ end
214
+
215
+ def post_data(trx_type, post)
216
+ post[:username] = @options[:login]
217
+ post[:password] = @options[:password]
218
+ post[:type] = TRANSACTIONS[trx_type]
219
+
220
+ post.to_s
221
+ end
222
+ end
223
+ end
224
+ end
@@ -0,0 +1,171 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class ViaklixGateway < Gateway
4
+ class_attribute :test_url, :live_url, :delimiter, :actions
5
+
6
+ self.test_url = 'https://demo.viaklix.com/process.asp'
7
+ self.live_url = 'https://www.viaklix.com/process.asp'
8
+ self.delimiter = "\r\n"
9
+
10
+ self.actions = {
11
+ purchase: 'SALE',
12
+ credit: 'CREDIT'
13
+ }
14
+
15
+ APPROVED = '0'
16
+
17
+ self.supported_cardtypes = %i[visa master american_express discover]
18
+ self.supported_countries = ['US']
19
+ self.display_name = 'ViaKLIX'
20
+ self.homepage_url = 'http://viaklix.com'
21
+
22
+ # Initialize the Gateway
23
+ #
24
+ # The gateway requires that a valid login and password be passed
25
+ # in the +options+ hash.
26
+ #
27
+ # ==== Options
28
+ #
29
+ # * <tt>:login</tt> -- Merchant ID
30
+ # * <tt>:password</tt> -- PIN
31
+ # * <tt>:user</tt> -- Specify a subuser of the account (optional)
32
+ # * <tt>:test => +true+ or +false+</tt> -- Force test transactions
33
+ def initialize(options = {})
34
+ requires!(options, :login, :password)
35
+ super
36
+ end
37
+
38
+ # Make a purchase
39
+ def purchase(money, creditcard, options = {})
40
+ form = {}
41
+ add_invoice(form, options)
42
+ add_creditcard(form, creditcard)
43
+ add_address(form, options)
44
+ add_customer_data(form, options)
45
+ add_test_mode(form, options)
46
+ commit(:purchase, money, form)
47
+ end
48
+
49
+ # Make a credit to a card (Void can only be done from the virtual terminal)
50
+ # Viaklix does not support credits by reference. You must pass in the credit card
51
+ def credit(money, creditcard, options = {})
52
+ raise ArgumentError, 'Reference credits are not supported. Please supply the original credit card' if creditcard.is_a?(String)
53
+
54
+ form = {}
55
+ add_invoice(form, options)
56
+ add_creditcard(form, creditcard)
57
+ add_address(form, options)
58
+ add_customer_data(form, options)
59
+ add_test_mode(form, options)
60
+ commit(:credit, money, form)
61
+ end
62
+
63
+ private
64
+
65
+ def add_test_mode(form, options)
66
+ form[:test_mode] = 'TRUE' if options[:test_mode]
67
+ end
68
+
69
+ def add_customer_data(form, options)
70
+ form[:email] = options[:email].to_s.slice(0, 100) unless options[:email].blank?
71
+ form[:customer_code] = options[:customer].to_s.slice(0, 10) unless options[:customer].blank?
72
+ end
73
+
74
+ def add_invoice(form, options)
75
+ form[:invoice_number] = (options[:order_id] || options[:invoice]).to_s.slice(0, 10)
76
+ form[:description] = options[:description].to_s.slice(0, 255)
77
+ end
78
+
79
+ def add_address(form, options)
80
+ billing_address = options[:billing_address] || options[:address]
81
+
82
+ if billing_address
83
+ form[:avs_address] = billing_address[:address1].to_s.slice(0, 30)
84
+ form[:address2] = billing_address[:address2].to_s.slice(0, 30)
85
+ form[:avs_zip] = billing_address[:zip].to_s.slice(0, 10)
86
+ form[:city] = billing_address[:city].to_s.slice(0, 30)
87
+ form[:state] = billing_address[:state].to_s.slice(0, 10)
88
+ form[:company] = billing_address[:company].to_s.slice(0, 50)
89
+ form[:phone] = billing_address[:phone].to_s.slice(0, 20)
90
+ form[:country] = billing_address[:country].to_s.slice(0, 50)
91
+ end
92
+
93
+ if shipping_address = options[:shipping_address]
94
+ first_name, last_name = split_names(shipping_address[:name])
95
+ form[:ship_to_first_name] = first_name.to_s.slice(0, 20)
96
+ form[:ship_to_last_name] = last_name.to_s.slice(0, 30)
97
+ form[:ship_to_address] = shipping_address[:address1].to_s.slice(0, 30)
98
+ form[:ship_to_city] = shipping_address[:city].to_s.slice(0, 30)
99
+ form[:ship_to_state] = shipping_address[:state].to_s.slice(0, 10)
100
+ form[:ship_to_company] = shipping_address[:company].to_s.slice(0, 50)
101
+ form[:ship_to_country] = shipping_address[:country].to_s.slice(0, 50)
102
+ form[:ship_to_zip] = shipping_address[:zip].to_s.slice(0, 10)
103
+ end
104
+ end
105
+
106
+ def add_creditcard(form, creditcard)
107
+ form[:card_number] = creditcard.number
108
+ form[:exp_date] = expdate(creditcard)
109
+
110
+ add_verification_value(form, creditcard) if creditcard.verification_value?
111
+
112
+ form[:first_name] = creditcard.first_name.to_s.slice(0, 20)
113
+ form[:last_name] = creditcard.last_name.to_s.slice(0, 30)
114
+ end
115
+
116
+ def add_verification_value(form, creditcard)
117
+ form[:cvv2cvc2] = creditcard.verification_value
118
+ form[:cvv2] = 'present'
119
+ end
120
+
121
+ def preamble
122
+ result = {
123
+ 'merchant_id' => @options[:login],
124
+ 'pin' => @options[:password],
125
+ 'show_form' => 'false',
126
+ 'result_format' => 'ASCII'
127
+ }
128
+
129
+ result['user_id'] = @options[:user] unless @options[:user].blank?
130
+ result
131
+ end
132
+
133
+ def commit(action, money, parameters)
134
+ parameters[:amount] = amount(money)
135
+ parameters[:transaction_type] = self.actions[action]
136
+
137
+ response = parse(ssl_post(test? ? self.test_url : self.live_url, post_data(parameters)))
138
+
139
+ Response.new(response['result'] == APPROVED, message_from(response), response,
140
+ test: @options[:test] || test?,
141
+ authorization: authorization_from(response),
142
+ avs_result: { code: response['avs_response'] },
143
+ cvv_result: response['cvv2_response'])
144
+ end
145
+
146
+ def authorization_from(response)
147
+ response['txn_id']
148
+ end
149
+
150
+ def message_from(response)
151
+ response['result_message']
152
+ end
153
+
154
+ def post_data(parameters)
155
+ result = preamble
156
+ result.merge!(parameters)
157
+ result.collect { |key, value| "ssl_#{key}=#{CGI.escape(value.to_s)}" }.join('&')
158
+ end
159
+
160
+ # Parse the response message
161
+ def parse(msg)
162
+ resp = {}
163
+ msg.split(self.delimiter).collect { |li|
164
+ key, value = li.split('=')
165
+ resp[key.strip.gsub(/^ssl_/, '')] = value.to_s.strip
166
+ }
167
+ resp
168
+ end
169
+ end
170
+ end
171
+ end
@@ -0,0 +1,246 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class VisanetPeruGateway < Gateway
4
+ include Empty
5
+ self.display_name = 'VisaNet Peru Gateway'
6
+ self.homepage_url = 'http://www.visanet.com.pe'
7
+
8
+ self.test_url = 'https://devapi.vnforapps.com/api.tokenization/api/v2/merchant'
9
+ self.live_url = 'https://api.vnforapps.com/api.tokenization/api/v2/merchant'
10
+
11
+ self.supported_countries = %w[US PE]
12
+ self.default_currency = 'PEN'
13
+ self.money_format = :dollars
14
+ self.supported_cardtypes = %i[visa master american_express discover]
15
+
16
+ def initialize(options = {})
17
+ requires!(options, :access_key_id, :secret_access_key, :merchant_id)
18
+ super
19
+ end
20
+
21
+ def purchase(amount, payment_method, options = {})
22
+ MultiResponse.run() do |r|
23
+ r.process { authorize(amount, payment_method, options) }
24
+ r.process { capture(amount, r.authorization, options) }
25
+ end
26
+ end
27
+
28
+ def authorize(amount, payment_method, options = {})
29
+ params = {}
30
+
31
+ add_invoice(params, amount, options)
32
+ add_payment_method(params, payment_method)
33
+ add_antifraud_data(params, options)
34
+ params[:email] = options[:email] || 'unknown@email.com'
35
+ params[:createAlias] = false
36
+
37
+ commit('authorize', params, options)
38
+ end
39
+
40
+ def capture(amount, authorization, options = {})
41
+ params = {}
42
+ options[:id_unico] = split_authorization(authorization)[1]
43
+ add_auth_order_id(params, authorization, options)
44
+ commit('deposit', params, options)
45
+ end
46
+
47
+ def void(authorization, options = {})
48
+ params = {}
49
+ add_auth_order_id(params, authorization, options)
50
+ commit('void', params, options)
51
+ end
52
+
53
+ def refund(amount, authorization, options = {})
54
+ params = {}
55
+ params[:amount] = amount(amount) if amount
56
+ add_auth_order_id(params, authorization, options)
57
+ response = commit('cancelDeposit', params, options)
58
+ return response if response.success? || split_authorization(authorization).length == 1 || !options[:force_full_refund_if_unsettled]
59
+
60
+ # Attempt RefundSingleTransaction if unsettled (and stash the original
61
+ # response message so it will be included it in the follow-up response
62
+ # message)
63
+ options[:error_message] = response.message
64
+ prepare_refund_data(params, authorization, options)
65
+ commit('refund', params, options)
66
+ end
67
+
68
+ def verify(credit_card, options = {})
69
+ MultiResponse.run(:use_first_response) do |r|
70
+ r.process { authorize(100, credit_card, options) }
71
+ r.process(:ignore_result) { void(r.authorization, options) }
72
+ end
73
+ end
74
+
75
+ def supports_scrubbing?
76
+ true
77
+ end
78
+
79
+ def scrub(transcript)
80
+ transcript.
81
+ gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
82
+ gsub(%r((\"cardNumber\\\":\\\")\d+), '\1[FILTERED]').
83
+ gsub(%r((\"cvv2Code\\\":\\\")\d+), '\1[FILTERED]')
84
+ end
85
+
86
+ private
87
+
88
+ CURRENCY_CODES = Hash.new { |_h, k| raise ArgumentError.new("Unsupported currency: #{k}") }
89
+ CURRENCY_CODES['USD'] = 840
90
+ CURRENCY_CODES['PEN'] = 604
91
+
92
+ def add_invoice(params, money, options)
93
+ # Visanet Peru expects a 9-digit numeric purchaseNumber
94
+ params[:purchaseNumber] = (SecureRandom.random_number(900_000_000) + 100_000_000).to_s
95
+ params[:externalTransactionId] = options[:order_id]
96
+ params[:amount] = amount(money)
97
+ params[:currencyId] = CURRENCY_CODES[options[:currency] || currency(money)]
98
+ end
99
+
100
+ def add_auth_order_id(params, authorization, options)
101
+ purchase_number, = split_authorization(authorization)
102
+ params[:purchaseNumber] = purchase_number
103
+ params[:externalTransactionId] = options[:order_id]
104
+ end
105
+
106
+ def add_payment_method(params, payment_method)
107
+ params[:firstName] = payment_method.first_name
108
+ params[:lastName] = payment_method.last_name
109
+ params[:cardNumber] = payment_method.number
110
+ params[:cvv2Code] = payment_method.verification_value
111
+ params[:expirationYear] = format(payment_method.year, :four_digits)
112
+ params[:expirationMonth] = format(payment_method.month, :two_digits)
113
+ end
114
+
115
+ def add_antifraud_data(params, options)
116
+ antifraud = {}
117
+
118
+ if billing_address = options[:billing_address] || options[:address]
119
+ antifraud[:billTo_street1] = billing_address[:address1]
120
+ antifraud[:billTo_city] = billing_address[:city]
121
+ antifraud[:billTo_state] = billing_address[:state]
122
+ antifraud[:billTo_country] = billing_address[:country]
123
+ antifraud[:billTo_postalCode] = billing_address[:zip]
124
+ end
125
+
126
+ antifraud[:deviceFingerprintId] = options[:device_fingerprint_id] || SecureRandom.hex(16)
127
+ antifraud[:merchantDefineData] = options[:merchant_define_data] if options[:merchant_define_data]
128
+
129
+ params[:antifraud] = antifraud
130
+ end
131
+
132
+ def prepare_refund_data(params, authorization, options)
133
+ params.delete(:purchaseNumber)
134
+ params[:externalReferenceId] = params.delete(:externalTransactionId)
135
+ _, transaction_id = split_authorization(authorization)
136
+
137
+ options.update(transaction_id: transaction_id)
138
+ params[:ruc] = options[:ruc]
139
+ end
140
+
141
+ def split_authorization(authorization)
142
+ authorization.split('|')
143
+ end
144
+
145
+ def commit(action, params, options = {})
146
+ raw_response = ssl_request(method(action), url(action, params, options), params.to_json, headers)
147
+ response = parse(raw_response)
148
+ rescue ResponseError => e
149
+ raw_response = e.response.body
150
+ response_error(raw_response, options, action)
151
+ rescue JSON::ParserError
152
+ unparsable_response(raw_response)
153
+ else
154
+ Response.new(
155
+ success_from(response),
156
+ message_from(response, options, action),
157
+ response,
158
+ test: test?,
159
+ authorization: authorization_from(params, response, options),
160
+ error_code: response['errorCode']
161
+ )
162
+ end
163
+
164
+ def headers
165
+ {
166
+ 'Authorization' => 'Basic ' + Base64.strict_encode64("#{@options[:access_key_id]}:#{@options[:secret_access_key]}").strip,
167
+ 'Content-Type' => 'application/json'
168
+ }
169
+ end
170
+
171
+ def url(action, params, options = {})
172
+ if action == 'authorize'
173
+ "#{base_url}/#{@options[:merchant_id]}"
174
+ elsif action == 'refund'
175
+ "#{base_url}/#{@options[:merchant_id]}/#{action}/#{options[:transaction_id]}"
176
+ else
177
+ "#{base_url}/#{@options[:merchant_id]}/#{action}/#{params[:purchaseNumber]}"
178
+ end
179
+ end
180
+
181
+ def method(action)
182
+ %w(authorize refund).include?(action) ? :post : :put
183
+ end
184
+
185
+ def authorization_from(params, response, options)
186
+ id_unico = response['data']['ID_UNICO'] || options[:id_unico]
187
+ "#{params[:purchaseNumber]}|#{id_unico}"
188
+ end
189
+
190
+ def base_url
191
+ test? ? test_url : live_url
192
+ end
193
+
194
+ def parse(body)
195
+ JSON.parse(body)
196
+ end
197
+
198
+ def success_from(response)
199
+ response['errorCode'] == 0
200
+ end
201
+
202
+ def message_from(response, options, action)
203
+ message_from_messages(
204
+ response['errorMessage'],
205
+ action_code_description(response),
206
+ options[:error_message]
207
+ )
208
+ end
209
+
210
+ def message_from_messages(*args)
211
+ args.reject { |m| error_message_empty?(m) }.join(' | ')
212
+ end
213
+
214
+ def action_code_description(response)
215
+ return nil unless response['data']
216
+
217
+ response['data']['DSC_COD_ACCION']
218
+ end
219
+
220
+ def error_message_empty?(error_message)
221
+ empty?(error_message) || error_message == '[ ]'
222
+ end
223
+
224
+ def response_error(raw_response, options, action)
225
+ response = parse(raw_response)
226
+ rescue JSON::ParserError
227
+ unparsable_response(raw_response)
228
+ else
229
+ return Response.new(
230
+ false,
231
+ message_from(response, options, action),
232
+ response,
233
+ test: test?,
234
+ authorization: response['transactionUUID'],
235
+ error_code: response['errorCode']
236
+ )
237
+ end
238
+
239
+ def unparsable_response(raw_response)
240
+ message = 'Invalid JSON response received from VisanetPeruGateway. Please contact VisanetPeruGateway if you continue to receive this message.'
241
+ message += " (The raw response returned by the API was #{raw_response.inspect})"
242
+ return Response.new(false, message)
243
+ end
244
+ end
245
+ end
246
+ end