swiss-activemerchant 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (287) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +4033 -0
  3. data/CONTRIBUTORS +568 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.md +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 +112 -0
  10. data/lib/active_merchant/billing/compatibility.rb +118 -0
  11. data/lib/active_merchant/billing/credit_card.rb +451 -0
  12. data/lib/active_merchant/billing/credit_card_formatting.rb +24 -0
  13. data/lib/active_merchant/billing/credit_card_methods.rb +512 -0
  14. data/lib/active_merchant/billing/cvv_result.rb +37 -0
  15. data/lib/active_merchant/billing/gateway.rb +332 -0
  16. data/lib/active_merchant/billing/gateways/adyen.rb +774 -0
  17. data/lib/active_merchant/billing/gateways/airwallex.rb +370 -0
  18. data/lib/active_merchant/billing/gateways/alelo.rb +256 -0
  19. data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
  20. data/lib/active_merchant/billing/gateways/authorize_net.rb +1125 -0
  21. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +424 -0
  22. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +977 -0
  23. data/lib/active_merchant/billing/gateways/axcessms.rb +243 -0
  24. data/lib/active_merchant/billing/gateways/balanced.rb +263 -0
  25. data/lib/active_merchant/billing/gateways/bambora_apac.rb +222 -0
  26. data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
  27. data/lib/active_merchant/billing/gateways/banwire.rb +116 -0
  28. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +397 -0
  29. data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +15 -0
  30. data/lib/active_merchant/billing/gateways/be2bill.rb +131 -0
  31. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +474 -0
  32. data/lib/active_merchant/billing/gateways/beanstream.rb +238 -0
  33. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +57 -0
  34. data/lib/active_merchant/billing/gateways/blue_pay.rb +549 -0
  35. data/lib/active_merchant/billing/gateways/blue_snap.rb +644 -0
  36. data/lib/active_merchant/billing/gateways/bogus.rb +190 -0
  37. data/lib/active_merchant/billing/gateways/borgun.rb +272 -0
  38. data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
  39. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +28 -0
  40. data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
  41. data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
  42. data/lib/active_merchant/billing/gateways/braintree_blue.rb +952 -0
  43. data/lib/active_merchant/billing/gateways/braintree_orange.rb +19 -0
  44. data/lib/active_merchant/billing/gateways/bridge_pay.rb +244 -0
  45. data/lib/active_merchant/billing/gateways/cams.rb +230 -0
  46. data/lib/active_merchant/billing/gateways/card_connect.rb +338 -0
  47. data/lib/active_merchant/billing/gateways/card_save.rb +21 -0
  48. data/lib/active_merchant/billing/gateways/card_stream.rb +394 -0
  49. data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
  50. data/lib/active_merchant/billing/gateways/cardprocess.rb +256 -0
  51. data/lib/active_merchant/billing/gateways/cashnet.rb +235 -0
  52. data/lib/active_merchant/billing/gateways/cc5.rb +198 -0
  53. data/lib/active_merchant/billing/gateways/cecabank.rb +249 -0
  54. data/lib/active_merchant/billing/gateways/cenpos.rb +328 -0
  55. data/lib/active_merchant/billing/gateways/checkout.rb +212 -0
  56. data/lib/active_merchant/billing/gateways/checkout_v2.rb +587 -0
  57. data/lib/active_merchant/billing/gateways/citrus_pay.rb +21 -0
  58. data/lib/active_merchant/billing/gateways/clearhaus.rb +219 -0
  59. data/lib/active_merchant/billing/gateways/commerce_hub.rb +366 -0
  60. data/lib/active_merchant/billing/gateways/commercegate.rb +142 -0
  61. data/lib/active_merchant/billing/gateways/conekta.rb +230 -0
  62. data/lib/active_merchant/billing/gateways/creditcall.rb +272 -0
  63. data/lib/active_merchant/billing/gateways/credorax.rb +526 -0
  64. data/lib/active_merchant/billing/gateways/ct_payment.rb +269 -0
  65. data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
  66. data/lib/active_merchant/billing/gateways/cyber_source/cyber_source_common.rb +36 -0
  67. data/lib/active_merchant/billing/gateways/cyber_source.rb +1148 -0
  68. data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +454 -0
  69. data/lib/active_merchant/billing/gateways/d_local.rb +343 -0
  70. data/lib/active_merchant/billing/gateways/data_cash.rb +302 -0
  71. data/lib/active_merchant/billing/gateways/decidir.rb +358 -0
  72. data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
  73. data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
  74. data/lib/active_merchant/billing/gateways/digitzs.rb +295 -0
  75. data/lib/active_merchant/billing/gateways/ebanx.rb +346 -0
  76. data/lib/active_merchant/billing/gateways/efsnet.rb +215 -0
  77. data/lib/active_merchant/billing/gateways/elavon.rb +475 -0
  78. data/lib/active_merchant/billing/gateways/element.rb +406 -0
  79. data/lib/active_merchant/billing/gateways/epay.rb +296 -0
  80. data/lib/active_merchant/billing/gateways/evo_ca.rb +307 -0
  81. data/lib/active_merchant/billing/gateways/eway.rb +226 -0
  82. data/lib/active_merchant/billing/gateways/eway_managed.rb +289 -0
  83. data/lib/active_merchant/billing/gateways/eway_rapid.rb +578 -0
  84. data/lib/active_merchant/billing/gateways/exact.rb +219 -0
  85. data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
  86. data/lib/active_merchant/billing/gateways/fat_zebra.rb +223 -0
  87. data/lib/active_merchant/billing/gateways/federated_canada.rb +158 -0
  88. data/lib/active_merchant/billing/gateways/finansbank.rb +22 -0
  89. data/lib/active_merchant/billing/gateways/first_giving.rb +143 -0
  90. data/lib/active_merchant/billing/gateways/first_pay.rb +182 -0
  91. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +452 -0
  92. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +505 -0
  93. data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
  94. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
  95. data/lib/active_merchant/billing/gateways/fluidpay.rb +275 -0
  96. data/lib/active_merchant/billing/gateways/forte.rb +286 -0
  97. data/lib/active_merchant/billing/gateways/garanti.rb +256 -0
  98. data/lib/active_merchant/billing/gateways/global_collect.rb +580 -0
  99. data/lib/active_merchant/billing/gateways/global_transport.rb +193 -0
  100. data/lib/active_merchant/billing/gateways/hdfc.rb +205 -0
  101. data/lib/active_merchant/billing/gateways/hps.rb +472 -0
  102. data/lib/active_merchant/billing/gateways/iats_payments.rb +312 -0
  103. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
  104. data/lib/active_merchant/billing/gateways/inspire.rb +213 -0
  105. data/lib/active_merchant/billing/gateways/instapay.rb +159 -0
  106. data/lib/active_merchant/billing/gateways/ipg.rb +420 -0
  107. data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
  108. data/lib/active_merchant/billing/gateways/iridium.rb +467 -0
  109. data/lib/active_merchant/billing/gateways/itransact.rb +448 -0
  110. data/lib/active_merchant/billing/gateways/iveri.rb +290 -0
  111. data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
  112. data/lib/active_merchant/billing/gateways/jetpay.rb +395 -0
  113. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +432 -0
  114. data/lib/active_merchant/billing/gateways/klarna.rb +317 -0
  115. data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
  116. data/lib/active_merchant/billing/gateways/kushki.rb +297 -0
  117. data/lib/active_merchant/billing/gateways/latitude19.rb +412 -0
  118. data/lib/active_merchant/billing/gateways/linkpoint.rb +448 -0
  119. data/lib/active_merchant/billing/gateways/litle.rb +643 -0
  120. data/lib/active_merchant/billing/gateways/mastercard.rb +286 -0
  121. data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
  122. data/lib/active_merchant/billing/gateways/mercado_pago.rb +348 -0
  123. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +228 -0
  124. data/lib/active_merchant/billing/gateways/merchant_one.rb +110 -0
  125. data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
  126. data/lib/active_merchant/billing/gateways/merchant_ware.rb +313 -0
  127. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +284 -0
  128. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +248 -0
  129. data/lib/active_merchant/billing/gateways/mercury.rb +352 -0
  130. data/lib/active_merchant/billing/gateways/metrics_global.rb +293 -0
  131. data/lib/active_merchant/billing/gateways/micropayment.rb +182 -0
  132. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
  133. data/lib/active_merchant/billing/gateways/migs.rb +329 -0
  134. data/lib/active_merchant/billing/gateways/mit.rb +260 -0
  135. data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
  136. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +215 -0
  137. data/lib/active_merchant/billing/gateways/moka.rb +290 -0
  138. data/lib/active_merchant/billing/gateways/monei.rb +424 -0
  139. data/lib/active_merchant/billing/gateways/moneris.rb +488 -0
  140. data/lib/active_merchant/billing/gateways/money_movers.rb +150 -0
  141. data/lib/active_merchant/billing/gateways/mundipagg.rb +366 -0
  142. data/lib/active_merchant/billing/gateways/nab_transact.rb +299 -0
  143. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +163 -0
  144. data/lib/active_merchant/billing/gateways/net_registry.rb +198 -0
  145. data/lib/active_merchant/billing/gateways/netaxept.rb +180 -0
  146. data/lib/active_merchant/billing/gateways/netbanx.rb +376 -0
  147. data/lib/active_merchant/billing/gateways/netbilling.rb +229 -0
  148. data/lib/active_merchant/billing/gateways/netpay.rb +223 -0
  149. data/lib/active_merchant/billing/gateways/network_merchants.rb +238 -0
  150. data/lib/active_merchant/billing/gateways/nmi.rb +396 -0
  151. data/lib/active_merchant/billing/gateways/ogone.rb +509 -0
  152. data/lib/active_merchant/billing/gateways/omise.rb +323 -0
  153. data/lib/active_merchant/billing/gateways/openpay.rb +246 -0
  154. data/lib/active_merchant/billing/gateways/opp.rb +394 -0
  155. data/lib/active_merchant/billing/gateways/optimal_payment.rb +331 -0
  156. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +45 -0
  157. data/lib/active_merchant/billing/gateways/orbital.rb +1267 -0
  158. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +206 -0
  159. data/lib/active_merchant/billing/gateways/pagarme.rb +239 -0
  160. data/lib/active_merchant/billing/gateways/pago_facil.rb +120 -0
  161. data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
  162. data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
  163. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +277 -0
  164. data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
  165. data/lib/active_merchant/billing/gateways/pay_junction.rb +390 -0
  166. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +206 -0
  167. data/lib/active_merchant/billing/gateways/pay_secure.rb +110 -0
  168. data/lib/active_merchant/billing/gateways/pay_trace.rb +450 -0
  169. data/lib/active_merchant/billing/gateways/paybox_direct.rb +224 -0
  170. data/lib/active_merchant/billing/gateways/payeezy.rb +513 -0
  171. data/lib/active_merchant/billing/gateways/payex.rb +409 -0
  172. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +235 -0
  173. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +42 -0
  174. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
  175. data/lib/active_merchant/billing/gateways/payflow.rb +473 -0
  176. data/lib/active_merchant/billing/gateways/payflow_express.rb +220 -0
  177. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +14 -0
  178. data/lib/active_merchant/billing/gateways/payflow_uk.rb +20 -0
  179. data/lib/active_merchant/billing/gateways/payment_express.rb +373 -0
  180. data/lib/active_merchant/billing/gateways/paymentez.rb +365 -0
  181. data/lib/active_merchant/billing/gateways/paymill.rb +369 -0
  182. data/lib/active_merchant/billing/gateways/paynetworx.rb +227 -0
  183. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +718 -0
  184. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +69 -0
  185. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -0
  186. data/lib/active_merchant/billing/gateways/paypal.rb +136 -0
  187. data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
  188. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +44 -0
  189. data/lib/active_merchant/billing/gateways/paypal_express.rb +272 -0
  190. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
  191. data/lib/active_merchant/billing/gateways/paypal_standard.rb +281 -0
  192. data/lib/active_merchant/billing/gateways/paysafe.rb +420 -0
  193. data/lib/active_merchant/billing/gateways/payscout.rb +159 -0
  194. data/lib/active_merchant/billing/gateways/paystation.rb +204 -0
  195. data/lib/active_merchant/billing/gateways/payu_in.rb +249 -0
  196. data/lib/active_merchant/billing/gateways/payu_latam.rb +482 -0
  197. data/lib/active_merchant/billing/gateways/payway.rb +207 -0
  198. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
  199. data/lib/active_merchant/billing/gateways/pin.rb +273 -0
  200. data/lib/active_merchant/billing/gateways/pixxels.rb +263 -0
  201. data/lib/active_merchant/billing/gateways/plexo.rb +308 -0
  202. data/lib/active_merchant/billing/gateways/plugnpay.rb +283 -0
  203. data/lib/active_merchant/billing/gateways/priority.rb +392 -0
  204. data/lib/active_merchant/billing/gateways/pro_pay.rb +325 -0
  205. data/lib/active_merchant/billing/gateways/psigate.rb +227 -0
  206. data/lib/active_merchant/billing/gateways/psl_card.rb +295 -0
  207. data/lib/active_merchant/billing/gateways/qbms.rb +302 -0
  208. data/lib/active_merchant/billing/gateways/quantum.rb +274 -0
  209. data/lib/active_merchant/billing/gateways/quickbooks.rb +377 -0
  210. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
  211. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +297 -0
  212. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
  213. data/lib/active_merchant/billing/gateways/quickpay.rb +24 -0
  214. data/lib/active_merchant/billing/gateways/qvalent.rb +305 -0
  215. data/lib/active_merchant/billing/gateways/rapyd.rb +319 -0
  216. data/lib/active_merchant/billing/gateways/reach.rb +277 -0
  217. data/lib/active_merchant/billing/gateways/realex.rb +400 -0
  218. data/lib/active_merchant/billing/gateways/redsys.rb +723 -0
  219. data/lib/active_merchant/billing/gateways/s5.rb +247 -0
  220. data/lib/active_merchant/billing/gateways/safe_charge.rb +298 -0
  221. data/lib/active_merchant/billing/gateways/sage.rb +446 -0
  222. data/lib/active_merchant/billing/gateways/sage_pay.rb +434 -0
  223. data/lib/active_merchant/billing/gateways/sallie_mae.rb +141 -0
  224. data/lib/active_merchant/billing/gateways/secure_net.rb +260 -0
  225. data/lib/active_merchant/billing/gateways/secure_pay.rb +191 -0
  226. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +290 -0
  227. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +103 -0
  228. data/lib/active_merchant/billing/gateways/securion_pay.rb +305 -0
  229. data/lib/active_merchant/billing/gateways/shift4.rb +345 -0
  230. data/lib/active_merchant/billing/gateways/simetrik.rb +368 -0
  231. data/lib/active_merchant/billing/gateways/skip_jack.rb +450 -0
  232. data/lib/active_merchant/billing/gateways/smart_ps.rb +274 -0
  233. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
  234. data/lib/active_merchant/billing/gateways/spreedly_core.rb +312 -0
  235. data/lib/active_merchant/billing/gateways/stripe.rb +866 -0
  236. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +602 -0
  237. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +151 -0
  238. data/lib/active_merchant/billing/gateways/telr.rb +273 -0
  239. data/lib/active_merchant/billing/gateways/tns.rb +23 -0
  240. data/lib/active_merchant/billing/gateways/trans_first.rb +240 -0
  241. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +612 -0
  242. data/lib/active_merchant/billing/gateways/transact_pro.rb +222 -0
  243. data/lib/active_merchant/billing/gateways/transax.rb +21 -0
  244. data/lib/active_merchant/billing/gateways/transnational.rb +9 -0
  245. data/lib/active_merchant/billing/gateways/trexle.rb +221 -0
  246. data/lib/active_merchant/billing/gateways/trust_commerce.rb +500 -0
  247. data/lib/active_merchant/billing/gateways/usa_epay.rb +24 -0
  248. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1612 -0
  249. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +367 -0
  250. data/lib/active_merchant/billing/gateways/vanco.rb +303 -0
  251. data/lib/active_merchant/billing/gateways/verifi.rb +224 -0
  252. data/lib/active_merchant/billing/gateways/viaklix.rb +171 -0
  253. data/lib/active_merchant/billing/gateways/visanet_peru.rb +250 -0
  254. data/lib/active_merchant/billing/gateways/vpos.rb +223 -0
  255. data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
  256. data/lib/active_merchant/billing/gateways/wepay.rb +235 -0
  257. data/lib/active_merchant/billing/gateways/wirecard.rb +430 -0
  258. data/lib/active_merchant/billing/gateways/wompi.rb +197 -0
  259. data/lib/active_merchant/billing/gateways/world_net.rb +345 -0
  260. data/lib/active_merchant/billing/gateways/worldpay.rb +1050 -0
  261. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +208 -0
  262. data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
  263. data/lib/active_merchant/billing/gateways.rb +14 -0
  264. data/lib/active_merchant/billing/model.rb +30 -0
  265. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
  266. data/lib/active_merchant/billing/payment_token.rb +21 -0
  267. data/lib/active_merchant/billing/rails.rb +3 -0
  268. data/lib/active_merchant/billing/response.rb +120 -0
  269. data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
  270. data/lib/active_merchant/billing.rb +16 -0
  271. data/lib/active_merchant/connection.rb +194 -0
  272. data/lib/active_merchant/country.rb +338 -0
  273. data/lib/active_merchant/empty.rb +20 -0
  274. data/lib/active_merchant/errors.rb +38 -0
  275. data/lib/active_merchant/net_http_ssl_connection.rb +11 -0
  276. data/lib/active_merchant/network_connection_retries.rb +78 -0
  277. data/lib/active_merchant/post_data.rb +26 -0
  278. data/lib/active_merchant/posts_data.rb +92 -0
  279. data/lib/active_merchant/version.rb +3 -0
  280. data/lib/active_merchant.rb +63 -0
  281. data/lib/activemerchant.rb +1 -0
  282. data/lib/certs/cacert.pem +3214 -0
  283. data/lib/support/gateway_support.rb +69 -0
  284. data/lib/support/outbound_hosts.rb +28 -0
  285. data/lib/support/ssl_verify.rb +88 -0
  286. data/lib/support/ssl_version.rb +86 -0
  287. metadata +506 -0
