/** * Get the 'STRIPE_SECRET_KEY' and 'STRIPE_PUBLISHABLE_KEY' from * https://dashboard.stripe.com/test/apikeys After you login * * Get the 'STRIPE_WEBHOOK_SECRET' from * https://dashboard.stripe.com/test/webhooks After you login */define("STRIPE_SECRET_KEY","sk_test_xxx");
define("STRIPE_PUBLISHABLE_KEY","pk_test_xxx");
define("STRIPE_WEBHOOK_SECRET","whsec_xxx");
Run the PHP program
$ php -S localhost:5000
Run the your ngrok program
$ ngrok http 5000
Copy the external url from ngrok to the webhook settng of Stripe console
https://dashboard.stripe.com/test/webhooks
Access the pages
One input card
http://localhost:5000/web/one-input-card.php
Multi input card
http://localhost:5000/web/multi-input-card.php
Other(AliPay, WeChatPay)
http://localhost:5000/web/others.php
To limit specify card
/** * If you would like to handle card, e.g.Limit only visa * https://stripe.com/docs/js/element/events/on_change?type=cardElement */card.on('change',function(event){if(event.error){// show validation to customer}vardisplayError=document.getElementById('card-errors');if(event.brand==='visa'){// to do the logicdisplayError.textContent='';}else{displayError.textContent='only visa';}});