Skip to content

Stripe

Set up Stripe_

Add paid app subscription plans to your app with Stripe and Appwrite Functions.

2 min read

Raw

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.

Stripe API keys page
Stripe API keys page

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:

  1. If you're asked where to listen for events, select Your account.
  2. Under the payload format, select Snapshot, then leave the API version as is.
  3. Search for subscription and select the customer.subscription.created and customer.subscription.deleted events. Click Continue.
  4. Select Webhook endpoint as the destination type and click Continue.
  5. Enter https://example.com/webhook as the Endpoint URL. Optionally, give the destination a name and description.
  6. Click Create destination.

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.

Stripe webhook destination details
Stripe webhook destination details

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.