Code Monkey home page Code Monkey logo

stripe-local's Introduction

Stripe Local

Build Status JavaScript Style Guide

A library to receive Stripe Webhooks locally with Node. Uses real events from your Stripe account by polling for them at a defined interval and passing the data to your local server.

Stripe Local will only receive events that occur while it is running. Because of this, you will never receive old events.

NOTE: This package is meant for a local development environment. For live environments with a publicly accessible URL, you should use Stripe webhooks themselves.

Getting Started

# to use the CLI
$ npm install -g stripe-local

# or the API
$ npm install --save-dev stripe-local

# or Docker
docker run jsonmaur/stripe-local

CLI

# start listening for events
$ stripe-local --key $STRIPE_KEY --url http://localhost:7000/stripe

# get a list of options
$ stripe-local help

API

/* make sure you only run in dev environment */
if (process.env.NODE_ENV === 'development') {
  require('stripe-local')({
    secretKey: process.env.STRIPE_KEY,
    webhookUrl: 'http://localhost:7000/stripe'
  })
}

Using Docker

If you want a quick and easy way to get started, use Docker. This image is located at jsonmaur/stripe-local on Docker Hub. The two required environment variables are STRIPE_KEY and WEBHOOK_URL.

docker run -e "STRIPE_KEY=..." -e "WEBHOOK_URL=..." jsonmaur/stripe-local
Options
  • secretKey Your Stripe test secret key. You should set this in an environment variable to avoid committing to version control.

    Type: string
    Required

  • webhookUrl The local URL to send Stripe webhooks as events are received. This endpoint should be setup in your application to handle Stripe webhooks.

    Type: string
    Required

  • interval The amount of time (in milliseconds) to wait between polling for new events.

    Type: number
    Default: 5000 (5s)

  • overlap The amount of time (in milliseconds) to overlap with the last request. Because multiple stripe events can happen per second if there is no overlap some events may be missed.

    Type: number Default: 2000 (2s)

  • quiet Whether to hide all logged messages.

    Type: boolean
    Default: false

Todo

  • Store requests so we can monitor their statuses
  • Retry failed requests
  • Log request responses

License

MIT © Jason Maurer

stripe-local's People

Contributors

alxmrtn avatar jsonmaur avatar loctrice avatar mcfilib avatar ricky-crichq 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.