title: Getting "Cannot charge a customer that has no active card" on php stripe
body: <p>I'm trying to create a customer before i charge them. on my <code>charge.php</code> file i have this.</p>
  <pre><code>if (isset($_POST['stripeToken'])) {   
   
      \Stripe\Stripe::setApiKey('___stripe_secret_key_____');
  
      $api_error = false;
      $token = $_POST['stripeToken'];
      try { 
       
                           $customer = \Stripe\Customer::create(array(
                               &quot;name&quot; =&gt; $name,
                               &quot;email&quot; =&gt; $email,
                               &quot;source&quot; =&gt; $token,
                               &quot;metadata&quot; =&gt; ['id' =&gt; $uid]
                           ));
       
                           $stripe_id = $customer-&gt;id;
       
                           //update stripe ID to DB
                           User::model()-&gt;updateByPk($uid, array('stripe_id' =&gt; $stripe_id));
       
                           
                       } catch(Exception $e) {  
                           $api_error = $e-&gt;getMessage();
                       } 
       if(empty($api_error) &amp;&amp; $stripe_id) {
       
                       try { 
                           $charge = \Stripe\Charge::create(
                               array(
                                   'customer' =&gt; $stripe_id, //customer id
                                   'amount' =&gt; $_POST['stripe-amount'],
                                   'currency' =&gt; strtolower($_POST['stripe-currency']),
                                   'description' =&gt; 'US Report',
                                   'metadata' =&gt; [
                                                   'Currency' =&gt; $_POST['stripe-currency'],
                                                   'Invoice' =&gt; $_POST['ref_id'],
                                               ],
                                  'receipt_email' =&gt; $email,
                               ), array (
                                   'idempotency_key' =&gt; preg_replace('/[^a-z\d]/im', '', $_POST['idempotency']),
                               )
                           );
                       } catch(\Stripe\Exception\CardException $e) {
                          // Since it's a decline, \Stripe\Exception\CardException will be caught
                          $api_error = 'Status is:' . $e-&gt;getHttpStatus() . '&lt;br /&gt;';
                          $api_error .=  'Type is:' . $e-&gt;getError()-&gt;type . '&lt;br /&gt;';
                          $api_error .=  'Code is:' . $e-&gt;getError()-&gt;code . '&lt;br /&gt;';
                          // param is '' in this case
                          $api_error .=  'Param is:' . $e-&gt;getError()-&gt;param . '&lt;br /&gt;';
                          $api_error .=  'Message is:' . $e-&gt;getError()-&gt;message . '&lt;br /&gt;';
                        }
  </code></pre>
  <p>I'm using my own HTML form for the credit card , expiry and ccv. and included <code>https://js.stripe.com/v3/</code> in my page.</p>
  <p>When i submit my payment i get this error</p>
  <pre><code>Charge creation failed! Status is:402
  Type is:card_error
  Code is:missing
  Param is:card
  Message is:Cannot charge a customer that has no active card
  </code></pre>
  <p>Any idea what i'm missing here?</p>