Aller au contenu principal

Paiements

Flux de paiement via Viva Wallet ISV (par défaut) ou Stripe Connect. Requiert le rôle ADMIN.

Schéma Payment

Champs du modèle Payment
ChampTypeDescription
idstringIdentifiant unique (pay_...)
courseIdstringFormation associée
userIdstringApprenant payant
amountnumberMontant en centimes
currencystringCode ISO 4217 (EUR...)
gatewayenumVIVA_ISV | STRIPE | FREE
statusenumPENDING | CAPTURED | REFUNDED | FAILED
gatewayPaymentIdstringID côté gateway (pour support)
createdAtstringDate de création ISO 8601

POST/payments/intent

Crée une intention de paiement et retourne une URL de redirection vers le portail de paiement. Après paiement, le gateway redirige vers successUrl ou cancelUrl.

Créer une intention de paiement · cURL / Shell
TOKEN="eyJhbGci..."

# Créer une intention de paiement (Viva ISV par défaut)
curl -X POST https://api.qualiforma.site/api/v1/payments/intent \
  -H "Authorization: Bearer $TOKEN" \
  -H 'X-Tenant-ID: votre-tenant' \
  -H 'Content-Type: application/json' \
  -d '{
    "courseId": "crs_abc123",
    "userId": "usr_xyz789",
    "gateway": "VIVA_ISV",
    "successUrl": "https://votre-app.com/success",
    "cancelUrl": "https://votre-app.com/cancel"
  }'

# Réponse :
# {
#   "data": {
#     "paymentId": "pay_ghi012",
#     "redirectUrl": "https://www.vivapayments.com/web/checkout?ref=...",
#     "expiresAt": "2026-01-01T13:00:00Z"
#   }
# }

POST/payments/:id/refund

Remboursement total ou partiel. Omettre amount pour un remboursement total. Requiert ADMIN. Délai de remboursement : 3-5 jours ouvrés.

Rembourser un paiement · cURL / Shell
TOKEN="eyJhbGci..."
PAYMENT_ID="pay_ghi012"

# Remboursement partiel (5000 centimes = 50 €)
curl -X POST "https://api.qualiforma.site/api/v1/payments/$PAYMENT_ID/refund" \
  -H "Authorization: Bearer $TOKEN" \
  -H 'X-Tenant-ID: votre-tenant' \
  -H 'Content-Type: application/json' \
  -d '{"amount": 5000}'

# Remboursement total (omettre amount)
curl -X POST "https://api.qualiforma.site/api/v1/payments/$PAYMENT_ID/refund" \
  -H "Authorization: Bearer $TOKEN" \
  -H 'X-Tenant-ID: votre-tenant' \
  -H 'Content-Type: application/json' \
  -d '{}'