onOrderCycleStarted( )


An event that triggers at the start of each payment cycle for online orders.

The onOrderCycleStarted() event handler runs when an order's payment cycle is triggered. The received OrderCycleStarted object contains information about the order whose cycle is triggered.

This event handler runs when:

  • An online order starts, either at the current or a future date.
  • When a new payment cycle starts in an existing order.

Note: Backend events don't work when previewing your site.

Method Declaration
Copy
function onOrderCycleStarted(event: OrderCycleStartedEvent): void;
Method Parameters
eventOrderCycleStartedEventRequired

Information about the order whose payment cycle started and metadata for the event.

An event triggered when an order's payment cycle started
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_onOrderCycleStarted(event) { const orderId = event.data.order._id; const wixPayId = event.data.transactionId; const eventId = event.metadata.id; const eventTime = event.metadata.eventTime; } /* A full event object: * { * "metadata": { * "id":"2b71b90d-d535-4cc4-94ab-60753f6b2f3e", * "entityId":"b6a9c5ab-f692-4b21-b9d4-9f6875e6b2d0", * "eventTime":"2022-08-09T10:36:18.292166Z", * "triggeredByAnonymizeRequest":false * }, * "data": { * "order": { * "_id":"b6a9c5ab-f692-4b21-b9d4-9f6875e6b2d0", * "planId":"8b84025d-57a4-4028-8254-cdd8ab675d5c", * "subscriptionId":"67ab82ea-ade2-48d6-813c-cb8b4330d8d8", * "wixPayOrderId":"b4602b5d-362f-453a-84df-db02bf0d04e0", * "buyer": { * "memberId":"18c148cf-e151-4d60-9cbf-a22f20439a67", * "contactId":"18c148cf-e151-4d60-9cbf-a22f20439a67" * }, * "priceDetails": { * "subtotal":"4.99", * "discount":"0", * "total":"4.99", * "planPrice":"4.99", * "currency":"USD", * "subscription": { * "cycleDuration": { * "count":1, * "unit":"WEEK" * }, * "cycleCount":26 * }}, * "pricing": { * "subscription": { * "cycleDuration": { * "count":1, * "unit":"WEEK" * }, * "cycleCount":26 * }, * "prices": [{ * "duration": { * "cycleFrom":1, * "numberOfCycles":26 * }, * "price": { * "subtotal":"4.99", * "discount":"0", * "total":"4.99", * "currency":"USD" * } * }]}, * "type":"ONLINE", * "orderMethod":"UNKNOWN", * "status":"ACTIVE", * "autoRenewCanceled":false, * "lastPaymentStatus":"PAID", * "startDate":"2022-08-09T10:35:16.659Z", * "endDate":"2023-02-07T10:35:16.659Z", * "pausePeriods":[], * "earliestEndDate":"2023-02-07T10:35:16.659Z", * "currentCycle": { * "index":1, * "startedDate":"2022-08-09T10:35:16.659Z", * "endedDate":"2022-08-16T10:35:16.659Z" * }, * "planName":"Cooking for Kids", * "planDescription":"", * "planPrice":"4.99", * "_createdDate":"2022-08-09T10:35:16.659Z", * "_updatedDate":"2022-08-09T10:36:18.208Z" * }, * "cycleNumber":1 * } * } */
Errors

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

Did this help?