{% extends 'shop/_layouts/checkout' %} {% block content %}

Payment

{# ╔══════════════════════════════════════════════════╗ ║ ┌───────────────────────────────────────────┐ ║ ║ │ Set up variables and check if we have any │ ║ ║ │ gateways set up. │ ║ ║ └───────────────────────────────────────────┘ ║ ╚══════════════════════════════════════════════════╝ #} {# Get the available payment sources the user has to be used later in this page. #} {% set storedCards = craft.commerce.paymentSources.allPaymentSourcesByUserId(currentUser.id ?? null) %} {# Get the available gateways to be used later in this page #} {% set availableGateways = craft.commerce.gateways.allCustomerEnabledGateways %} {# If there are no gateway then payment sources wont work either, so lets #} {% if availableGateways is empty %}

No payment methods available.

{% endif %} {# ╔══════════════════════════════════════════════════╗ ║ ┌───────────────────────────────────────────┐ ║ ║ │ This form updates the order with the │ ║ ║ │ preferred payment source or gateway, as │ ║ ║ │well as allowing the selection of a payment│ ║ ║ │ currency if more than one is set up. │ ║ ║ └───────────────────────────────────────────┘ ║ ╚══════════════════════════════════════════════════╝ #} {% if availableGateways|length %}
{{ redirectInput('shop/checkout/payment') }} {{ csrfInput() }} {% set currencies = craft.commerce.paymentCurrencies.allPaymentCurrencies %} {% if currencies|length > 1 %} {% endif %}
{% endif %} {% js %} // If the payment currency changes, submit the form immediately $('#paymentCurrency').change(function(){ $('form#paymentPreferenceForm').submit(); }); $('#paymentMethod').change(function(ev){ $select = $(ev.currentTarget); if ($select.val().length === 0) { return; } var parts = $select.val().split(':'); var name = 'gatewayId'; if (parts[0] === 'card') { name = 'paymentSourceId'; } $select.prop('disabled', 'disabled'); $('form#paymentPreferenceForm').append('').submit(); }); {% endjs %} {% if cart.gatewayId or cart.paymentSourceId %}
{{ redirectInput('/shop/customer/order?number='~cart.number) }} {{ csrfInput() }}
{% if cart.gatewayId %} {{ cart.gateway.getPaymentFormHtml({})|raw }} {% if cart.gateway.supportsPaymentSources() and currentUser %}

{% endif %} {% else %} {{ cart.gateway.getPaymentConfirmationFormHtml({})|raw }} {% endif %} {% set user = craft.users.email(cart.email).one() %} {% if not user %} {% endif %}
{% endif %}
{% include "shop/_includes/order-review" with { showShippingAddress: true, showShippingMethod: true } %}
{% js %} $('#paymentForm').on('submit', function (ev) { $form = $(this); if ($form.data('processing')) { ev.preventDefault(); return false; } $form.data('processing', true); }); {% endjs %} {% endblock %}