Commit 6f2791dc authored by Birin Sanchez's avatar Birin Sanchez
Browse files

When upgrading/downgrading bundle plan avoid a race condition between

WC and middleware by checking that the order is paid and the linked
subscription is active.
Signed-off-by: Birin Sanchez's avatarBirin Sanchez <>
parent 5b55596c
Pipeline #17440 passed with stage
in 28 seconds
......@@ -133,8 +133,24 @@ def process_bundle_changes():
for pending_change in pending_changes:
if order_paid(pending_change.new_order_id):
is_active = False
is_paid = order_paid(pending_change.new_order_id)
# Check if the subscription is active
subs = get_user_subscriptions(pending_change.user)
for sub in subs:
order_id = sub.get('parent_id', -1)
sub_status = sub.get('status', '')
if (
order_id == int(pending_change.new_order_id)
and sub_status == 'active'
is_active = True
# if subscription is active and order is paid we process the
# bundle change
if is_paid and is_active:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment