Skip to content

queen-raae/gatsby-funcjam-21

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

27 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Sell access to a private Github repo

A demo showing how to sell sell access to a private Github repo.

  • Authenticates the buyer using Github
  • Collects payment using Stripe
  • Automagically adds buyers to repo when payment goes through

Also a Gatsby FuncJam โ€˜21 Winner ๐Ÿฅณ

ย 

A message or two or three from Queen Raae ๐Ÿ‘‘

1-on-1 Emergency Gatsby Call

Are you stuck on a reef in the sharky waters around the Gatsby islands? Check out 1-on-1 Emergency Gatsby Call with Queen Raae to get friendly advice you can put into action immediately from a seasoned Gatsby developer.

Stay updated and get the most out of Gatsby

Learn how to get the most out of Gatsby and stay updated on the demo by subscribing to daily emails from Queen Raae and Cap'n Ola.

Video Walkthrough

Watch us do a walkthrough of the code on this unauthorized and rum-fueled treasure hunt in the sharky waters around the Gatsby islands on YouTube with Queen Raae, Pirate Paul and Cap'n Ola.

ย 

How does it work?

To make it easier to follow there is a page for each major step in the process:

  • Index page triggers a GET request to /api/auth that triggers a redirect to Github page for authentication
    • On success Github redirects back to /auth/?code=<github auth code>
  • Auth page triggers a POST request to /api/auth to exchange the github auth code for an access token
    • On success navigates to /checkout with access token as state param
  • Checkout page triggers a POST request to /api/checkout creating a Stripe Checkout Session
    • On success navigates to the Checkout Sesssion URL returned from the function when on completing redirects back to /success/?sessionId=<Stripe Checkout Session ID>
  • Success Page triggers a POST request to /api/checkout retreivng the Stripe Checkout Session
    • On sucess displays message returned from the function.

Make it your own

  1. Prerequisite

    • A Stripe Secret Key (get one by creating a Stripe account)
    • A Stripe Price Id (get one by making a product, then a product price)
    • A GitHub OAuth App (create one in your Github settings)
    • A private Github repo to sell (create one on GitHub)
    • A Github Personal Access Token for the owner of above repo (create one in your Github settings)
  2. Develop

    • To get started clone this repo locally and run yarn install to add all necessary packages.
    • Create your own .env.development by copying .env.example: cp .env.example .env.development
    • Login with Stripe CLI: stripe login and follow the directions
    • Forward Stripe event to the Stripe Webook: stripe listen --forward-to http://localhost:8000/api/stripe-webhook
    • Fill out .env.development with your own data and you are ready for yarn develop
  3. Deploy

You can deploy this example on Gatsby Cloud by connecting your repo Gatsby Cloud.

Make sure to add all the keys needed as environment variables.

Helpful Links

About

My submission for Gatsby FuncJam 2021 ๐Ÿ‘‘

Resources

Stars

Watchers

Forks

Languages

  • JavaScript 89.7%
  • CSS 9.6%
  • Shell 0.7%