Subscriptions

This commit is contained in:
aeroreyna
2022-02-04 22:54:48 -06:00
parent cb056a078a
commit 294cacf963
4 changed files with 78 additions and 12 deletions

View File

@@ -57,7 +57,8 @@ DB.getDB.then((DB) => {
paymentIntent,
userid,
price,
description
description,
client_secret: paymentIntent.client_secret,
};
DB.newIntent(intent);
@@ -81,7 +82,16 @@ DB.getDB.then((DB) => {
result,
userid
};
DB.newResult(payment);
//console.log(payment);
const intent = await DB.getIntent(result.client_secret);
if(intent.description === "Subscription 1 Month"){
//update profile subscription status
const profileid = getProfileId(req);
const isSubscriptor = await DB.isSubscriptor(profileid);
const updateR = await DB.updateProfileSubscription(profileid, !isSubscriptor);
console.log(updateR);
}
await DB.newResult(payment, result.client_secret);
return res.send({
status: 'ok'