gpt4 book ai didi

stripe-payments - 测试 Stripe 中的invoice_payment.failed事件

转载 作者:行者123 更新时间:2023-12-04 16:38:55 28 4
gpt4 key购买 nike

我想测试条纹中的invoice_payment.failed事件Web Hook 。我已经设置了一个Web Hook 端点,并尝试从数据条发送测试数据,但是由于事件ID不存在,所以该方法不起作用。 strip 准则中提到了一些解决方案。这是我看到的链接。

https://support.stripe.com/questions/test-failed-invoice-payment

它告诉我创建一个计划,并在试用期设置为1-2分钟的情况下订阅客户,并使用某个信用卡号创建客户对象。我将试用期设置为“现在”,并且仅使用给定的信用卡号获得了charge.failed,而没有使用invoice_payment.failed事件。我是条纹新手,想知道如何从现在开始将trial_end时段设置为1-2分钟,以及如何精确测试invoice_payment.failed事件。我在用PHP工作。任何帮助,将不胜感激。

最佳答案

设置为creating a subscription时,可以使用 trial_end 参数设置试用期。

为了测试invoice.payment_failed事件,您可以执行以下操作:

  • 首先,使用特殊的create a customer 4000 0000 0000 0341创建带有卡片 token (来自CheckoutStripe.js)的testing number:
    $customer = \Stripe\Customer::create([
    "source" => $token,
    "description" => "Test customer"
    ]);
  • 然后,以较短的试用期创建该计划的订阅:
    $subscription = \Stripe\Subscription::create([
    "customer" => $customer->id,
    "plan" => $plan,
    "trial_end" => strtotime("+1 minute")
    ]);

  • 这将创建具有一分钟试用期的订阅。一分钟后,将创建发票,大约一小时后,将尝试付款。

    如果您不想等待一个小时,则可以在创建后手动 retrieve the invoicetrigger the payment attempt:
    $invoice = \Stripe\Invoice::retrieve($invoice_id);
    $invoice->pay();

    关于stripe-payments - 测试 Stripe 中的invoice_payment.failed事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37740324/

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