> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: requestCancellation(_id: string, effectiveAt: CancellationEffectiveAt) # Method package: wixPricingPlansV2 # Method menu location: wixPricingPlansV2 --> orders --> requestCancellation # Method Link: https://dev.wix.com/docs/velo/apis/wix-pricing-plans-v2/orders/request-cancellation.md # Method Description: Cancels an order. Recurring orders can be canceled either immediately or at the next payment date. One time orders can only be canceled immediately. There may be some operations that continue to be processed before the status of the order is changed to `"CANCELED"`. For example, payments might need to be refunded before the order is fully canceled. Canceling during the free trial period: When a buyer cancels their order during the free trial period, the buyer's subscription expires at the end of the free trial period and they won't be billed. The buyer may continue using the benefits until the end of the free trial period. >**Note:** >This method requires [visitor or member authentication](https://dev.wix.com/docs/rest/articles/getting-started/access-types-and-permissions.md). # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Cancel an order immediately ```javascript import { orders } from 'wix-pricing-plans.v2'; /* Sample _id value: '7b4ec42c-582a-4e2f-874b-09e66e0ae09d' * * Sample effectiveAt value: 'IMMEDIATELY' */ export async function myRequestCancellationFunction(_id, effectiveAt) { try { await orders.requestCancellation(_id, effectiveAt); return; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to void */ ``` ## Cancel or pause a member order ```javascript /******************************* * Backend code - order.web.js * ********************************/ import { Permissions, webMethod } from 'wix-web-module'; import { orders } from 'wix-pricing-plans.v2'; import { elevate } from 'wix-auth'; const elevatedPauseOrder = elevate(orders.pauseOrder); export const listCurrentMemberOrders = webMethod( Permissions.Anyone, async (orderStatuses) => { try { const result = await orders.memberListOrders(orderStatuses); return result; } catch (error) { console.error(error); // Handle the error } }); export const requestCancellation = webMethod( Permissions.Anyone, async (orderId) => { const effectiveAt = 'NEXT_PAYMENT_DATE'; try { await orders.requestCancellation(orderId, effectiveAt) ; return; } catch (error) { console.error(error); // Handle the error } }); export const pauseOrder = webMethod( Permissions.Anyone, async (orderId) => { try { await elevatedPauseOrder(orderId); return; } catch (error) { console.error(error); // Handle the error } }); /************* * Page code * *************/ import { listCurrentMemberOrders, requestCancellation, pauseOrder } from 'backend/order.web'; $w.onReady(function () { // Disabe UI elements on page load $w('#requestCancelOrderBtn').disable(); $w('#pauseOrderBtn').disable(); $w('#ordersDropdown').disable(); let selectedOrderId; populateOrdersDropdown(); $w('#ordersDropdown').onChange( () => { selectedOrderId = $w('#ordersDropdown').value; $w('#requestCancelOrderBtn').enable(); $w('#pauseOrderBtn').enable(); }); $w('#requestCancelOrderBtn').onClick(async () => { await requestCancellation(selectedOrderId); }); $w('#pauseOrderBtn').onClick(async () => { await pauseOrder(selectedOrderId); }); }); async function populateOrdersDropdown() { const activeOrdersList = await listCurrentMemberOrders({orderStatuses: 'ACTIVE'}); $w('#ordersDropdown').options = activeOrdersList.orders.map((order) => { return { label: order.planName, value: order._id } }); $w('#ordersDropdown').enable(); } ``` ---