Search...
onOrderCycleStarted( )
An event that triggers at the start of each payment cycle for online orders.
Description
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.
Syntax
function onOrderCycleStarted(event: OrderCycleStartedEvent): void
onOrderCycleStarted Parameters
NAME
TYPE
DESCRIPTION
event
OrderCycleStartedEvent
Information about the order whose payment cycle started and metadata for the event.
Returns
This function does not return anything.
Return Type:
void
Was this helpful?
An event triggered when an order's payment cycle started
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_onOrderCycleStarted(event) {6 const orderId = event.data.order._id;7 const wixPayId = event.data.transactionId;8 const eventId = event.metadata.id;9 const eventTime = event.metadata.eventTime;10}1112/* A full event object:13 * {14 * "metadata": {15 * "id":"2b71b90d-d535-4cc4-94ab-60753f6b2f3e",16 * "entityId":"b6a9c5ab-f692-4b21-b9d4-9f6875e6b2d0",17 * "eventTime":"2022-08-09T10:36:18.292166Z",18 * "triggeredByAnonymizeRequest":false19 * },20 * "data": {21 * "order": {22 * "_id":"b6a9c5ab-f692-4b21-b9d4-9f6875e6b2d0",23 * "planId":"8b84025d-57a4-4028-8254-cdd8ab675d5c",24 * "subscriptionId":"67ab82ea-ade2-48d6-813c-cb8b4330d8d8",25 * "wixPayOrderId":"b4602b5d-362f-453a-84df-db02bf0d04e0",26 * "buyer": {27 * "memberId":"18c148cf-e151-4d60-9cbf-a22f20439a67",28 * "contactId":"18c148cf-e151-4d60-9cbf-a22f20439a67"29 * },30 * "priceDetails": {31 * "subtotal":"4.99",32 * "discount":"0",33 * "total":"4.99",34 * "planPrice":"4.99",35 * "currency":"USD",36 * "subscription": {37 * "cycleDuration": {38 * "count":1,39 * "unit":"WEEK"40 * },41 * "cycleCount":2642 * }},43 * "pricing": {44 * "subscription": {45 * "cycleDuration": {46 * "count":1,47 * "unit":"WEEK"48 * },49 * "cycleCount":2650 * },51 * "prices": [{52 * "duration": {53 * "cycleFrom":1,54 * "numberOfCycles":2655 * },56 * "price": {57 * "subtotal":"4.99",58 * "discount":"0",59 * "total":"4.99",60 * "currency":"USD"61 * }62 * }]},63 * "type":"ONLINE",64 * "orderMethod":"UNKNOWN",65 * "status":"ACTIVE",66 * "autoRenewCanceled":false,67 * "lastPaymentStatus":"PAID",68 * "startDate":"2022-08-09T10:35:16.659Z",69 * "endDate":"2023-02-07T10:35:16.659Z",70 * "pausePeriods":[],71 * "earliestEndDate":"2023-02-07T10:35:16.659Z",72 * "currentCycle": {73 * "index":1,74 * "startedDate":"2022-08-09T10:35:16.659Z",75 * "endedDate":"2022-08-16T10:35:16.659Z"76 * },77 * "planName":"Cooking for Kids",78 * "planDescription":"",79 * "planPrice":"4.99",80 * "_createdDate":"2022-08-09T10:35:16.659Z",81 * "_updatedDate":"2022-08-09T10:36:18.208Z"82 * },83 * "cycleNumber":184 * }85 * }86 */