1
votes

I am trying to generate a token using stripe lib and want to validate card for CVC check and other decline rule mention for the card on stripe documentation as below link.

https://stripe.com/docs/testing

Flow of stripe pay

Card Detail | Token Generation (This check only simple card validation and return) | Create payment (Authorization or Auth & Capture) - this validates all decline card rules.

I checked the stripe documentation and it generates token for every card as mention on the testing document. https://stripe.com/docs/testing

Demo code that I used - http://www.ilovephp.net/php/stripe-payment-gateway-integration-in-php-with-demo-examples/

on this example and decline rules working. But I want to generate a token on the server side with decline rules as working while the charge on the example.

1

1 Answers

0
votes

Stripe.js / Elements does not check the card with the issuing bank when creating a token, it only runs some sanity checks (correct number of digits, expiry date in the future, etc.).

In your server-side code, you can use the token to create a customer object. When creating a customer with a card token (or adding a card to an existing customer), Stripe will check the card with the issuing bank and return an error if the bank declines the $0 / $1 authorization run in the background by Stripe.

If you use Checkout to collect and tokenize the card information instead of Stripe.js, the card will be validated client-side and no token will be returned if the bank returns an error.

Also, the article you linked uses PHP code based on an older version of Stripe's PHP library. I would greatly recommend that you use the latest version of the library. You can find plenty of examples on Stripe's site, such as https://stripe.com/docs/checkout/php.