Skip to Content
API ReferenceWebhook Endpoints

Webhook Endpoints

Stripe Webhook

Endpoint: POST /stripe/webhook

Description: Receives events from Stripe when a credit purchase is completed.

Security:

  • Stripe signature verification using STRIPE_WEBHOOK_SECRET
  • Returns 400 Invalid signature if verification fails
  • Returns 400 Invalid payload if the payload is malformed

Events Handled:

EventDescription
checkout.session.completedA credit purchase was successful. Credits are atomically added to the institute’s balance.

Metadata Expected:

FieldTypeDescription
institute_idintegerThe institute to credit
creditsintegerNumber of credits to add

Idempotency: The endpoint checks Transaction::where('stripe_session_id', $session->id) before processing. Duplicate webhooks return 200 Already processed without double-crediting.

Response Codes:

CodeMeaning
200 OKEvent processed or already processed
400 Invalid signatureWebhook signature verification failed
400 Invalid payloadPayload could not be parsed
200 Missing metadataRequired metadata fields were absent (logged as error)
Last updated on