Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Kipperman's avatar

Stripe customer can't be charged with active card

I have followed the Stripe Checkout Turorial and have added the "e" to the function parameter. But yet I still get the error that I can't charge a customer?

document.querySelector('button').addEventListener('click', function(e) {

   stripe.open({
        
        name: 'My Book',
        description: 'Book Description',
        zipCode: true,
        amount:4500                        
        
    });
    
    e.preventDefault();
    
}); 

Any reason why I am still getting that error?

0 likes
5 replies
willvincent's avatar

Is your stripe account in test mode?

What is the specific error message you're seeing?

1 like
WebKenth's avatar

the e is the event submitted by the form, by calling the preventDefault() method you are stopping the form from submitting, this has nothing to do with the stripe code

Kipperman's avatar

I am currently away from my PC at the moment. But the specific error I am getting is found on Jefferys video. Stripe Checkout Episode 2 at around the half way point. And I am under test mode

I'm not sure what you mean WebKenth - Jeffery has the same error prior to adding the e.preventdefault...and then he adds it to the form and it works. I'm getting the same error wether I have the preventdefault or not.

Kipperman's avatar

Here is the Error -

Card in ApiRequestor.php line 112:

Cannot charge a customer that has no active card

  1. in ApiRequestor.php line 112 2.at ApiRequestor->handleApiError('{ "error": { "message": "Cannot charge a customer that has no active card", "type": "card_error", "param": "card", "code": "missing" } } ', '402', array('Server' => 'nginx', 'Date' => 'Sat, 03 Dec 2016 19:40:02 GMT', 'Content-Type' => 'application/json', 'Content-Length' => '157', 'Connection' => 'keep-alive', 'Access-Control-Allow-Credentials' => 'true', 'Access-Control-Allow-Methods' => 'GET, POST, HEAD, OPTIONS, DELETE', 'Access-Control-Allow-Origin' => '*', 'Access-Control-Max-Age' => '300', 'Cache-Control' => 'no-cache, no-store', 'Request-Id' => 'req_9g5Xb6TP2RevCk', 'Stripe-Version' => '2016-07-06'), array('error' => array('message' => 'Cannot charge a customer that has no active card', 'type' => 'card_error', 'param' => 'card', 'code' => 'missing'))) in ApiRequestor.php line 259
Evermore's avatar

I am experiencing same issues, did u find a fix for this?

Please or to participate in this conversation.