In App Purchases
Use in-app purchases to accept payments for one-time purchases or subscriptions directly within your app.1
Create a checkout configuration
Use the API to create a checkout configuration. This will allow you to attach custom metadata about this specific purchase.Do this on your server/backend, when the user selects the item / plan / option they want to purchase.
For the
company_id argument, use the company id that your app is owned by.
You can find this in the url of you app dashboard. It looks like biz_XXXXX.In order to process payments on behalf of other companies, request the required permissions,
and pass the company id of each respective company.
For example you can derive this from the experience id provided in the experience view.2
Open the in app purchase modal
Use the iframe SDK to trigger the in-app purchase modal in the client browser.
This step only works inside the whop iframe in client side JS (experience, dashboard or discover view).
3
Setup payment webhooks
Webhooks are the most reliable way to be notified on your server about successful payments.
We recommend using webhooks to unlock server gated content or fulfill payments.If processing payments on your own company, you need to setup a company webhook to receive webhooks correctly.
- Go to your developer dashboard Don’t select any app
- Click “Create Webhook” in the top right.
- Select API version
v1 - Select
payment_succeeded - Copy your webhook key and prepare your SDK:
Processing payments on other companies
Processing payments on other companies
When processing on other companies, you need to create an app level webhook and
request permission to receive payment events.
- Go to your developer dashboard
- Select your app from below the company webhooks
- Navigate to the webhooks tab.
- Create a new webhook and enter your server url
- Select API version
v1 - Select
payment_succeeded - Go to the permissions tab, and request
webhook_receive:paymentsand hit save - Copy your webhook key and prepare your SDK like above
4
Verify the payment
After a payment is processed, you should validate it on your server using webhooks to ensure the payment was successful and update your application accordingly.In your application framework, setup a webhook handler and fulfill purchases and/or update your database.
We recommend handling webhooks in an async queue or
waitUntil block to ensure the request
handler responds quickly to avoid unnecessary webhook retries.To see exactly what data you will receive, check out the API Reference
You can also fetch payment data using the
GET /api/v1/payments/:id api route
which will return exactly the same data that is included in the webhook.
