Validation card validation behaves differently in development versus production

I am having a weird issue with Stripe (on Rails, but the Rails part probably doesn't matter).

When I fill out my registration form in production with a syntactically valid but non-working card number (for example, 424242424242424242), I get this answer when I try to create a token:

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

When in development I use the card number "always returns card_declined " (4000000000000002), Stripe accepts it as if it were perfectly good:

 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) 

So it seems that either this part of the Stripe API does not work as advertised , or I myself am making some kind of stupid mistake or something like that.

I was a little confused. Any thoughts?

+8
stripe-payments credit-card
source share
1 answer

I cannot confirm the accuracy of the following, but this is the best of my understanding. Feel free to set me straight if you know better.

Two actions are performed when the user creates an account:

  • tokens. This happens with an XHR request.
  • Create an account. This happens on the server side.

In the Stripe test mode, I understand that all numbers that pass the Luhn test will be successfully marked, including significantly, the special numbers of the Stripe tests. If a (correct) failure occurs when an account is created on the server side.

In Stripe live mode, I understand that all numbers that pass the Luhn test will be successfully displayed. EXCLUSIVE REQUIREMENTS. Stripe will reject these numbers precisely because they are Stripe test numbers.

Thus, the best solution I can come up with is telling the client that the Stripe test numbers will always fail in production, and our options are: a) live with this or b) write code that will specifically catch the Stripe test numbers and present manufacturing error when these numbers are used.

+6
source share

All Articles