This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

## Stripe Checkout

Configure these environment variables in `apps/storefront/.env.local`:

```bash
STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
NEXT_PUBLIC_MONDIAL_RELAY_BRAND=BDTEST13
MONDIAL_RELAY_SHIPPING_OPTION_IDS=so_123,so_456
MONDIAL_RELAY_WEIGHT_UNIT=g
```

Then use the `Payer avec Stripe` button on `/panier`.

## Mondial Relay

The cart page now supports Mondial Relay ParcelShop selection through the official widget.

- `NEXT_PUBLIC_MONDIAL_RELAY_BRAND`: your Mondial Relay brand code (required to use the widget).
- `MONDIAL_RELAY_SHIPPING_OPTION_IDS`: optional comma-separated Medusa shipping option IDs that should be treated as Mondial Relay.
- `MONDIAL_RELAY_WEIGHT_UNIT`: `g` (default) or `kg` to match how your product weights are stored in Medusa.
- `MONDIAL_RELAY_DEFAULT_ITEM_WEIGHT`: fallback item weight used if product/variant weight is missing.
- `MONDIAL_RELAY_DEFAULT_LENGTH_CM`: fallback length in cm if missing.
- `MONDIAL_RELAY_DEFAULT_WIDTH_CM`: fallback width in cm if missing.
- `MONDIAL_RELAY_DEFAULT_HEIGHT_CM`: fallback height in cm if missing.
- `MONDIAL_RELAY_RATE_CARD_JSON`: optional JSON override for rate tiers.

If `MONDIAL_RELAY_SHIPPING_OPTION_IDS` is not set, detection falls back to shipping method labels (matching terms like `mondial` or `relay`).

### Create the webhook endpoint in Stripe

Use this endpoint URL:

- Local: `http://localhost:3000/api/stripe/webhook` (via Stripe CLI forwarding)
- Production: `https://your-domain.com/api/stripe/webhook`

In Stripe dashboard webhook event selection, choose:

- `checkout.session.completed`
- `checkout.session.async_payment_succeeded`
- `checkout.session.async_payment_failed`
- `checkout.session.expired`

For your screenshot settings:

- Event source: `Votre compte`
- API version: keep the default shown by Stripe

### Local webhook testing (recommended)

```bash
stripe listen --forward-to localhost:3000/api/stripe/webhook
```

Copy the emitted webhook secret (`whsec_...`) into `STRIPE_WEBHOOK_SECRET`.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.


