{% extends 'shop/_layouts/main' %} {% if not currentUser %} {% exit 404 %} {% endif %} {% block main %} {% set paymentSources = craft.commerce.paymentSources.getAllPaymentSourcesByUserId(currentUser.id) %} {% if paymentSources|length %}

Manage Cards

{% for paymentSource in paymentSources %}
{{ paymentSource.description }}
{{ paymentSource.gateway.name }}
{{ csrfInput() }} {{ redirectInput('/shop/customer/cards') }}
{% endfor %} {% endif %}

Add Card

{% for gateway in gateways %} {% if gateway.supportsPaymentSources() %} {% endif %} {% endfor %}
{% js %} $('#gatewayId').change(function(ev){ $('.gateway-fields').addClass('hidden'); $('#fields-'+ev.currentTarget.value).removeClass('hidden'); }); {% endjs %} {% js %} $('.paymentSource-form').on('submit', function (ev) { $form = $(this); if ($form.data('processing')) { ev.preventDefault(); return false; } $form.data('processing', true); }); {% endjs %} {% endblock %}