---
layout: integration
title: Payments with Dodo Payments
description: Connect Dodo Payments to Appwrite to sell one-time products, store paid orders in Appwrite Databases, and hand checkout and global tax to a Merchant of Record.
date: 2026-11-05
featured: false
isPartner: true
isNew: true
cover: /images/integrations/dodo-payments-payments/cover.avif
category: payments
product:
    avatar: '/images/integrations/avatars/dodo-payments.avif'
    vendor: Dodo Payments
    description: 'Dodo Payments is a Merchant of Record for SaaS, AI, and digital products that handles payments, tax, and billing in 220+ countries.'
platform:
    - 'Self-hosted'
    - 'Cloud'
images:
    - /images/integrations/dodo-payments-payments/cover.avif
    - /images/integrations/dodo-payments-payments/products.avif
    - /images/integrations/dodo-payments-payments/api-key.avif
    - /images/integrations/dodo-payments-payments/template.avif
    - /images/integrations/dodo-payments-payments/domain.avif
    - /images/integrations/dodo-payments-payments/webhook.avif
    - /images/integrations/dodo-payments-payments/variables.avif
    - /images/integrations/dodo-payments-payments/web-platform.avif
    - /images/integrations/dodo-payments-payments/checkout.avif
    - /images/integrations/dodo-payments-payments/demo.avif
    - /images/integrations/dodo-payments-payments/database.avif
---

Dodo Payments is a Merchant of Record for SaaS, AI, and digital products. It sells your product to customers in 220+ countries as the legal seller, so payment processing, sales tax and VAT, fraud screening, and chargebacks are handled for you. Its hosted checkout supports cards, wallets, bank debits, and other local payment methods, and shows prices in local currencies.

# How does the integration work?

You can use a pre-built Appwrite Function template to sell a one-time product with Dodo Payments, such as a course, an e-book, a lifetime license, or a pack of credits. The function creates a Dodo Payments checkout session for the signed-in Appwrite user. When the payment succeeds, it stores the order as a row in an Appwrite table that only the buyer can read.

The function verifies every webhook signature and looks the payment up in Dodo Payments before storing anything, so it never trusts the webhook payload. It also ships a demo page so you can test the full flow before writing any code.

# How to implement

To implement the Dodo Payments payments integration, there are several steps you must complete:

## Step 1: Set up Dodo Payments

