SetupIntent未将付款方式附加到客户

问题描述

因此,我正在尝试更新用户的payment_method并将其附加到客户,以便用户可以继续支付其定期订阅。我正在使用SetupIntents

节点

const intent =  await stripe.setupIntents.create({
    customer: customer_id,});
response.send(intent.client_secret);

反应

const result = await stripe.confirmCardSetup(client_secret,{
      payment_method: {
        card: elements.getElement(CardElement),billing_details: {
          email: email,},}
    });
    
    if (result.error) {
      // display result.error.message in your UI.
    } else {
        // The setup has succeeded. display a success message and send
        // result.setupIntent.payment_method to your server to save the
        // card to a Customer
    }

这确实可以成功,但是如果我尝试在客户上将invoice_settings.default_payment_method设置为PaymentMethod的ID

const customer = await stripe.customers.update(
  customer_id,{invoice_settings: {default_payment_method: payment_method}}

我得到了错误

StripeInvalidRequestError: The customer does not have a payment method with the ID pm_1HelzAB9lEAzymezFB8ZvHek. The payment method must be attached to the customer.

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)