Repository navigation
Read one connection status from GoDAM Central and show renewal instead of signup - #2377
Open
rudrakshi-gupta wants to merge 6 commits into
Open
rudrakshi-gupta wants to merge 6 commits into
rudrakshi-gupta wants to merge 6 commits into
Conversation
…d of signup - Add a Connection_Status enum (connected, trial, expired, unreachable, none) and a Connection helper that stores what verify_api_key returns: connection_status, trial_ends_at, organization and (when sent) expired_at - Read those fields from Central's 200, 401 and 403 answers, only for the stored key or a new key being saved, so a mistyped key changes nothing - On an older Central that doesn't send connection_status, work the status out from the key status as before - Treat a 200 with "none" (subscription still being set up) as connected, and a 403 that still says connected or trial (site not on the key's allowed sites) as no usable key, so neither shows the wrong screen - Report "unreachable" while Central can't be reached and the last good answer is still trusted - Show a renewal screen in the onboarding overlay when the plan has expired, instead of the signup screens: Renew plan, "I've renewed, check again", use a different license key, Contact support - Show the onboarding overlay only for "none" and "expired"; never while Central is unreachable - Build the renewal link from the organization: /godam_upgrade?organization=<org>&wp_return=<dashboard>, falling back to the Plans page when the organization isn't known - Count trial days left by calendar date in the site's timezone, since Central sends the trial's last day as UTC midnight - Show "Your GoDAM trial ends in N days" in the Media Library with an upgrade link; point the expired notice at renewal, and at Settings when Central refused the key for another reason - Add connectionStatus, trialDaysLeft and renewalUrl to the data the admin pages get, for the Woo add-on and the dashboard to use - Expose when the plan lapsed (Central's expired_at, otherwise the first time the site saw the key as expired) for the Woo grace period - Clear the stored status when the API key is removed - Add PHP tests for the status helper and for what verify_api_key stores, and JS tests for the renewal screen Refs rtCamp/godam-plugin-wp#101
🔍 WordPress Plugin Check Report
📊 Report
|
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
mismatched_plugin_name | Plugin name "GoDAM - Video Hosting for LMS & Online Courses" is different from the name declared in plugin header "GoDAM". |
📁 assets/build/pages/video-editor.min.js (1 warning)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
2 |
react_removed_api | This file calls "ReactDOM.findDOMNode", which was removed in React 19 and stops working once WordPress upgrades React. Use a ref on the element instead. |
📁 assets/build/css/main.css (1 warning)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
EnqueuedStylesScope | This style is being loaded in all contexts. |
📁 assets/src/libs/analytics.min.js (5 warnings)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
EnqueuedScriptsScope | This script is being loaded in all frontend contexts. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880 (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/2026/11/18/hello-world/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/sample-page/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/demo-attachment-post/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
📁 assets/build/js/main.min.js (5 warnings)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
EnqueuedScriptsScope | This script is being loaded in all frontend contexts. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880 (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/2026/11/18/hello-world/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/sample-page/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/demo-attachment-post/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check
- Keep Central's connection_status as sent, including on the not-allowed-site 403; it describes the plan, while the key status still decides features - Show the renewal screen only when the plan has expired and the key stopped working; when the key still works, show a renewal notice instead - Show the trial notice only when the key works, and point a refused key with a live plan to settings instead of renewal - Update the connection status tests
- Show a dismissible wp-admin notice when the subscription has ended but the licence still works: "Your GoDAM subscription has ended. Renew to keep Pro features." Never on the site, never a full screen - Save the dismissal for the whole site, and show the notice again for the next lapse - Replace get_expired_since() with get_licence_failed_since(): count Woo's grace period from the licence failing, not from connection_status saying expired - Return nothing while the licence works; use Central's expired_at once sent, otherwise the first failed check; Central being unreachable never starts it - Update the connection status tests
- Start Woo's grace period from the first failed key check, not Central's expired_at (the subscription can lapse while the licence still works) - Use expired_at only when no failed check is on record - Document what Central sends for 200, 401 and both 403 cases - Add tests for every final Central answer and the grace start date
rudrakshi-gupta
marked this pull request as ready for review
November 18, 2026 09:49
subodhr258
reviewed
Nov 18, 2026
subodhr258
left a comment
Collaborator
There was a problem hiding this comment.
Summary: The plugin side matches Central's merged contract, adds no new Central calls, and a Central outage cannot change the stored status or lock a paying site out, so I found no blockers; five small non-blocking items are inline.
Tested commit: 431552ed897b5069f02492272a041b984c85dbe7 (base develop, merge-base ed01a0b4).
Claim / how checked / result
| Claim (PR title, body, issue #101) | How checked | Result |
|---|---|---|
One connection status is stored per key check in rtgodam-connection (status, trial end, lapse date, organization) |
Read Connection::record() and the two call sites in rtgodam_verify_api_key(); ran ConnectionStatusTest (37) and ApiKeyVerificationResilienceTest (22) on PHP 7.4.33 |
Holds |
Reads Central's final contract: connection_status, trial_ends_at, expired_at, organization; 200 / 401 none / 403 expired with null expired_at / 403 whitelist keeps real status |
Compared with Central's merged verification.py (godam-core#1957, merge commit 6f78cc18) and the HTTP codes in its error_types.py; frappe-stripe-subscription#289 for custom_expired_at |
Holds: field names, codes and the UTC-midnight date format match. Note: Central raises 503 before it can send 200 + none, so that case is never sent today (the plugin handles it anyway) |
| No new Central calls before Central ships; older Central falls back to the key status | Read every Central URL in the diff; replayed an older-Central answer (200 without a status) | Holds: only the existing verify_api_key is called, and the renewal links use the existing /godam_upgrade (already used on develop by ProUpgradeNotice) and /web/billing. See note 2 below for one older-Central side effect |
| The status only chooses screens and notices, never features | Read the whole diff for feature gates | Holds: rtgodam_is_api_key_valid() and every feature check are untouched |
| Central down, timeout, 404 or 5xx does not flip the site to "renew" or lock it out | Followed rtgodam_verify_api_key(): 5xx, 408, 429, transport errors and non-JSON 404 never reach record(); the keep-last-good path is unchanged |
Holds |
| Subscription ended but licence works: dismissible admin-only notice, no screen; dismissal is nonce and capability checked; notice returns on the next lapse | Read subscription_ended_notice(), dismiss_subscription_ended_notice(), admin.js, and the reset in record() |
Holds by code. Not exercised in a browser |
| Licence 403 opens the renewal screen; whitelist 403 gets the "check your settings" message, never the renewal screen | Read should_overlay_onboarding() and api_key_status_notice() |
Holds, with one nuance: a site that is both off the allowed list and on a really expired plan still gets the renewal screen, because Central sends expired |
| "I've renewed, check again" says "Couldn't reach GoDAM" when Central is unreachable | Read RenewScreen.jsx and the refresh-api-key-status route; reproduced with a stored expired key and a 503 from Central |
Does not hold: the route answers 200 with valid_api_key: false and api_key_status: verification_failed, so the screen says "still shows as expired". See inline comment 1 |
| Trial notice shows days left as calendar days in the site's timezone | Read get_trial_days_left(); the trial-day tests pass |
Holds |
get_licence_failed_since() counts from the first failed check, not expired_at; GoDAM for Woo can use it |
Read it, ran its tests, read the open Woo licence-grace PR | Holds: Woo calls get_status(), get_licence_failed_since() and get_renewal_url() behind is_callable, and the signatures match |
| Removing the key clears the stored answer | deactivate_api_key() calls Connection::clear(); no other code deletes rtgodam-api-key |
Partly: uninstall does not remove the two new options (inline comment 3) |
| Nothing renamed or removed that GoDAM for Woo reads | Grepped godam-for-woo (current checkout and the Woo licence-grace PR branch) for rtgodam_get_user_data, api_key_status, rtgodam-api-key-error-since, window.userData, Connection:: |
Holds: Woo reads api_key_status and window.userData; the PR only adds keys to them |
| PHP 7.4 compatible | php -l under 7.4.33 on all 11 changed PHP files and the tests; Connection_Status is a plain class of constants, no enum, match, readonly, named args or union types |
Holds |
| All PHP and JS tests pass, phpcs clean | Full jest run: 90 suites, 1273 tests pass. phpcs on the changed PHP files: clean. eslint on pages/onboarding and admin.js: clean. Full PHPUnit on my machine: 28 errors, the same count on current develop (a local PHP setup problem in separate-process tests); the PR's own CI "Run PHP unit tests" is green |
Holds |
| Plugin items in issue #101: one status helper, the renewal screen, the renewal link, the Woo grace-period hook | Mapped each to the code | Holds |
Notes (non-blocking)
- Inline comments cover: the check-again message, the Back button from "Use it instead", the two options missing from
uninstall.php, the organization carried over to a newly saved key, and a test fixture that does not match Central's 403 shape. - Until Central ships, an older Central that answers 401 (key unknown) reads as
expiredthrough the key-status fallback, so the renewal screen would open for an unknown key. I replayed this. It goes away once Central's change is live; if you want it independent of Central, pass the HTTP status intorecord()and map 401 tonone. - While a check is being retried (
retry_atset)get_status()returnsunreachable, so the trial and subscription-ended notices disappear until the next good check. This is tested and intended; just flagging it.
Not tested
- No browser run: the renewal screen, the notices and the dismissal AJAX call were read, not clicked. The PR screenshots are the only UI evidence.
- No real WordPress: the PHP tests stub WordPress functions, so
update_optionautoload, nonces andadmin_noticeswere not exercised. - No call to the real Central, and I did not check that Central's change is deployed to production.
npm run build, multisite, and the Woo licence-grace PR running against this branch.- The repo's hook-coverage lint ran out of memory in my scratch worktree (it scanned the symlinked
node_modules); the PR's CI check for it is green.
- "Check again" says GoDAM couldn't be reached when the refresh can't reach Central or the request fails, not "still expired" - Back from the license key screen returns to renewal for a site with a lapsed plan - Remove rtgodam-connection and the dismissed-notice option on uninstall - Forget the previous key's answer, including its organization, when a different key is saved - Read an older Central's 401 as a key it doesn't know (connect screens, not renewal) - Match the key-check test answers to Central's shapes: subscription ended on a 200 with its date, an inactive licence on a 403 with no date
…n-status # Conflicts: # uninstall.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes rtCamp/godam-plugin-wp#101
GoDAM used to know only "valid key or not". So a site whose trial or plan lapsed was sent back to the signup screens instead of renewal, and nothing told the owner a trial was about to end. GoDAM Central now sends one connection status with every key check (rtCamp/godam-core#1957, rtCamp/frappe-stripe-subscription#289, both merged). This PR stores that status and uses it to pick the right screen and notice.
The connection status only chooses screens and notices. It never switches features on or off: that is still the key status (
rtgodam_is_api_key_valid()), as agreed with Mayank and Subodh.connectedtrialexpired, key still worksexpired)expired, key stopped workingunreachablenoneA site Central refuses because it isn't on the key's allowed sites (403 whitelist) gets the plan's real status. Renewing can't fix that, so it gets the "check your settings" message, never the renewal screen.
What Central sends (final contract)
verify_api_keynow returnsconnection_status,trial_ends_at,expired_atandorganizationon every answer:connection_status:connected(Active or Grace Period),trial,expired(subscription lapsed) ornone(no subscription yet)trial_ends_at: only on a trialexpired_at: the day the subscription lapsedorganizationnone, with no organizationexpiredwith the organization, butexpired_atisnulltrial_ends_atandexpired_atare calendar dates sent as that date's UTC midnight.Changes
New:
inc/classes/enums/class-connection-status.phpconnected,trial,expired,unreachable,none;from_central()lists the values Central can send.New:
inc/helpers/class-connection.php(RTGODAM\Inc\Helpers\Connection)record( $message, $succeeded, $http_status )stores Central's answer for the stored key inrtgodam-connection(status, trial end, lapse date, organization):connectedand a 401 asnone(a key Central doesn't know: the connect screens, not renewal); otherwise the key status decides.none(the key works but the subscription is still being set up): the key status decides, so a working key is never sent to the connect screen.expired: clears the dismissed "subscription ended" notice, so it comes back on the next lapse.get_status():none.unreachable.get_trial_days_left(): calendar days in the site's timezone, so a site west of UTC isn't shown one day short.get_licence_failed_since(): when the licence stopped working on this site, which is the start of GoDAM for Woo's grace period (Hide Transcoded MPD URL #113).rtgodam-api-key-error-since), not Central'sexpired_at.expired_atis when the subscription lapsed, and the licence can keep working long after it, so counting from it could cut Woo's grace period short.expired_atis used only when no failed check is on record.get_renewal_url():https://app.godam.io/godam_upgrade?organization=<org>&wp_return=<dashboard>, or the plans page when the organization is unknown. Filterable withrtgodam_renewal_url.should_show_subscription_ended_notice()anddismiss_subscription_ended_notice().clear(): called when the key is removed, and before a different key's answer is recorded.Key check (
admin/godam-transcoder-functions.php)Uninstall (
uninstall.php)rtgodam-connectionandrtgodam-subscription-ended-notice-dismissedwith the other key options.Data sent to the admin pages (
inc/helpers/custom-functions.php)window.userDatagetsconnectionStatus,trialDaysLeftandrenewalUrl, also when there's no key.Renewal screen (
pages/onboarding)RenewScreen: "Your GoDAM plan has expired", with:verification_failed) or the request failed (e.g. an expired nonce), it says "Couldn't reach GoDAM"; it says "still expired" only when Central answeredLicenseKeyScreen.jsx).expiredand the key no longer works (class-pages.php). A site whose subscription ended but whose licence still works gets the notice below instead of a screen.Notices (
admin/class-rtgodam-transcoder-admin.php,assets/src/js/admin.js)Dependencies
Connection::get_licence_failed_since()andget_renewal_url()when present).Screenshots
How to test
Build first:
npm run build.On a site with a working key, first stop GoDAM re-checking the key while you test (it re-checks about once an hour and would overwrite the test values):
1. Real Central answer
wp option get rtgodam-connection --format=jsonshowsstatusconnected(ortrial) and yourorganization.2. Trial
app.godam.io/godam_upgrade?organization=acme&wp_return=…in a new tab.+5 daysto+0 days: "Your GoDAM trial ends today." To+1 days: "1 day".3. Subscription ended, licence still active (200 + expired)
wp option update rtgodam-connection '{"status":"expired","trial_ends_at":0,"expired_at":0,"organization":"acme"}' --format=jsonrtgodam-subscription-ended-notice-dismissedis set).connected, then back toexpired→ the notice is back.4. Plan expired, key stopped working (403 inactive licence)
wp eval 'echo RTGODAM\Inc\Helpers\Connection::get_licence_failed_since();'prints the error-since time, notexpired_at.5. Site refused, plan live (403 site not on allowed sites)
Same as 4, but with
"status":"connected".6. Central unreachable
"retry_at": <future time>tortgodam_user_data→connectionStatusisunreachable, nothing covers the page, no renewal screen.7. No key / unknown key
rtgodam-connectionis deleted and the connect screens show, as before.Reset
Tests
tests/php/ConnectionStatusTest.php(37 tests):unreachableexpired_at), andexpired_atonly without onetests/php/ApiKeyVerificationResilienceTest.php: a trial recorded with its end date; a success without a status read as connected; a subscription ended on a 200 recorded with its lapse date; an inactive licence (403,expired_at: null) counting from the first failed check; an older Central's 401 read asnoneand its 403 left to the key status; saving a different key forgetting the previous organization; a rejected new key leaving the stored status alone.pages/onboarding/components/screens/RenewScreen.test.js: opens on renewal for a lapsed plan, renew link for the organization, check again (still expired / Central unreachable / the browser can't fetch / a failed request), use a different key.pages/onboarding/components/screens/LicenseKeyScreen.test.js(new): Back goes to renewal for a lapsed plan, to the start otherwise.