如何解决我网站使用的第三方系统未告知支付成功的问题?

发布于 2024-08-28 22:22:38 字数 533 浏览 7 评论 0原文

我有一个基于订阅的网站,它与第三方系统交互来处理付款。处理新订阅者注册的步骤如下:

  1. 订阅者在订阅表格中输入他/她的详细信息,然后单击提交按钮。
  2. 假设指定的详细信息有效,则会在数据库中创建一条新记录来存储这些详细信息。
  3. 然后,订阅者将被重定向到第 3 方系统(类似于 paypal)的网站来处理付款。
  4. 付款成功后,第 3 方网站会将订阅者重定向回我们的网站。
  5. 这时候我就知道支付成功了,于是更新数据库中的记录,表明支付成功了。

我发现经常发生的一个问题是,如果订阅者付款但没有正确完成该过程(例如使用后置浏览器,关闭窗口),他/她在数据库中的记录不会对此进行更新。因此,仅通过查看记录,我不知道他/她是否已付款,需要等待第3方系统的报告才能查明这一点。

你如何解决这个问题?

附言。在付款流程完成之前将其详细信息存储到数据库的主要原因之一是,这样他们就可以回来完成付款,而无需再次重新输入其详细信息。例如,当他们的信用卡被第三方系统拒绝时,他们需要与金融机构解决这个问题,这可能需要一段时间。

I have a subscription based website that interacts with a 3rd party system to handle the payments. The steps to process a new subscriber registration are as follow:

  1. The subscriber enters his/her details in the subscription form and click on the submit button.
  2. Assuming the details specified are valid, a new record is created in the database to store these details.
  3. The subscriber is then redirected to the website of the 3rd party system (similar to paypal) to process the payment.
  4. Once the payment is succesful, the 3rd party website then redirect the subscriber back to our website.
  5. At this time, I know that the payment was succesful, so the record in the database is updated to indicate that payment has been made successfully.

A problem that I have found occurring quite often is that if a subscriber pays but does not complete the process correctly (e.g. uses the back browser, closes the window), his/her record in the database doesn't get updated about this. Accordingly, I don't know if s/he has paid by just looking the record and need to wait for the report from the 3rd party system to find this out.

How do you solve this problem?

PS. One of the main reasons to store their details into the database before the payment process is done is so they can come back to complete the payment without re-entering their details again. For example, when their credit cards were rejected by the 3rd party system and they need to sort this out with their financial institution which may take a while.

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

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

发布评论

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

评论(1

哆啦不做梦 2024-09-04 22:22:38

无论用户做什么,第三方支付系统都应该通知您交易成功。

例如,在 PayPal 中,IPN(即时付款通知)会以 POST 数据的形式发送到您指定的 URL。然后,您的服务器会通过 Paypal 验证交易是否真实,如果是,则更新数据库记录以表明订阅有效。在将来的某个时刻,PayPal 可能也可能不会将用户重定向回您的网站。 (“可能不会”可能会在用户关闭浏览器、点击“返回”或跳转到新 URL 等情况下发生)

请注意,Paypal 和您的服务器之间的这种“对话”独立于用户的会话 - 它是一个“您和 PayPal 之间关于该用户交易的“私人对话”。

显然,可能会出现通信中断和服务器故障,因此如果 Paypal 没有立即从您的服务器收到验证请求,它会定期向您的服务器发送重试,以确保交易最终完成。

如果您的支付系统至少没有一些基本机制来确保交易可靠性,那么请选择其他提供商。它们很可能会这样做,但您必须在服务器上正确实施某些操作,以确保系统正常工作。

PS 在发起任何金融交易之前,要求用户登录(并因此在数据库中注册)是很正常的。您需要在他们购买之前收集所有相关信息,因为购买后您无法保证他们会返回给您提供任何进一步的信息。

The third-party payment system should inform you of the successful transaction regardless of what the user does.

For example, in PayPal, an IPN (instant payment notification) is sent to your server as POST data to a URL that you specify. Your server then verifies with Paypal that the transaction is genuine, and if so, updates the database record to indicate the subscription is valid. At a point in the future, PayPal may or may not then redirect the user back to your website. (The "may not" can occur in cases such as the user closing their browser, hitting Back, or jumping to a new URL)

Note that this "conversation" between Paypal and your server is independent of the user's session - it is a "private conversation" between you and PayPal about that user's transaction.

Obviously there can be communications outages and server failures, so if Paypal does not get the validation request from your server immediately it will periodically send retries to your server to ensure that the transaction is eventually completed.

If your payment system doesn't have at least some basic mechanism for ensuring transaction reliability, then choose a different provider. Chances are that they do, but you will have to implement things correctly on your server to be sure that the system works properly.

P.S. It is quite normal to require a user to log in (and thus be registered in the database) before they initiate any financial transaction. You need to gather all the relevant information before they go to purchase, as after the purchase you have no way of guaranteeing that they will return to you to provide any further information.

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