Stripe Mock Webhooks
Quickly test Stripe Webhooks against your application without hitting Stripe or requiring internet connectivity.
Features & Data
Install
$ npm install stripe-mock-webhooks --save-dev
Usage
var StripeMockWebhooks = require('stripe-mock-webhooks')
var webhooks = new StripeMockWebhooks({
version: '2015-10-01',
url: 'http://localhost:3001/stripe/events'
})
Send a webhook:
webhooks.trigger('invoice.created').then(function (response) {
}).catch(function (err) {
})
Or overwrite values in the response:
webhooks.trigger('invoice.created', {
data: {
object: {
plan: {
id: 'PLAN_IDENTIFIER'
}
}
}
})
Additional options can be turned on / off:
webhooks.trigger('invoice.created', undefined, {
now: false
})
Build JSON
response without triggering an event:
var response = webhooks.build('invoice.created', {
data: {
object: {
plan: {
id: 'PLAN_IDENTIFIER'
}
}
}
})
Supports the same arguments as webhooks.trigger
Trigger Options
now
- Updates event created
timestamp to Date.now()
, defaults to true
Examples
Look in tests to see example usage.
License
MIT © Nijiko Yonskai