A Go implementation for handling donations from the donation page.
This repo was forked from the Stripe quickstarts. You can ๐ฅ watch a video to see how the quickstart server was implemented.
- Go 1.13
- Configured
.env
file - Kafka cluster (if the webhook should send donation notifications to it)
- Fly.io CLI and account set up (for deploying only)
- Docker (for deploying only)
- Confirm
.env
configuration
Ensure the API keys are configured in .env
in this directory. It should include the following keys:
# Stripe API keys - see https://stripe.com/docs/development/quickstart#api-keys
STRIPE_PUBLISHABLE_KEY=pk_test...
STRIPE_SECRET_KEY=sk_test...
# Required to verify signatures in the webhook handler.
# See README on how to use the Stripe CLI to test webhooks
STRIPE_WEBHOOK_SECRET=whsec_...
# Port on which the server is exposed and Kafka topic name on which notifications are sent.
DONATION_SERVER_PORT="8080"
DONATION_SERVER_CUSTOMERS_TOPIC="customers"
# Other Kafka related variables.
UPSTASH_KAFKA_BOOTSTRAP_SERVERS=localhost:9092
UPSTASH_KAFKA_SCRAM_USERNAME=...
UPSTASH_KAFKA_SCRAM_PASSWORD=...
- Install dependencies
From the root of the project run:
go mod tidy
go mod vendor
- Run the application
Again from the root of the project, run:
go run cmd/server.go .env
Fly.io offers an easy (and free for 2 small machines) way to deploy apps using
a Dockerfile
and a fly.toml
.
To build the docker image on your own machine (because building on Fly isn't free)
and deploy to one of the free machines, run:
fly deploy --vm-size shared-cpu-1x --local-only
The vm-size
specifies the small (free) machine, while local-only
flag specifies that the image should be built locally,
which means Docker should be running.
- rewrite README
- extract some variables as constants
- move customer creation out of the Webhook, but where? To another webhook? It might stay as is.
- wrap http handlers to allow CORS
You have the whole thing documented on your tablet.