Skip to content

Paid Content: expire subscription access at end-of-day (NL-735)#50460

Open
allilevine wants to merge 1 commit into
trunkfrom
add/paid-content-renewal-grace
Open

Paid Content: expire subscription access at end-of-day (NL-735)#50460
allilevine wants to merge 1 commit into
trunkfrom
add/paid-content-renewal-grace

Conversation

@allilevine

@allilevine allilevine commented Jul 13, 2026

Copy link
Copy Markdown
Member

Fixes NL-735

Proposed changes

Paid Content enforced access on a membership subscription's exact end_date timestamp. Memberships store end_date as the precise purchase timestamp (e.g. 2026-07-10 09:34:45), and auto-renewals run via a deferred day-0 billing job that BDSE spreads across a 3–10 hour window. So a subscriber could lose access the instant their timestamp passed, hours before that day's renewal completed — even though the renewal then succeeded.

Billing (Shilling) confirmed the ~6h renewal deferral is expected, and that the wider WordPress.com / Jetpack platform already treats end-of-day as the formal expiration time for subscriptions (which is why expiration messaging/scheduling holds until EOD). Paid Content was the outlier, enforcing on the exact timestamp.

This PR aligns Paid Content with that convention: a subscription grants access through 23:59:59 UTC of its end_date day, in the two enforcement points (validate_subscriptions() non-tier, and maybe_gate_access_for_user_if_tier() tier). That naturally covers a same-day auto-renewal regardless of how long BDSE defers it.

Why no gating is needed: cancelled/inactive subscriptions never reach this check — they're dropped upstream by the 'active' === status filter in abbreviate_subscriptions(). So end-of-day only ever extends an already-active subscription to the end of its final day, matching the platform. No auto_renew flag or grace-period duration is involved.

Related product discussion/links

  • NL-735
  • Root-cause confirmed with Billing/Shilling: the 3–10h renewal deferral is expected; EOD expiration is the platform convention Monetize should follow.
  • Complements NL-546 (post-renewal stale-JWT refresh): EOD covers the same-day pre-renewal gap; refresh still handles genuinely-old stale tokens.

Does this pull request change what data or activity we track or use?

No. It changes only how the existing end_date is compared against the current time (rounded up to end-of-day, UTC). No new data, tracking, or token-shape change.

Testing instructions

Automated: jetpack docker phpunit jetpack -- tests/php/extensions/blocks/premium-content/Jetpack_Premium_Content_Test.php — 34 tests / 79 assertions pass, including:

  • A subscription whose exact end_date is earlier today still grants access (the incident case), end-to-end through current_visitor_can_access with no refresh call.
  • A subscription whose end_date day has fully passed is denied.
  • Future end_date still grants; string (Y-m-d H:i:s) and integer end_date values both handled.
  • NL-546 refresh-before-deny tests updated to use a prior-day stale end_date so they still exercise the refresh path under end-of-day expiry.

Manual (Simple/Atomic, or a Jetpack Beta JN site): with a Premium Content post gated to a plan and an active subscription, set the subscription's end_date to earlier today via the earn_get_user_subscriptions_for_site_id filter → content stays visible; set it to a prior day → paywall returns.

🤖 Generated with Claude Code

@allilevine allilevine self-assigned this Jul 13, 2026
@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the add/paid-content-renewal-grace branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/paid-content-renewal-grace

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions Bot added [Block] Paid Content aka Premium Content [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress [Tests] Includes Tests labels Jul 13, 2026
@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions github-actions Bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Jul 13, 2026
@jp-launch-control

jp-launch-control Bot commented Jul 13, 2026

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/plugins/jetpack/extensions/blocks/premium-content/_inc/subscription-service/class-abstract-token-subscription-service.php 192/289 (66.44%) 0.00% 2 ❤️‍🩹

Full summary · PHP report · JS report

@allilevine allilevine closed this Jul 13, 2026
@github-actions github-actions Bot removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Status] In Progress labels Jul 13, 2026
@allilevine allilevine reopened this Jul 13, 2026
@github-actions github-actions Bot added [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Jul 13, 2026
@allilevine allilevine changed the title Paid Content: grace period for pending auto-renewals (NL-735) Paid Content: expire subscription access at end-of-day (NL-735) Jul 13, 2026
@allilevine allilevine force-pushed the add/paid-content-renewal-grace branch from fef93f5 to a38841d Compare July 13, 2026 19:29
Paid Content enforced access on a membership subscription's exact end_date
timestamp. Memberships store end_date as the precise purchase timestamp,
and auto-renewals run via a deferred day-0 billing job that BDSE spreads
across a 3-10 hour window — so a subscriber could lose access the instant
their timestamp passed, hours before that day's renewal completed, even
though the renewal then succeeded.

Billing confirmed the deferral is expected and that the wider WordPress.com
/ Jetpack platform already treats end-of-day as the formal expiration time
for subscriptions. Paid Content was the outlier.

Grant access through 23:59:59 UTC of the end_date day in both enforcement
points (validate_subscriptions and the newsletter-tier gate), matching the
platform convention. This covers a same-day auto-renewal regardless of how
long BDSE defers it. Cancelled/inactive subscriptions never reach this
check (dropped by the active-status filter), so no gating is needed.

Tests that used a same-day past end_date to represent an expired
subscription (NL-546 refresh-before-deny, and the subscriptions/newsletter
access + comp tests) now use a prior-day end_date, so they still read as
expired under end-of-day expiry.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_015QcwooRyPv7STjV5KPc1rj
@allilevine allilevine force-pushed the add/paid-content-renewal-grace branch from a38841d to b05c634 Compare July 13, 2026 19:41
@allilevine allilevine marked this pull request as ready for review July 13, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Paid Content aka Premium Content [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant