Skip to content

visla/stripe-local

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

  • 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

About

For receiving Stripe webhooks locally

Resources

License

Stars

Watchers

Forks

Packages

No packages published