From 8860750487627c4db8a6984857389a45ba4a7831 Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Wed, 9 Apr 2025 13:25:06 -0400 Subject: [PATCH] Mollie --- src/lib/mollie.ts | 2 +- src/lib/pdf/pdfVerbrauchsausweisGewerbe.ts | 4 ++-- src/pages/api/rechnung/index.ts | 6 +++--- src/pages/api/webhooks/mollie.ts | 7 +++++++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/lib/mollie.ts b/src/lib/mollie.ts index 7b4c1bc3..19f5c495 100644 --- a/src/lib/mollie.ts +++ b/src/lib/mollie.ts @@ -3,4 +3,4 @@ import { createMollieClient } from "@mollie/api-client"; export const TEST_MOLLIE_API_TOKEN = "test_jenmp2Pq3j3N6HeQxwx7qbHasWMdnx"; export const LIVE_MOLLIE_API_TOKEN = "live_C9qrCGR6fjJfFpbEngeFpfGFcW9Jwq"; -export const mollieClient = createMollieClient({ apiKey: LIVE_MOLLIE_API_TOKEN }) \ No newline at end of file +export const mollieClient = createMollieClient({ apiKey: TEST_MOLLIE_API_TOKEN }) \ No newline at end of file diff --git a/src/lib/pdf/pdfVerbrauchsausweisGewerbe.ts b/src/lib/pdf/pdfVerbrauchsausweisGewerbe.ts index f0dbf6b8..4bcb2bfa 100644 --- a/src/lib/pdf/pdfVerbrauchsausweisGewerbe.ts +++ b/src/lib/pdf/pdfVerbrauchsausweisGewerbe.ts @@ -376,11 +376,11 @@ export async function pdfVerbrauchsausweisGewerbe(ausweis: VerbrauchsausweisGewe addEnergieverbrauchSkalaPfeile(pages[2]) if (ausweis.warmwasser_enthalten) { - addCheckMark(pages[2], 41, height - 269) + addCheckMark(pages[2], 41, height - 293) } if (ausweis.kuehlung_enthalten) { - addCheckMark(pages[2], 41, height - 281) + addCheckMark(pages[2], 41, height - 305) } if (ausweis.stromverbrauch_enthaelt_heizung) { diff --git a/src/pages/api/rechnung/index.ts b/src/pages/api/rechnung/index.ts index 99cd51a8..52afc044 100644 --- a/src/pages/api/rechnung/index.ts +++ b/src/pages/api/rechnung/index.ts @@ -216,9 +216,9 @@ export const PUT = defineApiRoute({ }, method: input.bezahlmethode as PaymentMethod, description: "Verbrauchsausweis Wohnen 2016", - redirectUrl: `https://online-energieausweis.org/payment/success?a=${ausweis.id}&r=${rechnung.id}`, - webhookUrl: `https://online-energieausweis.org/api/webhooks/mollie?uid=${rechnung.id}`, - cancelUrl: `https://online-energieausweis.org/kundendaten?a=${ausweis.id}&r=${rechnung.id}` + redirectUrl: `https://ibcornelsen.de/payment/success?a=${ausweis.id}&r=${rechnung.id}`, + webhookUrl: `https://ibcornelsen.de/api/webhooks/mollie?id=${rechnung.id}`, + cancelUrl: `https://ibcornelsen.de/kundendaten?a=${ausweis.id}&r=${rechnung.id}` }); const checkoutUrl = payment.getCheckoutUrl(); diff --git a/src/pages/api/webhooks/mollie.ts b/src/pages/api/webhooks/mollie.ts index 65f7990a..910102ff 100644 --- a/src/pages/api/webhooks/mollie.ts +++ b/src/pages/api/webhooks/mollie.ts @@ -21,6 +21,9 @@ export const POST = defineApiRoute({ const payment = await mollieClient.payments.get(id); const metadata = payment.metadata as { rechnung_id: string } + console.log(payment, metadata, id); + + if (!payment) { throw new APIError({ code: "NOT_FOUND", @@ -42,6 +45,9 @@ export const POST = defineApiRoute({ }, }); + console.log(rechnung); + + if (!rechnung) { throw new APIError({ code: "NOT_FOUND", @@ -57,6 +63,7 @@ export const POST = defineApiRoute({ data: { status: payment.status as Enums.Rechnungsstatus, transaktions_referenz: payment.id, + bezahlt_am: new Date() }, }); },