• Stars
    star
    1,465
  • Rank 32,103 (Top 0.7 %)
  • Language
    Go
  • License
    MIT License
  • Created over 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A headless e-commerce for JAMstack sites.

GoCommerce Build Status

A small go based API for static e-commerce sites.

It handles orders and payments. Integrates with Stripe for payments and will support international pricing and VAT verification.

GoCommerce is released under the MIT License. Please make sure you understand its implications and guarantees.

What your static site must support

Each product you want to sell from your static site must have unique URL where GoCommerce can find the meta data needed for calculating pricing and taxes in order to verify that the order is legitimate before using Stripe to charge the client.

The metadata can be anywhere on the page, and goes in a script tag in this format:

<script class="gocommerce-product" type="application/json">
{"sku": "my-product", "title": "My Product", "prices": [{"amount": "49.99", "currency": "USD"}], "type": "ebook"}
</script>

The minimum required is the Sku, title and at least one "price". Default currency is USD if nothing else specified.

VAT, Countries and Regions

GoCommerce will regularly check for a file called https://example.com/gocommerce/settings.json

This file should have settings with rules for VAT or currency regions.

This file is not required for GoCommerce to work, but will enable support for various advanced features. Currently it enables VAT calculations on a per country/product type basic.

The reason we make you include the file in the static site, is that you'll need to do the same VAT calculations client side during checkout to be able to show this to the user. The commerce-js client library can help you with this.

Here's an example settings file:

{
  "taxes": [{
    "percentage": 20,
    "product_types": ["ebook"],
    "countries": ["Austria", "Bulgaria", "Estonia", "France", "Gibraltar", "Slovakia", "United Kingdom"]
  }, {
    "percentage": 7,
    "product_types": ["book"],
    "countries": ["Austria", "Belgium", "Bulgaria", "Croatia", "Cyprus", "Denmark", "Estonia"]
  }]
}

Based on these rules, if an order includes a product with "type" set to "ebook" in the product metadata on the site and the users billing Address is set to "Austria", GoCommerce will verify that a 20 percentage tax has been included in that product.

JavaScript Client Library

The easiest way to use GoCommerce is with commerce-js.

IMPORTANT: Since Release 1.8.0 of GoCommerce at least Version 5.0.0 of the JavaScript Client is required.

Running the GoCommerce backend

GoCommerce can be deployed to any server environment that runs Go. Minimum requirement for Go is version 1.11 since GoCommerce is using Go modules.

The button below provides a quick way to get started by running on Heroku:

Deploy

Configuration

You may configure GoCommerce using either a configuration file named .env, environment variables, or a combination of both. Environment variables are prefixed with GOCOMMERCE_, and will always have precedence over values provided via file.

For local dev, the easiest way to get started is to copy the included example.env file to .env

Top-Level

GOCOMMERCE_SITE_URL=https://example.netlify.com/

SITE_URL - string required

The base URL your site is located at.

OPERATOR_TOKEN - string Multi-instance mode only

The shared secret with an operator (usually Netlify) for this microservice. Used to verify requests have been proxied through the operator and the payload values can be trusted.

API

GOCOMMERCE_API_HOST=localhost
PORT=9999

API_HOST - string

Hostname to listen on.

PORT (no prefix) / API_PORT - number

Port number to listen on. Defaults to 8080.

API_ENDPOINT - string Multi-instance mode only

Controls what endpoint Netlify can access this API on.

Database

GOCOMMERCE_DB_DRIVER=sqlite3
DATABASE_URL=gotrue.db

DB_DRIVER - string required

Chooses what dialect of database you want. Choose from sqlite3, mysql, or postgres.

DATABASE_URL (no prefix) / DB_DATABASE_URL - string required

Connection string for the database. See the gorm examples for more details.

DB_NAMESPACE - string

Adds a prefix to all table names.

DB_AUTOMIGRATE - bool

If enabled, creates missing tables and columns upon startup.

Logging

LOG_LEVEL=debug

LOG_LEVEL - string

Controls what log levels are output. Choose from panic, fatal, error, warn, info, or debug. Defaults to info.

LOG_FILE - string

If you wish logs to be written to a file, set log_file to a valid file path.

Payment

Stripe

PAYMENT_STRIPE_ENABLED - bool

Whether Stripe is enabled as a payment provider or not.

