Giter Club home page Giter Club logo

gatsby-theme-stripe-checkout-button-for-plans's Introduction

gatsby-stripe-checkout-button-for-plans

This is a fork of gatsby-theme-stripe-checkout-button and the only difference is that it works with Plans ( recursive payments )

A Gatsby theme that implements a stripe checkout, you bring the button, we submit it as a stripe checkout. Register an account at Stripe and follow the instruction for setting up a developer account to get started.

Add to your Gatsby sites gatsby-config.js just like you would with a plugin. The STRIPE_API_KEY, STRIPE_SECRET_KEY and siteUrl are passed in as options from the consuming theme or site.


It is recommended that you use environment variables to store your keys. You can store them in the root of your project in env.development or env.production files.

You can access these file in your gatsby-config.js like so:

let activeEnv =
  process.env.GATSBY_ACTIVE_ENV || process.env.NODE_ENV || "development" || "production"

require("dotenv").config({
  path: `.env.${activeEnv}`,
})


module.exports = {

    plugins: [
      {
        resolve: 'gatsby-stripe-checkout-button-for-plans',
        options: {
          STRIPE_API_KEY,
          STRIPE_SECRET_KEY,
          siteUrl
        }
      }
  ],
}

Example usage:

import { Checkout } from 'gatsby-stripe-checkout-button-for-plans';

    <Checkout
        button={<MyCustomButton type="submit" text="Buy Now!"/>}
        plan='plan_123'
        quantity={1}
        customerEmail={[email protected]}
    />

The component takes a custom button as its form submit which enables you to style it which ever way you wish, it only requires that you provide its type as 'submit'.

In addition the component requires you to provide the products sku (which can be taken from your products in your stripe dashboard) and the quantity of items to purchase. You can optionaly provide the customers email address from your form. This will enable you to prefill your customers billing information if they have already filled in the form before.

Once the user clicks the button to make a purchase they are redirected to the stripe checkout where they can fill out their card details and complete their purchase. Upon completion the user is redirected back to your gatsby site.

This theme provides three base components (success/canceled/error) which you should style yourself. These components should be placed inside your src/pages folder:

src/pages/checkout/success
src/pages/checkout/canceled
---
src/pages/error

Built With

Authors

  • Rich Haines - Hungry Bear Studio
  • Vagelis Papaioannou - Nuttifox

License

This project is licensed under the MIT License

gatsby-theme-stripe-checkout-button-for-plans's People

Contributors

vagelisp avatar

Stargazers

 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.