Skip to content

feat(portal): let clients end one monthly add-on online - #627

Merged
devantler merged 5 commits into
mainfrom
claude/portal-addon-ends
Nov 16, 2026
Merged

devantler merged 5 commits into
mainfrom
claude/portal-addon-ends

Conversation

@devantler

Copy link
Copy Markdown
Contributor

Stacked on #624 (fair use). Review only this PR's commit.

The maintainer's decision for the Consumer Contracts Act, section 28 a: a monthly add-on ordered in the portal can be ended there, one at a time, and the rest of the order continues. Ending all monthly billing in the portal already exists (#608).

What changes

  • Ending one add-on. The receipt offers "End this add-on after <this month>" for each monthly add-on (POST /requests/{id}/addon-end, portal_addon_ends, migration v27). It is billed through the current month and no longer after; a retry is admitted and changes nothing. The receipt then shows "ended after <month>", and the operator's page lists it. An order whose monthly billing already ended, or a one-time add-on, cannot end one: that is a conflict.
  • Invoice path. Each later monthly charge is the order's monthly price less the add-ons the client ended before that month. Its Numina invoice leaves their lines out, and the lines still add up to the charge.
  • Card path. Each add-on line's Stripe product now carries portal_addon metadata. Ending an add-on first removes that subscription item without proration (RemoveSubscriptionAddon): the current month stays paid, and the next invoice no longer charges it. The end is recorded only once Stripe confirms. If Stripe fails, nothing is recorded, the client sees the error, and a retry converges, since a missing item counts as already removed. Renewals expect the lower amount from the month after the end.
  • Level. Ending Priority or Express drops the client's level after its last month.
  • Purge. The retention purge deletes a former client's add-on ends.
  • Also adds onlyFields, a form-field helper shared with the operator's "finished" form, because jscpd found the parsing repeated.

Tests

  • TestAddonEndOnTheInvoicePath:
    • the end form names the last billed month;
    • the end, its retry, and a refused end of a one-time add-on;
    • the receipt's "ended after";
    • this month at the full monthly price and the next month without the add-on;
    • next month's invoice lines;
    • Express still active in its last month, then Standard.
  • TestAddonEndOnTheCardPath:
    • the subscription line carries its add-on's metadata;
    • a Stripe failure records nothing;
    • the retry removes si_email and records the end.

Mutation checks are load-bearing: skipping the Stripe removal, or the period exclusion, each fails its test. The full Go suite passes, on top of #625's latest head, and golangci-lint (with gocritic and revive), vet, gofmt, jscpd and cspell are clean.

Part of #21

🤖 Generated with Claude Code

@devantler

Copy link
Copy Markdown
Contributor Author

🤖 Generated by the Agentic Engineer

@codex review for Review this PR's own commits; it is stacked on its base branch, now on #625's latest head.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T03:05:35.584911Z 4e7040f Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3f1d1e85d5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread server/internal/identity/addon_end.go Resolved
Comment thread server/internal/identity/addon_end.go Resolved
Comment thread server/internal/identity/billing.go Resolved
Comment thread server/internal/stripe/stripe.go Resolved
@devantler
devantler force-pushed the claude/portal-priority branch from 636e6b3 to bee8e02 Compare November 16, 2026 01:29
devantler added a commit that referenced this pull request Nov 16, 2026
Codex review on #627:
- An add-on ended while the monthly Checkout was still open is removed
  from the subscription the Checkout creates, inside the completion
  event's transaction: if Stripe fails, the event is not recorded and
  Stripe's retry converges. The client's end locks the order's monthly
  Checkouts, so it and the completion are ordered.
- A closed card gate never changes a subscription: the end is refused
  before any Stripe call.
- A card order's last billed month is the UTC month, since Stripe
  renews at midnight UTC on the 1st.
- Work approval expects a monthly-only order's first month less any
  add-on ended before it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@devantler
devantler force-pushed the claude/portal-addon-ends branch from 3f1d1e8 to a95cb55 Compare November 16, 2026 01:29
@devantler

Copy link
Copy Markdown
Contributor Author

🤖 Generated by the Agentic Engineer

@codex review for Re-review this PR's own commits after rebasing onto main (#625 merged); findings on earlier heads are answered on their threads.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a95cb55004

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread server/internal/identity/addon_end.go Resolved
devantler added a commit that referenced this pull request Nov 16, 2026
Codex review on #627: if Stripe removed the item but its answer was
lost, or the session expired during the call, the rolled-back end left
the subscription changed with no record.

