Passer au contenu principal

Endpoint

POST https://buy.api.yabetoopay.com/v1/sessions

Authentification

Utilisez votre clé secrète dans l’en-tête Authorization :
Authorization: Bearer YOUR_SECRET_KEY

Corps de la requête

ParamètreTypeObligatoireDescription
totalnumberOuiMontant total dans la plus petite unité de devise (ex: 200000 = 200 000 XAF)
currencystringOuiCode devise (ex: xaf, xof)
accountIdstringOuiVotre ID de compte Yabetoo
successUrlstringOuiURL de redirection après un paiement réussi
cancelUrlstringOuiURL de redirection en cas d’annulation
itemsarrayNonListe des articles achetés
metadataobjectNonDonnées personnalisées pour votre référence

Structure d’un item

{
  "productId": "prod_12345",
  "productName": "Écran HD",
  "quantity": 1,
  "price": 200000
}

Exemple de requête

curl -X POST https://buy.api.yabetoopay.com/v1/sessions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_SECRET_KEY" \
  -d '{
    "total": 200000,
    "currency": "xaf",
    "accountId": "acct_xxxxxxxx",
    "successUrl": "https://votre-site.com/checkout-success",
    "cancelUrl": "https://votre-site.com/checkout-cancel",
    "metadata": { "orderId": "1234" },
    "items": [
      {
        "productId": "prod_12345",
        "quantity": 1,
        "price": 200000,
        "productName": "Écran HD"
      }
    ]
  }'

Réponse

200 OK

{
  "accountId": "acct_iNXIGeot1lqyhGI5eP7KL0LcWTCTgFLytfRa",
  "successUrl": "https://votre-site.com/checkout-success",
  "cancelUrl": "https://votre-site.com/checkout-cancel",
  "orderId": "ord_KowaIWyMlD25Lhb8MyY3GQyvN8nFaxTZ7ji7",
  "expiresAt": "2024-05-28T13:33:51.760+00:00",
  "id": "session_ajrw3pQUUZD8UI2eFkWyUgLxJ4kGuXCoaQeb",
  "createdAt": "2024-05-28T12:33:51.762+00:00",
  "updatedAt": "2024-05-28T12:33:51.762+00:00"
}

400 Bad Request

{
  "errors": [
    {
      "rule": "required",
      "field": "currency",
      "message": "required validation failed"
    }
  ]
}

401 Unauthorized

{
  "message": "Unauthorized"
}