Paddle payments integration for Google Cloud Firestore
npm install @discue/paddle-integration-firestore
bash
npm install @discue/paddle-integration-firestore
`
Components
- Webhooks Body Parser
- Webhooks Middleware
- Subscription Info
- Subscription Hydration
- Subscriptions API
$3
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.
You can see in the example below, the Subscriptions constructor is called with the name of the target collection and the id of the target document. The id could be your user or api_client id. Remember: the target document must exist before creating the placeholder.
`js
'use strict'
const readApiClient = require('./lib/your-application/read-api-client')
const paddleIntegration = require('@discue/paddle-firebase-integration')
// pass the path to the collection here
const subscriptions = new paddleIntegration.SubscriptionHooks('api_clients')
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
`bash
./test-e2e.sh
``