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

# Créer une intention de paiement

> Créez une intention de paiement pour traiter un paiement.

## Endpoint

```bash theme={null}
POST https://pay.sandbox.yabetoopay.com/v1/payment-intents   # Sandbox
POST https://pay.api.yabetoopay.com/v1/payment-intents       # Production
```

## Authentification

Utilisez votre clé secrète dans l'en-tête `Authorization` :

```bash theme={null}
Authorization: Bearer YOUR_SECRET_KEY
```

## Corps de la requête

| Paramètre     | Type     | Obligatoire | Description                                              |
| ------------- | -------- | ----------- | -------------------------------------------------------- |
| `amount`      | `number` | Oui         | Le montant à payer (dans la plus petite unité de devise) |
| `currency`    | `string` | Oui         | Code devise (ex: `xaf`, `xof`)                           |
| `description` | `string` | Non         | Description du paiement                                  |
| `metadata`    | `object` | Non         | Données personnalisées pour votre référence              |

## Exemple de requête

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://pay.sandbox.yabetoopay.com/v1/payment-intents \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer YOUR_SECRET_KEY" \
    -d '{
      "amount": 2000,
      "currency": "xaf",
      "description": "Paiement pour produit",
      "metadata": { "orderId": "1234" }
    }'
  ```

  ```javascript JavaScript theme={null}
  import Yabetoo from "@yabetoo/sdk-js";

  const yabetoo = new Yabetoo("YOUR_SECRET_KEY");

  const paymentIntent = await yabetoo.payments.create({
    amount: 2000,
    currency: "xaf",
    description: "Paiement pour produit",
    metadata: { orderId: "1234" },
  });
  ```

  ```python Python theme={null}
  from yabetoo import Yabetoo
  from yabetoo.models.payment import CreateIntentRequest

  yabetoo = Yabetoo("YOUR_SECRET_KEY")

  payment_intent = yabetoo.payments.create(CreateIntentRequest(
      amount=2000,
      currency="xaf",
      description="Paiement pour produit",
      metadata={"orderId": "1234"}
  ))
  ```

  ```php PHP theme={null}
  <?php
  require 'vendor/autoload.php';

  use Yabetoo\Yabetoo;

  $yabetoo = new Yabetoo("YOUR_SECRET_KEY");

  $paymentIntent = $yabetoo->payments->create([
      "amount" => 2000,
      "currency" => "xaf",
      "description" => "Paiement pour produit",
      "metadata" => ["orderId" => "1234"],
  ]);
  ```

  ```java Java theme={null}
  import com.yabetoo.Yabetoo;
  import com.yabetoo.YabetooConfig;
  import com.yabetoo.model.PaymentIntent;
  import com.yabetoo.request.PaymentIntentRequest;

  YabetooConfig config = new YabetooConfig()
      .setApiKey("YOUR_SECRET_KEY");

  Yabetoo yabetoo = new Yabetoo(config);

  PaymentIntentRequest request = PaymentIntentRequest.builder()
      .amount(2000)
      .currency("xaf")
      .description("Paiement pour produit")
      .putMetadata("orderId", "1234")
      .build();

  PaymentIntent paymentIntent = yabetoo.paymentIntents().create(request);
  ```
</CodeGroup>

## Réponse

### 200 OK

```json theme={null}
{
  "amount": 10000,
  "currency": "xaf",
  "description": "Payment for product",
  "metadata": {
    "orderId": "orderId-22"
  },
  "accountId": "acct_xsd",
  "liveMode": false,
  "label": "payment_intent",
  "id": "pi_OYgGCdY1VaWvszwZcAY7VXvuXI70Ao9rsuMl",
  "createdAt": "2026-02-16T15:33:55.048+00:00",
  "updatedAt": "2026-02-16T15:33:55.062+00:00",
  "clientSecret": "pi_OYgGCdY1VaWvszwZcAY7VXvuXI70Ao9rsuMl_secret_JYtxzKNhuwDCilaH72rEtMGuAlJl29qYAnOe"
}
```

### 422 Bad Request

```json theme={null}
{
  "errors": [
    {
      "rule": "required",
      "field": "currency",
      "message": "required validation failed"
    }
  ]
}
```

### 401 Unauthorized

```json theme={null}
{
  "error": "Unauthorized"
}
```
