Skip to content

fix(payments): G2A-CRIT-001 follow-up — cancel preflight on PATCH and Woo paths - #15

Merged
Shubochandrosarker merged 2 commits into
mainfrom
fix/g2a-crit-001-cancel-preflight
Oct 5, 2026
Merged

Shubochandrosarker merged 2 commits into
mainfrom
fix/g2a-crit-001-cancel-preflight

Conversation

@Shubochandrosarker

Copy link
Copy Markdown
Contributor

Summary

Closes the remaining G2A-CRIT-001 cancel gaps identified against public Memberistic v2.2.0: the dedicated POST .../cancel endpoint and wp-admin cancel already called Stripe_Service::cancel_remote_first(), but two paths still flipped local status first (or skipped Stripe entirely).

Changes

  1. Memberships_Controller::update_item (PATCH /memberships/{id})
    When status changes to cancelled, call cancel_remote_first() before change_status(). On Stripe failure return 502 memberistic_stripe_cancel_failed unless force=true (same behaviour/message as the dedicated cancel endpoint). Registers optional force boolean arg.

  2. WooCommerce_Bridge::sync_refunded_order
    Before dispatch_order(..., 'refunded'), resolve _memberistic_membership_id and call cancel_remote_first(). Local cancel via the payment-integrity gate always proceeds afterward (Woo refund already happened). Needed because the gate fires memberistic_membership_status_changed with the inbound-event flag set, which skips the post-hoc Stripe listener.

  3. CHANGELOG — Unreleased / Fixed entry. No version bump or tag.

Tests

  • find . -name '*.php' ... | xargs php -l — exit 0 (PHP 8.4)
  • php tests/licensing.php — 8 checks passed
  • No dedicated cancel unit suite in this repo (only tests/licensing.php + CI PHP lint)

Risks / notes

  • Woo path ignores Stripe WP_Error on purpose (documented); retries still queued by cancel_remote_first.
  • PATCH without force will refuse cancel if Stripe fails — callers that previously used PATCH to cancel must handle 502 or use /cancel / force=true.

G2A-CRIT-001 follow-up: gate PATCH /memberships/{id} status=cancelled
and WooCommerce refund/cancel through cancel_remote_first() before local
status flips, matching the dedicated cancel endpoint and wp-admin cancel.
PATCH accepts optional force=true; Woo always proceeds locally after the
Stripe attempt because the refund has already happened.
The clean-install/upgrade workflow still expected memberistic-2.1.1.zip
after the 2.2.0 release, so the version assertion failed on main and on
this PR. Update build/assert/install pins to 2.2.0; upgrade smoke still
starts from public v2.1.0.
@Shubochandrosarker
Shubochandrosarker merged commit c077d7f into main Oct 5, 2026
10 checks passed
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