Transaction

Below is a focused object derived from our broader gateway model, trimmed for this single‑partner integration.
interface Transaction {
  id: string; // txn_*
  merchantTransactionId?: string; // your id
  processor: 'mpesa';
  processorReference?: string; // M-Pesa receipt/Ref, once available
  status: 'pending' | 'completed' | 'failed' | 'settled';
  type: 'charge' | 'transfer' | 'settlement';
  paymentMethod: 'mobile_money';
  amount: number; // smallest unit
  chargedAmount: number;
  fees: number;
  currency: string; // e.g., 'KES'
  narration?: string;
  chargedPhone?: string; // for C2B and B2C
  description?: string; // optional display string
  message?: string; // human-friendly status message

  // Accounting / directions
  debitOrCredit: 'debit' | 'credit';
  destination?: 'customer_wallet' | 'merchant_account' | 'mpesa_paybill' | 'mpesa_till';

  // Timestamps
  createdAt: string; // ISO 8601
  updatedAt: string; // ISO 8601

  // Optional references
  reference?: string;
  externalReference?: string;
  invoiceId?: string;
  payoutId?: string;

  // State & metadata
  stage?: string;
  metadata?: Record<string, string>;
}
Mapping notes vs original schema:
  • EntityId, processorId, cardId, accountId, etc., are omitted in this shape.
  • Keep status narrowed to: pending | completed | failed | settled.
  • paymentMethod is fixed to mobile_money for this integration.