This repository was archived by the owner on Oct 17, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
openiap/src/main/java/dev/hyo/openiap/helpers Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -112,11 +112,18 @@ internal fun RequestPurchaseProps.toAndroidPurchaseArgs(): AndroidPurchaseArgs {
112112 is RequestPurchaseProps .Request .Subscription -> {
113113 val android = payload.value.android
114114 ? : throw IllegalArgumentException (" Android subscription parameters are required" )
115+
116+ // For subscription upgrades/downgrades, obfuscatedProfileIdAndroid and purchaseTokenAndroid
117+ // are mutually exclusive. If purchaseTokenAndroid is provided (upgrade scenario),
118+ // we should not send obfuscatedProfileIdAndroid to avoid "Invalid arguments" error
119+ val isUpgrade = ! android.purchaseTokenAndroid.isNullOrEmpty()
120+ val effectiveObfuscatedProfileId = if (isUpgrade) null else android.obfuscatedProfileIdAndroid
121+
115122 AndroidPurchaseArgs (
116123 skus = android.skus,
117124 isOfferPersonalized = android.isOfferPersonalized,
118125 obfuscatedAccountId = android.obfuscatedAccountIdAndroid,
119- obfuscatedProfileId = android.obfuscatedProfileIdAndroid ,
126+ obfuscatedProfileId = effectiveObfuscatedProfileId ,
120127 purchaseTokenAndroid = android.purchaseTokenAndroid,
121128 replacementModeAndroid = android.replacementModeAndroid,
122129 subscriptionOffers = android.subscriptionOffers,
You can’t perform that action at this time.
0 commit comments