Search...
onOrderEnded( )
An event that triggers when an order expires or is canceled immediately.
Description
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.
Syntax
function onOrderEnded(event: OrderEndedEvent): void
onOrderEnded Parameters
NAME
TYPE
DESCRIPTION
event
OrderEndedEvent
Information about the order that ended and metadata for the event.
Returns
This function does not return anything.
Return Type:
void
Was this helpful?
An event triggered when an order ends
Copy Code
1// Place this code in the events.js file2// of your site's Backend section.3// Add the file if it doesn't exist.45export function wixPricingPlans_onOrderEnded(event) {6 const orderId = event.data.order._id;7 const eventId = event.metadata.id;8 const eventTime = event.metadata.eventTime;9}1011/* Full event object:12 * {13 * "metadata": {14 * "id":"664bce7f-d30a-4d3f-8e1b-57840a766d25",15 * "entityId":"c778761f-0d19-4533-ac6d-434408398bf9",16 * "eventTime":"2022-08-08T11:00:03.912278Z",17 * "triggeredByAnonymizeRequest":false18 * },19 * "data": {20 * "order": {21 * "_id":"c778761f-0d19-4533-ac6d-434408398bf9",22 * "planId":"099e2c86-3b7e-4477-8c27-f77402b8cceb",23 * "subscriptionId":"5493bc14-2ca4-4496-ba43-bcfc0fc3a47c",24 * "wixPayOrderId":"c63bcec6-dc46-4080-8892-82cb09492986",25 * "buyer": {26 * "memberId":"fac761ea-e6f1-4e3d-8b30-a4852f091415",27 * "contactId":"fac761ea-e6f1-4e3d-8b30-a4852f091415"28 * },29 * "priceDetails": {30 * "subtotal":"74.99",31 * "discount":"0",32 * "total":"74.99",33 * "planPrice":"74.99",34 * "currency":"EUR",35 * "subscription": {36 * "cycleDuration": {37 * "count":1,38 * "unit":"MONTH"39 * },40 * "cycleCount":341 * }},42 * "pricing": {43 * "subscription": {44 * "cycleDuration": {45 * "count":1,46 * "unit":"MONTH"47 * },48 * "cycleCount":349 * },50 * "prices": [{51 * "duration": {52 * "cycleFrom":1,53 * "numberOfCycles":354 * },55 * "price": {56 * "subtotal":"74.99",57 * "discount":"0",58 * "total":"74.99",59 * "currency":"EUR"60 * }61 * }]},62 * "type":"OFFLINE",63 * "orderMethod":"UNKNOWN",64 * "status":"CANCELED",65 * "autoRenewCanceled":true,66 * "cancellation": {67 * "cause":"OWNER_ACTION",68 * "effectiveAt":"NEXT_PAYMENT_DATE"69 * },70 * "lastPaymentStatus":"PAID",71 * "startDate":"2022-06-08T11:00:00.000Z",72 * "endDate":"2022-08-08T11:00:02.862Z",73 * "pausePeriods":[],74 * "earliestEndDate":"2022-09-08T11:00:00.000Z",75 * "planName":"Platinum Pro",76 * "planDescription":"",77 * "planPrice":"74.99",78 * "_createdDate":"2022-08-08T10:54:30.869Z",79 * "_updatedDate":"2022-08-08T11:00:03.781Z"80 * }81 * }82 * }83 */