Skip to content

feat(kilo-pass): add Google Play purchase verifier - #5586

Open
iscekic wants to merge 5 commits into
android-iap-e895-s2from
android-iap-e895-s3
Open

feat(kilo-pass): add Google Play purchase verifier#5586
iscekic wants to merge 5 commits into
android-iap-e895-s2from
android-iap-e895-s3

Conversation

@iscekic

@iscekic iscekic commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

No new behavior — the level adds an internal purchase verification step that no customer-facing path uses yet.


Reviewer Notes

verifyGooglePlayKiloPassPurchase is a new entry point that fetches a Google Play subscriptions v2 payload for a purchase token and maps it onto ValidatedStoreKiloPassPurchase under the Google Play payment provider. The mapper now rejects a decoded purchase whose startTimeMs or expiryTimeMs is non-finite, so a pending subscription that omits its start time throws a domain error instead of failing later on an invalid Date. 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 — adds verifyGooglePlayKiloPassPurchase, decodeGooglePlaySubscriptionPurchase, and mapGooglePlayKiloPassPurchase plus the GooglePlayEnvironment and GooglePlayDecodedPurchase types; the mapper rejects non-finite timestamps before the expiry check, and decodeGooglePlaySubscriptionPurchase falls back to the top-level latestOrderId and 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.

  1. android-iap-e895feat(commerce): add Play Kilo Pass presentation flag #5581
  2. android-iap-e895-s2feat(kilo-pass): add Google Play publisher SDK #5582
  3. android-iap-e895-s3feat(kilo-pass): add Google Play purchase verifier #5586 ← this PR
  4. android-iap-e895-s4feat(kilo-pass): handle Play real-time notifications #5598
  5. android-iap-e895-s5feat(kilo-pass): add completePlayPurchase mutation #5608
  6. android-iap-e895-s6feat(mobile): offer Google Play Kilo Pass purchase #5618 (tip)

Comment thread apps/web/src/lib/kilo-pass/google-play-verifier.ts
@kilo-code-bot

kilo-code-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • apps/web/src/lib/kilo-pass/google-play-verifier.ts
  • apps/web/src/lib/kilo-pass/google-play-verifier.test.ts
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

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
apps/web/src/lib/kilo-pass/google-play-verifier.ts 78 Invalid timestamps parse to NaN and throw RangeError
Files Reviewed (2 files)
  • apps/web/src/lib/kilo-pass/google-play-verifier.ts - 1 issue
  • apps/web/src/lib/kilo-pass/google-play-verifier.test.ts - 0 issues

Fix these issues in Kilo Cloud

Previous review (commit 21e05a1)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
apps/web/src/lib/kilo-pass/google-play-verifier.ts 78 Invalid timestamps parse to NaN and throw RangeError
Files Reviewed (2 files)
  • apps/web/src/lib/kilo-pass/google-play-verifier.ts - 1 issue
  • apps/web/src/lib/kilo-pass/google-play-verifier.test.ts - 0 issues

Fix these issues in Kilo Cloud


Reviewed by grok-4.6 · Input: 60K · Output: 4.9K · Cached: 149.9K

Review guidance: REVIEW.md from base branch android-iap-e895-s2

@iscekic iscekic added the human-ready The PR is ready for human review. label Aug 27, 2026
Comment on lines +31 to +33
// 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()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

human-ready The PR is ready for human review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants