具有外部支付网关的电子商务库存管理

发布于 2024-08-12 11:13:56 字数 501 浏览 3 评论 0原文

这个问题与这个问题类似,但有一点不同(因此接受的答案较旧的问题在以下情况下无效)

我有一个售票网站(PHP/MYSQL)。假设我只剩下一张票:

  • 买家A将票放入购物车并转到支付网关页面(即paypal),
  • 票被锁定5分钟,因此买家B无法购买
  • 买家A用paypal等待5分钟页面打开,不执行任何操作,
  • 票证已解锁,因此买家 B 将其放入购物车并进入 paypal 页面
  • 买家 A 在 paypal 上成功执行付款程序
  • 买家 B 在 paypal 上成功执行付款程序

我可以等待更长的时间,但我不认为这不会解决更一般情况下的问题。此外,如果我这样做,就有可能进行某种 DoS,长时间锁定库存物品。

处理这种情况的最佳方法是什么?

this question is similar to this one but with a twist (so the answer accepted for the older question is not valid in the following scenario)

i have a site for selling tickets (PHP/MYSQL). Suppose i have just one ticket left:

  • buyer A puts the ticket in her cart and goes to the payment gateway page (ie. paypal)
  • the ticket is locked for 5 minutes, so buyer B cannot buy it
  • buyer A waits 5 minutes with the paypal page open, doing nothing
  • the ticket is unlocked so buyer B puts it in his cart and goes the the paypal page
  • buyer A executes the payment procedure on paypal with success
  • buyer B executes the payment procedure on paypal with success

i can wait longer but i don't think this will solve the issue in the more general case. moreover, if i do that, it will be possibile to make some kind of DoS, locking the items in stock for large periods of time.

what's the best way to handle this scenario ?

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

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

发布评论

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

评论(4

醉殇 2024-08-19 11:13:56

所有支付网关都会回发让您知道(例如)付款参考等。大多数还会回发授权/认证信息,例如CSC/CVV2检查结果,以便您(商户)最终决定是否接受付款与否。

收到回发后,您应该能够检查票据是否仍然“锁定”,如果没有,则通过支付网关发出付款撤销以取消付款。然后,您需要显示一条消息“抱歉,超时,请重试”

如果网关不支持“即时逆转”风格的功能,那么它们至少会支持某种“无效”功能,即资金永远不会真正从客户卡,授权保留会自动消失(通常在两天后,但某些卡可能需要更长时间)。对于超时的事务数量(希望很少)来说,这可能是可以接受的。值得监控有多少事务超时,以便调整超时时间。

或者,如果票证不再锁定,(如果网关支持的话)发回退款。

All payment gateways will do a postback to let you know (eg) the payment reference etc. Most will also postback authorisation/authentication information, such as CSC/CVV2 check results so that you (the merchant) have the final say in whether to accept the payment or not.

On receipt of the postback you should be able to check if the ticket is still 'locked', and if not then issue a payment reversal through the payment gateway to cancel the payment. You then need to display a message 'sorry, timeout exceeded please try again'

If the gateway doesnt support an 'instant reversal' style functionality, then they will at least support some sort of 'void' functionality whereby the funds are never actually taken from the customers card, and the authorisation hold drops off automatically (usually after two days, though it can take longer on some cards). For the (hopefully small) number of transactions that time-out, this may be acceptable. It would be worth monitoring how many transactions time-out so that the time-out period can be adjusted.

Alternatively, if the ticket is no longer locked, (and again, if the gateway supports it) send back a Refund payment.

夜司空 2024-08-19 11:13:56

您很可能无法使用外部支付网关入口页面并执行您想要执行的操作。

Paypal 和许多其他处理商都有直接的 Web 服务集成路线。这意味着您在页面上收集付款信息,将其提交到您的服务器,然后您进行 Web 服务调用并从处理器获得立即响应。 (我不记得 PayPal 将执行此操作的产品称为什么,但它曾经被命名为 PayFlow Pro,是从 Verisign 购买的。)

因此,当将门票放入购物车时,您不会锁定门票。您的工作流程是:

  1. 收集付款信息。
  2. 付款信息发送回您的服务器后:
    一个。尝试锁定门票 - 如果不可用则返回失败
    b.锁定成功后,处理授权 授权
  3. 成功后,票证将从可用池中删除。
  4. 如果授权不成功或出现错误,票证将被解锁并可供其他用户使用。

无需处理锁定超时。它们的锁定时间仅足以验证有效付款。

您没有询问在防止 PCI 暴露的同时解决问题。因为您可能会问:

有一些处理器允许您将付款信息集合嵌入到您自己的页面中。有些允许您获取“令牌”来替换卡号,以便您的服务器永远不会收到卡号。然后可以在服务器端 Web 服务调用中使用该令牌。您可以获得所需的内容,并且无需处理有关接收卡号码的 PCI 问题。

It is likely that you can not use an external payment gateway entry page and do what it is you are trying to do.

Paypal and many other processors have a direct web service integration route. This means you collect the payment information on your page, it gets submitted to your server, and you make the web service call and get an immediate response from the processor. (I don't remember what PayPal calls the product that does this, but it used to be named PayFlow Pro and was bought from Verisign.)

So you don't lock the tickets when they are placed in the cart. Your workflow would be:

  1. Collect payment information.
  2. Once payment info is posted back to your server:
    a. Try to lock the tickets - return failure if not available
    b. On successful lock, process authorization
  3. On successful authorization, tickets are removed from the available pool.
  4. On unsuccessful authorization or error, tickets are unlocked and available for other users.

No need to deal with lock timeouts. They are only locked long enough to verify a valid payment.

You didn't ask about solving the issue while preventing PCI exposure. Since you'll probably ask:

There are processors out there that allow you to embed the payment information collection in your own page. There are some that allow you to obtain a "token" to replace a card number so that your server never receives a card number. The token can then be used on the server side web service call. You get what you need and you don't have to deal with PCI issues around receiving card numbers.

枫以 2024-08-19 11:13:56

是否有一种更具社交性的解决方案而不是技术性的解决方案?为什么不明确表明,当您等待太久时,票证就会解锁?

How about a more social solution instead of a technical one? Why not make it absolutely obvious that a ticket will become unlocked when you wait too long?

╰ゝ天使的微笑 2024-08-19 11:13:56

我认为如果有人在这 5 分钟内将票放入购物车,您不应该阻止该票。你可能最终会赶走一些其他顾客...

我建议你允许每个人将门票添加到他/她的购物车,除非有人真正付款并购买。现在,当其他人继续结帐时,只需闪现一条消息“对不起,您迟到了......门票已售完!!!”并应将门票从购物车中取出。

这样,您的客户就不会阻止该票,并且不会出现两个人为同一张票付款的情况。

I think you should not block the ticket if someone puts it in his cart as in those 5 mins. you might end up driving away few other customers...

I suggest you to allow everyone to add the ticket to his/her cart unless someone actually makes the payment and buys it. Now when others proceed for checkout, just flash a message as "Sorry You Are Late... Ticket Sold Out !!!" and ticket should be removed from their cart.

This way the ticket will not be blocked from your customers and still the scenario of two people making payment for the same ticket will not arise.

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