fix delete payment app (#25801)
This commit is contained in:
@@ -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,
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user