onOrderCanceled( )


Developer Preview

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 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?