GithubHelp home page GithubHelp logo

weilyuwang / go-stripe Goto Github PK

View Code? Open in Web Editor NEW
6.0 1.0 2.0 780 KB

A sample e-commerce application, built from the ground up on Go, integrated with Stripe API to support secure transaction, product purchase/refund, plan subscription/cancel.

Go 100.00%
websocket mariadb db-migration stripe stripe-subscriptions stripe-payments authentication microservices restful-api

go-stripe's Introduction

GO Stripe

Components

A sample E-Commerce application that consists of multiple, separate applications:

  • A front end, rendered using Go's rich html/template package and services content to the end user as web pages.
  • A restful back end API, which is called by the front end as necessary.
  • A microservice that's dynamically building PDF invoices and sending them to customers as an email attachment.

Functionalities

The application:

  • allows users to purchase a single product.
  • allows users to purchase a recurring monthly subscription (a Stripe plan).
  • handles subscription cancellations and refunds.
  • saves all transaction information to a MariaDB database (for refunds, reporting, etc.).
  • secures access to the frontend via session authentication.
  • secures access to the backend API via stateful tokens.
  • manages users (add/edit/delete).
  • allows users to reset their passwords safely and securely.
  • supports logging a user out and cancel their account instantly, over websockets.
  • produces PDF invoices and sends them via email to the customers.

MariaDB database

Start the database:

docker-compose up

DB Migration Tool

Run DB migrations with Soda CLI

cd migrations &&
soda migrate

Generate DB dump from Docker container

docker exec -i [CONTAINER_NAME] mysqldump -uroot -p[ROOT_PASSWORD] --databases [DB_NAME] --skip-comments > [YOUR_PATH]/dump.sql

Environment variables required for each app component

Frontend (cmd/web/main.go)

// stripe
STRIPE_KEY=
STRIPE_SECRET=

// Secret Key (Must be 256 bits/32 chars)
SECRET_KEY=

Backend (cmd/api/api.go)

// stripe
STRIPE_KEY=
STRIPE_SECRET=

// Secret Key (must be the same as frontend SECRET_KEY)
SECRET_KEY=

// smtp (e.g. mailtrap.io)
SMTP_USERNAME=
SMTP_PASSWORD=

Invoice Microservice (cmd/micro/invoice/invoice.go)

// smtp (e.g. mailtrap.io)
SMTP_USERNAME=
SMTP_PASSWORD=

Start the app (with Makefile)

  • Fill out the ENV's at the top of the makefile.example
  • Rename Makefile.example to Makefile
  • Run make start to start all the app components

Main Go Modules Used in this project

go-stripe's People

Contributors

weilyuwang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  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.