简体   繁体   English

无法向没有活动卡的客户收费 - Stripe Payment

[英]Cannot charge a customer that has no active card - Stripe Payment

I am trying to charge already created customer but getting error " Cannot charge a customer that has no active card "我正在尝试向已创建的客户收费,但出现错误“无法向没有活动卡的客户收费

在此处输入图片说明

The card is already added too卡也已经添加了

在此处输入图片说明

Here is the node.js code I am using to charge the customer这是我用来向客户收费的 node.js 代码

const response = await stripe.charges.create({
        'amount': amount,
        'currency': currency,
        'description': title,
        'customer': customer,
    }, { idempotencyKey: onDemandId });






// What I am sending
    {
      "amount": "40",
      "currency": "usd",
      "description": "120 دقيقة",
      "customer": "cus_I33Z2JrUSj1bBm"
    }


// What I am getting
    {
      "error": {
        "code": "missing",
        "doc_url": "https://stripe.com/docs/error-codes/missing",
        "message": "Cannot charge a customer that has no active card",
        "param": "card",
        "type": "card_error"
      }
    }

Any idea why I am getting this error?知道为什么我会收到此错误吗?

You should check if the Customer has a default_source , and set it using one of their saved cards if needed.您应该检查 Customer 是否有default_source ,并在需要时使用他们保存的卡片之一进行设置

Even better, you should look at creating payment using a saved card with Payment Intents , and then the answer would be that you need to provide the payment_method explicitly.更好的是,您应该考虑使用带有 Payment Intents 的已保存卡创建付款,然后答案是您需要明确提供payment_method

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM