Skip to content

Improve accuracy of transactions origin Part 4: Post remaining transaction metadata when syncing purchases#2993

Merged
tonidero merged 77 commits intomainfrom
sdk-4188-puchases-android-improve-accuracy-and-reliability-of-4
Jan 14, 2026
Merged

Improve accuracy of transactions origin Part 4: Post remaining transaction metadata when syncing purchases#2993
tonidero merged 77 commits intomainfrom
sdk-4188-puchases-android-improve-accuracy-and-reliability-of-4

Conversation

@tonidero
Copy link
Copy Markdown
Contributor

@tonidero tonidero commented Jan 5, 2026

Description

Follow-up on #2989

This handles a possible edge case where a transaction is not returned by the store anymore. In this scenario, we still want to post any remaining cached metadata. This handles that by syncing all remaining metadata after any remaining purchases from the queue.

tonidero and others added 28 commits December 12, 2025 17:37
…ity-of' into sdk-4188-puchases-android-improve-accuracy-and-reliability-of-2
…ity-of-2' into sdk-4188-puchases-android-improve-accuracy-and-reliability-of-3
…ity-of-2' of github.com:RevenueCat/purchases-android into sdk-4188-puchases-android-improve-accuracy-and-reliability-of-3
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 5, 2026

Codecov Report

❌ Patch coverage is 82.05128% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.02%. Comparing base (11f29c0) to head (0b31bfa).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...enuecat/purchases/PostPendingTransactionsHelper.kt 57.89% 1 Missing and 7 partials ⚠️
...tlin/com/revenuecat/purchases/PostReceiptHelper.kt 91.07% 2 Missing and 3 partials ⚠️
...es/common/caching/LocalTransactionMetadataStore.kt 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2993      +/-   ##
==========================================
+ Coverage   78.99%   79.02%   +0.03%     
==========================================
  Files         341      341              
  Lines       13500    13566      +66     
  Branches     1825     1839      +14     
==========================================
+ Hits        10664    10721      +57     
- Misses       2078     2079       +1     
- Partials      758      766       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tonidero
Copy link
Copy Markdown
Contributor Author

I ended up doing a total refactor by moving most logic from the PostPendingTransactionHelper to the PostReceiptHelper in be50f92. Might be worth start reviewing from scratch TBH 😅 @RevenueCat/coresdk

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses an edge case where cached transaction metadata may not be synced if the associated transaction is no longer returned by the Play Store. It adds functionality to post any remaining cached transaction metadata after syncing regular purchases.

Changes:

  • Added getAllLocalTransactionMetadata() method to retrieve all cached transaction metadata
  • Implemented postRemainingCachedTransactionMetadata() to sync cached metadata not associated with active transactions
  • Integrated metadata syncing into the purchase queue sync flow to run after regular transaction processing
  • Renamed TransactionMetadata.userID field to appUserID for consistency (preserving serialization compatibility)

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
LocalTransactionMetadata.kt Renamed field from userID to appUserID for naming consistency while preserving JSON serialization compatibility
LocalTransactionMetadataStore.kt Added getAllLocalTransactionMetadata() method to retrieve all cached metadata
PostReceiptHelper.kt Implemented postRemainingCachedTransactionMetadata() and extracted shared logic into performPostReceipt()
PostPendingTransactionsHelper.kt Integrated cached metadata posting after regular transaction sync in all completion paths
PurchasesFactory.kt Updated dependency injection to pass postReceiptHelper to PostPendingTransactionsHelper
LocalTransactionMetadataStoreTest.kt Added comprehensive tests for getAllLocalTransactionMetadata() and updated field references
PostReceiptHelperTest.kt Added tests for postRemainingCachedTransactionMetadata() covering various scenarios including success, errors, and multiple transactions
PostPendingTransactionsHelperTest.kt Added integration tests for cached metadata posting in different sync scenarios
SubscriberAttributesPurchasesTests.kt Updated mock setup to include new dependencies

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Member

@JayShortway JayShortway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one! Just a suggestion.

