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