Introduction

 

Developer Preview
APIs in Developer Preview are subject to change and are not intended for use in production.
Send us your suggestions for improving this API. Your feedback is valuable to us.

 

Wix Pricing Plans events are fired in your site's backend when certain events occur with plans. You can write event handlers that react to these events. Event handler functions receive data that corresponds to the event that has occurred. Use event handlers to create custom responses to pricing plan events.

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

To add a pricing plans event handler, add an events.js file to the Backend section of your site if one does not already exist. All event handler functions for your site are defined in this file.

Event handler functions are defined using the following pattern:

Copy
export function <wixAppName>_<eventName>(event) { }

For example, an event handler that handles pricing plan updates looks like this:

Copy
export function wixPricingPlans_onPlanUpdated(event) {}

Order Events and Corresponding Statuses

As an order progresses through its lifecycle from order creation until order completion, various events get triggered. The order's status is updated accordingly.

For example, the following describes the events and statuses for an online, recurring order:

Timeline of EventsEvents TriggeredOrder Status
1) Online, recurring order createdorderCreatedDRAFT
2) Payment arranged, start date laterorderPurchasedPENDING
3) Start date arrivesorderStarted, orderCycleStartedACTIVE
4) Next cycle arrivesorderCycleStartedACTIVE
5) Last cycle finishesorderEndedENDED

The following flowchart details order events and statuses.

Order Events

Did this help?

onOrderAutoRenewCanceled( )


Triggered when an order is canceled and effectiveAt is set to NEXT_PAYMENT_DATE.

This webhook is not triggered in the following scenarios:

  • When an order is canceled and effectiveAt is set to IMMEDIATELY. Instead, at the time of cancellation, Order Canceled is triggered.
  • When an order expires at the end of the current payment cycle because it was canceled and effectiveAt was set to NEXT_PAYMENT_DATE. Instead, at the time of expiration, Order Canceled and Order Ended are triggered.
Method Declaration
Copy
function wixPricingPlans_onOrderAutoRenewCanceled(
  event: OrderAutoRenewCanceledEvent,
): void;
Method Parameters
eventOrderAutoRenewCanceledEvent

Information about the order whose auto-renewal is canceled and metadata for the event.

