Skip to content

discue/paddle-integration-mongodb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

707 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vue logo


GitHub tag Latest Stable Version License
NPM Downloads NPM Downloads
contributions - welcome Made with Node.js

paddle-integration-mongodb

paddle.com payments integration for MongoDB.

This module provides

  • a body parser function
  • a middleware function to receive and store Paddle Webhooks
  • access to the Paddle API.

It does not

  • validate webhook content. Use and register paddle-webhook-validator in your application to validate webhooks before storing them.

Installation

npm install @discue/paddle-integration-mongodb

Components

Preparing a New Subscription

For the webhooks integration to work and to be able to correlate incoming hooks with the correct subscription, a placeholder needs to be created before the checkout and - afterward - a specific value must be passed to the Checkout API via the passthrough parameter. This value will be returned by the addSubscriptionPlaceholder method.

import { SubscriptionHooks, subscriptionStorage } from '@discue/paddle-integration-mongodb'
import client from './my-mongodb-client.js' // <-- to be provided by your application

const storage = subscriptionStorage({ client })
const subscriptions = new SubscriptionHooks({ storage })

module.exports = async (req, res, next) => {
    // requires application to read api_client information 
    // based on incoming information like a JWT or a cookie
    const { id } = readApiClient(req)

    // create subscription placeholder
    const { passthrough } = await subscriptions.addSubscriptionPlaceholder([id])
    // return the passthrough to the frontend app
    res.status(200).send(JSON.stringify({ passthrough }))
}

Run E2E Tests

To run tests, run the following command

./test-e2e.sh

License

MIT

About

Paddle payments integration for mongodb database

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors