Repository navigation
fix(portal): judge a card end's renewal on the card clock, in UTC - #631
Conversation
TestPrivateCardRetriesAnEndAfterItsMonthPassed failed in the first hour or two of a Copenhagen month. It took the previous Copenhagen month as one whose renewal had passed, but Stripe renews at 00:00 UTC, so in that window the renewal is still ahead and the end is rightly scheduled at it. The test now uses the previous UTC month. scheduleCardEnd reads the card configuration's clock, like the first-charge anchor, and a new test pins the window: an end whose last month just ended in Copenhagen waits for Stripe's renewal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
✅MegaLinter analysis: Success
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
|
Code coverage overviewLanguages: Go Go / code-coverage/go
Line coverage data for the main branch is not yet available. View coverage of the 10 most covered files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
jscpd on #631: the two card end tests repeated the order and its subscription's completion. subscribedCardOrderWith takes the one-time amount; subscribedCardOrder keeps its callers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |

Summary
TestPrivateCardRetriesAnEndAfterItsMonthPassedfailed whenever it ran in the first hour or two of a month in Copenhagen: 00:00–01:00 in winter, 00:00–02:00 in summer. The product was right in that window; the test was not.scheduleCardEndthen correctly ends the subscription at the renewal, which charges nothing, rather than at once, which is what the test expected.TestPrivateCardEndWaitsForARenewalStillAheadpins the window at 2026-10-31 23:30 UTC, which is 00:30 on 1 November in Copenhagen. An end whose last month is October is scheduled at 2026-11-01 00:00 UTC, not at once.scheduleCardEndreads the card configuration's clock (CardBilling.Now) instead oftime.Now(). That is the clock the first-charge anchor and the webhook signature check already use. In production both aretime.Now, so behaviour is unchanged; the test can now set the time. Iftime.Now()is put back, the new test fails because the cancel becomes immediate.Audit of the other month decisions
Each one either follows Stripe's UTC 1st or dates invoices in Copenhagen, and none picks the wrong month in the window:
firstOfNextMonth)firstAnchor)applySubscriptionInvoicePaid)created, read in Copenhagenended_atless one secondThe two end rules differ in the window, but each matches what Stripe charges. A whole-order end can wait for the renewal. An add-on item is removed at once, so the add-on cannot be billed for a month whose renewal comes after its removal.
Test plan
time.Now()back inscheduleCardEndmakes the new one fail-race, all cohorts) passes against the local fixture database🤖 Generated with Claude Code