Hello,
I’m trying to grant users by writing to their userID, with a Webhook.
When the Webhook triggers, and I get the original_app_user_id
I search which user with this original_app_user_id
is requesting a purchase, so I’m sure it’s this userID. ( see attached the code to query )
I update the original_app_user_id
to the db right before I make a purchase from the iOS SDK by requesting purchaseInfo.
Does it seems to be a good way to do it ? or I could face bad scenarios ? If a change might happens to the original_app_user_id
will it be before, during or after the purchase ?
PS: I’m using Transfer now (and before I used Aliases)
Thank you,
async function returnCurrentUid(original_app_user_id){
const querySnapShot = await fb.collection('in_app')
.where('original_app_user_id', '==', original_app_user_id)
.orderBy('request_date', 'desc')
.get();
if (querySnapShot.empty) {
return 'Unknown'
};
const uid = querySnapShot.docs 0].id;
return uid;
};