PAYMENT_STRIPE_SECRET_KEY - string

The Stripe secret key used when authenticating with the Stripe API.

PayPal

PAYMENT_PAYPAL_ENABLED - bool

Whether PayPal is enabled as a payment provider or not.

PAYMENT_PAYPAL_CLIENT_ID - string PAYMENT_PAYPAL_SECRET - string

The OAuth credentials PayPal issued to you. GoCommerce will use them to obtain an access token.

PAYMENT_PAYPAL_ENV - string

The PayPal environment to use. Choose from production or sandbox.

Downloads

DOWNLOADS_PROVIDER - string

The provider to use for downloads. Choose from netlify or ``.

DOWNLOADS_NETLIFY_TOKEN - string

The authentication bearer token used to access the Netlify downloads API.

Coupons

COUPONS_URL - string

A URL that contains all the coupon information in JSON.

COUPONS_USER - string COUPONS_PASSWORD - string

HTTP Basic Authentication information to use if required to access the coupon information.

Webhooks

WEBHOOKS_ORDER - string WEBHOOKS_PAYMENT - string WEBHOOKS_UPDATE - string WEBHOOKS_REFUND - string

A URL to send a webhook to when the corresponding action has been performed.

WEBHOOKS_SECRET - string

A secret used to sign a JWT included in the X-Commerce-Signature header. This can be used to verify the webhook came from GoCommerce.

JSON Web Tokens (JWT)

GOCOMMERCE_JWT_SECRET=supersecretvalue

JWT_SECRET - string required

The secret used to verify JWT tokens with.

JWT_ADMIN_GROUP_NAME - string

The name of the admin group (if enabled). Defaults to admin.

E-Mail

Sending email is not required, but is highly recommended. If enabled, you must provide the required values below.

GOCOMMERCE_SMTP_HOST=smtp.mandrillapp.com
GOCOMMERCE_SMTP_PORT=587
[email protected]
GOCOMMERCE_SMTP_PASS=correcthorsebatterystaple
[email protected]
GOCOMMERCE_MAILER_SUBJECTS_ORDER_CONFIRMATION="Please confirm"

SMTP_ADMIN_EMAIL - string required

The From email address for all emails sent. Order receipts are also sent to this address.

SMTP_HOST - string required

The mail server hostname to send emails through.

SMTP_PORT - number required

The port number to connect to the mail server on.

SMTP_USER - string

If the mail server requires authentication, the username to use.

SMTP_PASS - string

If the mail server requires authentication, the password to use.

MAILER_SUBJECTS_ORDER_CONFIRMATION - string

Email subject to use for order confirmations. Defaults to Order Confirmation.

MAILER_SUBJECTS_ORDER_RECEIVED - string

Email subject to use for orders sent to the store admin. Defaults to Order Received From {{ .Order.Email }}.

MAILER_TEMPLATES_ORDER_CONFIRMATION - string

URL path, relative to the SITE_URL, of an email template to use when sending an order confirmation. Order and Transaction variables are available.

Default Content (if template is unavailable):

<h2>Thank you for your order!</h2>

<ul>
{{ range .Order.LineItems }}
<li>{{ .Title }} <strong>{{ .Quantity }} x {{ .Price }}</strong></li>
{{ end }}
</ul>

<p>Total amount: <strong>{{ .Order.Total }}</strong></p>

MAILER_TEMPLATES_ORDER_RECEIVED - string

URL path, relative to the SITE_URL, of an email template to use when sending order details to the store admin. Order and Transaction variables are available.

Default Content (if template is unavailable):

<h2>Order Received From {{ .Order.Email }}</h2>

<ul>
{{ range .Order.LineItems }}
<li>{{ .Title }} <strong>{{ .Quantity }} x {{ .Price }}</strong></li>
{{ end }}
</ul>

<p>Total amount: <strong>{{ .Order.Total }}</strong></p>

More Repositories

1

netlify-cms

A Git-based CMS for Static Site Generators
JavaScript
16,192
star
2

gotrue

An SWT based API for managing users and issuing SWT tokens.
Go
3,530
star
3

staticgen

StaticGen.com, A leaderboard of top open-source static site generators
JavaScript
2,471
star
4

cli

Netlify Command Line Interface
TypeScript
1,576
star
5

netlify-identity-widget

A zero config, framework free Netlify Identity widget
JavaScript
735
star
6

