Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
checkIfPro(){
// Send email and PRO_PRODUCT_ID to check.php.
// check.php must get the list of all users from Paddle, then see if current user is among Pro users.
const userEmail = "email@example.com";
const PRODUCT_ID = 11111; //See this ID in the Paddle dashboard.
const URL = 'https://unicornplatform.com/api/check.php';
const data = {
email: userEmail,
productID: PRODUCT_ID
};
const PARAMS = {
headers: {
"Accept": "application/json",
"Content-Type": "application/json; charset=UTF-8"
},
body: JSON.stringify(data),
method: 'POST'
};
fetch(URL, params)
.then(res => res.text())
.then(response => {
let res = JSON.parse(response);
//PHP script returns an object.
if(res.isPro === 'true'){
// It's a Pro user.
}else{
// It's a free-plan user.
}
})
.catch(error => console.error('Error:', error));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.