Search...
onOrderAutoRenewCanceled( )
Developer Preview
Triggered when an order is canceled and effectiveAt
is set to NEXT_PAYMENT_DATE
.
Description
This webhook is not triggered in the following scenarios:
- When an order is canceled and
effectiveAt
is set toIMMEDIATELY
. 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 toNEXT_PAYMENT_DATE
. Instead, at the time of expiration, Order Canceled and Order Ended are triggered.
Syntax
function wixPricingPlans_onOrderAutoRenewCanceled(event: OrderAutoRenewCanceledEvent): void
onOrderAutoRenewCanceled Parameters
NAME
TYPE
DESCRIPTION
event
Optional
OrderAutoRenewCanceledEvent
Returns
This function does not return anything.
Return Type:
void
Was this helpful?
onOrderAutoRenewCanceled 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.45export function wixPricingPlans_onOrderAutoRenewCanceled(event) {6 const orderId = event.data.order._id;7 const buyerContactId = event.data.buyer.contactId;8 const planId = event.data.planId;9 const eventTime = event.metadata.eventTime;1011 console.log(`Order autorenew was cancelled for order ID ${orderId} by buyer ID ${buyerContactId}, for plan ID ${planId} on ${eventTime}. Full event object:`, event)12}1314/* Full event object:15 * {16 * "data": {17 * "order": {18 * "_createdDate": "2024-01-28T09:49:21.041Z",19 * "_id": "82d99338-5653-459a-a751-b57483f7cfb5",20 * "_updatedDate": "2024-02-07T13:22:47.459Z",21 * "autoRenewCanceled": true,22 * "buyer": {23 * "contactId": "554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4",24 * "memberId": "554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4"25 * },26 * "cancellation": {27 * "cause": "OWNER_ACTION",28 * "effectiveAt": "NEXT_PAYMENT_DATE"29 * },30 * "currentCycle": {31 * "endedDate": "2024-04-27T09:49:21.041Z",32 * "index": 0,33 * "startedDate": "2024-01-28T09:49:21.041Z"34 * },35 * "cycles": [36 * {37 * "endedDate": "2024-04-27T09:49:21.041Z",38 * "index": 0,39 * "startedDate": "2024-01-28T09:49:21.041Z"40 * }41 * ],42 * "endDate": "2024-04-27T09:49:21.041Z",43 * "earliestEndDate": "2026-04-27T09:49:21.041Z",44 * "formData": {45 * "submissionData": {}46 * },47 * "freeTrialDays": 90,48 * "orderMethod": "UNKNOWN",49 * "pausePeriods": [],50 * "planDescription": "3 mo free trial with discount for 1 year",51 * "planId": "cb4a8c57-273a-4567-94e3-cc43d5d339f2",52 * "planName": "Beginner's Plan",53 * "planPrice": "50",54 * "priceDetails": {55 * "currency": "USD",56 * "discount": "0",57 * "fees": [],58 * "freeTrialDays": 90,59 * "planPrice": "50",60 * "subtotal": "50.00",61 * "total": "50.00",62 * "subscription": {63 * "cycleCount": 2,64 * "cycleDuration": {65 * "count": 1,66 * "unit": "YEAR"67 * }68 * }69 * },70 * "pricing": {71 * "prices": [72 * {73 * "duration": {74 * "cycleFrom": 1,75 * "numberOfCycles": 276 * },77 * "price": {78 * "currency": "USD",79 * "discount": "0",80 * "fees": [],81 * "proration": "0",82 * "subtotal": "50.00",83 * "total": "50.00"84 * }85 * }86 * ],87 * "subscription": {88 * "cycleCount": 2,89 * "cycleDuration": {90 * "count": 1,91 * "unit": "YEAR"92 * }93 * }94 * },95 * "startDate": "2024-01-28T09:49:21.041Z",96 * "status": "ACTIVE",97 * "statusNew": "ACTIVE",98 * "subscriptionId": "305f8fc9-3724-4cac-9f67-4e29f2c46def",99 * "type": "OFFLINE",100 * "wixPayOrderId": "2f0e79d8-f15d-46c6-ac1a-10ec7a2030fb"101 * }102 * },103 * "metadata": {104 * "entityId": "82d99338-5653-459a-a751-b57483f7cfb5",105 * "eventTime": "2024-02-07T13:22:47.641175778Z",106 * "id": "ef926c78-1c7a-4ffd-a8c4-fa59bdcf09c1",107 * "triggeredByAnonymizeRequest": false108 * }109 * }110 */111