मुख्य सामग्री पर जाएं

GitHub Repository

Minimal Go + Dodo Payments boilerplate

Overview

The Go boilerplate provides a production-ready starting point for integrating Dodo Payments with your Go backend. This template includes checkout session handling, webhook verification, customer portal integration, and follows Go best practices to help you start accepting payments quickly.
This boilerplate uses Go 1.21+ with clean architecture patterns (cmd, internal, templates), HTML templates, and the dodopayments-go SDK for seamless API integration.

Features

  • Quick Setup - Get started in under 5 minutes
  • Payment Integration - Pre-configured checkout flow using dodopayments-go SDK
  • Modern UI - Clean, dark-themed pricing page with HTML templates
  • Webhook Handling - Securely verify and process payment events
  • Customer Portal - Self-serve subscription management
  • Go Best Practices - Clean architecture with cmd, internal, and templates
  • Pre-filled Checkout - Demonstrates passing customer data to improve UX

Prerequisites

Before you begin, make sure you have:
  • Go 1.21+
  • Dodo Payments account (to access API and Webhook Keys from dashboard)

Quick Start

1

Clone the Repository

2

Install Dependencies

Or manually:
3

Get API Credentials

Sign up at Dodo Payments and get your credentials from the dashboard:
Make sure you’re in Test Mode while developing!
4

Configure Environment Variables

Create a .env file in the root directory:
Update the values with your Dodo Payments credentials:
.env
Never commit your .env file to version control. It’s already included in .gitignore.
5

Add Your Products

Update internal/lib/products.go with your actual product IDs from Dodo Payments:
6

Run the Development Server

Or manually:
Open http://localhost:8000 to see your pricing page!
You should see a dark-themed pricing page with your products ready to purchase.

Project Structure

API Endpoints

The boilerplate includes the following pre-configured endpoints:

Customization

Update Product Information

Edit internal/lib/products.go to modify:
  • Product IDs (from your Dodo dashboard)
  • Pricing
  • Features
  • Descriptions

Pre-fill Customer Data

In templates/index.html, replace the hardcoded customer data with your actual user data:
In a production app, you would dynamically inject these values from your authentication system.

Webhook Events

The boilerplate demonstrates handling webhook events in internal/api/webhook.go. Supported events include: Add your business logic inside the webhook handler to:
  • Update user permissions in your database
  • Send confirmation emails
  • Provision access to digital products
  • Track analytics and metrics

Testing Webhooks Locally

For local development, use tools like ngrok to expose your local server:
Update the webhook URL in your Dodo Payments Dashboard:

Deployment

Build for Production

Or manually:

Deploy to Vercel

[ Deploy with Vercel ](https://vercel.com/new/clone?repository-url=https://github.com/dodopayments/go-boilerplate)

Docker

Create a Dockerfile:
Build and run:

Production Considerations

Before deploying to production:
  • Switch DODO_PAYMENTS_ENVIRONMENT to live_mode
  • Use production API keys from the dashboard
  • Update the webhook URL to your production domain
  • Enable HTTPS for all endpoints

Troubleshooting

Ensure Go modules are properly downloaded:
Common causes:
  • Invalid product ID - verify it exists in your Dodo dashboard
  • Wrong API key or environment setting in .env
  • Check the server logs for detailed error messages
For local testing, use ngrok to expose your server:
Update the webhook URL in your Dodo dashboard to the ngrok URL. Make sure to update your .env file with the correct webhook verification key.
Ensure you’re running the server from the project root directory, or that the templates path is correctly configured in your code.

Learn More

Go SDK

Complete Go SDK documentation

Webhooks Documentation

Learn about all webhook events and best practices

Checkout Sessions

Deep dive into checkout session configuration

API Reference

Complete Dodo Payments API documentation

Support

Need help with the boilerplate?
अंतिम संशोधन 1 अप्रैल 2026