Comment thread purchases/src/main/kotlin/com/revenuecat/purchases/PostReceiptHelper.kt Outdated
Copy link
Copy Markdown
Member

@rickvdl rickvdl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! And thanks for all the iterations 🙌

…ity-of' into sdk-4188-puchases-android-improve-accuracy-and-reliability-of-2
…ity-of-2' into sdk-4188-puchases-android-improve-accuracy-and-reliability-of-3
tonidero and others added 5 commits January 13, 2026 09:27
…ity-of-3' into sdk-4188-puchases-android-improve-accuracy-and-reliability-of-4
…dk-4188-puchases-android-improve-accuracy-and-reliability-of-2
…ity-of-2' into sdk-4188-puchases-android-improve-accuracy-and-reliability-of-3
…dk-4188-puchases-android-improve-accuracy-and-reliability-of-3
…ity-of-3' into sdk-4188-puchases-android-improve-accuracy-and-reliability-of-4
Base automatically changed from sdk-4188-puchases-android-improve-accuracy-and-reliability-of-3 to main January 14, 2026 13:48
…dk-4188-puchases-android-improve-accuracy-and-reliability-of-4
@tonidero tonidero enabled auto-merge January 14, 2026 14:42
@tonidero tonidero added this pull request to the merge queue Jan 14, 2026
Merged via the queue into main with commit 23b743f Jan 14, 2026
24 checks passed
@tonidero tonidero deleted the sdk-4188-puchases-android-improve-accuracy-and-reliability-of-4 branch January 14, 2026 15:15
fire-at-will added a commit that referenced this pull request Jan 15, 2026
…g transaction metadata when syncing purchases (#2993)"

This reverts commit 23b743f.
tonidero pushed a commit that referenced this pull request Jan 16, 2026
**This is an automatic release.**

## RevenueCat SDK
### 🐞 Bugfixes
* Fixes incorrect lifecycle transitions in `CompatComposeView` (#3006)
via JayShortway (@JayShortway)
* Fixes `showInAppMessages` NPE when the Activity has no content View
(#3004) via JayShortway (@JayShortway)

## RevenueCatUI SDK
### Paywallv2
#### 🐞 Bugfixes
* Synchronize `cacheDirectory` lazy property to fix
`NullPointerException` on `UnsafeLazyImpl` (#3019) via Cesar de la Vega
(@vegaro)
### Customer Center
#### 🐞 Bugfixes
* Simplify determining paid price in Customer Center (#2600) via Cesar
de la Vega (@vegaro)

### 🔄 Other Changes
* Improve accuracy of transactions origin Part 6: Cleanup, Do not cache
user id (#3012) via Toni Rico (@tonidero)
* Properly cleanup new shared preferences files between tests (#3016)
via Toni Rico (@tonidero)
* [AUTOMATIC] Update golden test files for backend integration tests
(#3015) via RevenueCat Git Bot (@RCGitBot)
* Improve accuracy of transactions origin Part 5: Cleanup (#3002) via
Toni Rico (@tonidero)
* Improve accuracy of transactions origin Part 4: Post remaining
transaction metadata when syncing purchases (#2993) via Toni Rico
(@tonidero)
* Improve accuracy of transactions origin Part 3: Merge cached data when
posting receipts + Cache amazon data (#2989) via Toni Rico (@tonidero)
* Improve accuracy of transactions origin Part 2: Store transaction
metadata (#2988) via Toni Rico (@tonidero)
* Improve accuracy of transactions origin Part 1: Refactor to allow
caching transaction metadata (#2987) via Toni Rico (@tonidero)
* [AUTOMATIC] Update golden test files for backend integration tests
(#3010) via RevenueCat Git Bot (@RCGitBot)
* [AUTOMATIC] Update golden test files for backend integration tests
(#3008) via RevenueCat Git Bot (@RCGitBot)
* Track exit offers (#2975) via Cesar de la Vega (@vegaro)

Co-authored-by: revenuecat-ops <ops@revenuecat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants