fix delete payment app (#25801)
This commit is contained in:
1 parent
758b820a92
commit
e46c1bb40c
2 files changed
+73
-2
No files matched your search
@@ -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);
|
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);
|
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);
|
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);
|
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);
|
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({
|
const unpaidBookings = await prisma.booking.findMany({
|
||||||
where: {
|
where: {
|
||||||
userId: userId,
|
userId: userId,
|
||||||
eventTypeId: eventType.id,
|
eventTypeId: eventType.id,
|
||||||
status: "PENDING",
|
status: "PENDING",
|
||||||
paid: false,
|
paid: false,
|
||||||
|
startTime: {
|
||||||
|
gt: new Date(),
|
||||||
|
},
|
||||||
payment: {
|
payment: {
|
||||||
every: {
|
some: {
|
||||||
|
appId: credential.appId,
|
||||||
success: false,
|
success: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user