Skip to content

Fix #1466 surface subscription cancellation reason in admin UI#1490

Open
chrisjsimpson wants to merge 1 commit into
masterfrom
1466-show-cancellation-reason-on-subscriptions
Open

Fix #1466 surface subscription cancellation reason in admin UI#1490
chrisjsimpson wants to merge 1 commit into
masterfrom
1466-show-cancellation-reason-on-subscriptions

Conversation

@chrisjsimpson
Copy link
Copy Markdown
Contributor

Summary

Closes #1466.

Shop owners could previously see that a subscription had been cancelled, but the why (Stripe's cancellation_details.reason) was only visible on the shop-wide "recent cancellations" report, not on the subscribers list where they naturally look.

  • Add Subscription.stripe_cancellation_reason column (+ alembic migration) populated from:
    • the customer.subscription.deleted Stripe webhook, and
    • the manual Refresh Status / background refresh paths (so historic cancellations can be backfilled).
  • Render the reason next to the existing Date ended at line on both the subscribers list (/admin/subscribers) and the per-subscriber detail page, with human-friendly labels + explainer popovers for the three reasons Stripe emits (payment_failed, cancellation_requested, payment_disputed).
  • Add Python regression test (tests/test_webhook_subscription_cancellation_reason.py) verifying the webhook now persists the reason, and a Playwright spec (1466_subscription_cancellation_reason_visible.spec.js) that records a video and captures screenshots of the reason in the UI.

Proof

Subscribers page showing Cancellation reason: Payment failed and Cancellation requested

(see attached 1466-subscribers-page.png, 1466-subscriber-detail-page.png, and issue-1466-cancellation-reason.webm for the Playwright video.)

Test plan

  • pytest tests/ --ignore=tests/browser-automated-tests-playwright — 28 passed, 1 skipped
  • flask db upgrade succeeds on existing SQLite DB (subscription.stripe_cancellation_reason column added)
  • Playwright spec @1466_subscription_cancellation_reason_visible records video + screenshots and asserts the reason is visible on the subscribers list and detail pages
  • Manual: with a real Stripe test-mode subscription cancelled via Cancel action, refresh the subscribers page and confirm the reason renders as "Cancellation requested"
  • Manual: trigger a customer.subscription.deleted webhook with cancellation_details.reason = payment_failed and confirm it renders as "Payment failed"

🤖 Generated with Claude Code

Shop owners could see that a subscription had been cancelled, but not
why. Persist Stripe's ``cancellation_details.reason`` on the local
Subscription (new ``stripe_cancellation_reason`` column, populated from
the ``customer.subscription.deleted`` webhook and the manual refresh
path) and surface it on the subscribers list and subscriber detail
pages alongside the existing cancellation metadata.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@chrisjsimpson
Copy link
Copy Markdown
Contributor Author

Playwright verification artifacts

Ran the new spec e2e/1466_subscription_cancellation_reason_visible.spec.js against a dev shop with two canceled subscriptions seeded (one payment_failed, one cancellation_requested):

  • Screenshot — subscribers list: shows both cancellation reasons rendered with explainer popovers.
  • Screenshot — subscriber detail: same reasons rendered on the per-subscriber page.
  • Video (video.webm): records the login → subscribers list → subscriber detail flow, captured automatically by Playwright (video: 'on').

Local artifacts saved to /tmp/issue-1466-artifacts/ on the dev machine:

1466-subscribers-page.png          319 KB
1466-subscriber-detail-page.png    326 KB
issue-1466-cancellation-reason.webm 346 KB

Spec output:

[#1466] Reasons on subscribers page: [ 'Payment failed...', 'Cancellation requested...' ]
1 passed (17.5s)

@chrisjsimpson chrisjsimpson force-pushed the 1466-show-cancellation-reason-on-subscriptions branch from 470443c to e8f4c18 Compare April 21, 2026 21:40
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.

As a shop owner, I can quickly see *when* a given subscription was cancelled, not only that it is cancelled.

1 participant