fix delete payment app (#25801)

This commit is contained in:
Anik Dhabal Babu
2025-12-12 14:24:45 +00:00
committed by GitHub
parent 758b820a92
commit e46c1bb40c
2 changed files with 73 additions and 2 deletions
@@ -132,6 +132,19 @@ describe("handleDeleteCredential Integration Tests - BookingReference Soft Delet
},
],
},
payment: {
create: {
uid: "payment-uid-123",
appId: "stripe",
amount: 1000,
fee: 0,
currency: "usd",
success: false,
refunded: false,
data: {},
externalId: "ext-payment-123",
},
},
},
});
createdBookingIds.push(unpaidBooking.id);
@@ -212,6 +225,19 @@ describe("handleDeleteCredential Integration Tests - BookingReference Soft Delet
},
],
},
payment: {
create: {
uid: "payment-uid-456",
appId: "stripe",
amount: 1000,
fee: 0,
currency: "usd",
success: false,
refunded: false,
data: {},
externalId: "ext-payment-456",
},
},
},
});
createdBookingIds.push(unpaidBooking.id);
@@ -270,6 +296,19 @@ describe("handleDeleteCredential Integration Tests - BookingReference Soft Delet
},
],
},
payment: {
create: {
uid: "payment-uid-b1",
appId: "stripe",
amount: 1000,
fee: 0,
currency: "usd",
success: false,
refunded: false,
data: {},
externalId: "ext-payment-b1",
},
},
},
});
createdBookingIds.push(booking1.id);
@@ -293,6 +332,19 @@ describe("handleDeleteCredential Integration Tests - BookingReference Soft Delet
},
],
},
payment: {
create: {
uid: "payment-uid-b2",
appId: "stripe",
amount: 1000,
fee: 0,
currency: "usd",
success: false,
refunded: false,
data: {},
externalId: "ext-payment-b2",
},
},
},
});
createdBookingIds.push(booking2.id);
@@ -423,6 +475,19 @@ describe("handleDeleteCredential Integration Tests - BookingReference Soft Delet
},
],
},
payment: {
create: {
uid: "payment-uid-query-test",
appId: "stripe",
amount: 1000,
fee: 0,
currency: "usd",
success: false,
refunded: false,
data: {},
externalId: "ext-payment-query-test",
},
},
},
});
createdBookingIds.push(unpaidBooking.id);
@@ -209,15 +209,21 @@ const handleDeleteCredential = async ({
},
});
// Assuming that all bookings under this eventType need to be paid
// Only cancel unpaid pending bookings that:
// 1. Are in the future (startTime > now) - don't cancel old bookings
// 2. Have failed payments associated with the payment app being deleted
const unpaidBookings = await prisma.booking.findMany({
where: {
userId: userId,
eventTypeId: eventType.id,
status: "PENDING",
paid: false,
startTime: {
gt: new Date(),
},
payment: {
every: {
some: {
appId: credential.appId,
success: false,
},
},