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 is updated.
This is a general webhook that is triggered when any update is made to an order. More specific webhooks are also triggered for the same originating events.
Order event | Also triggered |
---|---|
Order is paid for. | onOrderPurchased() |
Free or offline order is created. | onOrderCreated() |
Order reaches its startDate . | onOrderStarted() |
Order reaches its endDate . | onOrderEnded() |
New payment cycle of an order starts. | onOrderCycleStarted() |
Offline order is marked as paid. | onOrderMarkedAsPaid() |
endDate of the order is postponed. | onOrderEndDatePostponed() |
Order is paused. | onOrderPaused() |
Paused order is resumed. | onOrderResumed() |
Order is canceled. | onOrderCanceled() |
Order is canceled and effectiveAt is set to NEXT_PAYMENT_DATE . | onOrderAutoRenewCanceled() |
function wixPricingPlans_onOrderUpdated(event: OrderUpdated): void;
Information about the order that was updated 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_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
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.