This commit is contained in:
marshal
2026-06-30 18:23:47 +03:00
4 changed files with 26 additions and 2 deletions

View File

@@ -118,6 +118,7 @@ export default registerAs("database", (): TypeOrmModuleOptions => {
migrationsRun: true,
// Schema changes via migrations only (synchronize breaks ITMLS backfill on existing rows).
synchronize: false,
logging: process.env.TYPEORM_LOGGING === "true",
logging:
process.env.TYPEORM_LOGGING === "true" ? true : ["error", "warn"],
};
});

View File

@@ -13,6 +13,8 @@ import {
import { ServiceAuthGuard } from "../../common/guards/service-auth.guard";
import { BillingModule } from "../billing/billing.module";
import { FirstMileModule } from "../first-mile/first-mile.module";
import { TrainSchedulingModule } from "../train-scheduling/train-scheduling.module";
import { PaymentRefundEntity } from "./entities/payment-refund.entity";
import { PaymentWebhookEventEntity } from "./entities/payment-webhook-event.entity";
import { PaymentEntity } from "./entities/payment.entity";
@@ -57,6 +59,8 @@ function rabbitMQImport(): DynamicModule[] {
HttpModule.register({ timeout: 10_000 }),
ConfigModule,
forwardRef(() => BillingModule),
forwardRef(() => TrainSchedulingModule),
FirstMileModule,
TypeOrmModule.forFeature([
PaymentEntity,
PaymentWebhookEventEntity,

View File

@@ -12,6 +12,8 @@ import { PaymentEntity } from "./entities/payment.entity";
import { PaymentRepository } from "./payment.repository";
import { PaymentClientService } from "./payment-client.service";
import { BillingService } from "../billing/billing.service";
import { FirstMileService } from "../first-mile/first-mile.service";
import { BookingBatchService } from "../train-scheduling/booking-batch.service";
import * as fs from "fs";
import * as path from "path";
@@ -106,6 +108,9 @@ export class PaymentService {
private readonly paymentClient: PaymentClientService,
@Inject(forwardRef(() => BillingService))
private readonly billing: BillingService,
@Inject(forwardRef(() => BookingBatchService))
private readonly bookingBatchService: BookingBatchService,
private readonly firstMileService: FirstMileService,
) { }
async getAll(filters: {
@@ -212,6 +217,20 @@ export class PaymentService {
failureUrl: input.failureUrl ?? "https://edrfreight.triaplc.com/payment/failure",
});
//////////////// fake
await this.datasource.manager.update(
Booking,
{ id: input.referenceId },
{ status: "PAID", paymentStatus: "PAID" },
);
await this.firstMileService.acceptBooking(input.referenceId);
await this.bookingBatchService.ensurePaidBookingAllocated(input.referenceId);
//////////////// fake
//update the booking heer for now the staus anf
const immediateSuccess = snapshot.status === ProviderPaymentStatus.SUCCEEDED;
const paidAt = snapshot.paidAt ? new Date(snapshot.paidAt) : undefined;

View File

@@ -13,7 +13,7 @@ export const BATCH_TIMEZONE = 'Africa/Addis_Ababa';
/** How long a selected commercial customer has to pay before their slot expires. */
// export const PAYMENT_WINDOW_MS = 60 * 60 * 1000; // 1 hour
export const PAYMENT_WINDOW_MS = 180 * 60 * 1000; // 5 minutes (test mode)
export const PAYMENT_WINDOW_MS = 5 * 60 * 1000; // 5 minutes (test mode)
/** Fallback wagons-per-booking when a booking has no computed `wagonsRequired`. */
export const DEFAULT_WAGONS_PER_BOOKING = 1;