import { type PaymentProvider, type PaymentType } from '@prisma/client';

/**
 * Minimal cross-module contract used by non-payment modules (e.g. listings)
 * to initiate a payment without importing payments application-layer commands.
 *
 * The concrete implementation lives in `payments` and is registered under the
 * `PAYMENT_INITIATOR` symbol. This keeps the dependency direction
 * listings → shared ← payments, matching our module-boundary rules (A-10).
 */
export interface InitiatePaymentInput {
  userId: string;
  provider: PaymentProvider;
  type: PaymentType;
  amountVND: bigint;
  description: string;
  returnUrl: string;
  ipAddress: string;
  /** Associated business-object id (e.g. listingId) when relevant. */
  transactionId?: string;
  idempotencyKey?: string;
}

export interface InitiatePaymentResult {
  paymentId: string;
  paymentUrl: string;
  providerTxId: string;
}

export interface IPaymentInitiator {
  initiate(input: InitiatePaymentInput): Promise<InitiatePaymentResult>;
}

export const PAYMENT_INITIATOR = Symbol('PAYMENT_INITIATOR');
