Search...
onOrderEnded( )
Developer Preview
Triggered when an order ends.
Description
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 toIMMEDIATELY
..
Syntax
function wixPricingPlans_onOrderEnded(event: OrderEndedEvent): void
onOrderEnded Parameters
NAME
TYPE
DESCRIPTION
event
Optional
OrderEndedEvent
Returns
This function does not return anything.
Return Type:
void
Was this helpful?
onOrderEnded example
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 buyerContactId = event.data.buyer.contactId;8 const planId = event.data.planId;9 const endDate = event.data.endDate;1011 console.log(`Order ID ${orderId} with buyer ID ${buyerContactId}, ended for the plan ID ${planId} on ${endDate}. Full event object:`, event);12}1314/* Full event object:15 * {16 * "data": {17 * "order": {18 * "_createdDate": "2024-02-01T10:27:58.453Z",19 * "_id": "9af3cbe6-fe27-4fdb-a0b0-892289b03d22",20 * "_updatedDate": "2024-02-11T08:13:44.674Z",21 * "buyer": {22 * "contactId": "402ec90c-235a-45c4-b4cc-52204d5f6b00",23 * "memberId": "402ec90c-235a-45c4-b4cc-52204d5f6b00"24 * },25 * "cancellation": {26 * "cause": "OWNER_ACTION",27 * "effectiveAt": "IMMEDIATELY"28 * },29 * "cycles": [30 * {31 * "endedDate": "2024-02-11T08:13:44.588Z",32 * "index": 1,33 * "startedDate": "2024-02-01T10:27:58.453Z"34 * }35 * ],36 * "endDate": "2024-02-11T08:13:44.588Z",37 * "formData": {38 * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",39 * "submissionData": {},40 * "submissionId": "10206732-e789-40e9-957d-2c7f3398efc6"41 * },42 * "lastPaymentStatus": "PAID",43 * "orderMethod": "UNKNOWN",44 * "pausePeriods": [45 * {46 * "pauseDate": "2024-02-04T10:02:03.726Z",47 * "resumeDate": "2024-02-04T13:05:04.465Z",48 * "status": "ENDED"49 * }50 * ],51 * "planDescription": "",52 * "planId": "0da57ac8-c3d0-4687-8aea-4100781b6386",53 * "planName": "Expensive Plan",54 * "planPrice": "10000",55 * "pricing": {56 * "prices": [57 * {58 * "duration": {59 * "cycleFrom": 1,60 * "numberOfCycles": 161 * },62 * "price": {63 * "currency": "USD",64 * "discount": "10000.00",65 * "fees": [],66 * "proration": "0",67 * "subtotal": "10000.00",68 * "total": "0"69 * }70 * }71 * ],72 * "singlePaymentUnlimited": true73 * },74 * "priceDetails": {75 * "coupon": {76 * "_id": "07de4c3a-536b-4c30-adb9-991935da1681",77 * "amount": "10000.00",78 * "code": "sale-day"79 * },80 * "currency": "USD",81 * "discount": "10000.00",82 * "planPrice": "10000",83 * "singlePaymentUnlimited": true,84 * "subtotal": "10000.00",85 * "total": "0"86 * },87 * "startDate": "2024-02-01T10:27:58.453Z",88 * "status": "CANCELED",89 * "statusNew": "CANCELED",90 * "subscriptionId": "0cd18587-a637-4327-a05c-ab4e86bd59fe",91 * "type": "ONLINE",92 * "wixPayOrderId": "4012ab0c-f1cb-4632-917e-f611de27dcad"93 * }94 * },95 * "metadata": {96 * "entityId": "9af3cbe6-fe27-4fdb-a0b0-892289b03d22",97 * "eventTime": "2024-02-11T08:13:44.817334927Z",98 * "id": "601feaeb-7306-4428-b768-906f12938004",99 * "triggeredByAnonymizeRequest": false100 * }101 * }102 */103