A complete Figma plugin example demonstrating Dodo Payments license key validation and activation functionality.
- Create your own figma plugin project using this guide. This should generate a scaffold for your plugin with a
manifest.json. - Clone this repository and update it's
manifest.jsonwith the name and id from the manifest of the previously generated plugin folder. - Run
npm installto install dependencies. - Customize the ui in
src/ui/components/Authenticated.tsxto expose functionality for users with valid license keys. - Customise
LicenseKeyInput.tsxto your linking. - Set the
API_MODEinsrc/ui/api.tsto"test_mode"for development or"live_mode"when ready for production use. - The rest of the process should be obvious and figuring out publishing, testing, etc. is left to the developer using this template.
Import this plugin into Figma using "Import Manifest". Run the following command to start the development server:
npm run devSet the API_MODE in src/ui/api.ts to "test_mode" for development or "live_mode" for production.
The plugin needs network access to communicate with the CORS proxy. Add the following to the networkAccess section in manifest.json:
"networkAccess": {
"allowedDomains": ["https://dodo-payments-proxy.aagarwal9782.workers.dev"]
}This allows the plugin to validate and activate license keys using the Dodo Payments API.
This plugin includes:
- License Key Validation: Validates license keys against the Dodo Payments API
- License Key Activation: Activates license keys with user identification
- Environment Support: Configurable for both test and live environments
- CORS Proxy: Uses a Cloudflare Worker proxy to handle CORS restrictions
- TypeScript Support: Fully typed implementation with proper error handling
npm run build- Build the plugin for productionnpm run dev- Start development server with file watchingnpm run lint- Check code style and errorsnpm run format- Format code with Prettier