Hello Guys,
I have third party platform and every hour user data get from that platform using CRON JOB.
That data valid and if data valid then grant-a-promotional-entitlement api and give lifetime access after some time or next time same data get then automatically revoke-promotional-entitlements call. all data valid and already verified.
package used Axios(https://www.npmjs.com/package/axios) for grant-a-promotional-entitlement
I will provide below sample code
import axios from "axios";
import config from "config";
const grantPromotionalEntitlements = async (app_user_id: string, cronName: string) => {
const PayloadObject = {
url:
revenueBaseAPI +
`subscribers/${app_user_id}/entitlements/${"All_Features"}/promotional`,
method: "POST",
headers: {
"content-type": "application/json",
Authorization: `Bearer ${SECRATE_KEY}`,
},
data: {
duration: "lifetime",
},
} as any;
const res = await axios(PayloadObject)
.then((res) => {
return res.data;
})
.catch((err) => {
//console.log("grantPromotionalEntitlements", err);
return null;
});
return res;
};
let me know if anything i missed this