@@ -29,7 +29,10 @@ import {
2929 type FormSubmissionError ,
3030 type FormSubmissionState
3131} from '~/src/server/plugins/engine/types.js'
32- import { createPaymentService } from '~/src/server/plugins/payment/helper.js'
32+ import {
33+ createPaymentService ,
34+ formatPaymentAmount
35+ } from '~/src/server/plugins/payment/helper.js'
3336
3437export class PaymentField extends FormComponent {
3538 declare options : PaymentFieldComponent [ 'options' ]
@@ -91,7 +94,7 @@ export class PaymentField extends FormComponent {
9194 return ''
9295 }
9396
94- return `£ ${ value . amount . toFixed ( 2 ) } - ${ value . description } `
97+ return `${ formatPaymentAmount ( value . amount ) } - ${ value . description } `
9598 }
9699
97100 getViewModel ( payload : FormPayload , errors ?: FormSubmissionError [ ] ) {
@@ -105,7 +108,10 @@ export class PaymentField extends FormComponent {
105108 // When user initially visits the payment page, there is no payment state yet so the amount is read form the form definition.
106109 const amount = paymentState ?. amount ?? this . options . amount
107110
108- const formattedAmount = amount . toFixed ( 2 )
111+ const formattedAmount = new Intl . NumberFormat ( 'en-GB' , {
112+ minimumFractionDigits : 2 ,
113+ maximumFractionDigits : 2
114+ } ) . format ( amount )
109115
110116 return {
111117 ...viewModel ,
@@ -153,7 +159,7 @@ export class PaymentField extends FormComponent {
153159
154160 getContextValueFromState ( state : FormSubmissionState ) {
155161 return this . isPaymentState ( state )
156- ? `Reference: ${ state . reference } \nAmount: ${ state . amount . toFixed ( 2 ) } `
162+ ? `Reference: ${ state . reference } \nAmount: ${ formatPaymentAmount ( state . amount ) } `
157163 : ''
158164 }
159165
0 commit comments