This commit is contained in:
marshal
2026-06-29 15:05:50 +03:00
parent 1491db304b
commit b688a76550

View File

@@ -289,20 +289,21 @@ export class PaymentService {
providerTxnId?: string; providerTxnId?: string;
paidAt?: Date; paidAt?: Date;
}): Promise<{ alreadyFinalized: boolean }> { }): Promise<{ alreadyFinalized: boolean }> {
const intent = await this.paymentRepo.findOneBy({ id: input.intentId }); // const intent = await this.paymentRepo.findOneBy({ id: input.intentId });
if (!intent) throw new NotFoundException("PaymentIntent not found"); // if (!intent) throw new NotFoundException("PaymentIntent not found");
if (intent.status === "success") return { alreadyFinalized: true }; // if (intent.status === "success") return { alreadyFinalized: true };
const paidAt = input.paidAt ?? new Date(); const paidAt = input.paidAt ?? new Date();
// Every booking is a real shipment now (contracts are a separate aggregate), // Every booking is a real shipment now (contracts are a separate aggregate),
// so payment always settles the booking to PAID and enters allocation. // so payment always settles the booking to PAID and enters allocation.
await this.datasource.transaction(async (mg) => { await this.datasource.transaction(async (mg) => {
await mg.update( // await mg.update(
PaymentEntity, // PaymentEntity,
{ id: intent.id }, // // { id: intent.id },
{ status: "success", paidAt, transactionId: input.providerTxnId ?? intent.transactionId }, // {id:input.intentId},
); // { status: "success", paidAt, transactionId: input.providerTxnId ?? intent.transactionId },
// );
await mg.update( await mg.update(
Booking, Booking,
{ id: input.bookingId }, { id: input.bookingId },