Payment providers
One PaymentProvider interface, with connectors for Whop and Stripe. How money flows in and out through each.
All money movement goes through an abstract PaymentProvider. Domain code asks for a provider and calls it; it never calls a provider’s SDK directly. That keeps bounties, payment requests and payouts the same whichever provider is behind them.
src/providers/
├── PaymentProvider.ts # the abstract connector
├── registry.ts # getPaymentProvider()
├── stripe/StripePaymentProvider.ts
├── whop/WhopPaymentProvider.ts
└── webhooks/WebhookEventRegistry.ts
Choosing a provider
The platform-wide default is set with PAYMENT_PROVIDER:
PAYMENT_PROVIDER=whop # or stripe (the default when unset)
Records remember the provider that created them, so an older order paid through Stripe is refunded through Stripe:
import { getPaymentProvider } from '../providers/registry'
const provider = getPaymentProvider(order.provider) // falls back to PAYMENT_PROVIDER
await provider.createInvoice({ purpose: 'bounty_order', amount, currency: 'usd', customerEmail })
The frontend build injects PAYMENT_PROVIDER, STRIPE_PUBKEY and WHOP_COMPANY_ID, so rebuild the frontend after changing them.
Pay-in
| Flow | Whop | Stripe |
|---|---|---|
| Bounty by card | Checkout configuration and hosted redirect | Elements and charges |
| Bounty by invoice | Whop invoices | Stripe invoices |
| Payment request, fixed amount | Product and plan on the seller’s company | Product, price and payment link |
| Payment request, custom amount | Gitpay-hosted page with an embedded, single-use checkout | Payment link with a customer-chosen price |
| Wallet top-up | Whop invoice | Stripe invoice |
Direct charge
New payment requests on Whop are created on the seller’s connected company, with Gitpay’s cut collected in the same charge through application_fee_amount. The seller is the merchant of record.
The fee is snapshotted on the row as platform_fee_percent when the payment request is created: 5% for direct charge, 8% for older links where Gitpay is the merchant of record. Always read it with getPlatformFeePercent(paymentRequest), never from the constants, because refunds, disputes and emails must use the rate that was actually charged.
Custom amounts on Whop
Whop plans have a fixed price, so a custom-amount payment request creates only a product. Its payment_url points to a Gitpay page, /#/payment-requests/:id/pay. That page collects the amount, calls POST /payment-requests-public/:id/checkout to create a single-use checkout for that exact amount, and renders it inline with Whop Elements. Whether the link is active is checked in that endpoint, before any checkout is created.
Pay-out
| Flow | Whop | Stripe |
|---|---|---|
| Pay a bounty to the contributor | Transfer to User.whop_account_id |
Transfer to User.account_id |
| Seller payout after a payment, older links | Transfer from the platform balance | Transfer with the charge as source |
| User withdrawal | POST /payouts/request creates a Whop withdrawal |
POST /payouts/request creates a Connect payout |
On Whop, money always moves as:
checkout → platform balance → transfer → connected company → withdrawal
Account onboarding on Whop
- The user picks a country, and
POST /user/accountcreates a Whop company withparent_company_id = WHOP_COMPANY_ID, storing its ID inUsers.whop_account_id. - Gitpay requests an onboarding link (
account_links,use_case: account_onboarding). - The user completes identity verification and adds a payout method on Whop. Bank details never touch Gitpay.
- Whop redirects to
GET /user/account/verification/return, or/refreshif the link expired, and the API sends the browser back into the app.
GET /user/account returns provider and active. active is true only when the provider has approved the account for payouts and it has a payout method.
Local development with Whop. Whop requires https:// callback URLs. Tunnel the API, for example with ngrok http 3000, set WHOP_API_HOST to the tunnel URL, and keep FRONTEND_HOST=http://localhost:8082. Set WHOP_SANDBOX=true to use the sandbox.
Adding a provider
- Implement
PaymentProviderinsrc/providers/<name>/. - Register it in
src/providers/registry.ts. - Map its webhook events in the webhook registry.
- Add tests with HTTP mocks, following
test/api/webhooks/whop/.
The full reference, with every webhook event and edge case, is docs/payments-providers.md in the repository.