Skip to content

πŸ’° A simple jam-stack commerce built on top of Supabase, Chakra UI, Typescript, Next.js and Stripe πŸ”.

License

Notifications You must be signed in to change notification settings

devkindhq/jamcommerce

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

JamCommerce

A full stack app to provide mini ecommerce system to sell service or products, collect donations. Inspirations are from Eventbrite, Gumroad, GoFundMe, OpenCollective, LaunchGood and so fourth.

Features

  • πŸ› Stripe Checkout
  • ΰΈΏ Multi-currency
  • πŸ’Έ Donation give levels
  • πŸ€‘ Donation tips
  • πŸ›’ Fundamental Shopping Cart logic
  • βš›οΈ State management
  • πŸ—ƒ Local Storage Support
  • ☁︎ Serverless Utilities (Product Validation)
  • 🧾 Easy-To-Access Cart Info
  • βœ… Fully Tested
  • 🎸 Jamstack friendly
  • and more to come πŸ”₯

Setup

Prequisites:

You will need to sign your account to the following services. Please make sure they're available in your country.

  • Stripe account
  • Supabase account
  • Currencyapi account
Clone the repo
git clone https://github.com/rome2o/jamcommerce
cd jamcommerce
Create your environment variables

Please fetch all your API keys and chuck it inside the following

cp .env.local.example .env.local

Also, create .env file

nano .env
# Supabase database URL
DATABASE_URL=postgres://postgres:[YOUR-PASSWORD]@db.abc.supabase.co:[PORT]/postgres
Push the database schema
npx prisma db push

Populate your currency table

Hit the currency API to populate your currencies. Make sure your you've CURRENCY_API_ENDPOINT and CURRENCY_API_KEY

curl --request POST \                                    
     --url 'http://localhost:3000/api/currency' \
     --header 'Authorization: Bearer <YOUR_API_TOKEN>'

Add campaign information

Some parameters are required to be set in the config/index.ts

export const CURRENCY = 'AUD'
// Set your amount limits: Use float for decimal currencies and
// Integer for zero-decimal currencies: https://stripe.com/docs/currencies#zero-decimal.
export const MIN_AMOUNT = 10.0
export const MAX_AMOUNT = 5000.0
export const AMOUNT_STEP = 5.0
export const DEALING_CURRENCIES =  ['AUD','EUR','USD','CAD','IDR']
export const BASE_CURRENCY = 'AUD'
export const RAISING_AMOUNT = 10000

Demo

  • Live demo: To be added
  • CodeSandbox: To be added
  • Tutorial: To be added

The demo is running in test mode -- use 4242424242424242 as a test card number with any CVC + future expiration date.

Use the 4000000000003220 test card number to trigger a 3D Secure challenge flow.

Read more about testing on Stripe at https://stripe.com/docs/testing.

Shopping Cart Checkout Demo A gif of the Shopping Cart Checkout payment page.
Checkout Donations Demo A gif of the Checkout payment page.
Elements Donations Demo A gif of the custom Elements checkout page.

Deploy your own

Once you have access to the environment variables you'll need from the Stripe Dashboard, deploy the example using Vercel:

Deploy to Vercel

Included functionality

Stripe information

Copy the .env.local.example file into a file named .env.local in the root directory of this project:

cp .env.local.example .env.local

You will need a Stripe account (register) to run this sample. Go to the Stripe developer dashboard to find your API keys and replace them in the .env.local file.

NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=<replace-with-your-publishable-key>
STRIPE_SECRET_KEY=<replace-with-your-secret-key>

Forward webhooks to your local dev server

First install the CLI and link your Stripe account.

Next, start the webhook forwarding:

stripe listen --forward-to localhost:3000/api/webhooks

The CLI will print a webhook secret key to the console. Set STRIPE_WEBHOOK_SECRET to this value in your .env.local file.

Setting up a live webhook endpoint

After deploying, copy the deployment URL with the webhook path (https://your-url.vercel.app/api/webhooks) and create a live webhook endpoint in your Stripe dashboard.

Once created, you can click to reveal your webhook's signing secret. Copy the webhook secret (whsec_***) and add it as a new environment variable in your Vercel Dashboard:

  • Select your newly created project.
  • Navigate to the Settings tab.
  • In the general settings scroll to the "Environment Variables" section.

After adding an environment variable you will need to rebuild your project for it to become within your code. Within your project Dashboard, navigate to the "Deployments" tab, select the most recent deployment, click the overflow menu button (next to the "Visit" button) and select "Redeploy".

Deploy on Vercel

You can deploy this app to the cloud with Vercel (Documentation).

Deploy Your Local Project

To deploy your local project to Vercel, push it to GitHub/GitLab/Bitbucket and import to Vercel.

Important: When you import your project on Vercel, make sure to click on Environment Variables and set them to match your .env.local file.

Forked from

This project is a fork a Next.js example. You can read related documentation here

Authors

About

πŸ’° A simple jam-stack commerce built on top of Supabase, Chakra UI, Typescript, Next.js and Stripe πŸ”.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published