我正在尝试通过 paypal-rest-node sdk 集成 paypal 支付系统,但我对如何区分哪些卡号属于哪些卡类型有点困惑
例如
这些是我直接从他们的 github 页面复制的代码,但在他们的信息之一中,它说 "type:""visa"
。所以从技术上讲,在客户端,用户会输入一些东西,然后他们会点击表单提交将数据发送到服务器。但我对类型有点困惑。
var card_data = {
"type": "visa",
"number": "4417119669820331",
"expire_month": "11",
"expire_year": "2018",
"cvv2": "123",
"first_name": "Joe",
"last_name": "Shopper"
};
paypal.creditCard.create(card_data, function(error, credit_card){
if (error) {
console.log(error);
throw error;
} else {
console.log("Create Credit-Card Response");
console.log(credit_card);
}
})
API 不能告诉哪些卡号属于哪种卡类型吗?
最佳答案
您可以使用类似 credit-card-type 的模块
let creditCardType = require('credit-card-type');
let visaCards = creditCardType(yourCCNumber);
console.log(visaCards[0].type); // Type
关于node.js - paypal rest sdk如何识别哪个卡号属于哪个卡种?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38917381/