代码之家  ›  专栏  ›  技术社区  ›  Eyeball

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

  •  4
  • Eyeball  · 技术社区  · 8 年前

    我正在尝试测试用户卡资金不足的情况。

    在以下位置跟踪文档 https://stripe.com/docs/testing -卡号 4000 0000 0000 0002 会产生这样的错误。考虑来源 valid 在stripe sdk中,它生成一个源 token 但是当他们 create_source API,它返回时带有 Request req_nGnzPdJHjw4lrk: Your card was declined. -消息,即使我还没有创建任何收费。

    文件位于 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.

    所以我的问题是,当一张卡被Stripe接受,但在收取费用时资金不足时,如何测试一个场景?

    1 回复  |  直到 7 年前
        1
  •  6
  •   karllekko    7 年前

    您可以使用 4000000000000341 测试卡来自 https://stripe.com/docs/testing#cards-responses .这张卡可以保存给客户,但当您尝试收费时,您将被拒绝。

    请注意,您将得到的错误是一般性的拒绝,而不是 insufficient_funds .如果您需要测试代码对错误代码的响应方式,我建议您模拟条带API的响应。一般来说,不管具体的拒绝原因是什么,您的错误处理都是非常相似的,所以Stripe不为所有的情况提供测试卡。

    编辑 :自从我写了这个之后,Stripe添加了一个新的测试卡 4000000000009995 / tok_chargeDeclinedInsufficientFunds 对于这个特定的案例。