Golang drop-in replacement for the official Node.js Stripe subscriptions template.
- Create Stripe checkout sessions for subscription payments
- Handle Stripe webhooks for subscription lifecycle events
- Automatic user label management in Appwrite
- Built-in error handling and logging
- Secure endpoints with Appwrite authentication
- Appwrite account and project
- Stripe account with webhooks configured
- Go 1.23 or later
- Appwrite CLI (optional, for deployment)
- Create a new Appwrite function
- Set up the following environment variables:
APPWRITE_FUNCTION_API_ENDPOINT=<your-appwrite-endpoint>
APPWRITE_FUNCTION_PROJECT_ID=<your-project-id>
STRIPE_SECRET_KEY=<your-stripe-secret-key>
STRIPE_WEBHOOK_KEY=<your-stripe-webhook-signing-secret>
- Configure Stripe webhook endpoints to point to your function's
/webhook
endpoint - Add the required webhook events in Stripe:
- customer.subscription.created
- customer.subscription.deleted
Creates a new Stripe checkout session for monthly subscription payments.
Requirements:
- User must be authenticated
- Valid success and failure URLs must be provided
Request Body:
{
"successUrl": "https://your-app.com/success",
"failureUrl": "https://your-app.com/failure"
}
Success Response:
- Redirects to Stripe checkout page (303)
Error Response:
- Redirects to failure URL (303)
Handles Stripe webhook events for subscription lifecycle management.
Supported Events:
customer.subscription.created
: Adds "subscriber" label to usercustomer.subscription.deleted
: Removes "subscriber" label from user
Headers Required:
stripe-signature
: Webhook signature from Stripe
- Authentication required for subscription creation
- Webhook signature verification
- Secure user ID handling
- Environment variable configuration
- Input validation