{"id":15549305,"url":"https://github.com/adityaoberai/payments-lemon-squeezy-appwrite-function","last_synced_at":"2026-04-16T17:32:29.021Z","repository":{"id":232278035,"uuid":"783914659","full_name":"adityaoberai/payments-lemon-squeezy-appwrite-function","owner":"adityaoberai","description":"Appwrite Function to receive payments in Lemon Squeezy and store paid orders.","archived":false,"fork":false,"pushed_at":"2024-04-12T11:45:13.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-10T06:42:23.100Z","etag":null,"topics":["appwrite","lemon-squeezy","payments"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adityaoberai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-08T20:32:29.000Z","updated_at":"2024-04-09T12:49:42.000Z","dependencies_parsed_at":"2024-04-12T13:04:23.170Z","dependency_job_id":null,"html_url":"https://github.com/adityaoberai/payments-lemon-squeezy-appwrite-function","commit_stats":null,"previous_names":["adityaoberai/payments-lemon-squeezy-appwrite-function"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adityaoberai%2Fpayments-lemon-squeezy-appwrite-function","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adityaoberai%2Fpayments-lemon-squeezy-appwrite-function/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adityaoberai%2Fpayments-lemon-squeezy-appwrite-function/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adityaoberai%2Fpayments-lemon-squeezy-appwrite-function/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adityaoberai","download_url":"https://codeload.github.com/adityaoberai/payments-lemon-squeezy-appwrite-function/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247256113,"owners_count":20909240,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["appwrite","lemon-squeezy","payments"],"created_at":"2024-10-02T13:34:19.610Z","updated_at":"2025-10-30T21:21:45.764Z","avatar_url":"https://github.com/adityaoberai.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 💳 Node.js Lemon Squeezy Payments Function\n\nAppwrite Function to receive payments in Lemon Squeezy and store paid orders.\n\n## 🧰 Usage\n\n### `POST /checkout`\n\nThis endpoint creates a Lemon Squeezy checkout. The user ID is fetched from the headers of the request. If the user ID is not found or a Lemon Squeezy checkout fails, the request will be redirected to a failure URL.\n\n**Parameters**\n\n| Name               | Description                                               | Location | Type               | Sample Value                |\n| ------------------ | --------------------------------------------------------- | -------- | ------------------ | --------------------------- |\n| x-appwrite-user-id | User ID from Appwrite.                                    | Header   | String             | 642...7cd                   |\n| Content-Type       | The content type of the request body                      | Header   | `application/json` | N/A                         |\n| failureUrl         | The URL to redirect to after a cancelled payment attempt. | Body     | String             | https://example.com/failure |\n\n**Response**\n\nSample `303` Response:\n\nThe response is a redirect to the Lemon Squeezy checkout URL or to the failure URL if an error occurs\n\n```text\nLocation: https://ap...re.lemonsqueezy.com/checkout/custom/7576abf3-...e2fb\n```\n\n```text\nLocation: https://mywebapp.com/cancel\n```\n\n### `POST /webhook`\n\nThis endpoint is a webhook that handles Lemon Squeezy event `order_created`. It validates the incoming request using the `X-Signature` header from the Lemon Squeezy webhook. If the validation fails, a `401` response is sent.\n\n**Parameters**\n\n| Name        | Description                         | Location | Type   | Sample Value                                                                                                                    |\n| ----------- | ----------------------------------- | -------- | ------ | ------------------------------------------------------------------------------------------------------------------------------- |\n| None        | Webhook payload from Lemon Squeezy. | Body     | Object | [See Lemon Squeezy docs](https://docs.lemonsqueezy.com/api/orders#the-order-object)                                             |\n| x-signature | Signature from Lemon Squeezy.       | Headers  | String | [See Lemon Squeezy docs](https://docs.lemonsqueezy.com/guides/developer-guide/webhooks#signing-and-validating-webhook-requests) |\n\n**Response**\n\nSample `200` Response:\n\nIn case of `order_created` event, document for the order is created in Appwrite Database.\n\n```json\n{ \"success\": true }\n```\n\nSample `401` Response:\n\n```json\n{ \"success\": false }\n```\n\n## ⚙️ Configuration\n\n| Setting           | Value                          |\n| ----------------- | ------------------------------ |\n| Runtime           | Node (18.0)                    |\n| Entrypoint        | `src/main.js`                  |\n| Build Commands    | `npm install \u0026\u0026 npm run setup` |\n| Permissions       | `any`                          |\n| Timeout (Seconds) | 15                             |\n\n\u003e If using a demo web app to create order, make sure to add your function domain as a web platform to your Appwrite project. Doing this fixes CORS errors and allows proper functionality.\n\n## 🔒 Environment Variables\n\n### APPWRITE_API_KEY\n\nYour Appwrite project's API key.\n\n| Question      | Answer                                                                                                                                                          |\n| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| Required      | Yes                                                                                                                                                             |\n| Sample Value  | `083d341ee48...`                                                                                                                                                |\n| Documentation | [Appwrite: Create an API key](https://appwrite.io/docs/advanced/platform/api-keys#:~:text=To%20create%20a%20new%20API,scope%20to%20grant%20your%20application.) |\n\n### APPWRITE_ENDPOINT\n\nThe endpoint where your Appwrite server is located. If not provided, it defaults to the Appwrite Cloud server: `https://cloud.appwrite.io/v1`.\n\n| Question     | Answer                         |\n| ------------ | ------------------------------ |\n| Required     | No                             |\n| Sample Value | `https://cloud.appwrite.io/v1` |\n\n### APPWRITE_DATABASE_ID\n\nThe ID of the database to store the orders.\n\n| Question     | Answer   |\n| ------------ | -------- |\n| Required     | No       |\n| Sample Value | `orders` |\n\n### APPWRITE_COLLECTION_ID\n\nThe ID of the collection to store the orders.\n\n| Question     | Answer   |\n| ------------ | -------- |\n| Required     | No       |\n| Sample Value | `orders` |\n\n### LEMON_SQUEEZY_API_KEY\n\nAPI key for sending requests to the Lemon Squeezy API.\n\n| Question      | Answer                                                                      |\n| ------------- | --------------------------------------------------------------------------- |\n| Required      | Yes                                                                         |\n| Sample Value  | `eyJ0eXAiOiJ...`                                                            |\n| Documentation | [Lemon Squeezy: API Keys](https://docs.lemonsqueezy.com/api#authentication) |\n\n### LEMON_SQUEEZY_WEBHOOK_SECRET\n\nSecret used to validate the Lemon Squuezy Webhook signature.\n\n| Question      | Answer                                                                                                      |\n| ------------- | ----------------------------------------------------------------------------------------------------------- |\n| Required      | Yes                                                                                                         |\n| Sample Value  | `abcd...`                                                                                                   |\n| Documentation | [Lemon Squeezy: Webhooks](https://docs.lemonsqueezy.com/guides/developer-guide/webhooks#from-the-dashboard) |\n\n### LEMON_SQUEEZY_STORE_ID\n\nStore ID required to create a checkout using the Lemon Squeezy API.\n\n| Question      | Answer                                                                                                                           |\n| ------------- | -------------------------------------------------------------------------------------------------------------------------------- |\n| Required      | Yes                                                                                                                              |\n| Sample Value  | `123456`                                                                                                                         |\n| Documentation | [Lemon Squeezy: Checkouts](https://docs.lemonsqueezy.com/guides/developer-guide/taking-payments#creating-checkouts-with-the-api) |\n\n### LEMON_SQUEEZY_VARIANT_ID\n\nVariant ID of a product required to create a checkout using the Lemon Squeezy API.\n\n| Question      | Answer                                                                                                                           |\n| ------------- | -------------------------------------------------------------------------------------------------------------------------------- |\n| Required      | Yes                                                                                                                              |\n| Sample Value  | `123456`                                                                                                                         |\n| Documentation | [Lemon Squeezy: Checkouts](https://docs.lemonsqueezy.com/guides/developer-guide/taking-payments#creating-checkouts-with-the-api) |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadityaoberai%2Fpayments-lemon-squeezy-appwrite-function","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadityaoberai%2Fpayments-lemon-squeezy-appwrite-function","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadityaoberai%2Fpayments-lemon-squeezy-appwrite-function/lists"}