From 0b1e33045912c4ea94bd0c2539d048ad5910967c Mon Sep 17 00:00:00 2001 From: Marshal Date: Mon, 29 Jun 2026 13:00:55 +0000 Subject: [PATCH 1/3] add payemnt test --- apps/edr-freight-api/html/payment-tester.html | 452 ++++++++++++++++++ 1 file changed, 452 insertions(+) create mode 100644 apps/edr-freight-api/html/payment-tester.html diff --git a/apps/edr-freight-api/html/payment-tester.html b/apps/edr-freight-api/html/payment-tester.html new file mode 100644 index 000000000..1bb1a5c80 --- /dev/null +++ b/apps/edr-freight-api/html/payment-tester.html @@ -0,0 +1,452 @@ + + + + + +EDR Freight β€” Payment Tester (Telebirr ETB + Card USD) + + + +
+

πŸš‚ EDR Freight β€” Payment Tester

+ Telebirr (ETB) + Card (USD) +
+ +
+ +
+

API connection

+
+
+ + +
+
+ + +
+
+
+ + not checked +
+
+ + +
+

1 Β· Choose a booking

+
+
+ + +
+ +
+
+ + Currency (ETB vs USD) is set per-booking via paymentCurrency. Pick an ETB booking to test Telebirr, a USD booking to test Card. +
+
+ + +
+ + +
+

2 Β· Initiate payment

+
+
+ + +
+
+ + +
+
+
+ + +
+
+ +
+
+ Telebirr β†’ forces method TELEBIRR. Card β†’ forces method CARD. + Each calls POST {base}/payments/initiate and follows the returned clientAction (REDIRECT url for web). +
+

+
+ + +
+

3 Β· Track intent & receipt

+
+ + + no intent yet +
+
+ + Receipt = GET {base}/payments/receipt/{merchantOrderId} +
+
+ + +
+
+

Last response

+
β€”
+
+
+

Request log

+
+
+
+
+ + + + From ce3584cd4a59f411803032f990fa037d9179d73f Mon Sep 17 00:00:00 2001 From: Marshal Date: Mon, 29 Jun 2026 15:41:00 +0000 Subject: [PATCH 2/3] cfix payment --- .../src/modules/payment/payment.service.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 71371989b..347fedc1e 100644 --- a/apps/edr-freight-api/src/modules/payment/payment.service.ts +++ b/apps/edr-freight-api/src/modules/payment/payment.service.ts @@ -462,16 +462,29 @@ export class PaymentService { failureCode?: string; failureMessage?: string; }): Promise<{ processed: boolean; alreadyFinalized?: boolean; reason?: string }> { + console.log(`Received payment event: ${JSON.stringify(event)}`); if (event.eventType === "payment.succeeded") { const intent = await this.paymentRepo.findOneBy({ refId: event.referenceId }); if (!intent) { return { processed: false, reason: `No local intent for reference ${event.referenceId}` }; } + console.log(`Processing payment succeeded event for intent: }`,intent); const { alreadyFinalized } = await this.markIntentSucceeded(intent.id, { providerTxnId: event.providerTxnId, paidAt: event.paidAt ? new Date(event.paidAt) : undefined, notify: true, }); + console.log(`Payment finalized for intent ${intent.id}, alreadyFinalized: ${alreadyFinalized}`); + + // When the intent references a booking, flip the booking itself paid. + // refId holds the booking id (the domain reference the intent opened with). + if (intent.referenceType === PaymentReferenceType.BOOKING) { + await this.datasource.manager.update( + Booking, + { id: intent.refId }, + { status: "PAID", paymentStatus: "PAID" }, + ); + } // console.log(`Payment finalized for booking ${event.referenceId}, intent ${intent.id}, alreadyFinalized: ${alreadyFinalized}`); return { processed: true, alreadyFinalized }; } From d91389daac5b9232cce0f01decc9bca60dac1d11 Mon Sep 17 00:00:00 2001 From: Marshal Date: Mon, 29 Jun 2026 15:46:17 +0000 Subject: [PATCH 3/3] cfix payment --- ...lumn.ts => 1810000000004-AddPostPaymentCompletedColumn.ts} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename apps/edr-freight-api/src/migrations/{1719667261000-AddPostPaymentCompletedColumn.ts => 1810000000004-AddPostPaymentCompletedColumn.ts} (93%) diff --git a/apps/edr-freight-api/src/migrations/1719667261000-AddPostPaymentCompletedColumn.ts b/apps/edr-freight-api/src/migrations/1810000000004-AddPostPaymentCompletedColumn.ts similarity index 93% rename from apps/edr-freight-api/src/migrations/1719667261000-AddPostPaymentCompletedColumn.ts rename to apps/edr-freight-api/src/migrations/1810000000004-AddPostPaymentCompletedColumn.ts index c755d6356..aeedae2b1 100644 --- a/apps/edr-freight-api/src/migrations/1719667261000-AddPostPaymentCompletedColumn.ts +++ b/apps/edr-freight-api/src/migrations/1810000000004-AddPostPaymentCompletedColumn.ts @@ -1,7 +1,7 @@ import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm'; -export class AddPostPaymentCompletedColumn1719667261000 implements MigrationInterface { - name = 'AddPostPaymentCompletedColumn1719667261000'; +export class AddPostPaymentCompletedColumn1810000000004 implements MigrationInterface { + name = 'AddPostPaymentCompletedColumn1810000000004'; public async up(queryRunner: QueryRunner): Promise { const firstMileTable = await queryRunner.hasTable('freight.first_mile_deliveries');