gpt4 book ai didi

asp.net-mvc - ASPNET 等待网页上的 Webhook 响应/结果

转载 作者:行者123 更新时间:2023-12-02 03:11:23 26 4
gpt4 key购买 nike

我们有一个接受 Stripe 付款的网页,一旦付款完成,Stripe 就可以调用我们服务器上的 webhook。

此时,我们可以将订单标记为已完成并完成任何其他附加任务。

我们如何让订购网页更新/让用户完成订购?

我们是否应该始终使用 AJAX 访问服务器以检查它现在是否已完成,或者是否有更好的方法来完成此操作。

最佳答案

Q: How can we have the order webpage update/move the user onto to order complete?

大多数支付引擎会将支付 session 重定向到您选择的带有结果代码的 URL 或每个结果代码的不同 URL。这些通常可以在发出请求时配置,也可以在一般配置中为整个站点配置。实际付款不应依赖这些结果,因为这是网络 Hook 的工作。他们足够可信,您的站点可以显示一般的成功/失败错误消息,并让用户继续执行任何操作。


Stripe 也允许这样做,您可以指定 success_url(或在客户端集成中指定 successUrl)。

参见 Create a Checkout Session on your server了解如何将此 URL 传递给请求。您还可以包含一个 cancel_url。请参阅下面代码示例中的最后 2 个参数:

curl https://api.stripe.com/v1/checkout/sessions \
-u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
-d payment_method_types[]=card \
-d line_items[][name]=T-shirt \
-d line_items[][description]="Comfortable cotton t-shirt" \
-d line_items[][images][]="https://example.com/t-shirt.png" \
-d line_items[][amount]=500 \
-d line_items[][currency]=usd \
-d line_items[][quantity]=1 \
-d success_url="https://example.com/success" \
-d cancel_url="https://example.com/cancel"

另见 Checkout Purchase Fulfillment .

When your customer successfully completes their payment or initiates a subscription using Checkout, Stripe redirects them to the URL that you specified in the success_url parameter (or successUrl in the client integration). Typically, this is a page on your website that informs your customer that their payment was successful.

正如我上面所说,如果付款成功,请不要将此作为实际指标。您应该为此使用网络 Hook 。

Do not rely on the redirect to the success_url alone for fulfilling purchases as:

  • Malicious users could directly access the success_url without paying and gain access to your goods or services.
  • Customers may not always reach the success_url after a successful payment. It is possible they close their browser tab before the redirect occurs.

关于asp.net-mvc - ASPNET 等待网页上的 Webhook 响应/结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57481021/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com