Überarbeitung des Stripe Prozesses

This commit is contained in:
2024-08-23 19:54:55 +02:00
parent 7a286e3519
commit 74d5f92aba
18 changed files with 164 additions and 68 deletions

View File

@@ -21,7 +21,10 @@ export class PaymentController {
const signature = req.headers['stripe-signature'] as string;
try {
const event = await this.paymentService.constructEvent(req.body, signature);
// Konvertieren Sie den req.body Buffer in einen lesbaren String
const payload = req.body instanceof Buffer ? req.body.toString('utf8') : req.body;
const event = await this.paymentService.constructEvent(payload, signature);
// const event = await this.paymentService.constructEvent(req.body, signature);
if (event.type === 'checkout.session.completed') {
await this.paymentService.handleCheckoutSessionCompleted(event.data.object as Stripe.Checkout.Session);