I currently use the wixPaidPlans_onPlanPurchased event to trigger additional data changes for a member within the site. I need to reverse or alter those same data changes when the user Cancels their plan. Yet I can find no mechanism to trigger this automatically. Just starting out here and realizing how much manual work is involved if I can not find an automation mechanism for this instead. Any ideas?
Hi Ben,
You can use the onPlanPurchased( ) event handler to check the status of the plan, so you can remove the member privileges when their plan expired or cancelled.
export function wixPaidPlans_onPlanPurchased(event) {
const status = event.order.status.toLowerCase();
if (status === 'canceled' || status === 'expired') {
// handle the case where the plan is canceled or expired
}
}
Hope this helps~!
Happy Coding
Ahmad
Ahh… I thouht it was only on a Purchase this event was triggered. But… based on your words, its triggered for Expired or Canceled plans as well? That would certainly do the trick for me!
@benblackettmusic Those events aren’t available yet, but they will be soon! We post about new APIs in the News & Announcements category of the Forum, so make sure to Follow the category to get updates directly in your inbox. Thanks!
@benblackettmusic Yes it’s triggered when plans are canceled and expired as well.
Ok… think I still am not fully understanding this. All I am seeing in the event . order . status field is “ACTIVE”. no other value seems to be present. And when I look at the API documentation, that is also the value being displayed in the sample code area.
https://www.wix.com/velo/reference/wix-paid-plans-backend/events/onplanpurchased
Ive been tracking planEvents now for some time using that very same sample code provided, and the only records it appears to be tracking are purchases. No other events are logged.
Am I missing something here?
export function wixPaidPlans_onPlanPurchased(event) {
let orderItem, isPaid, ownerId, planId, planName;
let orderData = {
"title": event.order.planName,
"data": event.order,
"price": event.order.price.amount,
"currency": event.order.price.currency,
"cancellationReason": event.order.cancellationReason,
"paymentStatus": event.order.paymentStatus,
"recurring": event.order.recurring,
"orderId": event.order.id,
"status": event.order.status,
"roleId": event.order.roleId,
"planDescription": event.order.planDescription,
"wixPayOrderId": event.order.wixPayOrderId,
"memberId": event.order.memberId,
"planId": event.order.planId,
"validForever": event.order.validFor.forever,
"validForAmount": event.order.validFor.period.amount,
"validForUnit": event.order.validFor.period.unit
}
wixData.insert("planEvents", orderData)
.then((results) => {
orderItem = results;
});
@benblackettmusic sorry if that wasn’t correct - I gave my answer based on this documentation.
@yisrael-wix would you please helps us on this? Am I missing something?
@ahmadnasriya certainly seems like it should be the case!
But I have 937 records in the planEvents table over the last few months and every single one states ACTIVE for that field. I cant get it to log any cancelation - done via the Wix Dashboard or via the subscribers My Subscription page.
thanks btw
The funny thing is… I know its tracked somewhere somehow! I do get Notifications via the Wix Dashboard when it occurs! =)
@ahmadnasriya @yisrael-wix @marlowe-shaeffer
So I just ran an experiment using the Real Time Event Log within the Site Monitoring tool. I confirmed that a purchase event WAS indeed captured, but that a Cancel event is NOT.
So, to answer my original question, it looks like there currently no way to track Cancel, Expired, or Non-Payment events and run follow up changes on that.
Does anyone know if there is a current request in for Wix to make this available? I’d like to go give it an upvote if there is.
Thanks.
Hi Ben,
I am not sure whether this will help, but I just learned of a workaround from Dashboard > Customer Management > Automations > New Automation. Select Pricing Plans and Webhook. I hope this does the trick! If not, we have a feature request for onPlanCancelled that you can upvote and comment on here: https://www.wix.com/velo/requested-feature/onplancancelled-event-required-for-wix-paid-plans
@marlowe-shaeffer Thanks for that workaround! I’ll give it a try and see what I can accomplish with it. Also thanks for the link! just gave it an upvote.
@marlowe-shaeffer Just did some experimenting and it looks like the Automation workaround will work for what I need it to do. I spent an hour in frustration however until I tried a NON-Admin account to do the actual plan purchase/cancel changes with. Apparently Plan Automation does not work for the Admin account
Thanks for the lead!
@benblackettmusic Indeed, not sure why the event isn’t triggered though
@marlowe-shaeffer I don’t think the automation will help, since the event is triggered only if the plan status is active, it’s like a notification to send to a 3rd party server, why I think so? Because the documentation indicates that the event should be triggered on any the status, so I think it’s a bug that needs to be fixed ASAP, I’ve built many sites to automatically do something when the plan is cancelled or expires, if that’s the case, members of those sites will enjoy a lifetime membership, which is not acceptable, it needs to escalated and fixed ASAP.
@ahmadnasriya I tested this and it did not fire when a plan was cancelled.
@marlowe-shaeffer is there an update on this thread. apart from automation, is there an event I can listen to when a plan is cancelled or expired? we currently have a six site and we need to add customisation to these events. We don’t want to use the automations route.
This event is currently in development and should be releasing soon.
Many thanks. Can I ask one more question if you don’t mind. When a purchased event is raised at backend, how can I get the details of the customers for whom the even was created? At the moment we are relying on automations in wix editor but ideally we want to run off that journey from the backend event.