> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: onOrderEnded(event: OrderEndedEvent) # Method package: wixPricingPlansBackend # Method menu location: wixPricingPlansBackend --> Events --> onOrderEnded # Method Link: https://dev.wix.com/docs/velo/apis/wix-pricing-plans-backend/events/on-order-ended.md # Method Description: An event that triggers when an order expires or is canceled immediately. The `onOrderEnded()` event handler runs when an order expires. The received `OrderEndedEvent` object contains information about the order that expired. > **Note:** Backend events don't work when previewing your site. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## An event triggered when an order ends ```javascript // 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_onOrderEnded(event) { const orderId = event.data.order._id; const eventId = event.metadata.id; const eventTime = event.metadata.eventTime; } /* Full event object: * { * "metadata": { * "id":"664bce7f-d30a-4d3f-8e1b-57840a766d25", * "entityId":"c778761f-0d19-4533-ac6d-434408398bf9", * "eventTime":"2022-08-08T11:00:03.912278Z", * "triggeredByAnonymizeRequest":false * }, * "data": { * "order": { * "_id":"c778761f-0d19-4533-ac6d-434408398bf9", * "planId":"099e2c86-3b7e-4477-8c27-f77402b8cceb", * "subscriptionId":"5493bc14-2ca4-4496-ba43-bcfc0fc3a47c", * "wixPayOrderId":"c63bcec6-dc46-4080-8892-82cb09492986", * "buyer": { * "memberId":"fac761ea-e6f1-4e3d-8b30-a4852f091415", * "contactId":"fac761ea-e6f1-4e3d-8b30-a4852f091415" * }, * "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":"NEXT_PAYMENT_DATE" * }, * "lastPaymentStatus":"PAID", * "startDate":"2022-06-08T11:00:00.000Z", * "endDate":"2022-08-08T11:00:02.862Z", * "pausePeriods":[], * "earliestEndDate":"2022-09-08T11:00:00.000Z", * "planName":"Platinum Pro", * "planDescription":"", * "planPrice":"74.99", * "_createdDate":"2022-08-08T10:54:30.869Z", * "_updatedDate":"2022-08-08T11:00:03.781Z" * } * } * } */ ``` ---