> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flasshpay.my/llms.txt
> Use this file to discover all available pages before exploring further.

# Paiement hébergé

> Redirigez votre client vers la page de paiement flasshpay.

Dans le mode hébergé, votre client est redirigé vers une page flasshpay. Il y choisit son opérateur et valide sur son téléphone.

## Créer la collecte

Ajoutez `"checkout": "hosted"` à votre requête.

```bash theme={null}
curl -X POST "https://flasshpay.my/api/v1/collections" \
  -H "X-FlashPay-Key: fp_test_xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "country_code": "CM",
    "amount": 5000,
    "transaction_id": "commande-1042",
    "description": "Commande 1042",
    "checkout": "hosted",
    "callback_url": "https://votre-site.com/paiement/succes",
    "failed_callback_url": "https://votre-site.com/paiement/echec"
  }'
```

## Champs

| Champ | Obligatoire | Description |
| - | - | - |
| `country_code` | Oui | Pays du client, code ISO à deux lettres. |
| `amount` | Oui | Montant supérieur à zéro, dans la devise du pays. |
| `transaction_id` | Recommandé | Votre identifiant de commande. Il doit être unique. |
| `description` | Non | Libellé affiché au client. |
| `checkout` | Oui | `"hosted"` pour ce mode. |
| `callback_url` | Non | Adresse `https` où renvoyer le client après un succès. |
| `failed_callback_url` | Non | Adresse `https` où renvoyer le client après un échec. |

## Réponse

```json theme={null}
{
  "mode": "test",
  "data": {
    "checkout_url": "https://flasshpay.my/pay/abc123",
    "country_code": "CM",
    "currency_code": "XAF",
    "amount": 5000,
    "message": "Redirige ton client vers checkout_url. Il choisit son opérateur et valide sur son téléphone."
  }
}
```

## Rediriger le client

```javascript Node.js theme={null}
const res = await fetch("https://flasshpay.my/api/v1/collections", {
  method: "POST",
  headers: {
    "X-FlashPay-Key": process.env.FLASSHPAY_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    country_code: "CM",
    amount: 5000,
    transaction_id: "commande-1042",
    checkout: "hosted",
  }),
});
const { data } = await res.json();
// Répondez à votre client par une redirection vers data.checkout_url
```

> [!NOTE]
>
> Sans `"checkout": "hosted"`, la collecte est directe. Voir [Paiement direct](https://docs.flasshpay.my/integration/paiement-direct.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.