Skip to content

docs: subscribe logged-in users (linkId + metadata) - #5

Merged
PancheI merged 3 commits into
mainfrom
docs/saas-subscriptions
Aug 18, 2026
Merged

docs: subscribe logged-in users (linkId + metadata)#5
PancheI merged 3 commits into
mainfrom
docs/saas-subscriptions

Conversation

@PancheI

@PancheI PancheI commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Why

Merchants with a logged-in SaaS could not see how a product (dashboard) maps to linkId (API) and how to start a subscription per user.

What

  • New guide: Subscribe users in your app
    1. One plan linkId
    2. On login, check stored subscription id
    3. checkouts.create({ linkId, buyerEmail, metadata.customerId })
    4. Webhook or poll sessionId
    5. Status, invoices, cancel
  • Linked from Guides index, sell-a-subscription, payments/subscriptions, SDK subscriptions
  • Glossary: Product vs linkId vs checkout URL
  • SDK: subscriptions.invoices(), paymentLinkId; cancel is period-end only

Public-repo check

No customer data, org ids, emails, or keys. Examples use sk_test_..., user.email, and Stripe test card 4242… only.

Out of scope

Unrelated local mor/account-review.mdx edits were not included.

Add a step-by-step guide: plan linkId, checkout per profile with
metadata.customerId, webhook or poll, then status, invoices, and cancel.
Wire it from the Guides index, sell-a-subscription, and SDK reference.
Document subscriptions.invoices() and stop recommending immediate cancel.

No secrets: placeholders only (sk_test_..., user.email, Stripe test card).
Rewrite the SaaS subscribe guide in the same ELI5 step style as
the other guides. Checkout create still uses linkId only.
customerId and subscriptionId are on checkout.session.completed
metadata; list() does not copy merchant metadata.
One guide for both paths: share the buyer link, or create a
checkout for a logged-in user. Old /guides/saas-subscriptions
redirects to this page.
@PancheI
PancheI merged commit 319f37d into main Aug 18, 2026
1 check passed
PancheI added a commit that referenced this pull request Aug 18, 2026
The squash of #5 landed paymentLinkId. Match the SDK and API:
same UUID as checkouts.create({ linkId }).
PancheI added a commit to AgentaOS/agentaos that referenced this pull request Aug 18, 2026
## Why

No open PR covered this. #32 (pay 2.0) is already merged. SaaS
integrators need to list a subscription’s invoices and know which plan
(`paymentLinkId`) it belongs to.

## What

- `subscriptions.invoices(id)` → `GET
/gateway/subscriptions/:id/invoices`
- `Subscription.paymentLinkId` (same as product **Copy link ID** /
`paymentLinks.id`)
- `cancelAtPeriodEnd`, `canceledAt`, `effectiveCancelDate` on the type
- JSDoc: `checkouts.create({ linkId })` uses that same id
- Changeset: `@agentaos/pay` minor
- Tests: 25/25 in `resources.test.ts`

## Public-repo check

No customer data, keys, or internal ids. Example invoice number is
`INV-2026-0001`.

Pairs with docs PR: AgentaOS/docs#5
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