[Android] How to handle different email for subscription and the one used to the app? #2826
Unanswered
therealaezel404
asked this question in
Q&A
Replies: 1 comment
-
|
User's Google Play account email may differ from the email registered in your app. Solution: Use obfuscatedAccountIdAndroidPass your app's user ID when making purchases to link the subscription to your user: import { requestPurchase } from 'react-native-iap';
await requestPurchase({
request: {
google: {
skus: ['subscription_id'],
obfuscatedAccountIdAndroid: hashUserId(user.id), // Your app's user ID (hashed)
obfuscatedProfileIdAndroid: hashProfileId(profile.id), // Optional: profile ID
},
},
type: 'subs',
});How It Works
Server-Side ValidationWhen validating purchases on your server, the Google Play Developer API response includes: {
"obfuscatedExternalAccountId": "hashed_user_id",
"obfuscatedExternalProfileId": "hashed_profile_id"
}Use this to link the purchase to the correct user in your database. Easy Option: Use IAPKitIf you don't want to build your own server, IAPKit handles this automatically: import { verifyPurchaseWithProvider } from 'react-native-iap';
const result = await verifyPurchaseWithProvider({
provider: 'iapkit',
iapkit: {
apiKey: 'your-iapkit-api-key',
google: { purchaseToken: purchase.purchaseToken! },
},
});Best Practices
Note on VersionYou're using v12.15.1 which is no longer supported. Please upgrade to v14+: References |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
**### react-native-iap version: **
12.15.1
**### react-native version: **
0.74.2
Hi everyone,
I'm working on a react-native project using react-native-iap, and I've encountered a situation where the email used for a subscription might be different from the registered email in my app.
Here's what I'm trying to figure out:
How should I handle situations where the subscription email and the app's registered email don't match?
What’s the best way to sync the subscription status with the correct user account?
Are there any best practices or recommended approaches for managing this scenario?
Any guides, examples or advice would be greatly appreciated!
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions