jai*_*jai 5 stripe-payments stripe-connect
我想测试stripe中的invoice_payment.failed事件Web钩子.我已经设置了一个Web钩子端点,并试图从条带发送测试数据,但这不起作用,因为事件ID不存在.条带指南中提到了一些解决方案.这是我看到的链接.
https://support.stripe.com/questions/test-failed-invoice-payment
它告诉我创建一个计划并订阅一个客户,其trial_end期限设置为1-2分钟,并使用某个信用卡号创建客户对象.我将trial_end期间设置为"now"并且仅使用给定的信用卡号而不是invoice_payment.failed事件获得charge.failed.我是条纹新手,想知道如何将trial_end时间段设置为1-2分钟,以及如何测试invoice_payment.failed事件.我在php工作.任何帮助,将不胜感激.
Ywa*_*ain 11
为了测试invoice.payment_failed事件,您可以执行以下操作:
首先,使用特殊测试编号创建的卡令牌(来自Checkout或Stripe.js)创建客户: 4000 0000 0000 0341
$customer = \Stripe\Customer::create(array(
"source" => $token,
"description" => "Test customer"
));
Run Code Online (Sandbox Code Playgroud)然后,使用较短的试用期创建对计划的订阅:
$subscription = \Stripe\Subscription::create(array(
"customer" => $customer->id,
"plan" => $plan,
"trial_end" => strtotime("+1 minute")
));
Run Code Online (Sandbox Code Playgroud)这将创建一分钟试用期的订阅.一分钟后,将创建发票,大约一小时后,将尝试支付发票.
如果您不想等待一小时,可以在创建发票后手动检索发票并触发付款尝试:
$invoice = \Stripe\Invoice::retrieve($invoice_id);
$invoice->pay();
Run Code Online (Sandbox Code Playgroud)
如果您只想测试和处理invoice.payment_failed 事件以及您可以创建和无法创建的其他事件,那么您应该转到stripe 仪表板并在webhooks 设置下,发送所需类型的测试事件。
| 归档时间: |
|
| 查看次数: |
3263 次 |
| 最近记录: |