title: Stripe: change credit card number?
body: <p>I'm using Stripe Payments and would like to give customers the possibility to change their credit card. Referring to <a href="https://stripe.com/docs/api#create_subscription" rel="nofollow noreferrer">https://stripe.com/docs/api#create_subscription</a> -> source, I tried the following PHP-code:</p>
  
  <pre><code>        $customer = \Stripe\Customer::retrieve($client_id);
  
          $customer = \Stripe\Customer::create(array(
          "source" =&gt; $token) //the token contains credit card details
          );
  </code></pre>
  
  <p>This works, but unfortunately it unintentionally also creates a new customer ID:</p>
  
  <p><a href="https://i.stack.imgur.com/ZZ45W.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZZ45W.jpg" alt="Stripe Dashboard"></a></p>
  
  <p>The original customer ID was <em>cus_6elZAJHMELXkKI</em> and I would like to keep it.</p>
  
  <p>Does anybody know the PHP-code that would update the card without creating a new customer?</p>
  
  <p>Thank you very much in advance!</p>
  
  <blockquote>
    <p>PS: Just in case you need it – this was the code that originally
    created the customer and the subscription:</p>
  
  <pre><code>$customer = \Stripe\Customer::create(array(
      "source" =&gt; $token,
      "description" =&gt; "{$fn} {$ln}",
      "email" =&gt; $e,
      "plan" =&gt; "basic_plan_id")
   );
  
  \Stripe\Charge::create(array(
    "amount" =&gt; 10000, # amount in cents, again
    "currency" =&gt; "eur",
    "customer" =&gt; $customer-&gt;id)
  );
  </code></pre>
  </blockquote>