feat: listen to stripe account updated webhook

This commit is contained in:
Ahmed Bouhuolia
2024-09-21 23:59:54 +02:00
parent ad74007d58
commit e04f5d26a3
7 changed files with 90 additions and 14 deletions

View File

@@ -2,7 +2,7 @@ import { NextFunction, Request, Response, Router } from 'express';
import { Inject, Service } from 'typedi';
import bodyParser from 'body-parser';
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
import { StripeCheckoutSessionCompletedEventPayload } from '@/interfaces/StripePayment';
import { StripeWebhookEventPayload } from '@/interfaces/StripePayment';
import { StripePaymentService } from '@/services/StripePayment/StripePaymentService';
import events from '@/subscribers/events';
import config from '@/config';
@@ -59,12 +59,16 @@ export class StripeWebhooksController {
events.stripeWebhooks.onCheckoutSessionCompleted,
{
event,
} as StripeCheckoutSessionCompletedEventPayload
} as StripeWebhookEventPayload
);
break;
case 'payment_intent.payment_failed':
// Handle failed payment intent
console.log('PaymentIntent failed.');
case 'account.updated':
this.eventPublisher.emitAsync(
events.stripeWebhooks.onAccountUpdated,
{
event,
} as StripeWebhookEventPayload
);
break;
// Add more cases as needed
default: