Skip to content
This repository was archived by the owner on Oct 17, 2025. It is now read-only.

Commit b5f21d2

Browse files
committed
fix: ensure effectiveObfuscatedProfileId when changing plan
1 parent e2d4c31 commit b5f21d2

File tree

1 file changed

+8
-1
lines changed
  • openiap/src/main/java/dev/hyo/openiap/helpers

1 file changed

+8
-1
lines changed

openiap/src/main/java/dev/hyo/openiap/helpers/Helpers.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff 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,

0 commit comments

Comments
 (0)