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

# Wallet LigdiCash

> Intégrer le paiement via wallet LigdiCash. Mode de validation : OTP SMS. Deux endpoints distincts : /v02/debitotp et /v02/debitwallet/withotp.

## Identité

| Champ              | Valeur                                           |
| ------------------ | ------------------------------------------------ |
| Opérateur          | Wallet LigdiCash                                 |
| `operator_id`      | -                                                |
| `operator_name`    | LIGDICASH \[NOM\_OPERATEUR]                      |
| Format du numéro   | `indicatif` + numéro local (sans `+` ni espaces) |
| Mode de validation | OTP SMS                                          |

<Note>
  Le Wallet LigdiCash utilise deux endpoints distincts des autres opérateurs (`/v02`). Le flux est différent : un premier appel déclenche l'envoi de l'OTP, un second appel soumet la transaction avec l'OTP.
</Note>

## Mode de validation : OTP SMS

Le client reçoit un code OTP sur son application ou par SMS LigdiCash après votre première requête. Il vous communique ce code. Vous soumettez ensuite une seconde requête avec l'OTP pour finaliser la transaction.

## UX recommandée

<Steps>
  <Step title="Collecter le numéro du client">
    Votre formulaire recueille le numéro de téléphone associé au compte LigdiCash du client.
  </Step>

  <Step title="Envoyer l'OTP — première requête">
    Appelez `GET /pay/v02/debitotp/{phone_number}/{amount}`. LigdiCash envoie un OTP au client.
  </Step>

  <Step title="Afficher le champ OTP">
    Après confirmation de l'envoi (`"error": false`), affichez un champ de saisie pour l'OTP. Indiquez au client de vérifier son application ou ses SMS LigdiCash.
  </Step>

  <Step title="Soumettre avec l'OTP — seconde requête">
    Appelez `POST /pay/v02/debitwallet/withotp` avec le numéro dans `customer` et l'OTP dans `otp`.
  </Step>

  <Step title="Attendre le callback">
    Affichez un indicateur d'attente. La confirmation arrive via votre `callback_url`.
  </Step>
</Steps>

## Étape 1 — Envoyer l'OTP

```
GET https://app.ligdicash.com/pay/v02/debitotp/{phone_number}/{amount}
```

Les paramètres `phone_number` et `amount` sont des **paramètres de chemin** (path parameters), pas un body JSON.

### Headers

<ParamField header="Apikey" type="string" required>
  La clé API de votre projet LigdiCash.
</ParamField>

<ParamField header="Authorization" type="string" required>
  Votre API TOKEN précédé de `Bearer `.
</ParamField>

<ParamField header="Accept" type="string" required>
  Doit être `application/json`.
</ParamField>

### Paramètres de chemin

<ParamField path="phone_number" type="string" required>
  Numéro de téléphone du client au format `indicatif` + numéro local, sans `+` ni espaces.
</ParamField>

<ParamField path="amount" type="integer" required>
  Montant en XOF (entier, sans décimales).
</ParamField>

