feat(kilo-pass): add Google Play purchase verifier - #5586
Conversation
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (2 files)
Previous Review Summaries (2 snapshots, latest commit 4d253e8)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 4d253e8)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (2 files)
Fix these issues in Kilo Cloud Previous review (commit 21e05a1)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (2 files)
Reviewed by grok-4.6 · Input: 60K · Output: 4.9K · Cached: 149.9K Review guidance: REVIEW.md from base branch |
| // Called only from the tRPC purchase-completion path; renewals and refunds enter via | ||
| // the Play notifications handler, which intentionally allows expired purchases. | ||
| if (decoded.expiryTimeMs <= Date.now()) { |
There was a problem hiding this comment.
bot: Reject non-entitled Google subscription states before mapping the purchase.
Suggested fix: Validate decoded.subscriptionState before returning a purchase. Permit only states that Google considers entitled for this completion flow (for example, active and any explicitly supported canceled-but-unexpired state), and reject ON_HOLD, PAUSED, pending, expired, and unknown states. Add mapper tests for at least on-hold and paused fixtures. The current expiry-only gate allows those states while their expiry remains future-dated, and downstream completion persists accepted purchases as active.
Summary
No new behavior — the level adds an internal purchase verification step that no customer-facing path uses yet.
Reviewer Notes
verifyGooglePlayKiloPassPurchaseis a new entry point that fetches a Google Play subscriptions v2 payload for a purchase token and maps it ontoValidatedStoreKiloPassPurchaseunder the Google Play payment provider. The mapper now rejects a decoded purchase whosestartTimeMsorexpiryTimeMsis non-finite, so a pending subscription that omits its start time throws a domain error instead of failing later on an invalidDate. The mapping also rejects missing identifiers, expired purchases, and products outside the enabled mobile store catalog, so completion fails before the purchase ledger runs; expired purchases are rejected on this path only because renewals and refunds arrive through the notifications handler.Files
apps/web/src/lib/kilo-pass/google-play-verifier.ts— addsverifyGooglePlayKiloPassPurchase,decodeGooglePlaySubscriptionPurchase, andmapGooglePlayKiloPassPurchaseplus theGooglePlayEnvironmentandGooglePlayDecodedPurchasetypes; the mapper rejects non-finite timestamps before the expiry check, anddecodeGooglePlaySubscriptionPurchasefalls back to the top-levellatestOrderIdand keeps the raw payload.Test: 1 test file added —
apps/web/src/lib/kilo-pass/google-play-verifier.test.ts, 197 lines.Generated: none.
Verification
E2E report: none — a lower PR names its own change alone; the tip PR carries the E2E report. No manual test paths were run for this level.
Visual Changes
Visual Changes: N/A
Human steps: none known.
Stacked PRs — merge bottom to top. Each level shows only its own diff.
Runtime verification (E2E, user advocacy, simplify) runs on the tip PR over every level.
Every level keeps its own checks, its own bot review, and its own threads; each one is answered on its own PR.
Each level is its own deliverable: it builds and passes its own checks alone.
A finding on a level is repaired on that level, then carried upward with stack.sh forward.
android-iap-e895— feat(commerce): add Play Kilo Pass presentation flag #5581android-iap-e895-s2— feat(kilo-pass): add Google Play publisher SDK #5582android-iap-e895-s3— feat(kilo-pass): add Google Play purchase verifier #5586 ← this PRandroid-iap-e895-s4— feat(kilo-pass): handle Play real-time notifications #5598android-iap-e895-s5— feat(kilo-pass): add completePlayPurchase mutation #5608android-iap-e895-s6— feat(mobile): offer Google Play Kilo Pass purchase #5618 (tip)