Giter Club home page Giter Club logo

donation-server's Introduction

Accept a donation

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.

Requirements

  • 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)

How to run

  1. 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=...
  1. Install dependencies

From the root of the project run:

go mod tidy
go mod vendor
  1. Run the application

Again from the root of the project, run:

go run cmd/server.go .env

How to deploy to Fly.io

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.

TODO

  • 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

Note to self

You have the whole thing documented on your tablet.

donation-server's People

Contributors

vedrankolka avatar vedran-kolka avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.