next-on-netlify

Build and deploy Next.js applications with Server-Side Rendering on Netlify!
JavaScript
720
star
7

headlesscms.org

Source for headlesscms.org
JavaScript
628
star
8

netlify-lambda

Helps building and serving lambda functions locally and in CI environments
JavaScript
601
star
9

next-runtime

The Next.js Runtime allows Next.js to run on Netlify with zero configuration
TypeScript
575
star
10

functions.netlify.com

Tutorials, examples, workshops and a playground for serverless with Netlify Functions
SCSS
515
star
11

build-image

This is the build image used for running automated builds
Shell
498
star
12

gotrue-js

JavaScript client library for GoTrue
JavaScript
457
star
13

create-react-app-lambda

JavaScript
414
star
14

netlify-faunadb-example

Using FaunaDB with netlify functions
JavaScript
388
star
15

actions

Shell
360
star
16

git-gateway

A Gateway to Git APIs
Go
355
star
17

zip-it-and-ship-it

Intelligently prepare Node.js Lambda functions for deployment
JavaScript
305
star
18

gotell

Netlify Comments is an API and build tool for handling large amounts of comments for JAMstack products
Go
276
star
19

explorers

JavaScript
262
star
20

million-devs

Microsite for the 1 Million Developers announcement.
Vue
250
star
21

netlify-statuskit

Netlify StatusKit is a template to deploy your own Status pages on Netlify.
HTML
237
star
22

open-api

Open API specification of Netlify's API
Go
234
star
23

build

Netlify Build (node process) runs the build command, Build Plugins and bundles Netlify Functions. Can be run in Buildbot or locally using Netlify CLI
JavaScript
216
star
24

js-client

A Open-API derived JS + Node.js API client for Netlify
JavaScript
214
star
25

netlify-plugin-lighthouse

Netlify Plugin to run Lighthouse on each build
JavaScript
198
star
26

netlifyctl

Go
178
star
27

netlify-dev-plugin

Local dev server with functions, rules engine and add-on support
JavaScript
176
star
28

framework-info

Framework detection utility
JavaScript
137
star
29

jekyll-srcset

Dead simple responsive images for jekyll
Ruby
136
star
30

gocommerce-js

A gocommerce client library
JavaScript
130
star
31

jekyll-gdrive

Access a Google Drive Spreadsheet from your Jekyll templates
Ruby
116
star
32

plugins

Netlify plugins directory.
JavaScript
95
star
33

prerender

Automatically rendering JS-driven pages for crawlers and social sharing
JavaScript
94
star
34

netlify-playground

89
star
35

netlify-plugin-gatsby

A build plugin to integrate Gatsby seamlessly with Netlify
TypeScript
88
star
36

code-examples

Code snippets for customers
HTML
87
star
37

labs

Documentation and samples for Netlify Labs features.
76
star
38

templates

This is board to showcase templates and boilerplates https://templates.netlify.com
Nunjucks
76
star
39

vue-cli-plugin-netlify-lambda

Netlify Lambda plugin for Vue CLI
JavaScript
76
star
40

remix-template

Deploy your Remix site to Netlify Edge Functions
JavaScript
73
star
41

netlify-cms-widget-starter

A boilerplate for creating Netlify CMS widgets.
JavaScript
73
star
42

classnames-template-literals

Small utility to format long classnames with template literals
JavaScript
70
star
43

edge-functions-examples

Explore a library of reference examples for learning about Edge Functions on Netlify.
JavaScript
70
star
44

gotiator

A tiny JWT based API gateway
Go
70
star
45

matterday.netlify.com

A site that asks us what we could do with more time.
CSS
70
star
46

react-server-components-demo

Minimal implementation on server components via Netlify functions
JavaScript
67
star
47

binrc

Binrc is a command line application to manage different versions of binaries stored on GitHub releases.
Makefile
52
star
48

next-on-netlify-demo

Demo of a Next.js app with Server-Side Rendering on Netlify
JavaScript
52
star
49

go-functions-example

Go
49
star
50

petsofnetlify

pets of netlifiers
Nunjucks
47
star
51

full-react-server-demo

JavaScript
45
star
52

rust-functions-example

Deploy Rust lambda functions on Netlify
Rust
45
star
53

gojoin

