信用卡重复交易
防止用户进行重复信用卡交易的最佳方法是什么? 无论是点击提交按钮太多次,还是从收据页面导航回来并再次点击提交按钮。
What's the best way to prevent a user from making duplicate credit card transactions? Be it by clicking the submit button too many times, or by navigating back from the receipt page and clicking the submit button again.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您可以生成一个唯一的值,并将其置于隐藏的形式中。 在向信用卡收费之前,请确保该唯一值尚未被处理。 再加上 CodeToGlory 禁用该按钮的建议应该可以解决您的两个用例。
You could generate a unique value, and put it in a hidden form. Before you charge the credit card make sure this unique value has not been processed already. This coupled with CodeToGlory's suggestion of disabling the button should resolve both of your use cases.
有几种方法:
单击按钮后立即禁用该按钮。
有一个批处理程序可以在当天晚些时候从结算中删除重复项,这样他们就不会被收取费用。
有一个批处理程序可以在当天
使用某种模式窗口来阻止用户导航,直到处理信用卡交易为止。 Jquery 有可以为您工作的 block.UI 插件。
Couple of ways:
Disable the button immediately after clicking it.
Have a batch process to remove duplicates from settlement later in the day, so they won't get charged.
Use some kind of modal window to stop the user from navigating till the credit card transaction is processed. Jquery has block.UI plugin that can work for you.
大多数银行要求您提供唯一订单 ID,因此无法对同一订单收取两次费用。
现在,如果您要求防止重复提交,标准方法是 发布/重定向/获取模式。 您还可以将其与使用 JavaScript 停用提交按钮结合起来。
您需要:
现在,如果用户单击重新加载,则仅重新加载静态
thankyou.html
。 如果他选择点击返回,则返回到order_form.aspx
,但他的购物篮已经空了。 如果以某种方式进行缓存,它将使用相同的订单 ID 进行缓存,因此不会有收取两次费用的风险。Most banks require that you provide unique order ID, so there is no way of charging twice for the same order.
Now, if you're asking for prevention of duplicate submit, the standard way is the Post/Redirect/Get pattern. You might also combine that with deactivating submit button with JavaScript.
You'd have:
Now, if user clicks reload, only reloads static
thankyou.html
. If he chooses to click back, get's back toorder_form.aspx
, but his basket is already empty. Should it somehow be cached, it'll get cached with the same order ID, so no risk of charging twice there.向后端系统添加某种同步机制,以便在任何一个时间点都可以只有一个线程将“待收费”记录处理到底层数据源中。 在此同步区域内,添加检查以确保数据源中尚不存在即将处理的费用。 如果确实发生这样的错误,请确保向客户输出某种优雅的消息 - 至少它不会在后端造成致命的后果。
正如 CodeToGlory 所建议的,它还有助于在 UI 级别添加第二层保护。 这将最大限度地减少这种情况发生的次数。
Add some sort of synchronization mechanism to your back-end system so that only one thread may be processing 'to be charged' records into your underlying datasource at any one point in time. Inside this synchronized region, add a check to ensure that the charge that is about to be processed does not already exist in the datasource. If such an error does occur, make sure to output some sort of graceful message to the customer - at least it won't be fatal on the back end.
It also helps to add a 2nd layer of protection at the UI level, as suggested by CodeToGlory. This will minimize the number of times that this occurs.
订购后立即删除购物篮中的商品并禁用提交按钮。
在这种情况下,即使用户回来、刷新等也不能购买两次,因为购物篮中将没有任何东西可购买。
Remove the basket items as soon as they ordered and disable the submit button.
In this case even if the user comes back, refresh etc. can't buy twice since there will be nothing in the basket to buy.
您可以在客户进入第一个结帐页面时创建会话,然后在按下提交按钮时强制会话超时。 这样客户就必须重新开始结账过程。
You can create a session when the customer enter the first check out page, and then when the submit button is pressed, force session timeout. That way the customer has to start over the checkout process again.