diff --git a/apps/api/src/stripe/stripe.controller.spec.ts b/apps/api/src/stripe/stripe.controller.spec.ts index d6334f87..e6690324 100644 --- a/apps/api/src/stripe/stripe.controller.spec.ts +++ b/apps/api/src/stripe/stripe.controller.spec.ts @@ -34,7 +34,7 @@ describe('StripeController', () => { checkout: { sessions: { create: jest.fn() } }, paymentIntents: { retrieve: jest.fn() }, refunds: { create: jest.fn() }, - setupIntents: { retrieve: jest.fn() }, + setupIntents: { retrieve: jest.fn(), update: jest.fn() }, customers: { create: jest.fn(), list: jest.fn() }, paymentMethods: { attach: jest.fn() }, products: { search: jest.fn(), create: jest.fn() }, @@ -199,7 +199,7 @@ describe('StripeController', () => { reason: 'requested_by_customer', }) }) - it(`should not call setupintents.update if campaign can't accept donations`, async () => { + it(`should not call setupintents.update if no campaignId is provided`, async () => { prismaMock.campaign.findFirst.mockResolvedValue({ id: 'complete-campaign', allowDonationOnComplete: false, diff --git a/apps/api/src/stripe/stripe.service.ts b/apps/api/src/stripe/stripe.service.ts index e01e96db..ee76a707 100644 --- a/apps/api/src/stripe/stripe.service.ts +++ b/apps/api/src/stripe/stripe.service.ts @@ -37,6 +37,9 @@ export class StripeService { ): Promise> { if (!inputDto.metadata.campaignId) throw new BadRequestException('campaignId is missing from metadata') + await this.campaignService.validateCampaignId( + inputDto.metadata.campaignId as string, + ) return await this.stripeClient.setupIntents.update(id, inputDto, { idempotencyKey }) } /**