You can use the below to perform various actions on plan state change.
Plan Active
Global
Triggers: onCPayUserStateChange
User: Automatic
Access: Everybody
Conditions
1: [var3] Equal To PLAN_ID_HERE
2: [var2] Equal To A
Plan Expired
Global
Triggers: onCPayUserStateChange
User: Automatic
Access: Everybody
Conditions
1: [var3] Equal To PLAN_ID_HERE
2: [var2] Not Equal To A
[var3] is the plan id. You could for example set that to a field using a Field action.
Alternatively instead of storing the plan id you can use CB Query Field to query for their subscription row and return their subscription id if they've an active subscription to a plan. This is done with the below query for example.
Code:
SELECT `id` FROM `#__cbsubs_subscriptions` WHERE `user_id` = '[user_id]' AND `status` = 'A' AND `plan_id` = PLAN_ID_HERE ORDER BY `subscription_date` DESC LIMIT 1