From 99f77af1696611d7f92370aa7d57bbadfe1a52d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Tue, 26 Mar 2024 13:07:33 +0000 Subject: [PATCH] fix: Better handling of default values for `GovPayMetadata` (#2925) --- api.planx.uk/modules/pay/middleware.ts | 2 +- editor.planx.uk/src/@planx/components/Pay/Public/Pay.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api.planx.uk/modules/pay/middleware.ts b/api.planx.uk/modules/pay/middleware.ts index fb62d7271d..b21a939221 100644 --- a/api.planx.uk/modules/pay/middleware.ts +++ b/api.planx.uk/modules/pay/middleware.ts @@ -147,7 +147,7 @@ export async function buildPaymentPayload( inviteToPay: true, }; - const metadata = govPayMetadata.length + const metadata = Object.keys(govPayMetadata).length ? govPayMetadata : defaultGovPayMetadata; diff --git a/editor.planx.uk/src/@planx/components/Pay/Public/Pay.tsx b/editor.planx.uk/src/@planx/components/Pay/Public/Pay.tsx index 001c7a7fc2..851c5370b4 100644 --- a/editor.planx.uk/src/@planx/components/Pay/Public/Pay.tsx +++ b/editor.planx.uk/src/@planx/components/Pay/Public/Pay.tsx @@ -74,7 +74,7 @@ function Component(props: Props) { { key: "flow", value: flowSlug }, { key: "isInviteToPay", value: false }, ]; - const metadata = props.govPayMetadata.length + const metadata = props.govPayMetadata?.length ? props.govPayMetadata : defaultMetadata;