使用 ActiveMerchant 和 ActiveMerchant 在实时网站上接受虚拟信用卡 贝宝

发布于 2024-07-25 02:50:52 字数 483 浏览 2 评论 0原文

我正在建立一个 Rails 网站,该网站将接受 ActiveMerchant 和 PayPal Website Payments Pro 的信用卡。 我已成功针对 PayPal 沙箱进行测试,但也需要能够在我的实时网站上进行测试。 我想实现一个解决方案,其中使用来自我自己域的电子邮件地址在我的实时网站上注册时使用 PayPal 沙箱,但对于其他人来说,它使用实时 PayPal 网站。 这样,当我测试我的实时网站时,我就不会自己付费,也不会在这个过程中被 PayPal 征税:-)

但问题是,要让 ActiveMerchant 使用测试服务器,您需要编写以下行:

ActiveMerchant: :Billing::Base.mode = :test

当我只是希望一项事务以测试服务器为目标时,它设置一个类变量,该变量将应用于站点上的其他事务。

谁能提出一个优雅的解决方案? 或者除了我想到的解决方案之外,还有更好的方法来实现这一目标吗?

I'm setting up a rails site that will accept credit cards with ActiveMerchant and PayPal Website Payments Pro. I am successfully testing against the PayPal sandbox, but need to be able to test on my live site as well. I'd like to implement a solution whereby registrations on my live site with email addresses from my own domain use the PayPal sandbox, but for everyone else it uses the live PayPal site. That way when I test my live site I'm not paying myself and getting taxed by PayPal in the process :-)

The problem, however, is that to get ActiveMerchant to use the test servers you write this line:

ActiveMerchant::Billing::Base.mode = :test

That sets a class variable which will apply to other transactions on the site, when I simply wish for one transaction to target the test servers.

Can anyone suggest an elegant solution? Or are there better ways to accomplish this other than the solution I have in mind?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

み格子的夏天 2024-08-01 02:50:52

打开后门总是很危险的。 我建议在任何情况下都不要在沙箱中运行生产环境。 如果您需要偶尔进行测试,请在真实的 PayPal 环境中进行测试并立即处理退款 - 无需大惊小怪,也不收取任何费用。

It´s always dangerous to leave a backdoor open. I'd recommend against running your production environment against the sandbox under any circumstance. If you need to run an ocassional test do it against the live PayPal environment and process a refund immediately - no fuss and no charge.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文