import type { PaymentProvider, CreatePaymentIntentResult } from "./types";

// PAYMENT_TEST_MODE stand-in (plan §7) — no network call, no real Stripe
// account needed. The synthetic providerReference is still persisted on
// the order exactly like a real one, so the whole downstream pipeline
// (webhooks/stripe/test-confirm, confirm-payment, expirePendingPayments)
// runs unmodified against it.
async function createPaymentIntent(): Promise<CreatePaymentIntentResult> {
  const fakeId = `pi_test_${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;
  return { clientSecret: `${fakeId}_secret_mock`, providerReference: fakeId };
}

async function attachOrderMetadata(): Promise<void> {
  // No real PaymentIntent to attach metadata to — nothing to do. The
  // test-confirm route (used instead of a real webhook in test mode)
  // already receives the order's id directly from the client, so it
  // never needs to resolve it via metadata the way the real webhook does.
}

export const mockProvider: PaymentProvider = { createPaymentIntent, attachOrderMetadata };
