Quickly test Stripe Webhooks against your application without hitting Stripe or requiring internet connectivity.
- Customize Webhook response
- Generate Webhook response object without triggering it against your application
- Offline mocking
- Supports multiple versions of the Stripe API
- Promises!
$ npm install stripe-mock-webhooks --save-dev// Require
var StripeMockWebhooks = require('stripe-mock-webhooks')
// Tell the server where it should send events
var webhooks = new StripeMockWebhooks({
version: '2015-10-01', // Default is latest Stripe API version
url: 'http://localhost:3001/stripe/events'
})Send a webhook:
webhooks.trigger('invoice.created').then(function (response) {
// success
}).catch(function (err) {
// error
})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
now- Updates eventcreatedtimestamp toDate.now(), defaults totrue
Look in tests to see example usage.
MIT © Nijiko Yonskai