diff --git a/apps/edr-freight-api/src/config/database.config.ts b/apps/edr-freight-api/src/config/database.config.ts index a75731cfd..c27d381e2 100644 --- a/apps/edr-freight-api/src/config/database.config.ts +++ b/apps/edr-freight-api/src/config/database.config.ts @@ -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"], }; }); diff --git a/apps/edr-freight-api/src/modules/payment/payment.module.ts b/apps/edr-freight-api/src/modules/payment/payment.module.ts index 330521218..532e1c06b 100644 --- a/apps/edr-freight-api/src/modules/payment/payment.module.ts +++ b/apps/edr-freight-api/src/modules/payment/payment.module.ts @@ -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, diff --git a/apps/edr-freight-api/src/modules/payment/payment.service.ts b/apps/edr-freight-api/src/modules/payment/payment.service.ts index a6bd457fb..35cebf057 100644 --- a/apps/edr-freight-api/src/modules/payment/payment.service.ts +++ b/apps/edr-freight-api/src/modules/payment/payment.service.ts @@ -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; diff --git a/apps/edr-freight-api/src/modules/train-scheduling/booking-batch.constants.ts b/apps/edr-freight-api/src/modules/train-scheduling/booking-batch.constants.ts index c5ab46987..5c9cb6119 100644 --- a/apps/edr-freight-api/src/modules/train-scheduling/booking-batch.constants.ts +++ b/apps/edr-freight-api/src/modules/train-scheduling/booking-batch.constants.ts @@ -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;