Triggered at the start of a new payment cycle for an existing order.
Not triggered at the initial start of an offline order.
function wixPricingPlans_onOrderCycleStarted(
event: OrderCycleStartedEvent,
): void;
Information about the order whose payment cycle started and metadata for the event.
// 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 transactionId = event.data.transactionId;
const eventTime = event.metadata.eventTime;
console.log(
`Order ID ${orderId} has started its order cycle with transaction ID ${transactionId} at ${eventTime}. The full event object:`,
event,
);
}
/* Full event object:
* {
* "data": {
* "cycleNumber": 1,
* "order": {
* "_createdDate": "2024-01-25T11:45:05.036Z",
* "_id": "3b620f8b-33f3-4e29-b1db-c21d7a6afa01",
* "_updatedDate": "2024-01-25T11:45:05.036Z",
* "buyer": {
* "contactId": "554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4",
* "memberId": "554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4"
* },
* "currentCycle": {
* "index": 1,
* "startedDate": "2024-01-25T11:45:05.036Z"
* },
* "cycles": [
* {
* "index": 1,
* "startedDate": "2024-01-25T11:45:05.036Z"
* }
* ],
* "formData": {
* "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",
* "submissionData": {},
* "submissionId": "1b282868-0a1e-42c6-9123-3a611b0014bf"
* },
* "lastPaymentStatus": "NOT_APPLICABLE",
* "orderMethod": "UNKNOWN",
* "pausePeriods": [],
* "planDescription": "",
* "planId": "aa0d8e0e-99ad-4c95-ac48-4955e37956c5",
* "planName": "Default",
* "planPrice": "0",
* "priceDetails": {
* "currency": "EUR",
* "discount": "0",
* "fees": [],
* "planPrice": "0",
* "proration": "0",
* "subtotal": "0.00",
* "total": "0"
* },
* "pricing": {
* "prices": [
* {
* "duration": {
* "cycleFrom": 1,
* "numberOfCycles": 1
* },
* "price": {
* "currency": "EUR",
* "discount": "0",
* "fees": [],
* "proration": "0",
* "subtotal": "0.00",
* "total": "0"
* }
* }
* ],
* "singlePaymentUnlimited": true
* },
* "startDate": "2024-01-25T11:45:05.036Z",
* "status": "ACTIVE",
* "statusNew": "DRAFT",
* "subscriptionId": "e9fff457-bc89-4c8c-94c0-1d162711c9a6",
* "type": "ONLINE"
* }
* },
* "metadata": {
* "entityId": "3b620f8b-33f3-4e29-b1db-c21d7a6afa01",
* "eventTime": "2024-01-25T11:45:06.852478956Z",
* "id": "9481d95b-3fd6-423c-af43-5198bed9691c",
* "triggeredByAnonymizeRequest": false
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Triggered when an order's endDate
is postponed.
function wixPricingPlans_onOrderEndDatePostponed(
event: OrderEndDatePostponedEvent,
): void;
Information about the order that is postponed and metadata for the event.
// 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_onOrderEndDatePostponed(event) {
const orderId = event.data.order._id;
const buyerContactId = event.data.buyer.contactId;
const planId = event.data.planId;
console.log(
`Order ID of ${orderId} was postponed for plan ID ${planId} for buyer contact ID ${buyerContactId}. Full event object:`,
event,
);
}
/* Full event object:
* {
* "data": {
* "order": {
* "_createdDate": "2024-01-28T09:49:21.041Z",
* "_id": "82d99338-5653-459a-a751-b57483f7cfb5",
* "_updatedDate": "2024-02-07T13:22:47.459Z",
* "autoRenewCanceled": true,
* "buyer": {
* "contactId": "554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4",
* "memberId": "554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4"
* },
* "cancellation": {
* "cause": "OWNER_ACTION",
* "effectiveAt": "NEXT_PAYMENT_DATE"
* },
* "currentCycle": {
* "endedDate": "2024-04-27T09:49:21.041Z",
* "index": 0,
* "startedDate": "2024-01-28T09:49:21.041Z"
* },
* "cycles": [
* {
* "endedDate": "2024-04-27T09:49:21.041Z",
* "index": 0,
* "startedDate": "2024-01-28T09:49:21.041Z"
* }
* ],
* "endDate": "2024-04-27T09:49:21.041Z",
* "earliestEndDate": "2026-04-27T09:49:21.041Z",
* "formData": {
* "submissionData": {}
* },
* "freeTrialDays": 90,
* "orderMethod": "UNKNOWN",
* "pausePeriods": [],
* "planDescription": "3 mo free trial with discount for 1 year",
* "planId": "cb4a8c57-273a-4567-94e3-cc43d5d339f2",
* "planName": "Beginner's Plan",
* "planPrice": "50",
* "priceDetails": {
* "currency": "USD",
* "discount": "0",
* "fees": [],
* "freeTrialDays": 90,
* "planPrice": "50",
* "subtotal": "50.00",
* "total": "50.00",
* "subscription": {
* "cycleCount": 2,
* "cycleDuration": {
* "count": 1,
* "unit": "YEAR"
* }
* }
* },
* "pricing": {
* "prices": [
* {
* "duration": {
* "cycleFrom": 1,
* "numberOfCycles": 2
* },
* "price": {
* "currency": "USD",
* "discount": "0",
* "fees": [],
* "proration": "0",
* "subtotal": "50.00",
* "total": "50.00"
* }
* }
* ],
* "subscription": {
* "cycleCount": 2,
* "cycleDuration": {
* "count": 1,
* "unit": "YEAR"
* }
* }
* },
* "startDate": "2024-01-28T09:49:21.041Z",
* "status": "ACTIVE",
* "statusNew": "ACTIVE",
* "subscriptionId": "305f8fc9-3724-4cac-9f67-4e29f2c46def",
* "type": "OFFLINE",
* "wixPayOrderId": "2f0e79d8-f15d-46c6-ac1a-10ec7a2030fb"
* }
* },
* "metadata": {
* "entityId": "82d99338-5653-459a-a751-b57483f7cfb5",
* "eventTime": "2024-02-07T13:22:47.641175778Z",
* "id": "ef926c78-1c7a-4ffd-a8c4-fa59bdcf09c1",
* "triggeredByAnonymizeRequest": false
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Triggered when an order ends.
This webhook is triggered:
effectiveAt
is set to IMMEDIATELY
.function wixPricingPlans_onOrderEnded(event: OrderEndedEvent): void;
Information about the order that ended and metadata for the event.
// 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
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Triggered when an offline order is marked as paid.
function wixPricingPlans_onOrderMarkedAsPaid(
event: OrderMarkedAsPaidEvent,
): void;
Information about the offline order that was paid and metadata for the event.
// 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_onOrderMarkedAsPaid(event) {
const orderId = event.entity._id;
const paidDate = event.metadata.eventTime;
const planId = event.data.planId;
const buyerContactId = event.entity.buyer.contactId;
console.log(
`Order ID ${event.orderId} to purchase plan ID ${planId} was paid on ${paidDate} by the buyer contact ID ${buyerContactId}. The 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
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Triggered when an order is paused.
function wixPricingPlans_onOrderPaused(event: OrderPausedEvent): void;
Information about the order that is paused and metadata for the event.
// 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_onOrderPaused(event) {
const orderId = event.data.order._id;
const buyerContactId = event.data.buyer.contactId;
const planId = event.data.planId;
console.log(
`Order ID of ${orderId} was paused for plan ID ${planId} for buyer contact ID ${buyerContactId}. Full event object:`,
event,
);
}
/* Full event object:
* {
* "data": {
* "order": {
* "_createdDate": "2024-01-28T09:49:21.041Z",
* "_id": "82d99338-5653-459a-a751-b57483f7cfb5",
* "_updatedDate": "2024-02-07T13:22:47.459Z",
* "autoRenewCanceled": true,
* "buyer": {
* "contactId": "554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4",
* "memberId": "554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4"
* },
* "cancellation": {
* "cause": "OWNER_ACTION",
* "effectiveAt": "NEXT_PAYMENT_DATE"
* },
* "currentCycle": {
* "endedDate": "2024-04-27T09:49:21.041Z",
* "index": 0,
* "startedDate": "2024-01-28T09:49:21.041Z"
* },
* "cycles": [
* {
* "endedDate": "2024-04-27T09:49:21.041Z",
* "index": 0,
* "startedDate": "2024-01-28T09:49:21.041Z"
* }
* ],
* "endDate": "2024-04-27T09:49:21.041Z",
* "earliestEndDate": "2026-04-27T09:49:21.041Z",
* "formData": {
* "submissionData": {}
* },
* "freeTrialDays": 90,
* "orderMethod": "UNKNOWN",
* "pausePeriods": [],
* "planDescription": "3 mo free trial with discount for 1 year",
* "planId": "cb4a8c57-273a-4567-94e3-cc43d5d339f2",
* "planName": "Beginner's Plan",
* "planPrice": "50",
* "priceDetails": {
* "currency": "USD",
* "discount": "0",
* "fees": [],
* "freeTrialDays": 90,
* "planPrice": "50",
* "subtotal": "50.00",
* "total": "50.00",
* "subscription": {
* "cycleCount": 2,
* "cycleDuration": {
* "count": 1,
* "unit": "YEAR"
* }
* }
* },
* "pricing": {
* "prices": [
* {
* "duration": {
* "cycleFrom": 1,
* "numberOfCycles": 2
* },
* "price": {
* "currency": "USD",
* "discount": "0",
* "fees": [],
* "proration": "0",
* "subtotal": "50.00",
* "total": "50.00"
* }
* }
* ],
* "subscription": {
* "cycleCount": 2,
* "cycleDuration": {
* "count": 1,
* "unit": "YEAR"
* }
* }
* },
* "startDate": "2024-01-28T09:49:21.041Z",
* "status": "ACTIVE",
* "statusNew": "ACTIVE",
* "subscriptionId": "305f8fc9-3724-4cac-9f67-4e29f2c46def",
* "type": "OFFLINE",
* "wixPayOrderId": "2f0e79d8-f15d-46c6-ac1a-10ec7a2030fb"
* }
* },
* "metadata": {
* "entityId": "82d99338-5653-459a-a751-b57483f7cfb5",
* "eventTime": "2024-02-07T13:22:47.641175778Z",
* "id": "ef926c78-1c7a-4ffd-a8c4-fa59bdcf09c1",
* "triggeredByAnonymizeRequest": false
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Triggered for any of the following purchase events:
function wixPricingPlans_onOrderPurchased(event: OrderPurchasedEvent): void;
Information about the order that was purchased and metadata for the event.
// 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_onOrderPurchased(event) {
const orderId = event.data.order._id;
const eventTime = event.metadata.eventTime;
const buyerContactId = event.data.buyer.contactId;
const planId = event.data.planId;
console.log(
`Order ${orderId}: Buyer contact ID ${buyerContactId} purchased plan ${planId} at ${eventTime}. Full event object:`,
event,
);
}
/* Full event object:
* {
* "data": {
* "order": {
* "_createdDate": "2024-01-25T11:45:05.036Z",
* "_id": "3b620f8b-33f3-4e29-b1db-c21d7a6afa01",
* "_updatedDate": "2024-01-25T11:45:05.036Z",
* "buyer": {
* "contactId": "554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4",
* "memberId": "554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4"
* },
* "currentCycle": {
* "index": 1,
* "startedDate": "2024-01-25T11:45:05.036Z"
* },
* "cycles": [
* {
* "index": 1,
* "startedDate": "2024-01-25T11:45:05.036Z"
* }
* ],
* "formData": {
* "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",
* "submissionData": {},
* "submissionId": "1b282868-0a1e-42c6-9123-3a611b0014bf"
* },
* "lastPaymentStatus": "NOT_APPLICABLE",
* "orderMethod": "UNKNOWN",
* "pausePeriods": [],
* "planDescription": "",
* "planId": "aa0d8e0e-99ad-4c95-ac48-4955e37956c5",
* "planName": "Default",
* "planPrice": "0",
* "priceDetails": {
* "currency": "EUR",
* "discount": "0",
* "fees": [],
* "planPrice": "0",
* "proration": "0",
* "subtotal": "0.00",
* "total": "0"
* },
* "pricing": {
* "prices": [
* {
* "duration": {
* "cycleFrom": 1,
* "numberOfCycles": 1
* },
* "price": {
* "currency": "EUR",
* "discount": "0",
* "fees": [],
* "proration": "0",
* "subtotal": "0.00",
* "total": "0"
* }
* }
* ],
* "singlePaymentUnlimited": true
* },
* "startDate": "2024-01-25T11:45:05.036Z",
* "status": "ACTIVE",
* "statusNew": "DRAFT",
* "subscriptionId": "e9fff457-bc89-4c8c-94c0-1d162711c9a6",
* "type": "ONLINE"
* }
* },
* "metadata": {
* "entityId": "3b620f8b-33f3-4e29-b1db-c21d7a6afa01",
* "eventTime": "2024-01-25T11:45:06.792096634Z",
* "id": "0f740093-c77c-4f3e-a307-3e86f659ec74",
* "triggeredByAnonymizeRequest": false
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Triggered when a paused order is resumed.
function wixPricingPlans_onOrderResumed(event: OrderResumedEvent): void;
Information about the order that was resumed and metadata for the event
// 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_onOrderResumed(event) {
const orderId = event.data.order._id;
const planId = event.data.planId;
const eventTime = event.metadata.eventTime;
console.log(
`Order ID ${orderId} was resumed for plan ID ${planId} at ${eventTime}. Full event object:`,
event,
);
}
/* Full event object:
* {
* "data": {
* "order": {
* "_createdDate": "2024-02-11T09:11:13.012Z",
* "_id": "3feb1cf5-bf38-47c4-81cb-06b61ca11c8a",
* "_updatedDate": "2024-02-11T09:14:57.750Z",
* "buyer": {
* "contactId": "3fc889f6-18e8-4fd9-a509-27db9f037f26",
* "memberId": "3fc889f6-18e8-4fd9-a509-27db9f037f26"
* },
* "currentCycle": {
* "index": 1,
* "startedDate": "2024-02-11T09:11:13.012Z"
* },
* "cycles": [
* {
* "index": 1,
* "startedDate": "2024-02-11T09:11:13.012Z"
* }
* ],
* "formData": {
* "submissionData": {}
* },
* "lastPaymentStatus": "PAID",
* "orderMethod": "UNKNOWN",
* "pausePeriods": [
* {
* "pauseDate": "2024-02-11T09:14:57.750Z",
* "resumeDate": "2024-02-11T09:28:13.186Z",
* "status": "ENDED"
* }
* ],
* "planDescription": "Full feature enablement - lifetime plan",
* "planId": "e901222b-c137-4bc7-adc3-c1efa3c880a2",
* "planName": "Quality Plan - Lifetime",
* "planPrice": "1500",
* "priceDetails": {
* "coupon": {
* "_id": "07de4c3a-536b-4c30-adb9-991935da1681",
* "amount": "1500.00",
* "code": "sale-day"
* },
* "currency": "USD",
* "discount": "1500.00",
* "planPrice": "1500",
* "subtotal": "1500.00",
* "tax": {
* "amount": "0",
* "includedInPrice": false,
* "name": "Tax",
* "rate": "6.5"
* },
* "total": "0"
* },
* "pricing": {
* "prices": [
* {
* "duration": {
* "cycleFrom": 1,
* "numberOfCycles": 1
* },
* "price": {
* "currency": "USD",
* "discount": "1500.00",
* "fees": [],
* "proration": "0",
* "subtotal": "1500.00",
* "tax": {
* "amount": "0",
* "includedInPrice": false,
* "name": "Tax",
* "rate": "6.5"
* },
* "total": "0"
* }
* }
* ],
* "singlePaymentUnlimited": true
* },
* "startDate": "2024-02-11T09:11:13.012Z",
* "status": "ACTIVE",
* "statusNew": "ACTIVE",
* "subscriptionId": "d3290015-f808-4f08-a4a0-6732acbf2a43",
* "type": "ONLINE",
* "wixPayOrderId": "36a79fab-c436-4bf0-b3be-14e9f75cf263"
* }
* },
* "metadata": {
* "entityId": "3feb1cf5-bf38-47c4-81cb-06b61ca11c8a",
* "eventTime": "2024-02-11T09:28:13.343708694Z",
* "id": "c020a4af-1647-4301-b821-d6ee72b7a462",
* "triggeredByAnonymizeRequest": false
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Triggered when an order's startDate
is changed.
function wixPricingPlans_onOrderStartDateChanged(
event: OrderStartDateChangedEvent,
): void;
Information about the order whose start date changed and metadata for the event.
// 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_onOrderStartDateChanged(event) {
const orderId = event.data.order._id;
const buyerContactId = event.data.buyer.contactId;
const startDate = event.startDate;
console.log(
`Start date for order ID ${orderId} was changed to ${startDate} by contact ID ${buyerContactId}. Full event object:`,
event,
);
}
/* Full event object:
* {
* "data": {
* "order": {
* "_createdDate": "2024-02-14T11:15:57.921Z",
* "_id": "a15b2fdf-f21c-4d3e-bae2-12a344cc4cad",
* "_updatedDate": "2024-02-14T11:16:45.641Z",
* "buyer": {
* "contactId": "600e2577-6414-42a5-b35b-839e166eaf5a",
* "memberId": "600e2577-6414-42a5-b35b-839e166eaf5a"
* },
* "cycles": [
* {
* "index": 1,
* "startedDate": "2024-02-16T22:00:00.000Z"
* }
* ],
* "formData": {
* "submissionData": {}
* },
* "lastPaymentStatus": "UNPAID",
* "orderMethod": "UNKNOWN",
* "pausePeriods": [],
* "planDescription": "Full feature enablement - lifetime plan",
* "planId": "e901222b-c137-4bc7-adc3-c1efa3c880a2",
* "planName": "Quality Plan - Lifetime",
* "planPrice": "1500",
* "priceDetails": {
* "currency": "USD",
* "discount": "0",
* "planPrice": "1500",
* "subtotal": "1500.00",
* "tax": {
* "amount": "97.50",
* "includedInPrice": false,
* "name": "Tax",
* "rate": "6.5"
* },
* "total": "1597.50"
* },
* "pricing": {
* "prices": [
* {
* "duration": {
* "cycleFrom": 1,
* "numberOfCycles": 1
* },
* "price": {
* "currency": "USD",
* "discount": "0",
* "fees": [],
* "proration": "0",
* "subtotal": "1500.00",
* "tax": {
* "amount": "97.50",
* "includedInPrice": false,
* "name": "Tax",
* "rate": "6.5"
* },
* "total": "1597.50"
* }
* }
* ],
* "singlePaymentUnlimited": true
* },
* "startDate": "2024-02-16T22:00:00.000Z",
* "status": "DRAFT",
* "statusNew": "DRAFT",
* "subscriptionId": "78933e41-6482-4545-a7e0-483ec74cfa97",
* "type": "ONLINE",
* "wixPayOrderId": "97aa019c-13f2-4e2a-a8a2-62cd9ffa6ef0"
* }
* },
* "metadata": {
* "entityId": "a15b2fdf-f21c-4d3e-bae2-12a344cc4cad",
* "eventTime": "2024-02-14T11:16:45.787406262Z",
* "id": "05924d5a-5f1e-4f9a-ba77-f3a784661d41",
* "triggeredByAnonymizeRequest": false
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.