Mini API wrapping Stripes Subscriptions for Single Page Aps and JAMstack sites
Go
41
star
54

netlify-git-api

Go
41
star
55

gatsby-parallel-runner

JavaScript
38
star
56

functions

JavaScript and TypeScript utilities for Netlify Functions.
TypeScript
38
star
57

elastinats

Go
36
star
58

netlify-photo-gallery

HTML
35
star
59

gocommerce-admin

Admin UI for Netlify Commerce
JavaScript
35
star
60

addons

Netlify add-on documentation
34
star
61

ask-netlify

A place to submit questions for Netlify to answer in tutorials, podcasts and blog posts
HTML
34
star
62

netlify-auth-demo

Demo for integrating GitHub OAuth with a Netlify site
HTML
33
star
63

explorers-up-and-running-with-serverless-functions

Free resource for learning how to use serverless functions!
HTML
31
star
64

hydrogen-netlify-starter

Get started with Hydrogen on Netlify
JavaScript
31
star
65

build-plugin-template

Template repository to create new Netlify Build plugins.
JavaScript
30
star
66

twickr

Twickr lets you send tweets of interest from Twitter to Slack
Go
30
star
67

next-edge-middleware

JavaScript
29
star
68

remix-compute

Remix adapter and server runtime for Netlify
TypeScript
29
star
69

www-post-scheduler

This is a serverless function to auto publish blog posts
JavaScript
28
star
70

postcss-fout-with-a-class

Rewrite all selectors that will trigger a font load to be scoped under a class
JavaScript
28
star
71

micro-api-client

Small library for talking to micro REST APIs (not related to Netlify's main API)
JavaScript
28
star
72

vue-lambda-starter

Starter Template for Vue + AWS Lambda with Netlify
Vue
27
star
73

netlify-browser-extension

netlify-chrome-extension
JavaScript
26
star
74

make-wp-epic

Migration tool for moving from WordPress to Victor Hugo
JavaScript
26
star
75

hydrogen-platform

Hydrogen support for Netlify Edge Functions
TypeScript
26
star
76

netlify-redirect-parser

Library for parsing Netlify redirects
JavaScript
23
star
77

next-react-server-components

JavaScript
22
star
78

netlify-auth-providers

JS library to use Netlify's OAuth providers
JavaScript
22
star
79

explorers-composition-api

Learn how the Composition API works in this Jamstack Explorers mission!
Vue
20
star
80

vite-plugin-netlify-edge

Netlify Edge Function support for Vite
TypeScript
19
star
81

angular-runtime

The Angular Runtime allows Angular to run on Netlify with zero configuration
JavaScript
18
star
82

mailme

MailMe sends mails with stylish templates
Go
18
star
83

eslint-config-node

ESLint, Prettier and Editorconfig shared by Netlify's Node.js projects
JavaScript
18
star
84

slate-markdown-serializer

JavaScript
17
star
85

delta-action

A GitHub Action for capturing benchmark data and tracking its variation against a baseline
JavaScript
17
star
86

netlify-credential-helper

Git credential helper to use Netlify's API as authentication backend
Go
16
star
87

blobs

A TypeScript client for Netlify Blobs
TypeScript
16
star
88

netlify-cms-www

Former repo for netlifycms.org. Moved to the code repo at
CSS
15
star
89

go-client

Depreciated repo: home of the old go client. See netlify/open-api for the new home of the go client
Go
15
star
90

verify-okta

Small Lambda function for verifying and gating content with Okta
Go
14
star
91

netlify-oauth-example

JavaScript
14
star
92

godoc-static

Generates static HTML of documentation of Go libraries
Go
13
star
93

fauna-one-click

Moved https://github.com/netlify/netlify-faunadb-example
JavaScript
13
star
94

screenshot

Take screenshots of websites
Shell
13
star
95

netlify-comments-starter

Start project for Netlify Comments
13
star
96

node-template

Netlify's Node.js repository template
Python
13
star
97

streamer

tail files and send them to nats
Go
12
star
98

edge-bundler

Intelligently prepare Netlify Edge Functions for deployment
TypeScript
12
star
99

ruby-client

Netlify API client for Ruby
Ruby
11
star
100

gatsby-plugin-netlify

Gatsby plugin. Automatically generates a _headers file and a _redirects file at the root of the public folder to configure HTTP headers and redirects on Netlify.
TypeScript
11
star