Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Latest commit

 

History

History
23 lines (17 loc) · 978 Bytes

README_HOOK_BODY_PARSER.md

File metadata and controls

23 lines (17 loc) · 978 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 paddleIntegrationFirestore = require('@discue/paddle-firebase-integration')
// pass the path to the collection here
const subscriptions = new paddleIntegrationFirestore.SubscriptionHooks('api_clients')

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

module.exports = app.listen(port)