Skip to main content
Question

Automatically revoke promotional entitlements

  • July 18, 2023
  • 4 replies
  • 76 views

Forum|alt.badge.img

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

This post has been closed for comments

4 replies

Michael Fogel
Forum|alt.badge.img+6
  • Dedicated Contributor
  • July 19, 2023

Hey @arpit-patel-78d3f8 ,

 

Are you having any issues with this way of doing things? It looks like you're granting promotional’s when desired like this. If you're having any difficulties, let us know! 


Forum|alt.badge.img

Hello @Michael Fogel 

Yes facing issue, my issue is when i granting promotional’ s after some time revoking promotional’ s but i don't what the reason and we are not calling revoke promotional api but still revoke promotional.

See i shared image grant then revoke


Michael Fogel
Forum|alt.badge.img+6
  • Dedicated Contributor
  • July 24, 2023

Is the access being revoked or is the user possibly being aliased to a new user? If they are assigned a new app user ID, then the entitlements linked to that old ID wont live on their new app user ID so they would appear to lose the entitlement. 


Forum|alt.badge.img

Hi Michael,

Thanks for your help. We have figure out the issue which was a code level.

So everything is working fine now.

Thanks