import { initStripe } from "@stripe/stripe-react-native";

const stripePublishableKey = process.env.EXPO_PUBLIC_STRIPE_PUBLISHABLE_KEY;

export interface GiftCardCheckoutInput {
  amount: number;
  recipientEmail?: string;
  sendToSelf: boolean;
}

export interface PassCheckoutInput {
  plan: "monthly" | "yearly";
  userId: string;
}

export async function configureStripe() {
  if (!stripePublishableKey) {
    return false;
  }

  await initStripe({
    publishableKey: stripePublishableKey,
    urlScheme: "amberieuvitrines"
  });

  return true;
}

export async function createGiftCardCheckout(input: GiftCardCheckoutInput) {
  return {
    checkoutReference: `gift-card-${Date.now()}`,
    amount: input.amount,
    sendToSelf: input.sendToSelf,
    recipientEmail: input.recipientEmail ?? null
  };
}

export async function createPassCheckout(input: PassCheckoutInput) {
  return {
    checkoutReference: `pass-${input.plan}-${input.userId}`,
    plan: input.plan
  };
}
