Skip to content

fix: select latest receipts and preserve unrelated Google Play purchases - #1727

Open
tiguven wants to merge 3 commits into
j3k0:masterfrom
gedevapps:fix/subscription-receipt-reconciliation
Open

tiguven wants to merge 3 commits into
j3k0:masterfrom
gedevapps:fix/subscription-receipt-reconciliation

Conversation

@tiguven

@tiguven tiguven commented Sep 9, 2026

Copy link
Copy Markdown

Summary

  • Prevent partial Google Play live updates from expiring unrelated receipts by moving missing-receipt reconciliation to inventory refreshes (onSetPurchases). Notify listeners when receipts are removed, including when the refreshed list is empty.
  • Fix LocalReceipts.find() selecting the oldest matching transaction when purchaseDate values differ. Select the newest known date while preserving existing ordering when either date is missing, including undated in-progress purchases that block repurchase.

Reported behavior

  1. Have an active Google Play subscription.
  2. Turn off auto-renewal in Google Play.
  3. Completely close the app and relaunch it before the subscription expires.

The reported failure is that the subscription receipt/entitlement disappears after relaunch, although the current subscription period is still valid.

Scope

The Google Play change preserves expiration reporting introduced for #1632, while avoiding removals triggered by partial live events. Equal purchase dates and lastRenewalDate handling are unchanged.

Native query behavior is unchanged. The historical partial-success fallback was intentional (516875e), so query failures can still produce partial inventories. Handling incomplete native query results remains outside this PR.

Test plan

  • Add 19 regression cases covering transaction ordering, missing dates, pending purchases, unrelated Google Play updates/consumption, and receipt removal notifications. Ten cases fail against unchanged upstream.
  • npm test -- --runInBand — all 143 tests pass.
  • make compile passes.
  • make capacitor-package passes.
  • Manual Google Play test: turn off auto-renewal, completely close the app, and relaunch before expiration; subscription entitlement is retained.
  • After the subscription expires, refresh purchases and confirm ownership is revoked and listeners receive the receipt update.
  • Additional device regression check: an unrelated product update or consumption event preserves an existing valid subscription.

@tiguven tiguven changed the title fix: preserve subscription receipts and select latest transactions fix: select latest receipts and preserve unrelated Google Play purchases Sep 9, 2026
@tiguven
tiguven marked this pull request as ready for review September 9, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant