Search.../

requestCurrentMemberOrderCancellation( )

Starts the process of cancelling the logged-in member's pricing plan order.

Description

The requestCurrentMemberOrderCancellation() function returns a Promise that resolves when the order cancellation is successfully requested.

For orders with recurring payments, a cancellation can be set to occur either immediately or at the next payment date. For orders with one-time payments, a cancellation occurs immediately after the request is processed.

Requesting an order cancellation starts the cancellation process. The event is triggered immediately and the function's promise is fulfilled. However, 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.

The onOrderUpdated() event handler runs when a cancellation is requested. The onOrderCanceled() event handler runs when the cancellation is completed.

Syntax

function requestCurrentMemberOrderCancellation(orderId: string, effectiveAt: string): Promise<void>

requestCurrentMemberOrderCancellation Parameters

NAME
TYPE
DESCRIPTION
orderId
string

ID of the order whose cancellation is requested.

effectiveAt
string

The request can be that the order is canceled immediately or at the next payment date. One-time orders can only be canceled immediately. One of:

  • "IMMEDIATELY" The request indicates that the order should be canceled immediately.
  • "NEXT_PAYMENT_DATE". The request indicates that the order be canceled at the next payment date.

Returns

Fulfilled - When the cancellation process is started.

Return Type:

Promise<void>

Was this helpful?

Start the cancellation process for the currently logged-in member's order

Copy Code
1import { orders } from 'wix-pricing-plans-backend';
2
3// Sample orderId value: 'a8c4a1b2-b5e8-4b33-9693-057ec93e9a27'
4//
5// Sample effectiveAt value: 'IMMEDIATELY'
6
7export async function myRequestCurrentMemberCancelFunction(orderId, effectiveAt) {
8 try {
9 const order = await orders.requestCurrentMemberOrderCancellation(orderId, effectiveAt);
10
11 return order;
12 } catch (error) {
13 console.error(error);
14 }
15}
16
17// Returns a promise that resolves to void