title: Please attach the payment method to this Customer before using it with a SetupIntent | Migrating stripe subscription to be SCA compliant
body: <p>I have a subscription, I collect card details on signup with a 7 day trial, after which the subscription bills monthly.</p>
  
  <p>I have followed the documentation to <a href="https://stripe.com/docs/billing/subscriptions/payment" rel="nofollow noreferrer">create a subscription</a>. </p>
  
  <p>Testing the flow with a fake card <a href="https://stripe.com/docs/payments/cards/saving-cards#testing" rel="nofollow noreferrer"><code>4000002500003155</code></a> which requires setup, I encountered an issue.</p>
  
  <p>My setup is as follows.</p>
  
  <ol>
  <li>Frontend does <code>stripe.createToken()</code></li>
  <li>Server does <code>stripe.customers.update(customer_id, { source })</code> with token </li>
  <li><p>Server creates the subscription</p>
  
  <pre><code>  stripe.subscriptions.create({
      customer: self.stripe_customer_id,
      tax_percent: 20,
      expand: ['latest_invoice.payment_intent', 'pending_setup_intent'],
      ...plan
    }
  </code></pre></li>
  <li>As expected the subscription response <code>subscription.pending_setup_intent</code> is not null and has <code>{ client_secret: 'seti__', status: 'requires_action', payment_method: 'card___', ... }</code>.</li>
  <li>On the frontend I attempt to handle the pending setup intent on the frontend with <code>stripe.handleCardSetup(client_secret, {});</code> but I got the following error.</li>
  </ol>
  
  <blockquote>
    <p>The payment method supplied (pm____) does not belong to a Customer, but you supplied Customer cus____. Please attach the payment method to this Customer before using it with a SetupIntent.</p>
  </blockquote>
  
  <p>I tried to remedy this by attaching the paymentMethod to the user before step 5</p>
  
  <pre><code>stripe.paymentMethods.attach('card____', {
    customer: customer_id
  });
  </code></pre>
  
  <p>But I got the following error </p>
  
  <blockquote>
    <p>The payment method you provided has already been attached to a customer.</p>
  </blockquote>
  
  <hr>
  
  <h3>Update</h3>
  
  <p>I replaced steps 1 and 2 by <a href="https://stripe.com/docs/payments/cards/saving-cards#saving-card-without-payment" rel="nofollow noreferrer">attaching payment method from setupIntent to the customer</a> using <code>handleCardSetup</code> and <code>paymentMethods.attach</code>. I was able to succesfully create subscription after that point. <code>subscription.pending_setup_intent</code> is then returned as <code>null</code> which means it is successful.</p>
  
  <p>For those who want some starter code, <a href="https://glitch.com/edit/#!/stripe-sca-subscription-react?path=README.md:22:0" rel="nofollow noreferrer">I created a working playground here with subscriptions, frontend (react) and backend (express) on glitch</a>.</p>
  
  <p><img src="https://user-images.githubusercontent.com/1690659/65525116-e8bc2700-dee6-11e9-814f-96ece40653cd.gif" alt="edAUunAs5S"></p>