This repository was archived by the owner on Oct 16, 2025. It is now read-only.
fix: skip upgraded transactions during subscription upgrade#20
Merged
Conversation
|
Caution Review failedThe pull request is closed. WalkthroughExpanded transaction skip logic in Sources/OpenIapModule.swift to also bypass upgraded transactions, not just revoked ones, and updated related comments and log messages accordingly. Control flow continues the observable stream without processing when transactions are revoked or upgraded. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant StoreKit as StoreKit
participant OpenIapModule as OpenIapModule
participant Processor as TransactionProcessor
participant Logger as Logger
StoreKit->>OpenIapModule: Emit transaction
OpenIapModule->>OpenIapModule: Check isRevoked OR isUpgraded
alt Revoked or Upgraded
OpenIapModule->>Logger: Log "Skipping revoked/upgraded transaction"
OpenIapModule-->>StoreKit: Continue without processing
else Normal
OpenIapModule->>Processor: Process transaction
Processor-->>OpenIapModule: Result
OpenIapModule-->>StoreKit: Acknowledge result
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
Comment |
This was referenced Oct 11, 2025
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Problem
When upgrading from a monthly subscription to a yearly subscription (within the same subscription group),
onPurchaseSuccesswas emitting old purchase objects first, and the correct upgraded transaction arrived only after 3-4 minutes in iOS Sandbox.Root Cause
StoreKit 2's
Transaction.updatesemits upgraded transactions (withisUpgraded = true) during subscription upgrades, in addition to the new subscription transaction. These old transactions should be filtered out.Solution
Added filtering logic to skip both revoked and upgraded transactions in
startTransactionListener():This follows Apple's official StoreKit 2 best practices from WWDC 2021 - Meet StoreKit 2:
Apple Documentation:
Transaction.isUpgraded- A Boolean that indicates whether the user upgraded to another subscriptionTransaction.revocationDate- The date that the App Store refunded the transactionChanges
transaction.isUpgradedcheck instartTransactionListener()revocationDatecheck for comprehensive filteringTesting
Summary by CodeRabbit