-
Notifications
You must be signed in to change notification settings - Fork 33
Subscriptions
Abraham Olaobaju edited this page Jul 31, 2023
·
3 revisions
This section discusses all API endpoints that are critical for managing user subscriptions. With these APIs, You can query your existing subscriptions, as well as activate or deactivate a user's subscription.
This allows the developers to query all subscribers (cancelled subscriber included).
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const fetchSubscription = async () => {
try {
const response = await flw.Subscription.fetch_all()
console.log(response);
} catch (error) {
console.log(error)
}
fetchSubscription();
describes how to activate a previously cancelled subscription.
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const activateSubscription = async () => {
try {
const payload={
"id":"3477" //This is the unique id of the subscription you want to activate. It is returned in the Get a subscription call as data.id
}
const response = await flw.Subscription.activate(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
activateSubscription();
describes how to deactivate an active subscription.
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const cancelSubscription = async () => {
try {
const payload={
"id":"3477" //This is the unique id of the subscription you want to cancel. It is returned in the Get a subscription call as data.id
}
const response = await flw.Subscription.cancel(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
cancelSubscription();