简体   繁体   English

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

[英]Testing - set declined card to a customer

I want to update a customer with a declined card for testing purposes. 我想用拒绝的卡更新客户以进行测试。

But if I do: 但是如果我这样做:

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

I get an exception: 我有一个例外:

Exception while invoking method 'stripe.test' { Error: Your card was declined. 调用方法'stripe.test'时发生异常{错误:您的卡被拒。

What I am missing? 我缺少什么?

When you attach a card to a customer(for example with that update call), Stripe makes a temporary $0 charge against the card, to validate it and ensure you can charge the customer successfully later. 当您将卡连接到客户时(例如,通过该更新呼叫),Stripe会对卡临时收取$ 0的费用,以进行验证并确保以后可以成功向客户收费。 This is mentioned at https://stripe.com/docs/saving-cards#saving-credit-card-details-for-later . https://stripe.com/docs/saving-cards#saving-credit-card-details-for-later中提到了这一点。

When you attach tok_chargeDeclined , this charge is declined and the card is not added to the customer. 当您附加tok_chargeDeclined ,此费用将被拒绝,并且不会将卡添加到客户。 To test the case where a card can be successfully added to a customer, but declined later(ie if it later expires or has no funds), you can use the tok_chargeCustomerFail card from https://stripe.com/docs/testing#cards-responses 要测试卡可以成功添加到客户但又被拒绝的情况(即,如果它以后过期或没有资金),可以使用https://stripe.com/docs/testing#cards上tok_chargeCustomerFail-responses

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM