【问题标题】:How to handle Exception while processing two third party APIs in Laravel在 Laravel 中处理两个第三方 API 时如何处理异常
【发布时间】:2020-12-22 01:02:03
【问题描述】:

我正在使用 Laravel 构建 Saas 应用程序,我担心这种情况。

我正在集成 Namecheap 域名购买 API 和 Paypal 支付网关 API。

我的逻辑是这样的

-Show Available Domains:
-Customer picks one:
-Customer pays with paypal (redirect to paypal page):
-If payment is success, I will call domain register API.
-If success, then I will show success message.

以上是一切都按我预期工作的完美案例。

但这是我的担忧。

...
-Customer pays with paypal (redirect to paypal page):
-Payment was success, I will call domain register API.
-Domain register API is not success: (maybe i need to refund?)

其他选项:

-Customer pays with paypal (redirect to paypal page):
-Before do actual payment on my side, I will call domain register API.
-If domain register AIP is success, I will do actual payment process.

在这种情况下,如果实际付款过程失败,那么客户将能够免费获得域名。

谁能给我一些建议来解决这些情况?

谢谢

【问题讨论】:

    标签: php laravel paypal namecheap


    【解决方案1】:

    我确定您会提前检查可用性,但您应该始终在注册域之前处理付款。如果注册失败,您可以立即退款或提供其他域名的选择或任何可行的方式。

    对于付款审批,最好的 PayPal 审批流程是:https://developer.paypal.com/demo/checkout/#/pattern/server

    这会在您的服务器上调用两条路由,一条用于“设置事务”,一条用于“捕获事务”,记录在此:https://developer.paypal.com/docs/checkout/reference/server-integration/

    • 如果在服务器上捕获成功,那么您将在该位置 注册域并成功响应。如果注册 失败,那是您可以退款或提供其他选择的地方。

    • 如果捕获不成功,您将在此处传播 正确处理失败消息。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-06-15
    • 2015-02-18
    • 2020-08-11
    • 2017-09-14
    • 1970-01-01
    • 2014-04-22
    • 2023-03-19
    相关资源
    最近更新 更多