The end is now recorded first, then Stripe is asked to remove the
add-on's item, and its confirmation is recorded on its own
(portal_addon_removals, in migration v27). A failure leaves the end
standing: the operator's page offers to ask Stripe again until it
confirms, as for order ends. A Checkout completing later removes ended
add-ons and records the confirmations in its own transaction.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@devantler

Copy link
Copy Markdown
Contributor Author

🤖 Generated by the Agentic Engineer

@codex review for Re-review after recording the add-on end before the Stripe call and confirming removals separately (portal_addon_removals) with an operator retry.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6696e51f79

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread server/internal/identity/addon_end.go Resolved
devantler added a commit that referenced this pull request Nov 16, 2026
Codex review on #627: commitProposalWrite refuses without rolling
back, so a gate closing or a principal expiring left the operator's
transaction and its locks open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@devantler

Copy link
Copy Markdown
Contributor Author

🤖 Generated by the Agentic Engineer

@codex review

@devantler
devantler force-pushed the claude/portal-priority branch from bee8e02 to 157ead2 Compare November 16, 2026 02:28

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 58b0f211a2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread server/internal/identity/request.go Resolved
Comment thread server/internal/stripe/stripe.go Resolved
@devantler
devantler force-pushed the claude/portal-priority branch from 157ead2 to 0db2aa7 Compare November 16, 2026 02:47
devantler added a commit that referenced this pull request Nov 16, 2026
Codex review on #627:
- An add-on ended while the monthly Checkout was still open is removed
  from the subscription the Checkout creates, inside the completion
  event's transaction: if Stripe fails, the event is not recorded and
  Stripe's retry converges. The client's end locks the order's monthly
  Checkouts, so it and the completion are ordered.
- A closed card gate never changes a subscription: the end is refused
  before any Stripe call.
- A card order's last billed month is the UTC month, since Stripe
  renews at midnight UTC on the 1st.
- Work approval expects a monthly-only order's first month less any
  add-on ended before it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
devantler added a commit that referenced this pull request Nov 16, 2026
Codex review on #627: if Stripe removed the item but its answer was
lost, or the session expired during the call, the rolled-back end left
the subscription changed with no record.

The end is now recorded first, then Stripe is asked to remove the
add-on's item, and its confirmation is recorded on its own
(portal_addon_removals, in migration v27). A failure leaves the end
standing: the operator's page offers to ask Stripe again until it
confirms, as for order ends. A Checkout completing later removes ended
add-ons and records the confirmations in its own transaction.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
devantler added a commit that referenced this pull request Nov 16, 2026
Codex review on #627: commitProposalWrite refuses without rolling
back, so a gate closing or a principal expiring left the operator's
transaction and its locks open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
devantler added a commit that referenced this pull request Nov 16, 2026
…d items

Codex review on #627:
- The receipt, the recorded end and the client's level now use one
  month (addonLastMonth): UTC for a card order, Copenhagen's for an
  invoice order, which differ for an hour or two on the 1st.
- Every Checkout line names what it charges (portal_line or
  portal_addon). A subscription with an unnamed item, or more items
  than one page, is refused, so no removal is confirmed that Stripe
  may still charge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@devantler
devantler force-pushed the claude/portal-addon-ends branch from 58b0f21 to 03e07d9 Compare November 16, 2026 03:01
@devantler

Copy link
Copy Markdown
Contributor Author

🤖 Generated by the Agentic Engineer

@codex review

Base automatically changed from claude/portal-priority to main November 16, 2026 03:02
devantler and others added 5 commits November 16, 2026 04:03
The maintainer's decision for Consumer Contracts Act section 28 a: a
monthly add-on ordered in the portal can be ended there.

- The receipt offers to end each monthly add-on after the current
  month (portal_addon_ends, migration v27). It is billed through that
  month; later monthly charges, invoices and card renewals leave it
  out.
- A card order's subscription first loses the add-on's item, found by
  the portal_addon metadata on its product, without proration. The end
  is recorded only once Stripe confirms, so a retry converges.
- Ending Priority or Express drops the client's level after that month.
- The operator's page and the retention purge know the ends.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex review on #627:
- An add-on ended while the monthly Checkout was still open is removed
  from the subscription the Checkout creates, inside the completion
  event's transaction: if Stripe fails, the event is not recorded and
  Stripe's retry converges. The client's end locks the order's monthly
  Checkouts, so it and the completion are ordered.
- A closed card gate never changes a subscription: the end is refused
  before any Stripe call.
- A card order's last billed month is the UTC month, since Stripe
  renews at midnight UTC on the 1st.
- Work approval expects a monthly-only order's first month less any
  add-on ended before it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex review on #627: if Stripe removed the item but its answer was
