Triggered when an order is canceled and effectiveAt
is set to NEXT_PAYMENT_DATE
.
This webhook is not triggered in the following scenarios:
effectiveAt
is set to IMMEDIATELY
. Instead, at the time of cancellation, Order Canceled is triggered.effectiveAt
was set to NEXT_PAYMENT_DATE
. Instead, at the time of expiration, Order Canceled and Order Ended are triggered.function wixPricingPlans_onOrderAutoRenewCanceled(
event: OrderAutoRenewCanceledEvent,
): void;
Information about the order whose auto-renewal is canceled 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_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
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Triggered when an order is canceled.
This webhook is triggered either immediately or at the end of the current payment cycle, as follows:
effectiveAt
is set to IMMEDIATELY
, the webhook is triggered immediately when canceled.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.function wixPricingPlans_onOrderCanceled(event: OrderCanceledEvent): void;
Information about the canceled order 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_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
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Triggered when an order is created.
function wixPricingPlans_onOrderCreated(event: OrderCreated): void;
Information about the created order 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_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
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Triggered at the start of a new payment cycle for an existing order.
Not triggered at the initial start of an offline order.
function wixPricingPlans_onOrderCycleStarted(
event: OrderCycleStartedEvent,
): void;
Information about the order whose payment cycle started 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_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
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.