You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何让Stripe Subscription Schedules立即扣费而非等待1小时

解决Stripe订阅计划第一阶段立即扣费的问题

你遇到的是Stripe默认的草稿发票延迟结算机制——即使客户绑定了支付卡,系统也会把初始阶段的发票保留1小时草稿状态后再完成扣费。要强制第一阶段立即扣费,只需在创建订阅计划时添加两个关键参数即可:

修改后的实现代码:

$phases = [
    [
        'items' => [
            [
                'price_data' => [
                    'currency' => 'usd',
                    'product' => $product->stripe_product_id,
                    'recurring' => [
                        'interval' => $payment_plan['frequency'],
                    ],
                    'unit_amount' => $payment_plan['stripe_amount']
                ],
                'quantity' => 1,
            ],
        ],
        'iterations' => (int) $payment_plan['total_payments']
    ],
];

$subscription = $stripe->subscriptionSchedules->create([
    'customer' => $customer->stripe_customer_id,
    'start_date' => 'now',
    'end_behavior' => 'cancel',
    'phases' => $phases,
    // 新增参数:强制立即扣费
    'payment_behavior' => 'default_incomplete',
    'invoice_settings' => [
        'days_until_due' => 0,
    ],
]);

参数说明:

  • payment_behavior: 'default_incomplete':让Stripe立即为第一阶段生成发票并发起扣款请求,不再保留草稿状态。如果支付失败,订阅会进入incomplete状态,方便你后续处理失败场景。
  • invoice_settings.days_until_due: 0:将发票到期日设为当天,彻底消除结算延迟的可能。

注意:确保客户已经绑定了支付卡,并且该卡片已设置为客户的默认支付方式(可通过customers.update接口设置invoice_settings.default_payment_method),否则立即扣费会失败。

内容的提问来源于stack exchange,提问作者Carlos Branco

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 21:10:52