### Exemple

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://app.ligdicash.com/pay/v02/debitotp/22670000000/5000" \
    -H "Apikey: {API_KEY}" \
    -H "Authorization: Bearer {API_TOKEN}" \
    -H "Accept: application/json"
  ```

  ```javascript Node.js theme={null}
  const phone = "22670000000";
  const amount = 5000;

  const response = await fetch(
    `https://app.ligdicash.com/pay/v02/debitotp/${phone}/${amount}`,
    {
      method: "GET",
      headers: {
        Apikey: process.env.LIGDICASH_API_KEY,
        Authorization: `Bearer ${process.env.LIGDICASH_API_TOKEN}`,
        Accept: "application/json",
      },
    }
  );

  const data = await response.json();
  ```

  ```php PHP theme={null}
  $phone = "22670000000";
  $amount = 5000;

  $ch = curl_init("https://app.ligdicash.com/pay/v02/debitotp/{$phone}/{$amount}");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Apikey: " . $_ENV["LIGDICASH_API_KEY"],
    "Authorization: Bearer " . $_ENV["LIGDICASH_API_TOKEN"],
    "Accept: application/json",
  ]);

  $data = json_decode(curl_exec($ch), true);
  curl_close($ch);
  ```
</CodeGroup>

### Réponse

```json Succès theme={null}
{
  "error": false,
  "message": "OTP sent. Please check your phone."
}
```

<Warning>
  Vérifiez que `error` vaut `false` avant d'afficher le champ OTP. Si `error` est `true`, affichez un message d'erreur et ne proposez pas la saisie de l'OTP.
</Warning>

***

## Étape 2 — Valider avec l'OTP

```
POST https://app.ligdicash.com/pay/v02/debitwallet/withotp
```

### Headers

<ParamField header="Apikey" type="string" required>
  La clé API de votre projet LigdiCash.
</ParamField>

<ParamField header="Authorization" type="string" required>
  Votre API TOKEN précédé de `Bearer `.
</ParamField>

<ParamField header="Accept" type="string" required>
  Doit être `application/json`.
</ParamField>

<ParamField header="Content-Type" type="string" required>
  Doit être `application/json`.
</ParamField>

### Body

Même structure que l'endpoint `/pay/v01/straight/checkout-invoice/create`, avec `customer` renseigné et `otp` contenant le code reçu par le client.

### Exemple

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://app.ligdicash.com/pay/v02/debitwallet/withotp \
    -H "Apikey: {API_KEY}" \
    -H "Authorization: Bearer {API_TOKEN}" \
    -H "Accept: application/json" \
    -H "Content-Type: application/json" \
    -d '{
      "commande": {
        "invoice": {
          "items": [
            {
              "name": "Abonnement Pro",
              "description": "Accès premium 1 mois",
              "quantity": 1,
              "unit_price": 5000,
              "total_price": 5000
            }
          ],
          "total_amount": 5000,
          "devise": "XOF",
          "description": "Abonnement Pro — Janvier 2025",
          "customer": "22670000000",
          "customer_firstname": "Amadou",
          "customer_lastname": "Diallo",
          "customer_email": "amadou@exemple.com",
          "external_id": "",
          "otp": "123456"
        },
        "store": {
          "name": "MonApp",
          "website_url": "https://monapp.com"
        },
        "actions": {
          "cancel_url": "",
          "return_url": "",
          "callback_url": "https://monapp.com/api/callback/ligdicash"
        },
        "custom_data": {
          "transaction_id": "ORD-2025-00042"
        }
      }
    }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
    "https://app.ligdicash.com/pay/v02/debitwallet/withotp",
    {
      method: "POST",
      headers: {
        Apikey: process.env.LIGDICASH_API_KEY,
        Authorization: `Bearer ${process.env.LIGDICASH_API_TOKEN}`,
        Accept: "application/json",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        commande: {
          invoice: {
            items: [
              {
                name: "Abonnement Pro",
                description: "Accès premium 1 mois",
                quantity: 1,
                unit_price: 5000,
                total_price: 5000,
              },
            ],
            total_amount: 5000,
            devise: "XOF",
            description: "Abonnement Pro — Janvier 2025",
            customer: "22670000000",
            customer_firstname: "Amadou",
            customer_lastname: "Diallo",
            customer_email: "amadou@exemple.com",
            external_id: "",
            otp: "123456",
          },
          store: { name: "MonApp", website_url: "https://monapp.com" },
          actions: {
            cancel_url: "",
            return_url: "",
            callback_url: "https://monapp.com/api/callback/ligdicash",
          },
          custom_data: { transaction_id: "ORD-2025-00042" },
        },
      }),
    }
  );

  const data = await response.json();
  ```

  ```php PHP theme={null}
  $payload = [
    "commande" => [
      "invoice" => [
        "items" => [[
          "name" => "Abonnement Pro",
          "description" => "Accès premium 1 mois",
          "quantity" => 1,
          "unit_price" => 5000,
          "total_price" => 5000,
        ]],
        "total_amount" => 5000,
        "devise" => "XOF",
        "description" => "Abonnement Pro — Janvier 2025",
        "customer" => "22670000000",
        "customer_firstname" => "Amadou",
        "customer_lastname" => "Diallo",
        "customer_email" => "amadou@exemple.com",
        "external_id" => "",
        "otp" => "123456",
      ],
      "store" => ["name" => "MonApp", "website_url" => "https://monapp.com"],
      "actions" => [
        "cancel_url" => "",
        "return_url" => "",
        "callback_url" => "https://monapp.com/api/callback/ligdicash",
      ],
      "custom_data" => ["transaction_id" => "ORD-2025-00042"],
    ],
  ];

  $ch = curl_init("https://app.ligdicash.com/pay/v02/debitwallet/withotp");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Apikey: " . $_ENV["LIGDICASH_API_KEY"],
    "Authorization: Bearer " . $_ENV["LIGDICASH_API_TOKEN"],
    "Accept: application/json",
    "Content-Type: application/json",
  ]);

  $data = json_decode(curl_exec($ch), true);
  curl_close($ch);
  ```
</CodeGroup>

### Réponse attendue

<CodeGroup>
  ```json Succès theme={null}
  {
    "response_code": "00",
    "token": "eyJ0eXAiOiJKV1Qi...",
    "response_text": "Votre requête est en cours de traitement",
    "wiki": "https://client.ligdicash.com/wiki/createInvoice"
  }
  ```

  ```json Échec theme={null}
  {
    "response_code": "01",
    "token": "",
    "response_text": "Echec (Code00)",
    "wiki": "https://client.ligdicash.com/wiki/createInvoice"
  }
  ```
</CodeGroup>

<Warning>
  Stockez le `token` retourné par `/debitwallet/withotp`. C'est lui que vous utiliserez pour appeler `confirm` à la réception du callback.
</Warning>

## Limites

| Paramètre          | Valeur        |
| ------------------ | ------------- |
| Montant minimum    | 10 XOF        |
| Montant maximum    | 2 000 000 XOF |
| Limite quotidienne | --            |

## Pages associées

* [Modes de validation — OTP SMS](/api-paiement/payin-sans-redirect/modes-validation) — détail du flux deux requêtes
* [Vérifier le statut](/api-paiement/payin-sans-redirect/verifier-statut) — appeler `confirm` après le callback
