Stripe通过获取客户来获取卡的详细信息

时间:2019-12-03 18:11:40

标签: javascript node.js stripe-payments

我正在尝试获取带有条纹的客户卡详细信息,我只有客户ID和Payment_method ID,我如何使用此ID来检索卡详细信息。主要是卡的后四位

我已经尝试购买以获取客户对象,但是它没有卡的最后4位数字。有谁知道如何使用客户ID或付款方式ID取回

stripe.customers.retrieve(
    req.body.customerId,
    function(err, customer) {
      // asynchronously called
      res.send(customer)
    }
);

2 个答案:

答案 0 :(得分:0)

sources对象上检查Customer。例如

stripe.customers.retrieve(
    req.body.customerId,
    function(err, customer) {
        // asynchronously called
        res.send(customer.sources.data[0].last4)
    }
);

参考:https://stripe.com/docs/api/customers/object

答案 1 :(得分:0)

 stripe.paymentMethods.retrieve(
     req.body.paymentId,
    function(err, paymentMethod) {
      // asynchronously called
      res.send(paymentMethod.card.last4)
    }
  );
相关问题