lost, or the session expired during the call, the rolled-back end left
the subscription changed with no record.

The end is now recorded first, then Stripe is asked to remove the
add-on's item, and its confirmation is recorded on its own
(portal_addon_removals, in migration v27). A failure leaves the end
standing: the operator's page offers to ask Stripe again until it
confirms, as for order ends. A Checkout completing later removes ended
add-ons and records the confirmations in its own transaction.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex review on #627: commitProposalWrite refuses without rolling
back, so a gate closing or a principal expiring left the operator's
transaction and its locks open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d items

Codex review on #627:
- The receipt, the recorded end and the client's level now use one
  month (addonLastMonth): UTC for a card order, Copenhagen's for an
  invoice order, which differ for an hour or two on the 1st.
- Every Checkout line names what it charges (portal_line or
  portal_addon). A subscription with an unnamed item, or more items
  than one page, is refused, so no removal is confirmed that Stripe
  may still charge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@devantler
devantler force-pushed the claude/portal-addon-ends branch from 03e07d9 to 4e7040f Compare November 16, 2026 03:03
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 03e07d957d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@devantler

Copy link
Copy Markdown
Contributor Author

🤖 Generated by the Agentic Engineer

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 4e7040f8fd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

Copy link
Copy Markdown

✅MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Max errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 1.25s
✅ CSS stylelint 1 0 0 0 1.22s
✅ GO golangci-lint yes yes no no 130.83s
✅ GO revive 191 0 0 1.02s
✅ HTML djlint 5 0 0 1.86s
✅ HTML htmlhint 5 0 0 0.4s
✅ JSON jsonlint 2 0 0 0.09s
✅ JSON prettier 2 0 0 0 0.73s
✅ JSON v8r 2 0 0 1.36s
✅ MARKDOWN markdownlint 17 0 0 0 1.54s
✅ MARKDOWN markdown-table-formatter 17 0 0 0 0.59s
✅ REPOSITORY betterleaks yes no no 0.79s
✅ REPOSITORY checkov yes no no 15.4s
✅ REPOSITORY git_diff yes no no 0.13s
✅ REPOSITORY grype yes no no 167.41s
✅ REPOSITORY osv-scanner yes no no 155.46s
✅ REPOSITORY secretlint yes no no 0.91s
✅ REPOSITORY syft yes no no 2.78s
✅ REPOSITORY trivy yes no no 10.09s
✅ REPOSITORY trivy-sbom yes no no 0.26s
✅ REPOSITORY trufflehog yes no no 2.87s
✅ SPELL cspell 218 0 0 6.16s
✅ SPELL lychee 24 0 0 133.45s

See detailed reports in MegaLinter artifacts

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@10.2.0 --custom-flavor-setup --custom-flavor-linters COPYPASTE_JSCPD,CSS_STYLELINT,GO_GOLANGCI_LINT,GO_REVIVE,HTML_DJLINT,HTML_HTMLHINT,JSON_JSONLINT,JSON_V8R,JSON_PRETTIER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_CHECKOV,REPOSITORY_GIT_DIFF,REPOSITORY_BETTERLEAKS,REPOSITORY_GRYPE,REPOSITORY_OSV_SCANNER,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY,REPOSITORY_TRIVY_SBOM,REPOSITORY_TRUFFLEHOG,SPELL_CSPELL,SPELL_LYCHEE

MegaLinter is provided by OX Security
Show us your support by starring ⭐ the repository

@github-code-quality

Copy link
Copy Markdown

Code coverage overview

Languages: Go

Go / code-coverage/go

main claude/portal-addon-... 4e7040f +/-
— 77% —

Line coverage data for the main branch is not yet available.

View coverage of the 10 most covered files.
File main claude/portal-addon-... 4e7040f +/-
internal/identity/browser.go — 90% —
internal/webapp/app.go — 89% —
internal/identity/contact.go — 89% —
internal/custom...ity/material.go — 85% —
internal/identity/request.go — 82% —
internal/identi...ork_approval.go — 79% —
internal/identi...l_acceptance.go — 77% —
internal/identity/order.go — 77% —
internal/identity/card.go — 76% —
internal/identity/billing.go — 69% —

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

@devantler
devantler marked this pull request as ready for review November 16, 2026 03:18
@devantler
devantler requested a review from a team as a code owner November 16, 2026 03:18
@devantler
devantler merged commit 019c62b into main Nov 16, 2026
40 checks passed
@devantler
devantler deleted the claude/portal-addon-ends branch November 16, 2026 03:18
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