onOrderAutoRenewCanceled 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_onOrderAutoRenewCanceled(event) { const orderId = event.data.order._id; const buyerContactId = event.data.buyer.contactId; const planId = event.data.planId; const eventTime = event.metadata.eventTime; console.log( `Order autorenew was cancelled for order ID ${orderId} by buyer ID ${buyerContactId}, for plan ID ${planId} on ${eventTime}. 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 * } * } */
Errors

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

Did this help?

onOrderCanceled( )


Triggered when an order is canceled.

This webhook is triggered either immediately or at the end of the current payment cycle, as follows:

  • If the order is canceled and effectiveAt is set to IMMEDIATELY, the webhook is triggered immediately when canceled.
  • If the order is canceled and effectiveAt is set to NEXT_PAYMENT_DATE, the webhook is triggered at the end of the current payment cycle. In this case, the Order Auto Renew Canceled Webhook is triggered immediately.
Method Declaration
Copy
function wixPricingPlans_onOrderCanceled(event: OrderCanceledEvent): void;
Method Parameters
eventOrderCanceledEvent

Information about the canceled order and metadata for the event.

onOrderCanceled 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_onOrderCanceled(event) { const orderId = event.data.order._id; const buyerContactId = event.data.buyer.contactId; const planId = event.data.planName; const eventTime = event.metadata.endDate; console.log( `Order ID ${orderId} was canceled by buyer ID ${buyerContactId}, for plan ID ${planId} at ${eventTime}. Full event object:`, event, ); } /* Full event object: * { * "data": { * "cancellation": { * "cause": "OWNER_ACTION", * "effectiveAt": "IMMEDIATELY" * }, * "order": { * "_createdDate": "2024-02-04T09:02:48.592Z", * "_id": "e6f12ae0-2618-41e7-a643-31ca2ee51e2b", * "_updatedDate": "2024-02-06T07:31:59.180Z", * "buyer": { * "contactId": "3fc889f6-18e8-4fd9-a509-27db9f037f26", * "memberId": "3fc889f6-18e8-4fd9-a509-27db9f037f26" * }, * "cycles": [ * { * "endedDate": "2024-02-06T07:31:59.123Z", * "index": 1, * "startedDate": "2024-02-04T09:02:48.592Z" * } * ], * "endDate": "2024-02-06T07:31:59.123Z", * "formData": { * "submissionData": {} * }, * "lastPaymentStatus": "PAID", * "orderMethod": "UNKNOWN", * "pausePeriods": [], * "planDescription": "Full feature enablement - lifetime plan", * "planId": "b20feb39-a452-453e-96ee-01036adcd04e", * "planName": "Premium Plan - Lifetime Membership", * "planPrice": "1000", * "priceDetails": { * "coupon": { * "_id": "07de4c3a-536b-4c30-adb9-991935da1681", * "amount": "1000.00", * "code": "sale-day" * }, * "currency": "USD", * "discount": "1000.00", * "planPrice": "1000", * "singlePaymentUnlimited": true, * "subtotal": "1000.00", * "tax": { * "amount": "0", * "includedInPrice": false, * "name": "Tax", * "rate": "6.5" * }, * "total": "0" * }, * "pricing": { * "prices": [ * { * "duration": { * "cycleFrom": 1, * "numberOfCycles": 1 * }, * "price": { * "currency": "USD", * "discount": "1000.00", * "fees": [], * "proration": "0", * "subtotal": "1000.00", * "tax": { * "amount": "0", * "includedInPrice": false, * "name": "Tax", * "rate": "6.5" * }, * "total": "0" * } * } * ], * "singlePaymentUnlimited": true * }, * "startDate": "2024-02-04T09:02:48.592Z", * "status": "CANCELED", * "statusNew": "CANCELED", * "subscriptionId": "02e297ba-c270-4415-9f77-748507bb7b9d", * "type": "ONLINE", * "wixPayOrderId": "8f012204-4d60-457b-8772-b0cf92a11d84" * } * }, * "metadata": { * "entityId": "e6f12ae0-2618-41e7-a643-31ca2ee51e2b", * "eventTime": "2024-02-06T07:31:59.288259731Z", * "id": "85a7ec5f-2ab4-4582-9a1d-5845c5f38e87", * "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?

onOrderCreated( )


Triggered when an order is created.

Method Declaration
Copy
function wixPricingPlans_onOrderCreated(event: OrderCreated): void;
Method Parameters
eventOrderCreated

Information about the created order and metadata for the event.

onOrderCreated 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_onOrderCreated(event) { const orderId = event.entity._id; const createdDate = event.entity._createdDate; const buyer = event.entity.buyer; console.log( `The order with ID ${event.orderId} to purchase the ${event.plan.name} plan was created on ${createdDate} by the buyer ${buyer}. The full event object:`, event, ); } /* Full event object: * { * "entity": { * "_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", * "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.457639259Z", * "id": "6a0b2d17-6211-4394-b3e4-9c1a1bb1b1cc", * "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?

onOrderCycleStarted( )


Triggered at the start of a new payment cycle for an existing order.

Not triggered at the initial start of an offline order.

Method Declaration
Copy
function wixPricingPlans_onOrderCycleStarted(
  event: OrderCycleStartedEvent,
): void;
Method Parameters
eventOrderCycleStartedEvent

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

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

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

Did this help?

onOrderEndDatePostponed( )


Triggered when an order's endDate is postponed.

Method Declaration
Copy
function wixPricingPlans_onOrderEndDatePostponed(
  event: OrderEndDatePostponedEvent,
): void;
Method Parameters
eventOrderEndDatePostponedEvent

Information about the order that is postponed and metadata for the event.

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

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

Did this help?

onOrderEnded( )


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?

onOrderMarkedAsPaid( )


Triggered when an offline order is marked as paid.

Method Declaration
Copy
function wixPricingPlans_onOrderMarkedAsPaid(
  event: OrderMarkedAsPaidEvent,
): void;
Method Parameters
eventOrderMarkedAsPaidEvent

Information about the offline order that was paid and metadata for the event.

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

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

Did this help?

onOrderPaused( )


Triggered when an order is paused.

Method Declaration
Copy
function wixPricingPlans_onOrderPaused(event: OrderPausedEvent): void;
Method Parameters
eventOrderPausedEvent

Information about the order that is paused and metadata for the event.

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

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

Did this help?

onOrderPurchased( )


Triggered for any of the following purchase events:

  • Order is paid in full.
  • At least 1 order cycle payment is paid for.
  • Offline order is created, even if not yet marked as paid.
  • Free order is created.
Method Declaration
Copy
function wixPricingPlans_onOrderPurchased(event: OrderPurchasedEvent): void;
Method Parameters
eventOrderPurchasedEvent

Information about the order that was purchased and metadata for the event.

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

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

Did this help?

onOrderResumed( )


Triggered when a paused order is resumed.

Method Declaration
Copy
function wixPricingPlans_onOrderResumed(event: OrderResumedEvent): void;
Method Parameters
eventOrderResumedEvent

Information about the order that was resumed and metadata for the event

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

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

Did this help?

onOrderStartDateChanged( )


Triggered when an order's startDate is changed.

Method Declaration
Copy
function wixPricingPlans_onOrderStartDateChanged(
  event: OrderStartDateChangedEvent,
): void;
Method Parameters
eventOrderStartDateChangedEvent

Information about the order whose start date changed and metadata for the event.

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

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

Did this help?

onOrderStarted( )


Triggered when an order reaches its startDate. Applies to both purchased and free orders.

Method Declaration
Copy
function wixPricingPlans_onOrderStarted(event: OrderStartedEvent): void;
Method Parameters
eventOrderStartedEvent

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

onOrderStarted 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_onOrderStarted(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( `New order started: Order ID ${orderId} at ${eventTime} by contact ID ${buyerContactId} to purchase plan ${planId}. 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", * "planPrice": "0", * "singlePaymentUnlimited": true, * "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": "ACTIVE", * "subscriptionId": "e9fff457-bc89-4c8c-94c0-1d162711c9a6", * "type": "ONLINE" * } * }, * "metadata": { * "entityId": "3b620f8b-33f3-4e29-b1db-c21d7a6afa01", * "eventTime": "2024-01-25T11:45:05.860485075Z", * "id": "f02f2b76-5044-4f82-b6de-82548a65b37a", * "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?

onOrderUpdated( )


Triggered for any of the following update events:

  • Order is paid for. Order Purchased is also triggered.
  • Order reaches its start date or end date. Order Started and Order Ended, respectively, are also triggered.
  • New payment cycle of an order starts. Order Cycle Started is also triggered.
  • Offline order is marked as paid. Order Marked As Paid is also triggered.
  • End date of the order is postponed. Order End Date Postponed is also triggered
  • Order is paused, or a paused order is resumed. Order Paused and Order Resumed, respectively, are also triggered.
  • Order is canceled, either immediately or at the end of the payment cycle. Order Canceled and Order Auto Renew Canceled, respectively, are also triggered.
Method Declaration
Copy
function wixPricingPlans_onOrderUpdated(event: OrderUpdated): void;
Method Parameters
eventOrderUpdated

Information about the order that was updated and metadata for the event.

onOrderUpdated 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_onOrderUpdated(event) { const orderId = event.data.order._id; const eventTime = event.metadata.eventTime; const buyerContactId = event.data.buyer.contactId; console.log( `Order update: Order ID ${orderId} was updated at ${eventTime} by contact ID ${buyerContactId}. Full event object:`, event, ); } /* Full event object: * { * "entity": { * "_createdDate": "2024-02-06T06:56:57.193Z", * "_id": "537a3f44-57bf-4658-9833-47357198d88d", * "_updatedDate": "2024-02-06T06:57:24.932Z", * "buyer": { * "contactId": "695568ff-1dc2-49ff-83db-2b518d35692b", * "memberId": "695568ff-1dc2-49ff-83db-2b518d35692b" * }, * "currentCycle": { * "index": 1, * "startedDate": "2024-02-06T06:56:57.193Z" * }, * "cycles": [ * { * "index": 1, * "startedDate": "2024-02-06T06:56:57.193Z" * } * ], * "formData": { * "submissionData": {} * }, * "lastPaymentStatus": "PAID", * "orderMethod": "UNKNOWN", * "pausePeriods": [], * "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", * "singlePaymentUnlimited": true, * "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-06T06:56:57.193Z", * "status": "ACTIVE", * "statusNew": "ACTIVE", * "subscriptionId": "24bd018a-a4a2-4ca4-b83b-b4af9d6d8eb4", * "type": "ONLINE", * "wixPayOrderId": "2e0c2738-8541-43f5-842b-37c7e94e9f4c" * }, * "metadata": { * "entityId": "537a3f44-57bf-4658-9833-47357198d88d", * "eventTime": "2024-02-06T06:57:26.229867928Z", * "id": "5212464e-f2c6-423f-b768-05401295b94d", * "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?

onPlanArchived( )


Triggered when a pricing plan is archived.

Method Declaration
Copy
function wixPricingPlansV2_onPlanArchived(event: PlanArchivedEvent): void;
Method Parameters
eventPlanArchivedEvent
onPlanArchived example
JavaScript
export function wixPricingPlansV2_onPlanArchived(event) { const eventId = event.metadata.id; const entityId = event.data.plan._id; }
Errors

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

Did this help?