Search...
onOrderCanceled( )
Developer Preview
Triggered when an order is canceled.
Description
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 toIMMEDIATELY
, the webhook is triggered immediately when canceled. - If the order is canceled and
effectiveAt
is set toNEXT_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.
Syntax
function wixPricingPlans_onOrderCanceled(event: OrderCanceledEvent): void
onOrderCanceled Parameters
NAME
TYPE
DESCRIPTION
event
Optional
OrderCanceledEvent
Returns
This function does not return anything.
Return Type:
void
Was this helpful?
onOrderCanceled example
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.456export function wixPricingPlans_onOrderCanceled(event) {7 const orderId = event.data.order._id;8 const buyerContactId = event.data.buyer.contactId;9 const planId = event.data.planName;10 const eventTime = event.metadata.endDate;1112 console.log(`Order ID ${orderId} was canceled by buyer ID ${buyerContactId}, for plan ID ${planId} at ${eventTime}. Full event object:`, event);13}1415/* Full event object:16 * {17 * "data": {18 * "cancellation": {19 * "cause": "OWNER_ACTION",20 * "effectiveAt": "IMMEDIATELY"21 * },22 * "order": {23 * "_createdDate": "2024-02-04T09:02:48.592Z",24 * "_id": "e6f12ae0-2618-41e7-a643-31ca2ee51e2b",25 * "_updatedDate": "2024-02-06T07:31:59.180Z",26 * "buyer": {27 * "contactId": "3fc889f6-18e8-4fd9-a509-27db9f037f26",28 * "memberId": "3fc889f6-18e8-4fd9-a509-27db9f037f26"29 * },30 * "cycles": [31 * {32 * "endedDate": "2024-02-06T07:31:59.123Z",33 * "index": 1,34 * "startedDate": "2024-02-04T09:02:48.592Z"35 * }36 * ],37 * "endDate": "2024-02-06T07:31:59.123Z",38 * "formData": {39 * "submissionData": {}40 * },41 * "lastPaymentStatus": "PAID",42 * "orderMethod": "UNKNOWN",43 * "pausePeriods": [],44 * "planDescription": "Full feature enablement - lifetime plan",45 * "planId": "b20feb39-a452-453e-96ee-01036adcd04e",46 * "planName": "Premium Plan - Lifetime Membership",47 * "planPrice": "1000",48 * "priceDetails": {49 * "coupon": {50 * "_id": "07de4c3a-536b-4c30-adb9-991935da1681",51 * "amount": "1000.00",52 * "code": "sale-day"53 * },54 * "currency": "USD",55 * "discount": "1000.00",56 * "planPrice": "1000",57 * "singlePaymentUnlimited": true,58 * "subtotal": "1000.00",59 * "tax": {60 * "amount": "0",61 * "includedInPrice": false,62 * "name": "Tax",63 * "rate": "6.5"64 * },65 * "total": "0"66 * },67 * "pricing": {68 * "prices": [69 * {70 * "duration": {71 * "cycleFrom": 1,72 * "numberOfCycles": 173 * },74 * "price": {75 * "currency": "USD",76 * "discount": "1000.00",77 * "fees": [],78 * "proration": "0",79 * "subtotal": "1000.00",80 * "tax": {81 * "amount": "0",82 * "includedInPrice": false,83 * "name": "Tax",84 * "rate": "6.5"85 * },86 * "total": "0"87 * }88 * }89 * ],90 * "singlePaymentUnlimited": true91 * },92 * "startDate": "2024-02-04T09:02:48.592Z",93 * "status": "CANCELED",94 * "statusNew": "CANCELED",95 * "subscriptionId": "02e297ba-c270-4415-9f77-748507bb7b9d",96 * "type": "ONLINE",97 * "wixPayOrderId": "8f012204-4d60-457b-8772-b0cf92a11d84"98 * }99 * },100 * "metadata": {101 * "entityId": "e6f12ae0-2618-41e7-a643-31ca2ee51e2b",102 * "eventTime": "2024-02-06T07:31:59.288259731Z",103 * "id": "85a7ec5f-2ab4-4582-9a1d-5845c5f38e87",104 * "triggeredByAnonymizeRequest": false105 * }106 * }107 */108