Answers.Body: <p>If you have a look at the docs <a href="https://github.com/craftcms/commerce-stripe/tree/4.x?tab=readme-ov-file#api-version" rel="nofollow noreferrer">here</a>, from v4 onwards the way Subscriptions work has been updated quite significantly. Have a more thorough read through and make sure you've made all the necessary changes. We had quite a few similar issues when we upgraded, and we had missed some of the detail in the docs. Stuff like...</p>
  <ol>
  <li>The API version in Stripe will likely need changing to a more modern version (2022-11-15 is now the minimum). We updated to the very latest version and that works fine.</li>
  <li>You aren't able to use the <code>commerce/subscriptions/subscribe</code> to also add payment sources. You need to have already added the Payment Source to Stripe before you use it to subscribe.</li>
  </ol>
  <p>Also take a look at the <a href="https://github.com/craftcms/commerce/tree/4.x/example-templates/dist/shop" rel="nofollow noreferrer">example templates</a> and see if there's any differences to what you have. If you're able to, see if you can use the templates as-is in your project to see if they work. There were some small details in there that we'd missed, such as the payment forms being namespaced. One final thing, make sure you've got an <code>update-billing-details</code> template setup (it's in the example templates linked) and added to your Commerce settings. If any of your subscribers have issues with their cards (expired, run out of money, need 3DS verification (in UK), this page will help with that.</p>
  <p>Hopefully, there's something in amongst this lot that might help, best of luck.</p>
  <p><strong>[Edit]</strong> Failing all of that, you might be as well to post the issue on <a href="https://github.com/craftcms/commerce-stripe/issues" rel="nofollow noreferrer">Github</a>. In the end we've ended up using a dev branch of the Commerce Stripe plugin to resolve our issues (it was 3DS related, so might not be relevant to you).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-08-07T07:31:54.693Z
Answers.LastActivityDate: 2024-08-14T16:10:59.933Z
Answers.LastEditDate: 2024-08-14T16:10:59.933Z
Answers.UserDisplayName: Steve Holland
Body: <p>My subscription process with stripe payment form is not showing up anymore in Craft V4.<br />
  CraftCMS 4.6.1 + Craft Commerce 4.4.1.1 + Stripe for Craft Commerce 4.1.2.3.</p>
  <p>I got this message now:<br />
  <code>Can not use the Stripe payment form to subscribe. Please create a payment source first. </code></p>
  <p>Here the code of my signup page:</p>
  <pre><code>{% set plan1 = craft.commerce.getPlans().getPlanByHandle('membershipPlan5MonthlyTest') %}
  {% set paymentSources = craft.commerce.getPaymentSources().getAllGatewayPaymentSourcesByCustomerId(plan1.gateway.id, currentUser.id ?? null) %}
  
  &lt;div class=&quot;paymentForm&quot;&gt;
    {{ plan1.gateway.getPaymentFormHtml({})|raw }}
  &lt;/div&gt;
  </code></pre>
  <p>For info I mounted an old version of the project with Craft V3 and it is still working.<br />
  So the problem does not come from Stripe...</p>
  <p>Any ideas as to how to fix this?</p>
  
Tags: <craft4><plugin-commerce-stripe><commerce-subscriptions>
Title: Craft CMS Stripe payment form not working anymore in Craft V4
ThreadText: # Craft CMS Stripe payment form not working anymore in Craft V4
  
  (Asked by: username_0 on 2024-07-24)
  
  My subscription process with stripe payment form is not showing up anymore in Craft V4.  
  CraftCMS 4.6.1 + Craft Commerce 4.4.1.1 + Stripe for Craft Commerce 4.1.2.3.
  
  I got this message now:  
  `Can not use the Stripe payment form to subscribe. Please create a payment source first.`
  
  Here the code of my signup page:
  
  ```
  {% set plan1 = craft.commerce.getPlans().getPlanByHandle('membershipPlan5MonthlyTest') %}
  {% set paymentSources = craft.commerce.getPaymentSources().getAllGatewayPaymentSourcesByCustomerId(plan1.gateway.id, currentUser.id ?? null) %}
  
  <div class="paymentForm">
    {{ plan1.gateway.getPaymentFormHtml({})|raw }}
  </div>
  
  ```
  
  For info I mounted an old version of the project with Craft V3 and it is still working.  
  So the problem does not come from Stripe...
  
  Any ideas as to how to fix this?
  
  **Tags:** craft4, plugin-commerce-stripe, commerce-subscriptions
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-08-07. Score: 1
  
  If you have a look at the docs [here](https://github.com/craftcms/commerce-stripe/tree/4.x?tab=readme-ov-file#api-version), from v4 onwards the way Subscriptions work has been updated quite significantly. Have a more thorough read through and make sure you've made all the necessary changes. We had quite a few similar issues when we upgraded, and we had missed some of the detail in the docs. Stuff like...
  
  1. The API version in Stripe will likely need changing to a more modern version (2022-11-15 is now the minimum). We updated to the very latest version and that works fine.
  2. You aren't able to use the `commerce/subscriptions/subscribe` to also add payment sources. You need to have already added the Payment Source to Stripe before you use it to subscribe.
  
  Also take a look at the [example templates](https://github.com/craftcms/commerce/tree/4.x/example-templates/dist/shop) and see if there's any differences to what you have. If you're able to, see if you can use the templates as-is in your project to see if they work. There were some small details in there that we'd missed, such as the payment forms being namespaced. One final thing, make sure you've got an `update-billing-details` template setup (it's in the example templates linked) and added to your Commerce settings. If any of your subscribers have issues with their cards (expired, run out of money, need 3DS verification (in UK), this page will help with that.
  
  Hopefully, there's something in amongst this lot that might help, best of luck.
  
  **[Edit]** Failing all of that, you might be as well to post the issue on [Github](https://github.com/craftcms/commerce-stripe/issues). In the end we've ended up using a dev branch of the Commerce Stripe plugin to resolve our issues (it was 3DS related, so might not be relevant to you).
  
  
  ---
  
  