{% extends "pinax/stripe/base.html" %}


{% load bootstrap %}

{% block body_class %}{{ block.super }} pinax-stripe-subscriptions{% endblock %}

{% block content %}

{% if object %}
    {% url "pinax_stripe_subscription_update" object.pk as post_url %}
{% else %}
    {% url "pinax_stripe_subscription_create" as post_url %}
{% endif %}

<div class="pinax-stripe-subscriptions-container">
    <h4>
        {% if object %}Change{% else %}Add{% endif %} Subscription
        <span class="current-plan">{% if object %}{{ object.plan.name }}{% endif %}</span>
    </h4>
    {% if errors %}
        <div class="errors">
            {{ errors }}
        </div>
    {% endif %}
    <form data-stripe-key="{{ PINAX_STRIPE_PUBLIC_KEY }}" data-card-mount-id="card-element" data-card-errors-id="card-errors" action="{{ post_url }}" method="post">
        {% csrf_token %}
        {{ form|bootstrap }}
        {% if not request.user.customer.default_source %}
            <div id="card-element"></div>
            <div id="card-errors" role="alert"></div>
        {% endif %}
        <div class="form-actions">
            <button>{% if object %}Update{% else %}Subscribe{% endif %}</button>
        </div>
    </form>
</div>

{% endblock %}


{% block scripts %}
    {% include "pinax/stripe/_stripe_js.html" %}
    {{ block.super }}
{% endblock %}
