Expose gateway tracking fields on order transactions.

Include authority, track id, masked card, and paid-at from gateway meta for support and reconciliation.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Alireza Hassani
2026-10-02 22:15:10 +03:30
co-authored by Cursor
parent 0a330b8749
commit 0d9e866a57
+17
View File
@@ -29,6 +29,9 @@ import {
} from './dto/order.dto';
import { ShippingAddressDto } from '../cart/dto/cart.dto';
function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === 'object' && value !== null && !Array.isArray(value);
}
type OrderWithItems = Prisma.OrderGetPayload<{
include: typeof ORDER_RELATIONS_INCLUDE;
}>;
@@ -910,6 +913,18 @@ export class OrdersService {
}
private serializeTransaction(transaction: Transaction) {
const meta = isRecord(transaction.gatewayMeta)
? transaction.gatewayMeta
: null;
const verify = meta && isRecord(meta.verify) ? meta.verify : null;
const cardPan =
(verify && typeof verify.cardPan === 'string' && verify.cardPan.trim()) ||
(meta && typeof meta.cardPan === 'string' && meta.cardPan.trim()) ||
null;
const completedAt =
(meta && typeof meta.completedAt === 'string' && meta.completedAt.trim()) ||
null;
return {
id: transaction.id.toString(),
type: transaction.type,
@@ -919,6 +934,8 @@ export class OrdersService {
gatewayType: transaction.gatewayType,
gatewayRef: transaction.gatewayRef ?? null,
gatewayTrackId: transaction.gatewayTrackId ?? null,
cardPan,
paidAt: completedAt,
transferAccount: transaction.transferAccount,
transferRefNumber: transaction.transferRefNumber,
notes: transaction.notes,