feat(customers): surface active entitlements from simulate-purchase - #145
Merged
Conversation
simulate-purchase returns the SDK /receipts customer_info (entitlements keyed by identifier), which differs from customers show's v2 shape — an agent had to switch commands to verify a purchase granted access. Add a derived active_entitlements list (active identifiers) to the output so the purchase is verifiable from the one command. Best-effort parse; malformed entries skipped. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
A nil slice serialized to `null` under --json, breaking `jq` pipelines that expect an array. Initialize to an empty slice and return it on the parse-error path too. Locks it with a marshal assertion. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Member
Author
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit ca528de. Configure here.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
simulate-purchasereturns the SDK/receiptscustomer_info— entitlements keyed by identifier — which is a different shape fromcustomers show(v2,active_entitlements.items[]keyed by internalentitlement_id). An agent verifying a simulated purchase had to switch commands to confirm the entitlement was active.This adds a derived
active_entitlementsfield (list of active entitlement identifiers) to thesimulate-purchaseoutput, so the purchase is verifiable from the one command:Active = expiry in the future, or none (lifetime). Best-effort parse of the stable
/receiptsshape; malformed entries are skipped, never falsely reported active. Rawcustomer_infois unchanged.Note: this doesn't make the two commands byte-identical — they use different id systems (SDK lookup key vs v2
entitlement_id). Full cross-command entitlement-shape unification is a separate, larger API question.🤖 Generated with Claude Code
Note
Low Risk
CLI-only output enrichment and local JSON parsing; no API or purchase flow changes.
Overview
simulate-purchasenow includes a derivedactive_entitlementsfield (sorted SDK entitlement identifiers) alongside the unchanged rawcustomer_info, so scripts and agents can confirm a purchase granted access without runningcustomers show.The new
activeEntitlementIDshelper parses the/receiptssubscriber.entitlementsmap: an ID counts as active whenexpires_dateis missing (lifetime) or parses as a future RFC3339 timestamp; expired, unparseable, or malformed payloads are skipped (empty slice, nevernull). Unit tests cover happy path and malformed JSON.Reviewed by Cursor Bugbot for commit ca528de. Bugbot is set up for automated code reviews on this repo. Configure here.