Getting started with Craft Commerce 2 subscriptions using Stripe I’m new to Craft Commerce and am really having trouble getting started with subscriptions.

I used the example from the docs and nothing happened. When reloading the cp though, it kept telling me "Unable to start the subscription. Please check your payment details." I learned from the docs that "Subscribing a user to a plan requires that the user have a stored payment source." So I added the getPaymentFormHtml bit. Without any success. Not to mention error messages of any kind. 

This is my template so far:

&lt;ul&gt;
{% for item in craft.session.getFlashes() %}
    &lt;li&gt;{{item}}&lt;/li&gt;
{% endfor %}
&lt;/ul&gt;

{% set plans = craft.commerce.getPlans().getAllPlans() %}

&lt;form method="POST"&gt;
    &lt;input type="hidden" name="action" value="commerce/subscriptions/subscribe"&gt;

    {{ csrfInput() }}

    &lt;div&gt;
        {% for plan in plans %}
            &lt;input type="hidden" name="planUid" value="{{ plan.uid|hash }}"/&gt;

            {# Display only if the user does not have a payment soure saved #}
            {{ plan.getGateway().getPaymentFormHtml({})|raw }}

        {% endfor %}
    &lt;/div&gt;

    &lt;button type="submit"&gt;{{ "Subscribe"|t('commerce') }}&lt;/button&gt;
&lt;/form&gt;


I’ve set up a subscription in the cp, added store information and tried a valid testing card from the stripe docs. But even then it keeps giving me the above flash notice.

Could anybody shed some light here? Am I missing anything obvious?
So I had trouble with the demo's also. But if you head into the Craft Demo Store Templates you will find the following demo page you can use. Here's what I used to get it working.

{% set plans = craft.commerce.getPlans().getAllPlans() %}

{% if currentUser and plans|length%}
    {% for plan in plans %}
        &lt;div class="md:flex service"&gt;
            &lt;div class="md:w-1/4"&gt;
                &lt;h2 class="mt-8"&gt;{{ plan.name }}&lt;/h2&gt;
                {% set information = plan.getInformation() %}
            &lt;/div&gt;
            &lt;div class="md:w-3/4 md:mt-8 md:pt-4"&gt;
                {% set subscriptions = plan.getActiveUserSubscriptions(currentUser.id) %}
                {% if subscriptions|length == 0 %}
                    &lt;p&gt;&lt;strong&gt;You have no subscriptions to this plan.&lt;/strong&gt;&lt;/p&gt;
                {% endif %}
                {% if subscriptions|length &gt; 1 %}
                    &lt;p&gt;&lt;strong&gt;You have multiple subscriptions to this plan.&lt;/strong&gt;&lt;/p&gt;
                {% endif %}
                {% for subscription in subscriptions %}
                    {% if subscription.isCanceled %}
                        Your subscription was canceled on {{ subscription.dateCanceled|date('Y-m-d') }} and will expire on {{ subscription.nextPaymentDate|date('Y-m-d') }}
                    {% else %}
                        You are subscribed and your next payment is due on {{ subscription.nextPaymentDate|date('Y-m-d') }}
                    {% endif %}
                    &lt;br /&gt;&lt;br /&gt;

                    &lt;a href="{{ url('/shop/services/subscription', {subscription: subscription.id}) }}"&gt;Manage subscription&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                {% endfor %}
            &lt;/div&gt;
        &lt;/div&gt;
        {% if loop.last %}
            &lt;hr /&gt;
        {% endif %}
    {% endfor %}
    &lt;div class="md:flex"&gt;
        &lt;div class="md:w-1/4"&gt;
            &lt;h2&gt;Available plans&lt;/h2&gt;
        &lt;/div&gt;
        &lt;div class="md:w-3/4 md:pt-4"&gt;
            {% for plan in plans %}
                &lt;form method="POST"&gt;
                    &lt;input type="hidden" name="action" value="commerce/subscriptions/subscribe"&gt;
                    &lt;input type="hidden" name="planUid" value="{{ plan.uid|hash }}"&gt;
                    {{ redirectInput('shop/services') }}
                    {{ csrfInput() }}

                    &lt;h4&gt;{{ plan.name }}&lt;/h4&gt;

                    &lt;select name="trialDays" data-plan="{{ plan.id }}"&gt;
                        {% for i in [0, 3, 7, 14] %}
                            {% if i == 0 %}
                                &lt;option value="{{ (plan.uid~':0')|hash}}"&gt;No trial period.&lt;/option&gt;
                            {% else %}
                                &lt;option value="{{ (plan.uid~':'~i)|hash  }}"&gt;Trial for {{ i }} days&lt;/option&gt;
                            {% endif %}
                        {% endfor %}
                    &lt;/select&gt;

                    {% set paymentSources = craft.commerce.getPaymentSources().getAllGatewayPaymentSourcesByUserId(plan.gateway.id, currentUser.id ?? null) %}

                    {% if not paymentSources|length %}
                        &lt;div class="paymentForm"&gt;
                            {{ plan.gateway.getPaymentFormHtml({})|raw }}
                        &lt;/div&gt;
                    {% endif %}

                    &lt;button type="submit"&gt;{{ "Subscribe"|t }}&lt;/button&gt;
                &lt;/form&gt;
            {% endfor %}
        &lt;/div&gt;
    &lt;/div&gt;
{% endif %}