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

Stripe Payment Component付款后未设置默认支付方式问题

问题原因及解决方案

你遇到的问题是设置了save_default_payment_method: "on_subscription"但卡片未被设为默认支付方式,导致后续订阅扣款失败,主要有以下几个可能的原因及对应解决方法:

1. 前端确认支付时未明确允许未来扣款

虽然服务端配置了保存默认支付方式,但前端调用confirmPayment时需要明确声明允许支付方式用于后续off_session扣款。修改前端代码,在confirmPayment参数中添加setup_future_usage: "off_session":

const response = await stripe.confirmPayment({
  type: "card",
  elements,
  redirect: "if_required",
  setup_future_usage: "off_session", // 新增该行
});

2. 服务端未强制设置支付意向的未来使用属性

部分场景下,save_default_payment_method: "on_subscription"可能未自动为支付意向设置setup_future_usage。可以在创建订阅时,手动通过payment_intent_data配置该属性:

const subscription = await stripe.subscriptions.create({
  customer: customer.id,
  items: [{ price: getPricePlan(plan) }],
  payment_behavior: "default_incomplete",
  payment_settings: { save_default_payment_method: "on_subscription" },
  payment_intent_data: { setup_future_usage: "off_session" }, // 新增该行
  expand: ["latest_invoice.payment_intent"],
});

3. 客户已有默认支付方式未被覆盖

如果客户账户中已存在默认支付方式,save_default_payment_method: "on_subscription"不会自动替换现有默认。可以在支付成功后(比如通过payment_intent.succeeded webhook),手动将新支付方式设为默认:

// 在webhook处理逻辑中
await stripe.customers.update(customerId, {
  invoice_settings: {
    default_payment_method: paymentIntent.payment_method,
  },
});

4. 支付方式不支持未来扣款

部分支付方式(如一次性预付卡)无法用于off_session自动扣款,这种情况下无法被设为默认支付方式。确保使用的是支持重复扣款的标准信用卡类型。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.24 12:37:28