简体   繁体   English

Stripe 付款意图使用哪种付款方式

[英]Which payment method to use for Stripe Payment intent

I'm trying to auto charge customers on stripe in NodeJS我正在尝试在 NodeJS 中自动向客户收费

I have an issue where some customers have a:我有一个问题,一些客户有:

  • default_source and some have default_source 和一些有
  • invoice_settings.default_payment_method invoice_settings.default_payment_method

My current workflow (C# WPF):我当前的工作流程(C# WPF):

  • Create customer + Add subscription to customer创建客户 + 为客户添加订阅
  • Get URL for portal获取门户的 URL
  • Customer adds card details on stripe portal客户在条带门户上添加卡详细信息

This works fine and payment are running well.这工作正常,付款运行良好。

I also charge for SMS fees using a nodejs api:我还使用 nodejs api 收取短信费用:

async function chargeSMS(stripeCusID,chargeValue,chemistName,chemistID,countSMS){
//console.log(stripeCusID);
//console.log(chargeValue);
let customerObject;
let payMethodID;
customerObject = await stripe.customers.retrieve(
            
);

console.log("PaymentID received:" + customerObject.invoice_settings.default_payment_method);
  
payMethodID = customerObject.invoice_settings.default_payment_method;
  
await stripe.paymentIntents.create({
    amount: chargeValue,
    currency: 'aud',
    customer: stripeCusID,
    description: 'SMS Charges: ' + countSMS + " sent",
    payment_method: payMethodID,
    confirm: true
},
function(err, response) {
    if (err) {
    console.log("Charge", err.message,stripeCusID,chargeValue,chemistName);
    return;
    }

    console.log("Successful SMS Charge:", response.id,chemistName);
    chemCharged(chemistID);
}) 

} }

This has also been working fine as a Cron on 1st of each month.这在每个月的 1 日作为 Cron 也运行良好。

My issue is that recently one of my customer's cards expired.我的问题是最近我的一张客户卡过期了。 They used my WPF to open the portal and add a new card This worked.他们使用我的 WPF 打开门户并添加新卡这工作。

HOWEVER this new card on the portal is only listed as customer.default_source但是,门户网站上的这张新卡仅列为 customer.default_source

Their invoice_settings.default_payment_method他们的 invoice_settings.default_payment_method

Is now null!现在为空!

So my code above fails.所以我上面的代码失败了。

I've checked and:我已经检查过并且:

  • All new customers using portal have their cards saved as invoice_settings.default_payment_method所有使用门户的新客户都将他们的卡保存为 invoice_settings.default_payment_method
  • any time a customer adds a new card it is only added as defult_source每当客户添加新卡时,它只会添加为 defult_source

I ahve no idea why this is the situation but I'm using the stripe customer portal so i would have thought they would add in the same way!我不知道为什么会出现这种情况,但我使用的是条纹客户门户,所以我原以为他们会以同样的方式添加!

Any ideas how I can fix this or figure out what I've done wrong?有什么想法可以解决这个问题或找出我做错了什么吗?

On the stripe web portal (my business) I can see that this customer DOES have a default card, and it looks the same as any other customer, but the api side has it registered under the different section!在条带 web 门户(我的业务)上,我可以看到该客户确实有一张默认卡,并且看起来与任何其他客户相同,但 api 方面已将其注册在不同的部分下!

You can add the Card as the Customer's invoice_settings.default_payment_method yourself by calling the Update Customer API .您可以通过调用更新客户 API自己将卡添加为客户的 invoice_settings.default_payment_method。

FYI in a subscription the precedence chain is:仅供参考,订阅中的优先链是:

  1. Subscription's default_payment_method订阅的 default_payment_method
  2. Subscription's default_source订阅的 default_source
  3. Customer's invoice_settings.default_payment_method客户的 invoice_settings.default_payment_method
  4. Customer's default_source客户的 default_source

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

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