Fix: return ProductAlreadyPurchasedError when purchasing an already-active subscription on a paywall#3699
Draft
vegaro wants to merge 3 commits into
Draft
Fix: return ProductAlreadyPurchasedError when purchasing an already-active subscription on a paywall#3699vegaro wants to merge 3 commits into
vegaro wants to merge 3 commits into
Conversation
…ption on paywall When a user taps purchase on a paywall package for a subscription they already actively own (same product id AND same base plan id), launching the Google billing flow fails with ITEM_ALREADY_OWNED, and the proration/product-change path errors with "arguments invalid". Detect this exact-match case client-side in ProductChangeCalculator and throw a PurchasesException with ProductAlreadyPurchasedError. This propagates through PaywallViewModel.performPurchase's existing PurchasesException catch, so the developer's onPurchaseError callback and the actionError state receive it on the same path as real purchase failures, and no billing flow is launched. Same product with a different base plan keeps its existing behavior (no error), and a different product keeps going through the proration path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JArdd49GRtykeca3meB8RA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Slack thread
On an Android paywall with proration modes configured, tapping purchase on a subscription the user already actively owns (same product + same base plan) opens the Google Play billing flow just to fail. The product-change path errors with "One or more of the arguments provided are invalid", and a plain purchase is rejected by Google Play as
ITEM_ALREADY_OWNED.After this change the SDK detects this case client-side and surfaces
PurchasesErrorCode.ProductAlreadyPurchasedErrorwithout opening the billing flow at all. The error goes through the normal paywall purchase-error path, so developers already handling purchase errors receive it on the same callback as any real purchase failure.Note: re-enabling auto-renew on a cancelled-but-still-active subscription is not possible programmatically. Google treats that as a restore, only available via the Play Store Resubscribe button or the server-side API, so erroring out is the correct behavior here.