Skip to content

feat(cli): AnythinkPay management — offers, plans, subscriptions, Apple IAP, trial, history, admin recovery, offer-delete#21

Draft
chrisaddams wants to merge 3 commits into
mainfrom
feat/anythinkpay-offers
Draft

feat(cli): AnythinkPay management — offers, plans, subscriptions, Apple IAP, trial, history, admin recovery, offer-delete#21
chrisaddams wants to merge 3 commits into
mainfrom
feat/anythinkpay-offers

Conversation

@chrisaddams

Copy link
Copy Markdown
Contributor

Status

Draft — opening for review and ongoing iteration, not yet ready to merge.

Summary

Brings the AnythinkPay administration surface into the CLI (and MCP). Most of what's here corresponds to capabilities already shipping in the admin UI; the CLI now lets you script the same operations or work them into CI flows.

What lands

  • `pay offers` — list / get / create / update / pause / activate / delete / codes / add-code / redemptions / user-code. Convenience flags for common reward shapes (trial-extension days, discount percent, referral redeemer/referrer days) plus a raw `--redeemer-reward` JSON escape hatch for custom shapes.
  • `pay plans` — manage subscription plans end-to-end including Apple App Store product/subscription-group identifiers.
  • `pay subscriptions` — list, view, and admin-side recovery (cancel-at-period-end, full cancel, supersede stale records).
  • `pay apple` — verify a signed transaction, configure App Store credentials, run the ASSN test-notification flow end-to-end.
  • `pay trial` — manage the engagement trial (free app access without a subscription).
  • `pay entitlement` — show the current user's access / trial status.
  • `pay payments` / `pay methods` / `pay payment-options` — read-side views of live data.
  • `pay offers delete` (most recent commit) — pairs with the new `DELETE /v1/offers/{id}` endpoint; prompts for confirmation, prints server-reported counts of codes / redemptions deleted and trial bonuses preserved.

Tests added under `tests/OffersClientTests.cs` cover the client-level shape of the offers commands.

Notes for reviewers

  • Several commands rely on backend endpoints that have rolled out as part of the offers / Apple IAP work; the offer-delete subcommand specifically needs the matching backend PR before it does anything useful.
  • Confirmation prompts default to deny on every destructive action; `--yes` / `--force` skip for scripting.

…story, admin recovery)

CLI (`anythink pay …`):
- trial status|enable|disable — app engagement trial toggle
- apple credentials set|show|notification-url — Apple IAP config (.p8 read from
  file, stored encrypted, never logged; identifiers masked on show)
- apple verify — receipt verification for testing
- subscriptions events|delete|force-expire|relink|resync — history + admin recovery
- payment-options, entitlement, setup (guided Stripe Connect → Apple → first plan)
- plans gain --apple-product-id / --apple-subscription-group-id

MCP: new PayTools.cs with anythinkpay_* tools (active-profile based, no orgId arg).

Fixes:
- plan models sent template_name but the server field is plan_name; renamed across
  models and the create/update flag (--plan-name)
- CliTool workflow create used the old 6-arg CreateWorkflowRequest; updated to the
  triggers-based shape so the MCP project builds

Docs: README pay section with required-permissions table + Homebrew install/update
instructions; docs command reference extended.

Verified: dotnet build (0 errors); CLI tests 370/0, MCP tests 39/0.
CLI (`anythink pay offers …`, admin/tenant-scoped):
- list / get / create / update offers (kind: discount | trial_extension | referral)
- pause / activate (status patch — no dedicated route server-side)
- codes / add-code — manage an offer's promo/referral codes (shared or per-user)
- redemptions — per-offer redemption history
- user-code — look up a user's personal referral code

Rewards and eligibility are opaque JSON strings forwarded to AnythinkPay, so the
reward vocabulary can evolve without a CLI release. create/update take raw JSON
(--redeemer-reward / --referrer-reward / --eligibility) plus convenience flags
(--redeemer-trial-days, --discount-percent[/--discount-duration],
--referrer-trial-days, --referrer-subscription-days). central_tenant_id is set
server-side and never sent by the CLI.

End-user code redemption is intentionally NOT exposed — that happens in the app;
the CLI is admin configuration only.

MCP: anythinkpay_* tools mirroring the offer surface (list/get/create/update,
set-status, list/create codes, redemptions, user-code), active-profile based.

Docs: README + docs command reference updated with the offers commands and the
offer permission rows (anythink_subscription_plans:read/create/update).

Verified: dotnet build (0 errors); CLI tests 395/0, MCP tests 39/0.
Prompts for confirmation by default, showing the offer name and the
destructive nature of the operation: codes, redemptions, and history
are removed, but trial days already granted to users stay. --yes /
--force skips the prompt.

On success, prints the server-reported counts: codes deleted,
redemptions deleted, trial bonuses preserved.
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