An event that triggers when an order is canceled.
The onOrderCanceled()
event handler runs either immediately when an order is canceled IMMEDIATELY
or at the end of the current payment cycle when an order is set to cancel at the NEXT_PAYMENT_DATE
.
The received OrderCanceledEvent
object contains information about the canceled order.
The onOrderCanceled()
event will not trigger immediately when the order is canceled with effectiveAt
as NEXT_PAYMENT_DATE
.
In that case, the onOrderAutoRenewCanceled()
event will trigger immediately and the onOrderCanceled()
event will trigger following the current payment cycle.
Note: Backend events don't work when previewing your site.
function onOrderCanceled(event: OrderCanceledEvent): void;
Information about the canceled order and metadata for the event.
// Place this code in the events.js file
// of your site's Backend section.
// Add the file if it doesn't exist.
export function wixPricingPlans_onOrderCanceled(event) {
const orderId = event.data.order._id;
const eventId = event.metadata.id;
const eventTime = event.metadata.eventTime;
}
/* Full event object:
* {
* "metadata": {
* "id": "b54fa4e8-3739-4554-b884-1aaec298e202",
* "entityId": "50a888fb-5b07-4b78-b3b9-4e02a7314728",
* "eventTime": "2022-07-25T06:40:54.814784Z",
* "triggeredByAnonymizeRequest":false
* },
* "data": {
* "order": {
* "_id": "50a888fb-5b07-4b78-b3b9-4e02a7314728",
* "planId": "099e2c86-3b7e-4477-8c27-f77402b8cceb",
* "subscriptionId": "70a6511f-d929-422a-9478-029dd64b53ea",
* "wixPayOrderId": "3163cb56-942b-418f-8ff5-700553f1863c",
* "buyer": {
* "memberId": "0c9bca47-1f00-4b92-af1c-7852452e949a",
* "contactId": "0c9bca47-1f00-4b92-af1c-7852452e949a"
* },
* "priceDetails": {
* "subtotal": "74.99",
* "discount": "0",
* "total": "74.99",
* "planPrice": "74.99",
* "currency": "EUR",
* "subscription": {
* "cycleDuration": {
* "count": 1,
* "unit": "MONTH"
* },
* "cycleCount": 3
* }},
* "pricing": {
* "subscription": {
* "cycleDuration": {
* "count": 1,
* "unit": "MONTH"
* },
* "cycleCount": 3
* },
* "prices": [{
* "duration": {
* "cycleFrom": 1,
* "numberOfCycles": 3
* },
* "price": {
* "subtotal": "74.99",
* "discount": "0",
* "total": "74.99",
* "currency": "EUR"
* }
* }]},
* "type": "OFFLINE",
* "orderMethod": "UNKNOWN",
* "status": "CANCELED",
* "autoRenewCanceled": true,
* "cancellation": {
* "cause": "OWNER_ACTION",
* "effectiveAt": "IMMEDIATELY"
* },
* "lastPaymentStatus": "UNPAID",
* "startDate": "2022-07-19T12:06:33.259Z",
* "endDate": "2022-07-25T06:40:54.602Z",
* "pausePeriods": [],
* "earliestEndDate": "2022-10-19T12:06:33.259Z",
* "planName": "Platinum Pro",
* "planDescription": "",
* "planPrice": "74.99",
* "_createdDate": "2022-07-19T12:06:33.259Z",
* "_updatedDate": "2022-07-25T06:40:54.666Z"
* }
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.