Hello guys! Ok, so how many of you had wanted to create subscriptions for your game, so that you can charge players a specific amount once and give them access to the Benefits of the Subscription for Specific time and then automatically make them expired when the time ends? Many people did, but many people found this hard. So we, built a module for everyone to create Subscriptions for their game!
Bringing to you Subscriber! A Module that does all the work for creating, retrieving and cancelling subscriptions, everything in the background!
About Subscriber
Subscriber is a Subscription essential module, that is built by @WaterJamesPlough and @TheBrainy06! It can be used to create, retrieve or cancel subscriptions, an example usage of it can be – A VIP subscription, in which you can call the Create Function on PurchaseFinished Event, you will probably know when you call the other 2 functions.
Subscriber has most of its code run in NodeJS & saves the subscriptions in MongoDB, we chose to do this because we felt like building this in NodeJS gave more flexiblity for functions.
Subscriber Usage
Our module has 3 main functions currently, but we will surely be updated it depending on the feedback/suggestions of everyone! One thing to remember, you need to place the subscriber module in Server Script Storage, as it makes HTTP requests, we don’t want to expose anything to our players.
Setup
First of all create two String values in ServerStorage (SubscriptionUsername & SubscriptionPassword) and enter in your Username & Password, it can be anything if its the first time you are running the module. Once you create the first subscription, your password can’t be changed.
1. Creating Subscriptions:
local subscriber = require(script.parent.Subscriber) --The location of the module script in Server Script Storage
subscriber.Create(857125712, 30, "VIP")
The Create method accepts three arguments - Player ID, Subscription Validity and Subscription Name
Player ID: Its the Player.UserId, just to recognize the player for which this subscription is.
Subscription Validity: A Number, which represents how long this Subscription is valid for in Days.
Subscription Name: A String, which represents the name of the Subscription, so you can retrieve it later on.
The Create method returns a response object, which looks like this:
{"plrID":422797741,"validTill":"Wed Jun 24 2020","valid":true,"failResponse":"Faced No Errors"}
It returns 4 Values - Player ID, Valid Till Date (In a readable form), Valid and Fail Reason.
Player ID - The UserId of the player
Valid Till Date - A Date given in Human Readable form, until when the subscription is valid.
Valid - Specifies if the Subscription is still valid
Fail Reason - If there were any errors while creating the Subscription, it will be stated here.
2. Retrieving Subscriptions
local subscriber = require(script.parent.Subscriber) --The location of the module script in Server Script Storage
subscriber.Retrieve(857125712, "VIP")
The Retrieve method accepts two arguments - Player ID and Subscription Name
Player ID: Its the Player.UserId, just to recognize the player whose this subscription is.
Subscription Name: A String, which represents the name of the Subscription.
The Retrieve method returns a response object, which looks like this:
{"plrID":422797741,"subscriptionName":"VIP","valid":true,"validTill":"Wed Jun 24 2020"}
It returns 4 Values - Player ID, Subscription Name, Validity And Valid Till Date.
Player ID - The UserId of the player
Subscription Name - The Unique Identifier Name for the Subscription
Validity - Returns a boolean, which represents if the Subscription is valid or not. Will return false, if there is no subscription.
Valid Till Date - Returns a Human Readable String, representing the date till which the subscription is valid. Will be null if the Subscription does not have a valid till date, meaning probably there isn’t a subscription.
3. Cancelling Subscriptions:
local subscriber = require(script.parent.Subscriber) --The location of the module script in Server Script Storage
subscriber.Cancel(857125712,"VIP")
The Cancel method accepts two arguments - Player ID and Subscription Name
Player ID: Its the Player.UserId, just to recognize the player for which this subscription is of.
Subscription Name: A String, which represents the name of the Subscription, to recognize which subscription to cancel, as there might be multiple subscriptions (VIP, PREMIUM etc).
The Cancel method returns a response object, which looks like this:
{"plrID":422797741,"subscriptionName":"VIP","Cancelled":false,"validTill":"Wed Jun 24 2020"}
It returns 4 Values - Player ID, Subscription Name, Cancelled, Valid Till Date
Player ID - The UserId of the player, whose Subscription was cancelled
Subscription Name - Specifies the name of the Subscription that was cancelled
Cancelled Property - Specifies if the Subscription was cancelled, boolean response.
Valid Till Date - A Date given in Human Readable form, until when the subscription is valid. Our module automatically expires the subscription when the Valid Till Date ends, suppose the Person bought it today and cancelled it after 3 days (For Some Reason), and 5 days are left for the Subscription. Our System will expire the subscription after 5 days, till then the subscription will still be Valid.
@TheBrainy06 will be making a tutorial on this explaining with an example soon, keep a look out for it! Till then if you would like to install and test our module
Source Code:
Roblox Module Code:
Thank you.