Stripe.Customers.listSources 不返回任何内容

Alk*_*Alk 5 javascript credit-card node.js stripe-payments

我创建了以下代码来为我的客户获取所有卡片:

return stripe.customers.listSources(customerId, {
    object: "card",
    limit: 10
}).then(cards => {
    if (cards) {
        res.status(200).send({
            cards: cards.data
        });
        return;
    }
    res
        .status(500)
        .send({ error: "error getting cards" });

})
    .catch(error => {
        console.log(error);
        res.status(500).send({ error: "error getting cards" });
    });
Run Code Online (Sandbox Code Playgroud)

遵循本文档:

https://stripe.com/docs/api/cards/list

我还向我的客户添加了测试卡,这些测试卡在仪表板中可见:

在此输入图像描述

但 API 总是返回以下结果:

{
  object: 'list',
  data: [],
  has_more: false,
  url: '/v1/customers/<my_cus_id>/sources'
}
Run Code Online (Sandbox Code Playgroud)

Alk*_*Alk 9

看起来用这个代替是有效的:

stripe.paymentMethods.list(
   { customer: customerId, type: "card" }
)
Run Code Online (Sandbox Code Playgroud)

https://stripe.com/docs/api/ payment_methods/list