Skip to content

Commit 4098209

Browse files
committed
WIP: add paymentfield.html
1 parent 1e07fac commit 4098209

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{% from "govuk/components/fieldset/macro.njk" import govukFieldset %}
2+
{% from "govuk/components/warning-text/macro.njk" import govukWarningText %}
3+
{% from "govuk/components/button/macro.njk" import govukButton %}
4+
5+
{% macro PaymentField(component) %}
6+
{% set model = component.model %}
7+
{% set paymentState = model.paymentState %}
8+
{% set amount = model.amount %}
9+
{% set description = model.description %}
10+
11+
{% set paymentContent %}
12+
<p class="govuk-body">{{ description }}</p>
13+
14+
{{ govukWarningText({
15+
text: "You may see a pending transaction in your bank account but you will only be charged when you submit the form.",
16+
iconFallbackText: "Warning"
17+
}) }}
18+
19+
<p class="govuk-body">You can submit the form after you have added your payment details.</p>
20+
21+
<p class="govuk-body govuk-!-margin-bottom-1">Total amount:</p>
22+
<p class="govuk-heading-l govuk-!-margin-bottom-4">£{{ amount }}</p>
23+
24+
{% if paymentState and paymentState.preAuth and paymentState.preAuth.status == 'success' %}
25+
{# Payment pre-authorised - show confirmation #}
26+
<p class="govuk-body">
27+
<strong class="govuk-tag govuk-tag--green">Payment ready</strong>
28+
</p>
29+
<p class="govuk-body">
30+
Reference: {{ paymentState.reference }}
31+
</p>
32+
{{ govukButton({
33+
text: "Use different payment details",
34+
attributes: {
35+
name: "action",
36+
value: "external-" + model.name
37+
},
38+
classes: "govuk-button--secondary"
39+
}) }}
40+
{% else %}
41+
{# No payment yet - show button to initiate #}
42+
{{ govukButton({
43+
text: "Add payment details",
44+
attributes: {
45+
name: "action",
46+
value: "external-" + model.name
47+
}
48+
}) }}
49+
{% endif %}
50+
{% endset %}
51+
52+
{{ govukFieldset({
53+
legend: {
54+
text: model.label.text if model.label and model.label.text else "Payment details required",
55+
classes: "govuk-fieldset__legend--m",
56+
isPageHeading: false
57+
},
58+
html: paymentContent
59+
}) }}
60+
{% endmacro %}

0 commit comments

Comments
 (0)