Edit this page

Webhooks

How Gitpay receives events from Whop and Stripe, verifies them, and updates payments, payouts and disputes.

Payments finish outside Gitpay: a customer pays on a checkout, a bank settles an invoice, a withdrawal lands. Providers tell Gitpay through webhooks, and webhooks drive most state changes for money.

How a webhook is handledWhop or Stripe sends an event to a webhook endpoint. The signature is verified, the event registry finds the handler for the event type, and the handler updates records and sends notifications.ProvidereventSigned JSONPOST /webhooks/whopExpress routeVerifysignaturewebhook secretEventregistrytype tohandlerHandlerrecords,email, Slack

Endpoints

Provider Endpoint Verified with
Whop POST /webhooks/whop Standard Webhooks headers and WHOP_WEBHOOK_SECRET
Stripe, platform POST /webhooks/stripe-platform stripe-signature and STRIPE_WEBHOOK_SECRET_PLATFORM
Stripe, Connect POST /webhooks/stripe-connect STRIPE_WEBHOOK_SECRET_CONNECT

Webhook routes receive the raw body, mounted before the JSON parser, so signatures can be verified. In NODE_ENV=test, verification is skipped. Unhandled event types still return 200, so providers stop retrying.

The registry

src/providers/webhooks/WebhookEventRegistry.ts maps an event type to a handler. Handlers live in src/modules/webhooks/, and the per-provider registrations in src/modules/webhooks/register/.

Whop events

Event What Gitpay does
payment.succeeded, payment.failed Marks bounty orders and payment request payments paid or failed, and sends emails.
membership.activated, membership.went_valid Treated as a paid signal for payment requests when payment.succeeded doesn’t arrive, which is common for plan purchases.
invoice.paid, invoice.past_due Updates bounty invoices and wallet top-ups.
withdrawal.created, withdrawal.updated Updates payouts and notifies the user.
refund.created, refund.updated Marks payment request payments refunded and records any balance debit.
dispute.created, dispute.updated Records disputes and their outcome on the seller’s balance, and emails the seller.
dispute_alert.created Emails the seller an early warning, and records Whop’s alert fee when Whop charges one.

Stripe events

Stripe handlers cover checkout.session.completed, charge.succeeded, charge.failed, charge.refunded, the charge.dispute.* events, the invoice.* events, transfer.created, transfer.reversed, the payout.* events, and balance.available.

Setting up Whop

  1. Create a company API key under the platform business, with access to companies, payments, checkout, invoices, transfers, withdrawals and company:balance:read.
  2. Create a webhook pointing to https://<api-host>/webhooks/whop, subscribed to the events above.
  3. Store the secret as WHOP_WEBHOOK_SECRET.

Testing locally

# Stripe: forward events to your local API
npm run stripe:webhook

# Whop: sign and send a synthetic dispute, refund or alert
npm run scripts:whop:simulate_dispute -- --type=dispute.created --payment-id=pay_xxx --amount=49.95 --url=http://localhost:3000/webhooks/whop

# Run the Whop webhook tests
npm run test:whop

Next steps