@@ -0,0 +1,13 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class PayflowResponse < Response
4
+ def profile_id
5
+ @params['profile_id']
6
+ end
7
+
8
+ def payment_history
9
+ @payment_history ||= @params['rp_payment_result'].collect(&:stringify_keys) rescue []
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,473 @@
1
+ require 'nokogiri'
2
+ require 'active_merchant/billing/gateways/payflow/payflow_common_api'
3
+ require 'active_merchant/billing/gateways/payflow/payflow_response'
4
+ require 'active_merchant/billing/gateways/payflow_express'
5
+
6
+ module ActiveMerchant #:nodoc:
7
+ module Billing #:nodoc:
8
+ class PayflowGateway < Gateway
9
+ include PayflowCommonAPI
10
+
11
+ RECURRING_ACTIONS = Set.new(%i[add modify cancel inquiry reactivate payment])
12
+
13
+ self.supported_cardtypes = %i[visa master american_express jcb discover diners_club]
14
+ self.homepage_url = 'https://www.paypal.com/cgi-bin/webscr?cmd=_payflow-pro-overview-outside'
15
+ self.display_name = 'PayPal Payflow Pro'
16
+
17
+ def authorize(money, credit_card_or_reference, options = {})
18
+ request = build_sale_or_authorization_request(:authorization, money, credit_card_or_reference, options)
19
+
20
+ commit(request, options)
21
+ end
22
+
23
+ def purchase(money, funding_source, options = {})
24
+ request = build_sale_or_authorization_request(:purchase, money, funding_source, options)
25
+
26
+ commit(request, options)
27
+ end
28
+
29
+ def credit(money, funding_source, options = {})
30
+ if funding_source.is_a?(String)
31
+ ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
32
+ # Perform referenced credit
33
+ refund(money, funding_source, options)
34
+ elsif card_brand(funding_source) == 'check'
35
+ # Perform non-referenced credit
36
+ request = build_check_request(:credit, money, funding_source, options)
37
+ commit(request, options)
38
+ else
39
+ request = build_credit_card_request(:credit, money, funding_source, options)
40
+ commit(request, options)
41
+ end
42
+ end
43
+
44
+ def refund(money, reference, options = {})
45
+ commit(build_reference_request(:credit, money, reference, options), options)
46
+ end
47
+
48
+ def verify(payment, options = {})
49
+ if credit_card_type(payment) == 'Amex'
50
+ MultiResponse.run(:use_first_response) do |r|
51
+ r.process { authorize(100, payment, options) }
52
+ r.process(:ignore_result) { void(r.authorization, options) }
53
+ end
54
+ else
55
+ authorize(0, payment, options)
56
+ end
57
+ end
58
+
59
+ def store(payment, options = {})
60
+ raise ArgumentError, 'Store is not supported on Payflow gateways'
61
+ end
62
+
63
+ def verify_credentials
64
+ response = void('0')
65
+ response.params['result'] != '26'
66
+ end
67
+
68
+ # Adds or modifies a recurring Payflow profile. See the Payflow Pro Recurring Billing Guide for more details:
69
+ # https://www.paypal.com/en_US/pdf/PayflowPro_RecurringBilling_Guide.pdf
70
+ #
71
+ # Several options are available to customize the recurring profile:
72
+ #
73
+ # * <tt>profile_id</tt> - is only required for editing a recurring profile
74
+ # * <tt>starting_at</tt> - takes a Date, Time, or string in mmddyyyy format. The date must be in the future.
75
+ # * <tt>name</tt> - The name of the customer to be billed. If not specified, the name from the credit card is used.
76
+ # * <tt>periodicity</tt> - The frequency that the recurring payments will occur at. Can be one of
77
+ # :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily, :semimonthly, :quadweekly, :quarterly, :semiyearly
78
+ # * <tt>payments</tt> - The term, or number of payments that will be made
79
+ # * <tt>comment</tt> - A comment associated with the profile
80
+ def recurring(money, credit_card, options = {})
81
+ ActiveMerchant.deprecated RECURRING_DEPRECATION_MESSAGE
82
+
83
+ options[:name] = credit_card.name if options[:name].blank? && credit_card
84
+ request = build_recurring_request(options[:profile_id] ? :modify : :add, money, options) do |xml|
85
+ add_credit_card(xml, credit_card, options) if credit_card
86
+ add_stored_credential(xml, options[:stored_credential])
87
+ end
88
+ commit(request, options.merge(request_type: :recurring))
89
+ end
90
+
91
+ def cancel_recurring(profile_id)
92
+ ActiveMerchant.deprecated RECURRING_DEPRECATION_MESSAGE
93
+
94
+ request = build_recurring_request(:cancel, 0, profile_id: profile_id)
95
+ commit(request, options.merge(request_type: :recurring))
96
+ end
97
+
98
+ def recurring_inquiry(profile_id, options = {})
99
+ ActiveMerchant.deprecated RECURRING_DEPRECATION_MESSAGE
100
+
101
+ request = build_recurring_request(:inquiry, nil, options.update(profile_id: profile_id))
102
+ commit(request, options.merge(request_type: :recurring))
103
+ end
104
+
105
+ def express
106
+ @express ||= PayflowExpressGateway.new(@options)
107
+ end
108
+
109
+ def supports_scrubbing?
110
+ true
111
+ end
112
+
113
+ def scrub(transcript)
114
+ transcript.
115
+ gsub(%r((<CardNum>)[^<]*(</CardNum>)), '\1[FILTERED]\2').
116
+ gsub(%r((<CVNum>)[^<]*(</CVNum>)), '\1[FILTERED]\2').
117
+ gsub(%r((<AcctNum>)[^<]*(</AcctNum>)), '\1[FILTERED]\2').
118
+ gsub(%r((<Password>)[^<]*(</Password>)), '\1[FILTERED]\2')
119
+ end
120
+
121
+ private
122
+
123
+ def build_sale_or_authorization_request(action, money, funding_source, options)
124
+ if funding_source.is_a?(String)
125
+ build_reference_sale_or_authorization_request(action, money, funding_source, options)
126
+ elsif card_brand(funding_source) == 'check'
127
+ build_check_request(action, money, funding_source, options)
128
+ else
129
+ build_credit_card_request(action, money, funding_source, options)
130
+ end
131
+ end
132
+
133
+ def build_reference_sale_or_authorization_request(action, money, reference, options)
134
+ xml = Builder::XmlMarkup.new
135
+ xml.tag! TRANSACTIONS[action] do
136
+ xml.tag! 'PayData' do
137
+ xml.tag! 'Invoice' do
138
+ # Fields accepted by PayFlow and recommended to be provided even for Reference Transaction, per Payflow docs.
139
+ xml.tag! 'CustIP', options[:ip] unless options[:ip].blank?
140
+ xml.tag! 'InvNum', options[:order_id].to_s.gsub(/[^\w.]/, '') unless options[:order_id].blank?
141
+ xml.tag! 'Description', options[:description] unless options[:description].blank?
142
+ xml.tag! 'OrderDesc', options[:order_desc] unless options[:order_desc].blank?
143
+ xml.tag! 'Comment', options[:comment] unless options[:comment].blank?
144
+ xml.tag!('ExtData', 'Name' => 'COMMENT2', 'Value' => options[:comment2]) unless options[:comment2].blank?
145
+ xml.tag! 'TaxAmt', options[:taxamt] unless options[:taxamt].blank?
146
+ xml.tag! 'FreightAmt', options[:freightamt] unless options[:freightamt].blank?
147
+ xml.tag! 'DutyAmt', options[:dutyamt] unless options[:dutyamt].blank?
148
+ xml.tag! 'DiscountAmt', options[:discountamt] unless options[:discountamt].blank?
149
+ xml.tag! 'MerchDescr', options[:merch_descr] unless options[:merch_descr].blank?
150
+
151
+ billing_address = options[:billing_address] || options[:address]
152
+ add_address(xml, 'BillTo', billing_address, options) if billing_address
153
+ add_address(xml, 'ShipTo', options[:shipping_address], options) if options[:shipping_address]
154
+
155
+ xml.tag! 'TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money)
156
+ end
157
+ xml.tag! 'Tender' do
158
+ xml.tag! 'Card' do
159
+ xml.tag! 'ExtData', 'Name' => 'ORIGID', 'Value' => reference
160
+ end
161
+ end
162
+ add_stored_credential(xml, options[:stored_credential])
163
+ end
164
+ xml.tag! 'ExtData', 'Name' => 'BUTTONSOURCE', 'Value' => application_id unless application_id.blank?
165
+ end
166
+ xml.target!
167
+ end
168
+
169
+ def build_credit_card_request(action, money, credit_card, options)
170
+ xml = Builder::XmlMarkup.new
171
+ xml.tag! TRANSACTIONS[action] do
172
+ xml.tag! 'PayData' do
173
+ xml.tag! 'Invoice' do
174
+ xml.tag! 'CustIP', options[:ip] unless options[:ip].blank?
175
+ xml.tag! 'InvNum', options[:order_id].to_s.gsub(/[^\w.]/, '') unless options[:order_id].blank?
176
+ xml.tag! 'Description', options[:description] unless options[:description].blank?
177
+ xml.tag! 'OrderDesc', options[:order_desc] unless options[:order_desc].blank?
178
+ # Comment and Comment2 will show up in manager.paypal.com as Comment1 and Comment2
179
+ xml.tag! 'Comment', options[:comment] unless options[:comment].blank?
180
+ xml.tag!('ExtData', 'Name' => 'COMMENT2', 'Value' => options[:comment2]) unless options[:comment2].blank?
181
+ xml.tag! 'TaxAmt', options[:taxamt] unless options[:taxamt].blank?
182
+ xml.tag! 'FreightAmt', options[:freightamt] unless options[:freightamt].blank?
183
+ xml.tag! 'DutyAmt', options[:dutyamt] unless options[:dutyamt].blank?
184
+ xml.tag! 'DiscountAmt', options[:discountamt] unless options[:discountamt].blank?
185
+ xml.tag! 'EMail', options[:email] unless options[:email].nil?
186
+ xml.tag! 'MerchDescr', options[:merch_descr] unless options[:merch_descr].blank?
187
+
188
+ billing_address = options[:billing_address] || options[:address]
189
+ add_address(xml, 'BillTo', billing_address, options) if billing_address
190
+ add_address(xml, 'ShipTo', options[:shipping_address], options) if options[:shipping_address]
191
+
192
+ xml.tag! 'TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money)
193
+ end
194
+
195
+ if %i(authorization purchase).include? action
196
+ add_mpi_3ds(xml, options[:three_d_secure]) if options[:three_d_secure]
197
+ end
198
+
199
+ xml.tag! 'Tender' do
200
+ add_credit_card(xml, credit_card, options)
201
+ end
202
+ add_stored_credential(xml, options[:stored_credential])
203
+ end
204
+ xml.tag! 'ExtData', 'Name' => 'BUTTONSOURCE', 'Value' => application_id unless application_id.blank?
205
+ end
206
+ add_level_two_three_fields(xml.target!, options)
207
+ end
208
+
209
+ def add_mpi_3ds(xml, three_d_secure_options)
210
+ # structure as per https://developer.paypal.com/api/nvp-soap/payflow/3d-secure-mpi/
211
+ authentication_id = three_d_secure_options[:authentication_id]
212
+ authentication_status = three_d_secure_options[:authentication_response_status]
213
+
214
+ eci = three_d_secure_options[:eci]
215
+ cavv = three_d_secure_options[:cavv]
216
+ xid = three_d_secure_options[:xid]
217
+ version = three_d_secure_options[:version]
218
+
219
+ # 3DS2 only
220
+ ds_transaction_id = three_d_secure_options[:ds_transaction_id] if version_2_or_newer?(three_d_secure_options)
221
+
222
+ xml.tag!('ExtData', 'Name' => 'AUTHENTICATION_ID', 'Value' => authentication_id) unless authentication_id.blank?
223
+ xml.tag!('ExtData', 'Name' => 'AUTHENTICATION_STATUS', 'Value' => authentication_status) unless authentication_status.blank?
224
+
225
+ xml.tag!('ExtData', 'Name' => 'CAVV', 'Value' => cavv) unless cavv.blank?
226
+ xml.tag!('ExtData', 'Name' => 'ECI', 'Value' => eci) unless eci.blank?
227
+ xml.tag!('ExtData', 'Name' => 'XID', 'Value' => xid) unless xid.blank?
228
+ xml.tag!('ExtData', 'Name' => 'THREEDSVERSION', 'Value' => version) unless version.blank?
229
+ xml.tag!('ExtData', 'Name' => 'DSTRANSACTIONID', 'Value' => ds_transaction_id) unless ds_transaction_id.blank?
230
+ end
231
+
232
+ def add_level_two_three_fields(xml_string, options)
233
+ if options[:level_two_fields] || options[:level_three_fields]
234
+ xml_doc = Nokogiri::XML.parse(xml_string)
235
+ %i[level_two_fields level_three_fields].each do |fields|
236
+ xml_string = add_fields(xml_doc, options[fields]) if options[fields]
237
+ end
238
+ end
239
+ xml_string
240
+ end
241
+
242
+ def check_fields(parent, fields, xml_doc)
243
+ fields.each do |k, v|
244
+ if v.is_a? String
245
+ new_node = Nokogiri::XML::Node.new(k, xml_doc)
246
+ new_node.add_child(v)
247
+ xml_doc.at_css(parent).add_child(new_node)
248
+ else
249
+ check_subparent_before_continuing(parent, k, xml_doc)
250
+ check_fields(k, v, xml_doc)
251
+ end
252
+ end
253
+ xml_doc
254
+ end
255
+
256
+ def check_subparent_before_continuing(parent, subparent, xml_doc)
257
+ unless xml_doc.at_css(subparent)
258
+ subparent_node = Nokogiri::XML::Node.new(subparent, xml_doc)
259
+ xml_doc.at_css(parent).add_child(subparent_node)
260
+ end
261
+ end
262
+
263
+ def add_fields(xml_doc, options_fields)
264
+ fields_to_add = JSON.parse(options_fields)
265
+ check_fields('Invoice', fields_to_add, xml_doc)
266
+ xml_doc.root.to_s
267
+ end
268
+
269
+ def build_check_request(action, money, check, options)
270
+ xml = Builder::XmlMarkup.new
271
+ xml.tag! TRANSACTIONS[action] do
272
+ xml.tag! 'PayData' do
273
+ xml.tag! 'Invoice' do
274
+ xml.tag! 'CustIP', options[:ip] unless options[:ip].blank?
275
+ xml.tag! 'InvNum', options[:order_id].to_s.gsub(/[^\w.]/, '') unless options[:order_id].blank?
276
+ xml.tag! 'Description', options[:description] unless options[:description].blank?
277
+ xml.tag! 'OrderDesc', options[:order_desc] unless options[:order_desc].blank?
278
+ xml.tag! 'MerchDescr', options[:merch_descr] unless options[:merch_descr].blank?
279
+ xml.tag! 'BillTo' do
280
+ xml.tag! 'Name', check.name
281
+ end
282
+ xml.tag! 'TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money)
283
+ end
284
+ xml.tag! 'Tender' do
285
+ xml.tag! 'ACH' do
286
+ xml.tag! 'AcctType', check.account_type == 'checking' ? 'C' : 'S'
287
+ xml.tag! 'AcctNum', check.account_number
288
+ xml.tag! 'ABA', check.routing_number
289
+ end
290
+ end
291
+ add_stored_credential(xml, options[:stored_credential])
292
+ end
293
+ xml.tag! 'ExtData', 'Name' => 'BUTTONSOURCE', 'Value' => application_id unless application_id.blank?
294
+ end
295
+ add_level_two_three_fields(xml.target!, options)
296
+ end
297
+
298
+ def add_credit_card(xml, credit_card, options = {})
299
+ xml.tag! 'Card' do
300
+ xml.tag! 'CardType', credit_card_type(credit_card)
301
+ xml.tag! 'CardNum', credit_card.number
302
+ xml.tag! 'ExpDate', expdate(credit_card)
303
+ xml.tag! 'NameOnCard', credit_card.first_name
304
+ xml.tag! 'CVNum', credit_card.verification_value if credit_card.verification_value?
305
+
306
+ add_three_d_secure(options, xml)
307
+
308
+ xml.tag! 'ExtData', 'Name' => 'LASTNAME', 'Value' => credit_card.last_name
309
+ end
310
+ end
311
+
312
+ def add_stored_credential(xml, stored_credential)
313
+ return unless stored_credential
314
+
315
+ xml.tag! 'CardOnFile', add_card_on_file_type(stored_credential)
316
+ xml.tag! 'TxnId', stored_credential[:network_transaction_id] if stored_credential[:network_transaction_id]
317
+ end
318
+
319
+ def card_on_file_initiator(initator)
320
+ case initator
321
+ when 'merchant'
322
+ 'MIT'
323
+ when 'cardholder'
324
+ 'CIT'
325
+ end
326
+ end
327
+
328
+ def card_on_file_reason(stored_credential)
329
+ return 'I' if stored_credential[:initial_transaction] && stored_credential[:reason_type] == 'unscheduled'
330
+
331
+ case stored_credential[:reason_type]
332
+ when 'recurring', 'installment'
333
+ 'R'
334
+ when 'unscheduled'
335
+ 'U'
336
+ end
337
+ end
338
+
339
+ def add_card_on_file_type(stored_credential)
340
+ card_on_file_initiator(stored_credential[:initiator]).to_s + card_on_file_reason(stored_credential).to_s
341
+ end
342
+
343
+ def add_three_d_secure(options, xml)
344
+ if options[:three_d_secure]
345
+ three_d_secure = options[:three_d_secure]
346
+ xml.tag! 'BuyerAuthResult' do
347
+ authentication_status(three_d_secure, xml)
348
+ xml.tag! 'AuthenticationId', three_d_secure[:authentication_id] unless three_d_secure[:authentication_id].blank?
349
+ xml.tag! 'PAReq', three_d_secure[:pareq] unless three_d_secure[:pareq].blank?
350
+ xml.tag! 'ACSUrl', three_d_secure[:acs_url] unless three_d_secure[:acs_url].blank?
351
+ xml.tag! 'ECI', three_d_secure[:eci] unless three_d_secure[:eci].blank?
352
+ xml.tag! 'CAVV', three_d_secure[:cavv] unless three_d_secure[:cavv].blank?
353
+ xml.tag! 'XID', three_d_secure[:xid] unless three_d_secure[:xid].blank?
354
+ xml.tag! 'ThreeDSVersion', three_d_secure[:version] unless three_d_secure[:version].blank?
355
+ xml.tag! 'DSTransactionID', three_d_secure[:ds_transaction_id] unless three_d_secure[:ds_transaction_id].blank?
356
+ end
357
+ end
358
+ end
359
+
360
+ def authentication_status(three_d_secure, xml)
361
+ status = if three_d_secure[:authentication_response_status].present?
362
+ three_d_secure[:authentication_response_status]
363
+ elsif three_d_secure[:directory_response_status].present?
364
+ three_d_secure[:directory_response_status]
365
+ end
366
+ if status.present?
367
+ xml.tag! 'Status', status
368
+ xml.tag! 'AuthenticationStatus', status if version_2_or_newer?(three_d_secure)
369
+ end
370
+ end
371
+
372
+ def version_2_or_newer?(three_d_secure)
373
+ three_d_secure[:version]&.start_with?('2')
374
+ end
375
+
376
+ def credit_card_type(credit_card)
377
+ return '' if card_brand(credit_card).blank?
378
+
379
+ CARD_MAPPING[card_brand(credit_card).to_sym]
380
+ end
381
+
382
+ def expdate(creditcard)
383
+ year = sprintf('%.4i', creditcard.year.to_s.sub(/^0+/, ''))
384
+ month = sprintf('%.2i', creditcard.month.to_s.sub(/^0+/, ''))
385
+
386
+ "#{year}#{month}"
387
+ end
388
+
389
+ def startdate(creditcard)
390
+ year = format(creditcard.start_year, :two_digits)
391
+ month = format(creditcard.start_month, :two_digits)
392
+
393
+ "#{month}#{year}"
394
+ end
395
+
396
+ def build_recurring_request(action, money, options)
397
+ raise StandardError, "Invalid Recurring Profile Action: #{action}" unless RECURRING_ACTIONS.include?(action)
398
+
399
+ xml = Builder::XmlMarkup.new
400
+ xml.tag! 'RecurringProfiles' do
401
+ xml.tag! 'RecurringProfile' do
402
+ xml.tag! action.to_s.capitalize do
403
+ unless %i[cancel inquiry].include?(action)
404
+ xml.tag! 'RPData' do
405
+ xml.tag! 'Name', options[:name] unless options[:name].nil?
406
+ xml.tag! 'TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money)
407
+ xml.tag! 'PayPeriod', get_pay_period(options)
408
+ xml.tag! 'Term', options[:payments] unless options[:payments].nil?
409
+ xml.tag! 'Comment', options[:comment] unless options[:comment].nil?
410
+ xml.tag! 'RetryNumDays', options[:retry_num_days] unless options[:retry_num_days].nil?
411
+ xml.tag! 'MaxFailPayments', options[:max_fail_payments] unless options[:max_fail_payments].nil?
412
+
413
+ if initial_tx = options[:initial_transaction]
414
+ requires!(initial_tx, %i[type authorization purchase])
415
+ requires!(initial_tx, :amount) if initial_tx[:type] == :purchase
416
+
417
+ xml.tag! 'OptionalTrans', TRANSACTIONS[initial_tx[:type]]
418
+ xml.tag! 'OptionalTransAmt', amount(initial_tx[:amount]) unless initial_tx[:amount].blank?
419
+ end
420
+
421
+ if action == :add
422
+ xml.tag! 'Start', format_rp_date(options[:starting_at] || Date.today + 1)
423
+ else
424
+ xml.tag! 'Start', format_rp_date(options[:starting_at]) unless options[:starting_at].nil?
425
+ end
426
+
427
+ xml.tag! 'EMail', options[:email] unless options[:email].nil?
428
+
429
+ billing_address = options[:billing_address] || options[:address]
430
+ add_address(xml, 'BillTo', billing_address, options) if billing_address
431
+ add_address(xml, 'ShipTo', options[:shipping_address], options) if options[:shipping_address]
432
+ end
433
+ xml.tag! 'Tender' do
434
+ yield xml
435
+ end
436
+ end
437
+ xml.tag! 'ProfileID', options[:profile_id] if action != :add
438
+ if action == :inquiry
439
+ xml.tag! 'PaymentHistory', (options[:history] ? 'Y' : 'N')
440
+ end
441
+ end
442
+ end
443
+ end
444
+ end
445
+
446
+ def get_pay_period(options)
447
+ requires!(options, %i[periodicity bimonthly monthly biweekly weekly yearly daily semimonthly quadweekly quarterly semiyearly])
448
+ case options[:periodicity]
449
+ when :weekly then 'Weekly'
450
+ when :biweekly then 'Bi-weekly'
451
+ when :semimonthly then 'Semi-monthly'
452
+ when :quadweekly then 'Every four weeks'
453
+ when :monthly then 'Monthly'
454
+ when :quarterly then 'Quarterly'
455
+ when :semiyearly then 'Semi-yearly'
456
+ when :yearly then 'Yearly'
457
+ end
458
+ end
459
+
460
+ def format_rp_date(time)
461
+ case time
462
+ when Time, Date then time.strftime('%m%d%Y')
463
+ else
464
+ time.to_s
465
+ end
466
+ end
467
+
468
+ def build_response(success, message, response, options = {})
469
+ PayflowResponse.new(success, message, response, options)
470
+ end
471
+ end
472
+ end
473
+ end