测试-将拒绝的卡片设置给客户

时间:2018-08-30 13:10:12

标签: node.js testing stripe-payments

我想用拒绝的卡更新客户,以进行测试。

但如果我这样做:

Stripe.customers.update(stripeCustomer.id, {
    source: 'tok_chargeDeclined', // Token provided by stripe of a declined card
});

我遇到异常:

  

调用方法'stripe.test'时发生异常{错误:您的卡   拒绝了。

我缺少什么?

1 个答案:

答案 0 :(得分:1)

当您将卡连接到客户时(例如通过该更新呼叫),Stripe会对卡临时收取$ 0的费用,以进行验证并确保以后可以成功向客户收费。在https://stripe.com/docs/saving-cards#saving-credit-card-details-for-later中有提及。

当您附加tok_chargeDeclined时,这笔费用会被拒绝,并且不会将卡添加到客户中。要测试可以成功将卡添加到客户但后来被拒绝的情况(例如,该卡以后过期或没有资金),可以使用https://stripe.com/docs/testing#cards-responses中的tok_chargeCustomerFail