How to confirm that two subscriptions are from the same user? #2903
Replies: 1 comment
-
|
On iOS, On Android, purchaseToken BehaviorScenario 1: Auto-renewalpurchaseToken stays the SAME. When a subscription renews automatically, the same Scenario 2: Upgrade/Downgrade (e.g., Monthly → Annual)purchaseToken CHANGES. A new To link them, use Scenario 3: Resubscribe after cancellation (before expiry)purchaseToken CHANGES. New token generated with Scenario 4: Resubscribe after expirationpurchaseToken CHANGES. New token generated, but Solution: Use linkedPurchaseToken (Server-side)Google Play Developer API returns
Important: Easy Solution: Use IAPKit with verifyPurchaseWithProviderIf you don't want to build your own server, you can use IAPKit with import { verifyPurchaseWithProvider } from 'react-native-iap';
const result = await verifyPurchaseWithProvider({
provider: 'iapkit',
iapkit: {
apiKey: 'your-iapkit-api-key',
google: { purchaseToken: purchase.purchaseToken! },
},
});
// IAPKit returns linkedPurchaseToken info when available
if (result.iapkit?.isValid) {
console.log('Purchase verified:', result.iapkit.state);
}Manual Approach
await requestPurchase({
request: {
google: {
skus: ['subscription_id'],
obfuscatedAccountIdAndroid: 'your_user_id_hash',
},
},
type: 'subs',
});References |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
On iOS, each subscription has the same originalTransactionIdentifierIOS, which can be used to confirm whether it comes from the same user.
However, there is no similar identifier in the purchaseHistory and currentPurchase objects in Android.
Can purchaseToken be used to make this judgment?
If a user subscribes to "Subscription A" (paid monthly), and it automatically renews after one month, is the purchaseToken used during renewal the same as the previous purchaseToken?
If a user subscribes to "Subscription A" (paid monthly), and one month later he wants to change to "Subscription B" (paid annually), is the purchaseToken used during subscription to "Subscription B" the same as the previous purchaseToken?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions