Set up Stripe_
Add paid app subscription plans to your app with Stripe and Appwrite Functions.
2 min read
Start by visiting Stripe and creating an account. When successful, you will see the Stripe Dashboard.
This tutorial uses a sandbox, Stripe's isolated test environment, so no real money moves. To switch to one, open the account picker in the Dashboard and select Sandboxes. The same steps also work in live mode when you're ready to accept real payments.
API key
Open the API keys page while viewing your sandbox. Under Standard keys, reveal and copy the Secret key, which starts with sk_test_. Note it down, as you will need it later when setting the STRIPE_SECRET_KEY environment variable.

Webhooks
Next, create a webhook so Stripe can notify your function when a subscription starts or ends. You will use a placeholder URL for now in order to get a signing secret. Later, when you set up the Appwrite Function, you will update this webhook with the function's domain.
Open the Webhooks tab in Workbench and click Add destination. If you haven't created any destinations yet, the button reads Create an event destination. Then, complete the form:
- If you're asked where to listen for events, select Your account.
- Under the payload format, select Snapshot, then leave the API version as is.
- Search for
subscriptionand select thecustomer.subscription.createdandcustomer.subscription.deletedevents. Click Continue. - Select Webhook endpoint as the destination type and click Continue.
- Enter
https://example.com/webhookas the Endpoint URL. Optionally, give the destination a name and description. - Click Create destination.
Stripe recommends Thin events for new integrations, but the template reads the subscription details from each event's payload, which only Snapshot events include. With a Thin destination, the function can't tell which user subscribed, and the subscriber label is never added.
Once created, Stripe opens the destination's details page. Reveal the Signing secret, which starts with whsec_, and copy it. Note it down, as you will need it later when setting the STRIPE_WEBHOOK_SECRET environment variable.

Keep this page open, as you will need it soon to replace the placeholder URL with your function's domain.
Was this page helpful?
Share what worked or what we should fix. Once approved, our agents automatically apply suggested updates to the docs.