Skip to content

docs: add subscription charge webhook guide#17

Open
next-devin wants to merge 2 commits into
mainfrom
docs-webhooks-fanout-and-correlation-guide
Open

docs: add subscription charge webhook guide#17
next-devin wants to merge 2 commits into
mainfrom
docs-webhooks-fanout-and-correlation-guide

Conversation

@next-devin

@next-devin next-devin commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a task-oriented guide for integrations that need to react to subscription charges and correlate them with external systems.

The guide explains how to:

  • detect a successful charge with transaction.created, type: "debit", and status: "succeeded"
  • distinguish the initial charge from renewals using subscription.billing_cycle
  • carry an external identifier across renewal transactions with attribution.metadata
  • process webhook retries safely by deduplicating event_id or transaction ID

The webhook overview now links to the focused guide instead of exposing an exhaustive internal model-to-event fan-out table that would be difficult to keep accurate.

Why

This flow surfaced through a merchant integration inquiry and previously required several rounds of support to explain. The public docs did not connect successful-payment filtering, renewal detection, external-ID correlation, and retry safety in one place.

Test plan

  • Run the full production documentation build (npm run build)
  • Verify the new guide and generated Admin API reference links compile
  • Review the rendered guide and webhook callout in the deploy preview

Two improvements to help external developers self-serve on common
integration questions:

1. webhooks/index.mdx — new "Event Trigger Sources" section listing
   the models whose post_save fires each *.updated event (so subscribers
   can pick the leanest event for their use case), plus an "Identifying
   Rebill Orders" section covering the order subscriptions block and
   the transaction.subscription.billing_cycle counter.

2. admin-api/guides/metadata-and-correlation.mdx — new guide enumerating
   the 9 metadata-supported object types, with a callout that
   subscriptions/carts aren't directly metadata-managed. Walks through
   the canonical attribution.metadata pattern for cross-rebill external
   ID correlation (set once on subscription attribution, flows through
   subscription/order/transaction webhooks via FK inheritance with no
   follow-up API call). Includes a worked plan_id example and a "When
   to Use Which Surface" decision table.

Surfaced via support inquiry from a merchant building integration to
an external plan-management service. The fan-out + correlation patterns
were institutional knowledge that took multiple rounds to produce
authoritatively; this PR puts both into the public docs so future
developers get the answer on first read.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@kilo-code-bot

kilo-code-bot Bot commented Apr 27, 2026

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • content/docs/admin-api/guides/meta.json
  • content/docs/admin-api/guides/subscription-charge-webhooks.mdx
  • content/docs/webhooks/index.mdx
Previous Review Summary (commit 5f245b0)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 5f245b0)

Status: No Issues Found | Recommendation: Merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 0
Other Observations (not in diff)

One item noted for awareness:

File Line Issue
content/docs/webhooks/index.mdx 97 product.updated row uses "AttributeOption*" with an asterisk. This is an informal notation; verify it accurately represents the actual model naming used by the codebase.
Files Reviewed (3 files)
  • content/docs/admin-api/guides/meta.json - Addition of new page entry
  • content/docs/admin-api/guides/metadata-and-correlation.mdx - New guide (132 lines)
  • content/docs/webhooks/index.mdx - New sections: Event Trigger Sources table (lines 74-104), Identifying Rebill Orders (lines 106-125)

Reviewer Notes:

The PR adds two valuable documentation improvements: (1) an "Event Trigger Sources" table clarifying the fan-out behavior of *.updated events, which is currently institutional knowledge, and (2) a new Metadata & External Correlation guide covering the canonical pattern for cross-rebill correlation via attribution.metadata. Both additions address real support pain points identified in the PR description.

The changes are accurate, well-structured, and follow existing documentation patterns. The internal links (#cross-rebill-correlation-via-attribution, /docs/admin-api/reference/metadata/metadataCreate) and sidebar placement appear correct.


Reviewed by minimax-m3 · Input: 37K · Output: 1.7K · Cached: 133.1K

@next-devin

Copy link
Copy Markdown
Contributor Author

@alexphelps is this worth adding? Or just noise?

Replace brittle implementation details with a task-oriented, retry-safe flow for detecting and correlating successful subscription charges.

Co-authored-by: Cursor <cursoragent@cursor.com>
@next-devin next-devin changed the title docs: webhook fan-out reference + metadata correlation guide docs: add subscription charge webhook guide Jul 15, 2026
@alexphelps

Copy link
Copy Markdown
Member

@next-devin The section that highlights the "subscription" object on transactions to link the related subscription and the biling cycle is good but the rest that discusses metadata, external plans, etc I think is noise.

Also don't believe this should have it's own dedicated page, should be additional sections on the existing Subscription Management guide here.

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.

2 participants