{% from "govuk/components/warning-text/macro.njk" import govukWarningText %} {% from "govuk/components/button/macro.njk" import govukButton %} {% macro PaymentField(component) %} {% set model = component.model %} {% set amount = model.amount %} {% set description = model.description %} {% set paymentState = model.paymentState %} {% set isPreAuthorised = paymentState and paymentState.preAuth and paymentState.preAuth.status == 'success' %}
{% if isPreAuthorised %} {# Payment already pre-authorised - show confirmation message #}

You have already authorised a payment for this form

Continue to submit the form. You will not be charged twice.

{% else %} {# No pre-authorisation - show payment form #}

{{ model.label.text if model.label and model.label.text else "Payment details required" }}

{{ description }}

{{ govukWarningText({ text: "You may see a pending transaction in your bank account but you will only be charged when you submit the form.", iconFallbackText: "Warning" }) }}

You can submit the form after you have added your payment details.

Total amount:

{{ amount }}

{{ govukButton({ text: "Add payment details", attributes: { name: "action", value: "external-" + model.name } }) }} {% endif %}
{% endmacro %}