Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.flexprice.io/llms.txt

Use this file to discover all available pages before exploring further.

Overview

The Flexprice–Whop integration is bidirectional:
  • Whop → Flexprice - When an invoice is paid through Whop, Flexprice is notified and marks the invoice paid automatically.
  • Flexprice → Whop - Finalized invoices are pushed to Whop. A hosted checkout link is generated for each invoice.
Both directions are asynchronous and handled via Temporal workflows - invoice creation in Flexprice is never blocked by Whop sync.

Inbound (Whop → Flexprice)

Triggered when payment is followed through on a Whop invoice.
1

Payment is followed through on Whop

The checkout URL from the Flexprice invoice is used and payment is completed on Whop.
2

Whop fires invoice.paid webhook

Whop sends a POST to your registered webhook URL:
{
  "type": "invoice.paid",
  "data": { "id": "whopInvoiceID" }
}
Flexprice acknowledges the webhook and processes the payment update asynchronously.
3

Flexprice identifies the invoice

Using the whopInvoiceID from the webhook, Flexprice identifies the corresponding Flexprice invoice.
4

Flexprice marks the invoice paid

If the invoice is not already paid, Flexprice reconciles the payment status to succeeded. If it was already paid, this step is skipped.
Result: The Flexprice invoice is marked paid and all associated actions follow through - for instance, if it’s credit topup invoice, the transaction completes. The wallet is credited immediately.

Outbound (Flexprice → Whop)

Invoice Sync

Triggered every time a Flexprice invoice is finalized.
1

Invoice is finalized in Flexprice

The invoice status transitions to finalized. This applies to all invoice types - subscription billing, one-off invoices, and credit topup invoices.
2

Flexprice checks if Whop sync should run

Before starting any workflow, Flexprice verifies:
  • A Whop connection exists and is active
  • Invoice outbound sync is enabled on the connection
If either check fails, the process exits silently - no error is raised.
3

WhopInvoiceSyncWorkflow starts

A Temporal workflow is queued with a short delay to allow the invoice to fully commit. The workflow runs asynchronously - it does not block the invoice finalization response.
4

SyncInvoiceToWhop activity runs

The activity performs the full sync:
  1. Idempotency check - if this invoice was already synced to Whop, returns immediately
  2. Product - uses the configured product, or creates Flexprice Billing Product if none exists
  3. Customer - resolves customer name and email. If no email is found, the workflow fails and does not retry
  4. Creates Whop invoice - POST /v1/invoices with the invoice amount, due date, customer details, and Flexprice invoice ID in plan.internal_notes
  5. Fetches checkout URL - GET /v1/plans/:id to retrieve the purchase_url from Whop
  6. Stores checkout URL - saves purchase_url to invoice.metadata["whop_checkout_url"]
  7. Saves mapping - records flexpriceInvoiceID ↔ whopInvoiceID in entity integration mapping
Result: The Whop invoice appears in your Whop dashboard. The Flexprice invoice now has a whop_checkout_url you can share with your customer.

Mark Paid

Triggered when a Flexprice invoice is marked paid directly - for example, via an admin action or an offline payment recorded in Flexprice.
1

Invoice payment recorded in Flexprice

Payment status on the Flexprice invoice transitions to succeeded.
2

WhopInvoiceMarkPaidWorkflow starts

Flexprice queues a Temporal workflow to mirror the payment status in Whop.
3

MarkWhopInvoicePaid activity runs

  1. Looks up the Whop invoice ID from entity integration mapping - if no mapping exists (invoice was never synced to Whop), the activity exits silently
  2. Calls GET /v1/invoices/:whopInvoiceID to check current status in Whop
  3. If Whop invoice is already paid - skips the mark_paid call
  4. Otherwise calls POST /v1/invoices/:whopInvoiceID/mark_paid
Result: The Whop invoice is marked as paid, keeping both systems in sync.

Error Handling

ScenarioBehavior
No Whop connection configuredWorkflow fails immediately - non-retryable
Customer has no email addressWorkflow fails immediately - non-retryable. Fix the customer data and re-finalize
Invoice already synced to WhopSkipped - idempotency check prevents duplicate creation
Whop invoice already paidSkipped - status check before mark_paid prevents the duplicate call
Invoice due date is in the pastFlexprice automatically uses 30 days from now instead
Whop API temporarily unavailableTemporal retries with backoff automatically
Whop sync failures never block invoice creation or finalization in Flexprice. All sync happens asynchronously.