mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 14:08:11 +00:00
feat(billing): enhance invoice payment processing and revert handling
feat(bookings): add event handlers for booking invoice payment processing fix(bookings): include PAYMENT_VERIFICATION_IN_PROGRESS status in queries fix(train-scheduling): update status checks to include PAYMENT_VERIFICATION_IN_PROGRESS feat(notifier): notify customers when a train is cancelled
This commit is contained in:
@@ -115,6 +115,34 @@ export class BookingInvoiceService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Success-redirect ack: the customer finished provider checkout, webhook not
|
||||
* in yet. Mirror the invoice's PAYMENT_PROCESSING on the booking so the
|
||||
* portal stops offering "Pay now". Display state only — settlement
|
||||
* (`booking.invoice.paid`) still drives PAID. Status-guarded, so it never
|
||||
* touches a booking that already advanced or was terminated.
|
||||
*/
|
||||
@OnEvent("booking.invoice.payment-processing")
|
||||
async onBookingInvoicePaymentProcessing(
|
||||
payload: InvoiceEventPayload,
|
||||
): Promise<void> {
|
||||
await this.dataSource.getRepository(Booking).update(
|
||||
{ id: payload.sourceId, status: "SELECTED_FOR_BATCH" },
|
||||
{ status: "PAYMENT_VERIFICATION_IN_PROGRESS" },
|
||||
);
|
||||
}
|
||||
|
||||
/** Payment failed after a redirect ack — the booking reads payable again. */
|
||||
@OnEvent("booking.invoice.payment-processing-reverted")
|
||||
async onBookingInvoicePaymentProcessingReverted(
|
||||
payload: InvoiceEventPayload,
|
||||
): Promise<void> {
|
||||
await this.dataSource.getRepository(Booking).update(
|
||||
{ id: payload.sourceId, status: "PAYMENT_VERIFICATION_IN_PROGRESS" },
|
||||
{ status: "SELECTED_FOR_BATCH" },
|
||||
);
|
||||
}
|
||||
|
||||
updateStatus(
|
||||
invoiceId: string,
|
||||
status: Freight.InvoiceStatus,
|
||||
|
||||
@@ -1405,7 +1405,9 @@ export class BookingsRepository extends BaseRepository<Booking> {
|
||||
.leftJoinAndSelect('bookingContainer.containerType', 'containerType')
|
||||
.leftJoinAndSelect('booking.cargoType', 'cargoType')
|
||||
.where('booking.train_schedule_id = :scheduleId', { scheduleId })
|
||||
.andWhere(`booking.status IN ('SELECTED_FOR_BATCH', 'AWAITING_PAYMENT')`)
|
||||
.andWhere(
|
||||
`booking.status IN ('SELECTED_FOR_BATCH', 'AWAITING_PAYMENT', 'PAYMENT_VERIFICATION_IN_PROGRESS')`,
|
||||
)
|
||||
.getMany();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user