title: Support 3D Secure card Stripe payment to start subscription
body: <p>My payment model idea for my application is really simple: Having a (laravel) website with a member area and some special funcionality, whereas a member account costs 19.90 / year. I wanted to integrate <a href="https://www.stripe.com" rel="nofollow noreferrer">Stripe</a> to my registration flow to allow a payment to happen. When the payment has succeeded, I create a subscription which will then automatically renew this payment each year.</p>
  
  <p>So good so far - I managed to get it working using the <a href="https://stripe.com/docs/billing/subscriptions/set-up-subscription" rel="nofollow noreferrer">Guide on how to set up a subscription</a> by Stripe. However, cards that required 3D Secure authentication did not work yet, and this is a must-have.</p>
  
  <p>So I read further and used a <a href="https://stripe.com/docs/payments/payment-intents" rel="nofollow noreferrer">PaymentIntent</a> (<a href="https://stripe.com/docs/api/payment_intents" rel="nofollow noreferrer">API Docs</a>). However, current behavior is the following:</p>
  
  <ul>
  <li>I create a PaymentIntent and pass the public key to the frontend</li>
  <li>Customer enters credentials and submits</li>
  <li>3D Secure Authentication happens correctly, returning me a payment_method_id</li>
  <li>On the server side, I retrieve the PaymentIntent again. It has status <code>succeeded</code> and the payment is recieved on my Stripe Dashboard.</li>
  <li>I then create the customer object (with the payment method I got from the PaymentIntent), and with that customer, <strong>create the subscription</strong></li>
  <li>The subscription has status <code>incomplete</code> and it seems that the subscription tries to again charge the customer but fails because of the 3D Secure validation that would be necessary the second time.</li>
  </ul>
  
  <p>So my actual question is: How can I create a subscription which notices somehow that the customer has already paid with my PaymentIntent and the PaymentMethod that I'm passing to it?</p>
  
  <h2>Some Code</h2>
  
  <h3>Create the PaymentIntent and pass that to the frontend</h3>
  
  <pre><code>\Stripe\Stripe::setApiKey(env('STRIPE_SECRET_KEY'));
  $intent = \Stripe\PaymentIntent::create([
     'amount' =&gt; '1990',
     'currency' =&gt; 'chf',
  ]);
  $request-&gt;session()-&gt;put('stripePaymentIntentId',$intent-&gt;id);
  return view('payment.checkout')-&gt;with('intentClientSecret',$intent-&gt;client_secret);
  </code></pre>
  
  <h3>Frontend Checkout when clicking "Buy"</h3>
  
  <pre><code>// I have stripe elements (the card input field) ready and working
  // using the variable "card". The Stripe instance is saved in "stripe".
  // Using "confirmCardPayment", the 3DS authentication is performed successfully.
  stripe.confirmCardPayment(intentClientSecret,{
      payment_method: {card: mycard},
      setup_future_usage: 'off_session'
  }).then(function(result) {
      $('#card-errors').text(result.error ? result.error.message : '');
      if (!result.error) {
          submitMyFormToBackend(result.paymentIntent.payment_method);
      }
      else {
          unlockPaymentForm();
      }
  });
  </code></pre>
  
  <h3>Backend after submitting</h3>
  
  <pre><code>// Get the PaymentMethod id from the frontend that was submitted
  $payment_method_id = $request-&gt;get('stripePaymentMethodId');
  // Get the PaymentIntent id which we created in the beginning
  $payment_intent_id = $request-&gt;session()-&gt;get('stripePaymentIntentId');
  \Stripe\Stripe::setApiKey(env('STRIPE_SECRET_KEY'));
  // Get the Laravel User
  $user = auth()-&gt;user();
  
  // Firstly load Payment Intent to have this failing first if anything is not right
  $intent = \Stripe\PaymentIntent::retrieve($payment_intent_id);
  if ($intent instanceof \Stripe\PaymentIntent) {
      // PaymentIntent loaded successfully.
  
      if ($intent-&gt;status == 'succeeded') {
  
          // The intent succeeded and at this point I believe the money
          // has already been transferred to my account, so it's paid.
          // Setting up the user with the paymentMethod given from the frontend (from
          // the 3DS confirmation).
          $customer = \Stripe\Customer::create([
              'payment_method' =&gt; $payment_method_id,
              'email' =&gt; $user-&gt;email,
              'invoice_settings' =&gt; [
                  'default_payment_method' =&gt; $payment_method_id,
              ],
          ]);
  
          $stripeSub = \Stripe\Subscription::create([
              'customer' =&gt; $customer-&gt;id,
              'items' =&gt; [
                  [
                      'plan' =&gt; env('STRIPE_PLAN_ID'),
                  ]
              ],
              'collection_method' =&gt; 'charge_automatically',
              'off_session' =&gt; false,
          ]);
  
          // If the state of the subscription would be "active" or "trialing", we would be fine
          // (depends on the trial settings on the plan), but both would be ok.
          if (in_array($stripeSub-&gt;status,['active','trialing'])) {
              return "SUCCESS";
          }
  
          // HOWEVER the state that I get here is "incomplete", thus it's an error.
          else {
              return "ERROR";
          }
      }
  }
  </code></pre>