paypal rest sdk如何识别哪个卡号属于哪个卡种?

How does paypal rest sdk identify which card number belong to which card type?

我正在尝试通过 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