> 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: wixPricingPlansV2 # Method menu location: wixPricingPlansV2 --> onOrderEnded # Method Link: https://dev.wix.com/docs/velo/events-service-plugins/pricing-plans/events/on-order-ended.md # Method Description: Triggered when an order ends. This webhook is triggered: + When an order expires at the end of the current payment cycle. + When an order is canceled and `effectiveAt` is set to `IMMEDIATELY`. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## onOrderEnded example ```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 buyerContactId = event.data.buyer.contactId; const planId = event.data.planId; const endDate = event.data.endDate; console.log(`Order ID ${orderId} with buyer ID ${buyerContactId}, ended for the plan ID ${planId} on ${endDate}. Full event object:`, event); } /* Full event object: * { * "data": { * "order": { * "_createdDate": "2024-02-01T10:27:58.453Z", * "_id": "9af3cbe6-fe27-4fdb-a0b0-892289b03d22", * "_updatedDate": "2024-02-11T08:13:44.674Z", * "buyer": { * "contactId": "402ec90c-235a-45c4-b4cc-52204d5f6b00", * "memberId": "402ec90c-235a-45c4-b4cc-52204d5f6b00" * }, * "cancellation": { * "cause": "OWNER_ACTION", * "effectiveAt": "IMMEDIATELY" * }, * "cycles": [ * { * "endedDate": "2024-02-11T08:13:44.588Z", * "index": 1, * "startedDate": "2024-02-01T10:27:58.453Z" * } * ], * "endDate": "2024-02-11T08:13:44.588Z", * "formData": { * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb", * "submissionData": {}, * "submissionId": "10206732-e789-40e9-957d-2c7f3398efc6" * }, * "lastPaymentStatus": "PAID", * "orderMethod": "UNKNOWN", * "pausePeriods": [ * { * "pauseDate": "2024-02-04T10:02:03.726Z", * "resumeDate": "2024-02-04T13:05:04.465Z", * "status": "ENDED" * } * ], * "planDescription": "", * "planId": "0da57ac8-c3d0-4687-8aea-4100781b6386", * "planName": "Expensive Plan", * "planPrice": "10000", * "pricing": { * "prices": [ * { * "duration": { * "cycleFrom": 1, * "numberOfCycles": 1 * }, * "price": { * "currency": "USD", * "discount": "10000.00", * "fees": [], * "proration": "0", * "subtotal": "10000.00", * "total": "0" * } * } * ], * "singlePaymentUnlimited": true * }, * "priceDetails": { * "coupon": { * "_id": "07de4c3a-536b-4c30-adb9-991935da1681", * "amount": "10000.00", * "code": "sale-day" * }, * "currency": "USD", * "discount": "10000.00", * "planPrice": "10000", * "singlePaymentUnlimited": true, * "subtotal": "10000.00", * "total": "0" * }, * "startDate": "2024-02-01T10:27:58.453Z", * "status": "CANCELED", * "statusNew": "CANCELED", * "subscriptionId": "0cd18587-a637-4327-a05c-ab4e86bd59fe", * "type": "ONLINE", * "wixPayOrderId": "4012ab0c-f1cb-4632-917e-f611de27dcad" * } * }, * "metadata": { * "entityId": "9af3cbe6-fe27-4fdb-a0b0-892289b03d22", * "eventTime": "2024-02-11T08:13:44.817334927Z", * "id": "601feaeb-7306-4428-b768-906f12938004", * "triggeredByAnonymizeRequest": false * } * } */ ``` ---