Question

How do I link purchase made by the user without login in my backend?

  • 7 August 2021
  • 3 replies
  • 74 views

Badge

The question is for an iOS app - 

 

My setup is that I am using my backend to give access to “Pro” features through the API and I am using Revenue cat to process the payment.

 

Sign up comes after the purchase is made and it is optional to the user.

 

I want to understand how I should give access from the backend to users who are making a purchase but do not sign up? This approach should also work when the user comes back and restores purchase after uninstalling the app. 


3 replies

Userlevel 3
Badge +7

Hey @Akash! 👋

RevenueCat is designed to be a source of truth for allowing access to pro/premium features, and we’ll handle syncing receipts and unlocking access with our Entitlements system, whether or not you use custom or anonymous user identifiers- you don’t need to handle granting access on your end as that’s what we’ve designed our platform to do.

We don’t require custom user IDs, but if you are using our default anonymous identifiers and don’t require a sign-in before making a purchase, there won’t be a great way to link the user from your backend since they are anonymous.

Additionally, when using our entitlement system, access will be handled correctly when restoring purchases with new installations and/or when using your app from other devices. You can read more about restoring purchases in our Restoring Purchases guide.

Does that make sense?

Badge

Thanks for the response. 

I want to make sure that I have understood this correctly when it is regarding restoring transaction for anonymous users. 

The scenario is as described below - 

My backend will generate anonymous user id’s for all users who are not logged in and supply it to revenue cat before any purchase is made. After the purchase is made, the webhook would update the purchase event in my database. Lets say a user makes such a purchase and doesn’t create an account. The same user then uninstalls and reinstalls the app. When the app is reinstalled my backend would create a new user id. Then the user goes onto restore the purchase. In that case, the purchase would be restored on the newly created user id. In this case “TRANSFER” webhook event would be triggered, which I can the use to associate the old payment with the new user id. 

Is this how I am supposed to deal with the above condition. 

Thanks

@Akash - We are thinking of a similar issue as you described (UserA deletes , makes new account , now has UserB id, user RESTORES PURCHASE ON iOS, revenue cat sends TRANSFER web hook) - but the issue is that TRANSFER webhook ONLY contains transfer data - not the payment expiry or anything else that happens when you subscribe/unsubscribe on Apple → Revenue Cat

I think solution will be you need to not destroy the user when delete happens and 
1. copy over subscription data from old ‘deactivated’ user
or
2. some how get that data again from Revenue Cat

@cody is there a reason TRANSFER webhook doesnt include all the subscription info?

Reply