如何解决我网站使用的第三方系统未告知支付成功的问题?
我有一个基于订阅的网站,它与第三方系统交互来处理付款。处理新订阅者注册的步骤如下:
- 订阅者在订阅表格中输入他/她的详细信息,然后单击提交按钮。
- 假设指定的详细信息有效,则会在数据库中创建一条新记录来存储这些详细信息。
- 然后,订阅者将被重定向到第 3 方系统(类似于 paypal)的网站来处理付款。
- 付款成功后,第 3 方网站会将订阅者重定向回我们的网站。
- 这时候我就知道支付成功了,于是更新数据库中的记录,表明支付成功了。
我发现经常发生的一个问题是,如果订阅者付款但没有正确完成该过程(例如使用后置浏览器,关闭窗口),他/她在数据库中的记录不会对此进行更新。因此,仅通过查看记录,我不知道他/她是否已付款,需要等待第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:
- The subscriber enters his/her details in the subscription form and click on the submit button.
- Assuming the details specified are valid, a new record is created in the database to store these details.
- The subscriber is then redirected to the website of the 3rd party system (similar to paypal) to process the payment.
- Once the payment is succesful, the 3rd party website then redirect the subscriber back to our website.
- 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无论用户做什么,第三方支付系统都应该通知您交易成功。
例如,在 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.