onOrderEnded( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

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 Declaration
Copy
function wixPricingPlans_onOrderEnded(event: OrderEndedEvent): void;
Method Parameters
eventOrderEndedEvent

Information about the order that ended and metadata for the event.

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 * } * } */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?