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

Latest commit

 

History

History
29 lines (23 loc) · 1008 Bytes

README_HOOK_MIDDLEWARE.md

File metadata and controls

29 lines (23 loc) · 1008 Bytes

Webhooks Middleware

The middleware component is necessary to receive and store payment related hooks from paddle.com. Currently supported hooks are:

  • subscription_created
  • subscription_updated
  • subscription_cancelled
  • subscription_payment_succeeded
  • subscription_payment_refunded
  • subscription_payment_failed

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-integration')
// pass the path to the collection here
const subscriptions = new paddleIntegration.SubscriptionHooks('api_clients')

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

module.exports = app.listen(port)