Skip to main content
Question

How to link an IAP purchase to a custom attribute?

  • January 22, 2025
  • 2 replies
  • 43 views

Forum|alt.badge.img+7

Hello,

I have an app (written in React Native) and use RevenueCatSdk to facilitate my IAP purchases. In my app I want to set an IAP price for a profile to unlock it. I can create 3 different IAPs to represent the different price tiers. When a user goes to buy the profile I will get a webhook saying the user bought lets call it “profile_access_first_tier” however, I won’t know what profile they unlocked. I will know who the purchaser is, and the product, but the actual product can apply to multiple profile unlocks. Is there a way, when the purchase is happening from the frontend to attach a custom attribute that will be sent with the “NON_RENEWING_PURCHASE” webhook? Such as attaching a custom attribute like “sellerId” would be useful so I can then give the user access to that seller’s profile? Yes I can solve this in a different way by storing something saying the profile the user is on before the purchase happens then link the two in the webhook, but I think this would be more reliable and avoid any race condition issues.

Thanks,
- Carl

This post has been closed for comments

2 replies

Forum|alt.badge.img+7
  • Author
  • Active Member
  • January 22, 2025

I found out a solution, setting this works from the frontend and propagates that into the corresponding webhook.
 

await Purchases.setAttributes({ lastProfileSeenSellerId: "testTheSeller" });


Webhooks will contain
 

"subscriber_attributes": {
"lastProfileSeenSellerId": { "value": "testTheSeller", "updated_at_ms": 1737572933391 }
},



This is awesome! And works perfectly for linking my in app purchase to the particular seller.


wes_clark
RevenueCat Staff
Forum|alt.badge.img+6
  • RevenueCat Staff
  • January 29, 2025

Hi! This is a good workaround. Just to let you know, we have investigated adding the ability to attach metadata to transactions in the past. I will raise your experience internally to the rest of the team.