First, [sign up for Dodo Payments](https://app.dodopayments.com/signup) and keep the dashboard in **Test Mode** while you build. Test mode and live mode have separate API keys, products, and webhooks.

Head to **Products** in the sidebar and click **Add Product**. Choose **One time** as the pricing type, fill in the name and price, and copy the **Product Id** from the product list.

![Dodo Payments products](/images/integrations/dodo-payments-payments/products.avif)

Next, head to **Developer** > **API Keys** and click **Create New Key**. Give the key a name and grant **Checkout Sessions** write access and **Payments** read access. Click **Create Key** and copy the key. Dodo Payments shows it only once.

![Create a Dodo Payments API key](/images/integrations/dodo-payments-payments/api-key.avif)

## Step 2: Create the Appwrite Function

For this step, you must [create an account on Appwrite Cloud](/sign-in) or [self-host Appwrite](/docs/advanced/self-hosting) if you haven't already. The Dodo Payments templates are available on Appwrite Cloud and in self-hosted Appwrite 2.6.0 and later. If you self-host Appwrite, there are [additional setup steps](/docs/advanced/self-hosting/configuration/functions) to use Appwrite Function templates.

Head over to the Appwrite Console, navigate to the **Functions** page, click the **Templates** tab, and search for the **Payments with Dodo Payments** function template. Click **Create from template**.

![Payments with Dodo Payments template](/images/integrations/dodo-payments-payments/template.avif)

In the **Domain** section, choose the subdomain your function will run on. Copy the full URL, for example `https://<FUNCTION_DOMAIN>.fra.appwrite.run`. You need it for the webhook in the next step, so keep this page open.

![Function domain](/images/integrations/dodo-payments-payments/domain.avif)

## Step 3: Add the webhook endpoint

In a new tab, go to **Developer** > **Webhooks** in the Dodo Payments dashboard and click **Add endpoint**. Set the **Endpoint URL** to your function domain followed by `/webhook`:

```text
https://<FUNCTION_DOMAIN>.fra.appwrite.run/webhook
```

Under **Subscribed events**, select `payment.succeeded`. An endpoint with no events selected receives every event type, so always pick the event.

![Add a Dodo Payments webhook endpoint](/images/integrations/dodo-payments-payments/webhook.avif)

Click **Create endpoint**. On the endpoint's page, reveal the **Signing secret** and copy it. The function uses it to verify that webhooks come from Dodo Payments.

## Step 4: Configure the variables and deploy

Back in the Appwrite Console, fill in the **Template variables**:

| Variable | Value |
| --- | --- |
| `DODO_PAYMENTS_API_KEY` | The API key from step 1 |
| `DODO_PAYMENTS_WEBHOOK_KEY` | The signing secret from step 3 |
| `DODO_PAYMENTS_PRODUCT_ID` | The product ID from step 1 |
| `DODO_PAYMENTS_ENVIRONMENT` | Optional. `test_mode` (default) or `live_mode` |
| `APPWRITE_DATABASE_ID` | Optional. The database for orders, `orders` by default |
| `APPWRITE_TABLE_ID` | Optional. The table for orders, `orders` by default |

The function creates the database and table when the first order comes in.

![Template variables](/images/integrations/dodo-payments-payments/variables.avif)

Choose **Connect your repository** to clone the template into a new Git repository you can edit later, or **Connect later** to deploy it right away. Then click **Create and deploy**.

You don't need to create an Appwrite API key. The function talks to Appwrite with an [ephemeral API key](/docs/products/functions/develop#ephemeral-api-key) limited to the scopes the template asks for: `databases.write`, `tables.read`, `tables.write`, and `rows.write`.

## Step 5: Test the function

The demo page runs on your function domain and calls Appwrite from the browser, so Appwrite needs to accept requests from that hostname. Open **Apps** in the project sidebar and click **Add app**. Choose **Web**, then **No framework**, and enter your function domain as the **Hostname**.

![Register the function domain as a web app](/images/integrations/dodo-payments-payments/web-platform.avif)

Then, open your function domain in a browser to load the demo page. Click **Register as anonymous**, then **Create checkout with Dodo Payments**. The function creates a checkout session and redirects you to the Dodo Payments checkout. Pay with the [Dodo Payments test card](https://docs.dodopayments.com/miscellaneous/testing-process) `4242 4242 4242 4242`, any future expiry date, and any CVC.

![Dodo Payments checkout](/images/integrations/dodo-payments-payments/checkout.avif)

After the payment, Dodo Payments sends you back to the demo page, which lists the new order.

![Payments demo with a paid order](/images/integrations/dodo-payments-payments/demo.avif)

You can visit the **Databases** page in your Appwrite project, open the `orders` database, and open the `orders` table to find the row. The row ID is the Dodo Payments payment ID, so a repeated webhook can't store the same order twice. Only the user who paid can read it.

![Paid orders in Appwrite Databases](/images/integrations/dodo-payments-payments/database.avif)

# How the function works

The function exposes four routes on its domain:

| Route | Purpose |
| --- | --- |
| `GET /` | Serves the demo page, where a user can register, start a checkout, and see their paid orders |
| `POST /checkout` | Creates a checkout session for the product in `DODO_PAYMENTS_PRODUCT_ID` and redirects to it |
| `GET /success` | Verifies the payment when the user returns from checkout, then redirects them to your success URL |
| `POST /webhook` | Handles the `payment.succeeded` event |

When a signed-in user starts a checkout, the function stores their Appwrite user ID in the checkout session's metadata, and Dodo Payments carries it through to the payment. That is how each order is tied back to the user who paid.

Dodo Payments signs every webhook following the [Standard Webhooks](https://www.standardwebhooks.com/) specification. The function verifies the signature on every request, then looks the payment up in Dodo Payments instead of trusting the webhook payload. The `/success` route repeats the same check when Dodo Payments sends the user back after checkout, so the user gets access even if the webhook is slow.

# Start a checkout from your app

To start a checkout from your own app, call the function's `/checkout` route as the signed-in user. Appwrite passes the caller's ID to the function in the `x-appwrite-user-id` header, and the function responds with a redirect to the checkout:

```js
import { Client, Functions, ExecutionMethod } from 'appwrite';

const client = new Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')
    .setProject('<PROJECT_ID>');

const functions = new Functions(client);

const execution = await functions.createExecution({
    functionId: '<FUNCTION_ID>',
    body: JSON.stringify({
        successUrl: 'https://example.com/thanks',
        failureUrl: 'https://example.com/pricing',
        verifyUrl: 'https://<FUNCTION_DOMAIN>/success',
    }),
    async: false,
    xpath: '/checkout',
    method: ExecutionMethod.POST,
    headers: { 'Content-Type': 'application/json' },
});

const redirect = execution.responseHeaders.find((header) => header.name === 'location');
window.location.href = redirect.value;
```

Your app can then list the user's orders from the `orders` table with the client SDK, and the row permissions make sure each user only sees their own.

# Before you go live

The demo flow is built for testing. Before you charge real customers:

- Create a live API key, product, and webhook endpoint in **Live Mode**, update the variables, and set `DODO_PAYMENTS_ENVIRONMENT` to `live_mode`.
- Check `successUrl`, `failureUrl`, and `verifyUrl` against your own domains in `POST /checkout`, so the function can't be used to redirect people to other sites.
- Replace the demo's anonymous sessions with the sign-in method your app uses.
- Mark the API key and signing secret as [secret variables](/docs/products/functions/environment-variables#secret-variables) so nobody can read them back from the Console.

# Read more about Dodo Payments and Appwrite Functions

If you would like to learn more about Dodo Payments and Appwrite Functions, we have some resources that you should visit:

- [Read the announcement of the Dodo Payments templates](/blog/post/announcing-dodo-payments-templates)
- [Sell recurring plans with the Subscriptions with Dodo Payments integration](/integrations/dodo-payments-subscriptions)
- [Learn about Dodo Payments checkout sessions](https://docs.dodopayments.com/developer-resources/checkout-session)
- [Learn more about Functions templates in Appwrite docs](/docs/products/functions/templates)
- [Payments with Dodo Payments template source](https://github.com/appwrite/templates/tree/main/node/payments-with-dodo-payments)
