A.vanBelzen
A.vanBelzen

Reputation: 21

Stripe error 402 in ruby on rails: does not recognize card number

So I am new to both ruby on rails and stripe and am working on integrating a payment service on my website made with ruby on rails. I am using a guide to help me with this.

After I filled in the information in my form and click submit I receive this message:

Blockquote undefined local variable or method `stripe_card_token' for # Did you mean? stripe_customer_token

Looking in my stripe log I find the error message:

{ 
   error:
   {
    message: "Your card number is incorrect."
    type: "card_error"
    param: "number"
    code: "incorrect_number"
   }
}

So at this point it is pretty clear that stripe has problem with my card number. But I find this very odd as I am working in test mode (stripe receives my publishable test key) and am using the card number for visa and American Express that stripe suggested themselves. See their suggestions here:https://stripe.com/docs/testing.

So I am really at a loss where the problem could possibly lie. This brings me to my question: What possible mistake could I have made that leads to this error message aside from the things I have already mentioned.

Upvotes: 2

Views: 571

Answers (1)

Anthony E
Anthony E

Reputation: 11245

Make sure you're using the Stripe keys for test mode, not live mode. They should start with 'sk_test', and 'pk_test' and you can get the keys from your Stripe dashboard:

enter image description here

If your site is using the "live" Stripe keys, then the test cards won't work.

Upvotes: 0

Related Questions