Skip to content

Latest commit

 

History

History
23 lines (17 loc) · 988 Bytes

README_HOOK_BODY_PARSER.md

File metadata and controls

23 lines (17 loc) · 988 Bytes

Webhooks Body Parser

The body parser middleware component is necessary to receive and store payment related hooks from paddle.com. There is nothing special to this body parser. It merely enables parsing of urlencoded parameters in request bodies.

Can be used like any old ExpressJS middleware.

Example

'use strict'

const express = require('express')
const app = express()
const port = process.env.PORT || 3456

const paddleIntegration = require('@discue/paddle-firebase-mongodb')
const storage = paddleIntegration.subscriptionStorage({ url: 'mongodb://localhost:27017' })
const subscriptions = new paddleIntegration.SubscriptionHooks({ storage })

// register body parser first and middleware second
app.use('/_/payments', paddleIntegration.bodyparser())
app.post('/_/payments', paddleIntegration.middleware(subscriptions))

module.exports = app.listen(port)