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,208 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class WorldpayOnlinePaymentsGateway < Gateway
4
+ self.live_url = 'https://api.worldpay.com/v1/'
5
+
6
+ self.default_currency = 'GBP'
7
+
8
+ self.money_format = :cents
9
+
10
+ self.supported_countries = %w(HK US GB BE CH CZ DE DK ES FI FR GR HU IE IT LU MT NL NO PL PT SE SG TR)
11
+ self.supported_cardtypes = %i[visa master american_express discover jcb maestro]
12
+
13
+ self.homepage_url = 'http://online.worldpay.com'
14
+ self.display_name = 'Worldpay Online Payments'
15
+
16
+ def initialize(options = {})
17
+ requires!(options, :client_key, :service_key)
18
+ @client_key = options[:client_key]
19
+ @service_key = options[:service_key]
20
+ super
21
+ end
22
+
23
+ def authorize(money, credit_card, options = {})
24
+ response = create_token(true, credit_card.first_name + ' ' + credit_card.last_name, credit_card.month, credit_card.year, credit_card.number, credit_card.verification_value)
25
+ if response.success?
26
+ options[:authorizeOnly] = true
27
+ post = create_post_for_auth_or_purchase(response.authorization, money, options)
28
+ response = commit(:post, 'orders', post, {}, 'authorize')
29
+ end
30
+ response
31
+ end
32
+
33
+ def capture(money, authorization, options = {})
34
+ if authorization
35
+ commit(:post, "orders/#{CGI.escape(authorization)}/capture", { 'captureAmount' => money }, options, 'capture')
36
+ else
37
+ Response.new(false,
38
+ 'FAILED',
39
+ 'FAILED',
40
+ test: test?,
41
+ authorization: false,
42
+ avs_result: {},
43
+ cvv_result: {},
44
+ error_code: false)
45
+ end
46
+ end
47
+
48
+ def purchase(money, credit_card, options = {})
49
+ response = create_token(true, credit_card.first_name + ' ' + credit_card.last_name, credit_card.month, credit_card.year, credit_card.number, credit_card.verification_value)
50
+ if response.success?
51
+ post = create_post_for_auth_or_purchase(response.authorization, money, options)
52
+ response = commit(:post, 'orders', post, options, 'purchase')
53
+ end
54
+ response
55
+ end
56
+
57
+ def refund(money, orderCode, options = {})
58
+ obj = money ? { 'refundAmount' => money } : {}
59
+ commit(:post, "orders/#{CGI.escape(orderCode)}/refund", obj, options, 'refund')
60
+ end
61
+
62
+ def void(orderCode, options = {})
63
+ response = commit(:delete, "orders/#{CGI.escape(orderCode)}", nil, options, 'void')
64
+ response = refund(nil, orderCode) if !response.success? && (response.params && response.params['customCode'] != 'ORDER_NOT_FOUND')
65
+ response
66
+ end
67
+
68
+ def verify(credit_card, options = {})
69
+ authorize(0, credit_card, options)
70
+ end
71
+
72
+ private
73
+
74
+ def create_token(reusable, name, exp_month, exp_year, number, cvc)
75
+ obj = {
76
+ 'reusable' => reusable,
77
+ 'paymentMethod' => {
78
+ 'type' => 'Card',
79
+ 'name' => name,
80
+ 'expiryMonth' => exp_month,
81
+ 'expiryYear' => exp_year,
82
+ 'cardNumber' => number,
83
+ 'cvc' => cvc
84
+ },
85
+ 'clientKey' => @client_key
86
+ }
87
+ token_response = commit(:post, 'tokens', obj, { 'Authorization' => @service_key }, 'token')
88
+ token_response
89
+ end
90
+
91
+ def create_post_for_auth_or_purchase(token, money, options)
92
+ {
93
+ 'token' => token,
94
+ 'orderDescription' => options[:description] || 'Worldpay Order',
95
+ 'amount' => money,
96
+ 'currencyCode' => options[:currency] || default_currency,
97
+ 'name' => options[:billing_address] && options[:billing_address][:name] ? options[:billing_address][:name] : '',
98
+ 'billingAddress' => {
99
+ 'address1' => options[:billing_address] && options[:billing_address][:address1] ? options[:billing_address][:address1] : '',
100
+ 'address2' => options[:billing_address] && options[:billing_address][:address2] ? options[:billing_address][:address2] : '',
101
+ 'address3' => '',
102
+ 'postalCode' => options[:billing_address] && options[:billing_address][:zip] ? options[:billing_address][:zip] : '',
103
+ 'city' => options[:billing_address] && options[:billing_address][:city] ? options[:billing_address][:city] : '',
104
+ 'state' => options[:billing_address] && options[:billing_address][:state] ? options[:billing_address][:state] : '',
105
+ 'countryCode' => options[:billing_address] && options[:billing_address][:country] ? options[:billing_address][:country] : ''
106
+ },
107
+ 'customerOrderCode' => options[:order_id],
108
+ 'orderType' => 'ECOM',
109
+ 'authorizeOnly' => options[:authorizeOnly] ? true : false
110
+ }
111
+ end
112
+
113
+ def parse(body)
114
+ body ? JSON.parse(body) : {}
115
+ end
116
+
117
+ def headers(options = {})
118
+ headers = {
119
+ 'Authorization' => @service_key,
120
+ 'Content-Type' => 'application/json',
121
+ 'User-Agent' => "Worldpay/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
122
+ 'X-Worldpay-Client-User-Agent' => user_agent,
123
+ 'X-Worldpay-Client-User-Metadata' => { ip: options[:ip] }.to_json
124
+ }
125
+ headers['Authorization'] = options['Authorization'] if options['Authorization']
126
+ headers
127
+ end
128
+
129
+ def commit(method, url, parameters = nil, options = {}, type = false)
130
+ raw_response = response = nil
131
+ success = false
132
+ begin
133
+ json = parameters ? parameters.to_json : nil
134
+
135
+ raw_response = ssl_request(method, self.live_url + url, json, headers(options))
136
+
137
+ if raw_response != ''
138
+ response = parse(raw_response)
139
+ if type == 'token'
140
+ success = response.key?('token')
141
+ else
142
+ if response.key?('httpStatusCode')
143
+ success = false
144
+ else
145
+ if type == 'authorize' && response['paymentStatus'] == 'AUTHORIZED'
146
+ success = true
147
+ elsif type == 'purchase' && response['paymentStatus'] == 'SUCCESS'
148
+ success = true
149
+ elsif type == 'capture' || type == 'refund' || type == 'void'
150
+ success = true
151
+ end
152
+ end
153
+ end
154
+ else
155
+ success = true
156
+ response = {}
157
+ end
158
+ rescue ResponseError => e
159
+ raw_response = e.response.body
160
+ response = response_error(raw_response)
161
+ rescue JSON::ParserError
162
+ response = json_error(raw_response)
163
+ end
164
+
165
+ if response['orderCode']
166
+ authorization = response['orderCode']
167
+ elsif response['token']
168
+ authorization = response['token']
169
+ else
170
+ authorization = response['message']
171
+ end
172
+
173
+ Response.new(success,
174
+ success ? 'SUCCESS' : response['message'],
175
+ response,
176
+ test: test?,
177
+ authorization: authorization,
178
+ avs_result: {},
179
+ cvv_result: {},
180
+ error_code: success ? nil : response['customCode'])
181
+ end
182
+
183
+ def test?
184
+ @service_key[0] == 'T'
185
+ end
186
+
187
+ def response_error(raw_response)
188
+ parse(raw_response)
189
+ rescue JSON::ParserError
190
+ json_error(raw_response)
191
+ end
192
+
193
+ def json_error(raw_response)
194
+ msg = 'Invalid response received from the Worldpay Online Payments API. Please contact techsupport.online@worldpay.com if you continue to receive this message.'
195
+ msg += " (The raw response returned by the API was #{raw_response.inspect})"
196
+ {
197
+ 'error' => {
198
+ 'message' => msg
199
+ }
200
+ }
201
+ end
202
+
203
+ def handle_response(response)
204
+ response.body
205
+ end
206
+ end
207
+ end
208
+ end
@@ -0,0 +1,221 @@
1
+ require 'nokogiri'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ class WorldpayUsGateway < Gateway
6
+ class_attribute :backup_url
7
+
8
+ self.display_name = 'Worldpay US'
9
+ self.homepage_url = 'http://www.worldpay.com/us'
10
+
11
+ # No sandbox, just use test cards.
12
+ self.live_url = 'https://trans.worldpay.us/cgi-bin/process.cgi'
13
+ self.backup_url = 'https://trans.gwtx01.com/cgi-bin/process.cgi'
14
+
15
+ self.supported_countries = ['US']
16
+ self.default_currency = 'USD'
17
+ self.money_format = :dollars
18
+ self.supported_cardtypes = %i[visa master american_express discover jcb]
19
+
20
+ def initialize(options = {})
21
+ requires!(options, :acctid, :subid, :merchantpin)
22
+ super
23
+ end
24
+
25
+ def purchase(money, payment_method, options = {})
26
+ post = {}
27
+ add_invoice(post, money, options)
28
+ add_payment_method(post, payment_method)
29
+ add_customer_data(post, options)
30
+
31
+ commit('purchase', options, post)
32
+ end
33
+
34
+ def authorize(money, payment, options = {})
35
+ post = {}
36
+ add_invoice(post, money, options)
37
+ add_credit_card(post, payment)
38
+ add_customer_data(post, options)
39
+
40
+ commit('authorize', options, post)
41
+ end
42
+
43
+ def capture(amount, authorization, options = {})
44
+ post = {}
45
+ add_invoice(post, amount, options)
46
+ add_reference(post, authorization)
47
+ add_customer_data(post, options)
48
+
49
+ commit('capture', options, post)
50
+ end
51
+
52
+ def refund(amount, authorization, options = {})
53
+ post = {}
54
+ add_invoice(post, amount, options)
55
+ add_reference(post, authorization)
56
+ add_customer_data(post, options)
57
+
58
+ commit('refund', options, post)
59
+ end
60
+
61
+ def void(authorization, options = {})
62
+ post = {}
63
+ add_reference(post, authorization)
64
+
65
+ commit('void', options, post)
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((&?merchantpin=)[^&]*)i, '\1[FILTERED]').
82
+ gsub(%r((&?ccnum=)[^&]*)i, '\1[FILTERED]').
83
+ gsub(%r((&?ckacct=)[^&]*)i, '\1[FILTERED]').
84
+ gsub(%r((&?cvv2=)[^&]*)i, '\1[FILTERED]')
85
+ end
86
+
87
+ private
88
+
89
+ def url(options)
90
+ options[:use_backup_url].to_s == 'true' ? self.backup_url : self.live_url
91
+ end
92
+
93
+ def add_customer_data(post, options)
94
+ if (billing_address = (options[:billing_address] || options[:address]))
95
+ post[:ci_companyname] = billing_address[:company]
96
+ post[:ci_billaddr1] = billing_address[:address1]
97
+ post[:ci_billaddr2] = billing_address[:address2]
98
+ post[:ci_billcity] = billing_address[:city]
99
+ post[:ci_billstate] = billing_address[:state]
100
+ post[:ci_billzip] = billing_address[:zip]
101
+ post[:ci_billcountry] = billing_address[:country]
102
+
103
+ post[:ci_phone] = billing_address[:phone]
104
+ post[:ci_email] = billing_address[:email]
105
+ post[:ci_ipaddress] = billing_address[:ip]
106
+ end
107
+
108
+ if (shipping_address = options[:shipping_address])
109
+ post[:ci_shipaddr1] = shipping_address[:address1]
110
+ post[:ci_shipaddr2] = shipping_address[:address2]
111
+ post[:ci_shipcity] = shipping_address[:city]
112
+ post[:ci_shipstate] = shipping_address[:state]
113
+ post[:ci_shipzip] = shipping_address[:zip]
114
+ post[:ci_shipcountry] = shipping_address[:country]
115
+ end
116
+ end
117
+
118
+ def add_invoice(post, money, options)
119
+ post[:amount] = amount(money)
120
+ post[:currencycode] = (options[:currency] || currency(money))
121
+ post[:merchantordernumber] = options[:order_id] if options[:order_id]
122
+ end
123
+
124
+ def add_payment_method(post, payment_method)
125
+ if card_brand(payment_method) == 'check'
126
+ add_check(post, payment_method)
127
+ else
128
+ add_credit_card(post, payment_method)
129
+ end
130
+ end
131
+
132
+ def add_credit_card(post, payment_method)
133
+ post[:ccname] = payment_method.name
134
+ post[:ccnum] = payment_method.number
135
+ post[:cvv2] = payment_method.verification_value
136
+ post[:expyear] = format(payment_method.year, :four_digits)
137
+ post[:expmon] = format(payment_method.month, :two_digits)
138
+ end
139
+
140
+ ACCOUNT_TYPES = {
141
+ 'checking' => '1',
142
+ 'savings' => '2'
143
+ }
144
+
145
+ def add_check(post, payment_method)
146
+ post[:action] = 'ns_quicksale_check'
147
+ post[:ckacct] = payment_method.account_number
148
+ post[:ckaba] = payment_method.routing_number
149
+ post[:ckno] = payment_method.number
150
+ post[:ckaccttype] = ACCOUNT_TYPES[payment_method.account_type] if ACCOUNT_TYPES[payment_method.account_type]
151
+ end
152
+
153
+ def split_authorization(authorization)
154
+ historyid, orderid = authorization.split('|')
155
+ [historyid, orderid]
156
+ end
157
+
158
+ def add_reference(post, authorization)
159
+ historyid, orderid = split_authorization(authorization)
160
+ post[:postonly] = historyid
161
+ post[:historykeyid] = historyid
162
+ post[:orderkeyid] = orderid
163
+ end
164
+
165
+ def parse(xml)
166
+ response = {}
167
+ doc = Nokogiri::XML(xml)
168
+ message = doc.xpath('//plaintext')
169
+ message.text.split(/\r?\n/).each do |line|
170
+ key, value = line.split(%r{=})
171
+ response[key] = value if key
172
+ end
173
+ response
174
+ end
175
+
176
+ ACTIONS = {
177
+ 'purchase' => 'ns_quicksale_cc',
178
+ 'refund' => 'ns_credit',
179
+ 'authorize' => 'ns_quicksale_cc',
180
+ 'capture' => 'ns_quicksale_cc',
181
+ 'void' => 'ns_void'
182
+ }
183
+
184
+ def commit(action, options, post)
185
+ post[:action] = ACTIONS[action] unless post[:action]
186
+ post[:acctid] = @options[:acctid]
187
+ post[:subid] = @options[:subid]
188
+ post[:merchantpin] = @options[:merchantpin]
189
+
190
+ post[:authonly] = '1' if action == 'authorize'
191
+
192
+ raw = parse(ssl_post(url(options), post.to_query))
193
+
194
+ succeeded = success_from(raw['result'])
195
+ Response.new(
196
+ succeeded,
197
+ message_from(succeeded, raw),
198
+ raw,
199
+ authorization: authorization_from(raw),
200
+ test: test?
201
+ )
202
+ end
203
+
204
+ def success_from(result)
205
+ result == '1'
206
+ end
207
+
208
+ def message_from(succeeded, response)
209
+ if succeeded
210
+ 'Succeeded'
211
+ else
212
+ (response['transresult'] || response['Reason'] || 'Unable to read error message')
213
+ end
214
+ end
215
+
216
+ def authorization_from(response)
217
+ [response['historyid'], response['orderid']].join('|')
218
+ end
219
+ end
220
+ end
221
+ end
@@ -0,0 +1,14 @@
1
+ require 'pathname'
2
+
3
+ module ActiveMerchant
4
+ module Billing
5
+ load_path = Pathname.new(__FILE__ + '/../../..')
6
+ Dir[File.dirname(__FILE__) + '/gateways/**/*.rb'].each do |filename|
7
+ gateway_name = File.basename(filename, '.rb')
8
+ gateway_classname = "#{gateway_name}_gateway".camelize
9
+ gateway_filename = Pathname.new(filename).relative_path_from(load_path).sub_ext('')
10
+
11
+ autoload(gateway_classname, gateway_filename)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,30 @@
1
+ require 'active_merchant/billing/compatibility'
2
+ require 'active_merchant/empty'
3
+
4
+ module ActiveMerchant
5
+ module Billing
6
+ class Model
7
+ include Compatibility::Model
8
+ include Empty
9
+
10
+ def initialize(attributes = {})
11
+ attributes.each do |key, value|
12
+ send("#{key}=", value)
13
+ end
14
+ end
15
+
16
+ def validate
17
+ {}
18
+ end
19
+
20
+ private
21
+
22
+ def errors_hash(array)
23
+ array.inject({}) do |hash, (attribute, error)|
24
+ (hash[attribute] ||= []) << error
25
+ hash
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,39 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class NetworkTokenizationCreditCard < CreditCard
4
+ # A +NetworkTokenizationCreditCard+ object represents a tokenized credit card
5
+ # using the EMV Network Tokenization specification, http://www.emvco.com/specifications.aspx?id=263.
6
+ #
7
+ # It includes all fields of the +CreditCard+ class with additional fields for
8
+ # verification data that must be given to gateways through existing fields (3DS / EMV).
9
+ #
10
+ # The only tested usage of this at the moment is with an Apple Pay decrypted PKPaymentToken,
11
+ # https://developer.apple.com/library/ios/documentation/PassKit/Reference/PaymentTokenJSON/PaymentTokenJSON.html
12
+
13
+ # These are not relevant (verification) or optional (name) for Apple Pay
14
+ self.require_verification_value = false
15
+ self.require_name = false
16
+
17
+ attr_accessor :payment_cryptogram, :eci, :transaction_id
18
+ attr_writer :source
19
+
20
+ SOURCES = %i(apple_pay android_pay google_pay network_token)
21
+
22
+ def source
23
+ if defined?(@source) && SOURCES.include?(@source)
24
+ @source
25
+ else
26
+ :apple_pay
27
+ end
28
+ end
29
+
30
+ def credit_card?
31
+ true
32
+ end
33
+
34
+ def type
35
+ 'network_tokenization'
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,21 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ # Base class representation of cryptographic payment data tokens that may be used for EMV-style transactions
4
+ # like Apple Pay. Payment data may be transmitted via any data type, and may also be padded
5
+ # with metadata specific to the cryptographer. This metadata should be parsed and interpreted in concrete
6
+ # implementations of your given cryptographer. Like credit cards, you must also return a string representing
7
+ # the token's type, like 'apple_pay' or 'stripe' should your target payment gateway process these tokens.
8
+ class PaymentToken
9
+ attr_reader :payment_data
10
+
11
+ def initialize(payment_data, options = {})
12
+ @payment_data = payment_data
13
+ @metadata = options.with_indifferent_access
14
+ end
15
+
16
+ def type
17
+ raise NotImplementedError
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ require 'active_merchant/billing/compatibility'
2
+
3
+ ActiveMerchant::Billing::Compatibility.rails_required!
@@ -0,0 +1,97 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class Error < ActiveMerchantError #:nodoc:
4
+ end
5
+
6
+ class Response
7
+ attr_reader :params, :message, :test, :authorization, :avs_result, :cvv_result, :error_code, :emv_authorization, :network_transaction_id
8
+
9
+ def success?
10
+ @success
11
+ end
12
+
13
+ def failure?
14
+ !success?
15
+ end
16
+
17
+ def test?
18
+ @test
19
+ end
20
+
21
+ def fraud_review?
22
+ @fraud_review
23
+ end
24
+
25
+ def initialize(success, message, params = {}, options = {})
26
+ @success, @message, @params = success, message, params.stringify_keys
27
+ @test = options[:test] || false
28
+ @authorization = options[:authorization]
29
+ @fraud_review = options[:fraud_review]
30
+ @error_code = options[:error_code]
31
+ @emv_authorization = options[:emv_authorization]
32
+ @network_transaction_id = options[:network_transaction_id]
33
+
34
+ @avs_result = if options[:avs_result].kind_of?(AVSResult)
35
+ options[:avs_result].to_hash
36
+ else
37
+ AVSResult.new(options[:avs_result]).to_hash
38
+ end
39
+
40
+ @cvv_result = if options[:cvv_result].kind_of?(CVVResult)
41
+ options[:cvv_result].to_hash
42
+ else
43
+ CVVResult.new(options[:cvv_result]).to_hash
44
+ end
45
+ end
46
+ end
47
+
48
+ class MultiResponse < Response
49
+ def self.run(use_first_response = false, &block)
50
+ new(use_first_response).tap(&block)
51
+ end
52
+
53
+ attr_reader :responses, :primary_response
54
+
55
+ def initialize(use_first_response = false)
56
+ @responses = []
57
+ @use_first_response = use_first_response
58
+ @primary_response = nil
59
+ end
60
+
61
+ def process(ignore_result = false)
62
+ return unless success?
63
+
64
+ response = yield
65
+ self << response
66
+
67
+ unless ignore_result
68
+ if @use_first_response && response.success?
69
+ @primary_response ||= response
70
+ else
71
+ @primary_response = response
72
+ end
73
+ end
74
+ end
75
+
76
+ def <<(response)
77
+ if response.is_a?(MultiResponse)
78
+ response.responses.each { |r| @responses << r }
79
+ else
80
+ @responses << response
81
+ end
82
+ end
83
+
84
+ def success?
85
+ (primary_response ? primary_response.success? : true)
86
+ end
87
+
88
+ %w(params message test authorization avs_result cvv_result error_code emv_authorization test? fraud_review?).each do |m|
89
+ class_eval %(
90
+ def #{m}
91
+ (@responses.empty? ? nil : primary_response.#{m})
92
+ end
93
+ )
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,27 @@
1
+ module ActiveMerchant
2
+ module Billing
3
+ module ThreeDSecureEciMapper
4
+ NON_THREE_D_SECURE_TRANSACTION = :non_three_d_secure_transaction
5
+ ATTEMPTED_AUTHENTICATION_TRANSACTION = :attempted_authentication_transaction
6
+ FULLY_AUTHENTICATED_TRANSACTION = :fully_authenticated_transaction
7
+
8
+ ECI_00_01_02_MAP = { '00' => NON_THREE_D_SECURE_TRANSACTION, '01' => ATTEMPTED_AUTHENTICATION_TRANSACTION, '02' => FULLY_AUTHENTICATED_TRANSACTION }.freeze
9
+ ECI_05_06_07_MAP = { '05' => FULLY_AUTHENTICATED_TRANSACTION, '06' => ATTEMPTED_AUTHENTICATION_TRANSACTION, '07' => NON_THREE_D_SECURE_TRANSACTION }.freeze
10
+ BRAND_TO_ECI_MAP = {
11
+ american_express: ECI_05_06_07_MAP,
12
+ dankort: ECI_05_06_07_MAP,
13
+ diners_club: ECI_05_06_07_MAP,
14
+ discover: ECI_05_06_07_MAP,
15
+ elo: ECI_05_06_07_MAP,
16
+ jcb: ECI_05_06_07_MAP,
17
+ maestro: ECI_00_01_02_MAP,
18
+ master: ECI_00_01_02_MAP,
19
+ visa: ECI_05_06_07_MAP
20
+ }.freeze
21
+
22
+ def self.map(brand, eci)
23
+ BRAND_TO_ECI_MAP.dig(brand, eci)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,16 @@
1
+ require 'active_merchant/errors'
2
+
3
+ require 'active_merchant/billing/avs_result'
4
+ require 'active_merchant/billing/cvv_result'
5
+ require 'active_merchant/billing/credit_card_methods'
6
+ require 'active_merchant/billing/credit_card_formatting'
7
+ require 'active_merchant/billing/credit_card'
8
+ require 'active_merchant/billing/network_tokenization_credit_card'
9
+ require 'active_merchant/billing/base'
10
+ require 'active_merchant/billing/check'
11
+ require 'active_merchant/billing/payment_token'
12
+ require 'active_merchant/billing/apple_pay_payment_token'
13
+ require 'active_merchant/billing/response'
14
+ require 'active_merchant/billing/gateways'
15
+ require 'active_merchant/billing/gateway'
16
+ require 'active_merchant/billing/three_d_secure_eci_mapper'