From 4c9876251612e9cd9ebc8ba55251a3dd3338fdd0 Mon Sep 17 00:00:00 2001 From: Aleksandar Petkov Date: Sun, 24 Nov 2024 07:44:20 -0500 Subject: [PATCH] fix: Connect non anonymous donation by personId It is not necessary for the billlingEmail to be the one of the registered user(e.g. company emails for billing) --- apps/api/src/donations/donations.service.ts | 8 +++++--- .../api/src/sockets/notifications/notification.service.ts | 3 ++- apps/api/src/stripe/stripe.service.ts | 3 --- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/api/src/donations/donations.service.ts b/apps/api/src/donations/donations.service.ts index 23200674..e334795e 100644 --- a/apps/api/src/donations/donations.service.ts +++ b/apps/api/src/donations/donations.service.ts @@ -914,7 +914,7 @@ export class DonationsService { create: { amount: paymentData.netAmount, type: paymentData.type as DonationType, - person: paymentData.personId ? { connect: { email: paymentData.billingEmail } } : {}, + person: paymentData.personId ? { connect: { id: paymentData.personId } } : {}, targetVault: targetVaultData, }, }, @@ -928,7 +928,7 @@ export class DonationsService { donation.amount, tx, ) - this.notificationService.sendNotification('successfulDonation', donation) + this.notificationService.sendNotification('successfulDonation', donation.donations[0]) } return donation @@ -966,7 +966,9 @@ export class DonationsService { }, include: { donations: true }, }) - Logger.debug('Donation found by subscription: ', donation) + if (donation) { + Logger.debug('Donation found by subscription: ', donation) + } } return donation } diff --git a/apps/api/src/sockets/notifications/notification.service.ts b/apps/api/src/sockets/notifications/notification.service.ts index ca02aea2..9d2f625d 100644 --- a/apps/api/src/sockets/notifications/notification.service.ts +++ b/apps/api/src/sockets/notifications/notification.service.ts @@ -9,11 +9,12 @@ export const donationNotificationSelect = Prisma.validator amount: true, extPaymentMethodId: true, createdAt: true, - donations: { select: { id: true, targetVaultId: true, + createdAt: true, + amount: true, person: { select: { firstName: true, diff --git a/apps/api/src/stripe/stripe.service.ts b/apps/api/src/stripe/stripe.service.ts index da944112..e01e96db 100644 --- a/apps/api/src/stripe/stripe.service.ts +++ b/apps/api/src/stripe/stripe.service.ts @@ -37,9 +37,6 @@ export class StripeService { ): Promise> { if (!inputDto.metadata.campaignId) throw new BadRequestException('campaignId is missing from metadata') - const campaign = await this.campaignService.validateCampaignId( - inputDto.metadata.campaignId as string, - ) return await this.stripeClient.setupIntents.update(id, inputDto, { idempotencyKey }) } /**