From 2d68e927ebd3db7ab38aba7d2978c085e47ca64a Mon Sep 17 00:00:00 2001 From: olaven Date: Tue, 20 May 2025 21:53:10 +0200 Subject: [PATCH] Fix formatting --- lib/vipps/vipps.ts | 9 ++++++--- routes/api/trigger-donation/vipps.ts | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/vipps/vipps.ts b/lib/vipps/vipps.ts index a11abf4..79f03da 100644 --- a/lib/vipps/vipps.ts +++ b/lib/vipps/vipps.ts @@ -93,9 +93,12 @@ export const createAgreement = async function (email: string) { } }; -export const getAgreement = async function (agreementId: string): Promise<{ - status: "PENDING" | "ACTIVE" | "STOPPED" | "EXPIRED"; -}> { +export const getAgreement = async function (agreementId: string): Promise< + | { + status: "PENDING" | "ACTIVE" | "STOPPED" | "EXPIRED"; + } + | Error +> { const token = await getAccessToken(); const response = await fetch( `${config.baseUrl}/recurring/v3/agreements/${agreementId}`, diff --git a/routes/api/trigger-donation/vipps.ts b/routes/api/trigger-donation/vipps.ts index 4f67fd6..236c8cc 100644 --- a/routes/api/trigger-donation/vipps.ts +++ b/routes/api/trigger-donation/vipps.ts @@ -27,6 +27,7 @@ export const handler = async function (req: Request): Promise { if ( agreementInVipps && + !(agreementInVipps instanceof Error) && agreementInVipps.status !== "ACTIVE" && hasActiveAgreement ) {