首页 文章

如何使用条带添加资金不足的付款来源?

提问于
浏览
2

我正在尝试测试用户卡没有足够资金的情况 .

https://stripe.com/docs/testing的文档之后 - 卡号 4000 0000 0000 0002 应该产生这样的错误 . 源代码在Stripe SDK中被认为是 valid ,它会生成一个源 token ,但在调用它们的 create_source API时,它会返回 Request req_nGnzPdJHjw4lrk: Your card was declined. -message,即使我还没有创建任何费用 .

https://stripe.com/docs/saving-cards的文件说明:

Stripe validates card information when it is saved. This does not guarantee that any future charges succeed (e.g., the card no longer has sufficient funds, is reported lost or stolen, or if the account is closed). This process also includes the results of any checks, including traditional bank checks by Radar (e.g., CVC or postal code), that may have been performed.

所以我的问题是,当一张卡被条带接受时,我如何测试一个场景,但是在捕获的那一刻,收费有足够的资金?

1 回答

  • 5

    您可以使用https://stripe.com/docs/testing#cards-responses中的 4000000000000341 测试卡 . 此卡可以保存给客户,但是当您尝试对其进行充电时,您的卡会下降 .

    请注意,您将获得的错误是一般性下降,而不是 insufficient_funds . 如果您需要测试代码如何专门响应该错误代码,我建议您只是模拟Stripe API的响应 . 通常,无论具体的拒绝原因,您的错误处理都会非常相似,因此Stripe不会为所有情况提供测试卡 .

相关问题