Question

Automatically revoke promotional entitlements

  • 18 July 2023
  • 4 replies
  • 45 views

Badge

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


4 replies

Userlevel 4
Badge +6

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! 

Badge

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

Userlevel 4
Badge +6

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. 

Badge

Hi Michael,

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

So everything is working fine now.

Thanks

Reply