[英]How to validate if the Credit card is valid or not through Stripe
I wanted to check if the Credit card details are valid or not.我想检查信用卡详细信息是否有效。 Precisely not just the format but if at all that these details are valid or not.不仅仅是格式,还有这些细节是否有效。 Is there a way to check that through Stripe API.有没有办法通过 Stripe API 进行检查。
If no, is there a way to make a payment of zero dollars.如果没有,有没有办法支付零美元。 Does Stripe deduct any payment charges (any additional charges) in that case?在这种情况下,Stripe 是否会扣除任何付款费用(任何额外费用)?
I prefer doing this through Stripe Javascript(Node js) SDK.我更喜欢通过 Stripe Javascript(Node js) SDK 来做到这一点。
You can try "stripe.tokens.create" to create a credit card token.您可以尝试“stripe.tokens.create”来创建信用卡令牌。 The code for creating the token is shown below:创建令牌的代码如下所示:
'use strict';
const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
const token = await stripe.tokens.create({
card: {
number: '4242424242424242',
exp_month: 4,
exp_year: 2022,
cvc: '314',
},
});
This code returns the created card token if successful.如果成功,此代码将返回创建的卡令牌。 Otherwise, this call raises an error.否则,此调用会引发错误。 You can read about this method at this link .您可以在此链接中阅读有关此方法的信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.