credit-card - Stripe 卡验证在开发和生产中的行为不同

标签 credit-card stripe-payments

我在使用 Stripe 时遇到了一个奇怪的问题(在 Rails 上,但 Rails 部分可能无关紧要)。

当我使用语法有效但非工作卡号(例如 4242424242424242)在生产中填写我的注册表单时,我在尝试创建 token 时收到此响应:

sjsonp1389885476573({
  "error": {
    "message": "Your card was declined.",
    "type": "card_error",
    "code": "card_declined"
  }
}
, 402)

在开发过程中,我使用“总是返回 card_declined”卡号(4000000000000002),Stripe 认为它非常好:
sjsonp1389885473743({
  "id": "tok_3JvncLYlEZ5NMF",
  "livemode": false,
  "created": 1389885584,
  "used": false,
  "object": "token",
  "type": "card",
  "card": {
    "id": "card_3Jvnr4MtIxzzd5",
    "object": "card",
    "last4": "0002",
    "type": "Visa",
    "exp_month": 2,
    "exp_year": 2020,
    "fingerprint": "dWQBpXrSXnyqoOxe",
    "customer": null,
    "country": "US",
    "name": null,
    "address_line1": null,
    "address_line2": null,
    "address_city": null,
    "address_state": null,
    "address_zip": null,
    "address_country": null,
    "address_line1_check": null,
    "address_zip_check": null,
    "cvc_check": null
  }
}
, 200)

所以似乎这部分 Stripe 的 API 不起作用 as advertised或者我自己正在犯一些愚蠢的错误或其他什么。

我有点不知所措。有什么想法吗?

最佳答案

我无法证明以下内容的准确性,但这是我最好的理解。如果你知道的更好,请随时告诉我。

用户创建帐户时会发生两个步骤:

  • 标记化。这是通过 XHR 请求发生的。
  • 帐户创建。这发生在服务器端。

  • 在 Stripe 测试模式下,我知道所有通过 Luhn 检查的数字都将被成功标记,包括,重要的是,Stripe 的特殊测试数字。发生(正确)失败的地方是服务器端帐户创建发生时。

    在 Stripe 实时模式下,我知道所有通过 Luhn 检查的数字都将被成功标记,除了 Stripe 的测试数字。 Stripe 会拒绝这些数字,因为它们是 Stripe 的测试数字。

    所以我能想到的最佳解决方案 是告诉客户 Stripe 的测试编号在生产中总是会默默地失败,我们的选择是 a) 接受它或 b) 编写代码来专门捕获 Stripe 测试编号并在使用这些编号时在生产中显示错误.

    关于credit-card - Stripe 卡验证在开发和生产中的行为不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21165884/

    相关文章:

    java - MagTek——uDynamo (DUKPT)

    credit-card - 我需要生成保留格式的信用卡代理( token )

    android - 不受支持的国家/地区的应用内计费

    Angular Ngx Stripe 错误 : Property 'id' does not exist on type 'Object'

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

    php - 如何修复 Stripe Payment Intent 中客户端或服务器端的 3D 安全确认付款?

    安卓和 iOS : storage of credit card data

    cordova - MOBILE SDK PAYPAL 直接信用卡支付 - 英国、美国以外

    ruby-on-rails - Stripe API 无效请求 : Must provide source or customer

    ssl - 处理付款和搭载 ssl