Solved

In- App Non Renewal Purchase original_app_user_id

  • 23 November 2021
  • 1 reply
  • 80 views

Badge +4
  • New Member
  • 2 replies

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;
};

 

icon

Best answer by cody 14 December 2021, 13:44

View original

1 reply

Userlevel 6
Badge +8

Hey @Ben!

While relying on `original_app_user_id` might work in a lot of cases, it’s best to be sure that you are considering the ‘aliases’ property of webhook events, as it will include all potential aliases of a user. If you’re keeping status in sync on your end, you’ll want to ensure you are granting access to all aliases of a particular user ID.

You can also get the current, on-device app user ID by checking Purchases.shared.appUserID on iOS, so you know which user ID the purchase will likely be associated with.

Additionally, it is possible that original_app_user_id can change (more likely when using the legacy alias behavior, though) when two users are merged. You’ll want to also watch out for `transfer` events so you know when a user has had their purchases transferred between user IDs.

I’d recommend taking a look at our webhook docs for more information: https://docs.revenuecat.com/docs/webhooks

Reply