> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> 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`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# GetMembershipVoidability

# Package: memberships

# Namespace: MembershipsSPI

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/payments/memberships/memberships-service-plugin/get-membership-voidability.md

## Introduction

Retrieves whether a membership charge can be voided.

Wix calls this method before attempting to reverse a charge, for example when an order is about
to be canceled or refunded.

Wix uses the response to decide whether to offer the reversal.

Reporting a charge as not voidable doesn't guarantee that no reversal follows: the refund and
rollback paths call [Void Membership Charge](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/payments/memberships/memberships-service-plugin/void-membership-charge.md) directly. Implement that method to answer for a charge you'd report here as not voidable, rather than assuming it can't arrive.

**Your implementation should:** Report whether the charge identified by `transactionId` can still
be reversed, and when it can't, give a `reason` suitable for showing to the person deciding.

**Error handling:** Report an unrecognized `transactionId` as `TRANSACTION_NOT_FOUND`. A charge
that exists but can't be reversed isn't an error: return `voidable` as `false` with a reason.

---

## REST API

### Schema

```
 Method: getMembershipVoidability
 Description: Retrieves whether a membership charge can be voided.  Wix calls this method before attempting to reverse a charge, for example when an order is about to be canceled or refunded.  Wix uses the response to decide whether to offer the reversal.  Reporting a charge as not voidable doesn't guarantee that no reversal follows: the refund and rollback paths call [Void Membership Charge](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/payments/memberships/memberships-service-plugin/void-membership-charge.md) directly. Implement that method to answer for a charge you'd report here as not voidable, rather than assuming it can't arrive.  **Your implementation should:** Report whether the charge identified by `transactionId` can still be reversed, and when it can't, give a `reason` suitable for showing to the person deciding.  **Error handling:** Report an unrecognized `transactionId` as `TRANSACTION_NOT_FOUND`. A charge that exists but can't be reversed isn't an error: return `voidable` as `false` with a reason.
 URL: {DEPLOYMENT-URI}/v1/get-voidability
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  transactionId
 Method parameters: 
   param name: transactionId | type: transactionId | description: GUID of the transaction to check, as returned in `ChargeMembershipResponse.transactionId`. | required: true | validation: minLength 1, maxLength 100
 Return type: GetMembershipVoidabilityResponse
  - name: voidable | type: boolean | description: Whether the charge can be voided.  
  - name: reason | type: string | description: Reason the charge can't be voided.  Returned only when `voidable` is `false`.  | validation: minLength 1, maxLength 200

 Possible Errors:
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: TRANSACTION_NOT_FOUND | Description: Transaction not found


```

### Examples

### Get Membership Voidability
Check if membership can be voided

```curl
curl -X POST \
  'https://provider.example.com/v1/get-voidability' \
  -H 'user-agent: Wix' \
  -H 'accept-encoding: gzip, deflate' \
  -H 'content-type: text/plain; charset=utf-8' \
  --data-binary '{
    "transactionId": "a178aeb7-6687-4402-862f-411a8f899205"
	}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.ecom.memberships.getMembershipVoidability(request, metadata)
 Description: Retrieves whether a membership charge can be voided.  Wix calls this method before attempting to reverse a charge, for example when an order is about to be canceled or refunded.  Wix uses the response to decide whether to offer the reversal.  Reporting a charge as not voidable doesn't guarantee that no reversal follows: the refund and rollback paths call [Void Membership Charge](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/payments/memberships/memberships-service-plugin/void-membership-charge.md) directly. Implement that method to answer for a charge you'd report here as not voidable, rather than assuming it can't arrive.  **Your implementation should:** Report whether the charge identified by `transactionId` can still be reversed, and when it can't, give a `reason` suitable for showing to the person deciding.  **Error handling:** Report an unrecognized `transactionId` as `TRANSACTION_NOT_FOUND`. A charge that exists but can't be reversed isn't an error: return `voidable` as `false` with a reason.
 Method parameters:
   param name: request | type: GetMembershipVoidabilityRequest    
        - name: transactionId | type: string | description: GUID of the transaction to check, as returned in `ChargeMembershipResponse.transactionId`.  | validation: minLength 1, maxLength 100
   param name: metadata | type: Context | description: this message is not directly used by any service, it exists to describe the expected parameters that SHOULD be provided to invoked Velo methods as part of open-platform. e.g. SPIs, event-handlers, etc.. NOTE: this context object MUST be provided as the last argument in each Velo method signature.  Example: ```typescript export function wixStores_onOrderCanceled({ event, metadata }: OrderCanceledEvent) { ... } ```  
        - name: requestId | type: string | description: A unique identifier of the request. You may print this GUID to your logs to help with future debugging and easier correlation with Wix's logs.  
        - name: currency | type: string | description: [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) 3-letter currency code.  | validation: format CURRENCY
        - name: identity | type: IdentificationData | description: An object that describes the identity that triggered this request.  
           - ONE-OF: 
              - name: anonymousVisitorId | type: string | description: GUID of a site visitor that has not logged in to the site.  | validation: format GUID
              - name: memberId | type: string | description: GUID of a site visitor that has logged in to the site.  | validation: format GUID
              - name: wixUserId | type: string | description: GUID of a Wix user (site owner, contributor, etc.).  | validation: format GUID
              - name: appId | type: string | description: GUID of an app.  | validation: format GUID
        - name: languages | type: array<string> | description: A string representing a language and region in the format of `"xx-XX"`. First 2 letters represent the language code according to ISO 639-1. This is followed by a dash "-", and then a by 2 capital letters representing the region according to ISO 3166-2. For example, `"en-US"`.  
        - name: instanceId | type: string | description: The service provider app's instance GUID.  | validation: format GUID
 Return type: PROMISE<GetMembershipVoidabilityResponse>
  - name: voidable | type: boolean | description: Whether the charge can be voided.  
  - name: reason | type: string | description: Reason the charge can't be voided.  Returned only when `voidable` is `false`.  | validation: minLength 1, maxLength 200

 Possible Errors:
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: TRANSACTION_NOT_FOUND | Description: Transaction not found


```

### Examples

### Example of a `getMembershipVoidability` return value
Reports whether a membership charge can still be reversed. A charge reported as not voidable is never sent to Void Membership Charge.

```javascript
import { memberships } from '@wix/ecom/service-plugins';

memberships.provideHandlers({

  getMembershipVoidability: async ( payload ) => {
    const {request, metadata} = payload;
        // Use the `request` and `metadata` received from Wix and
        // apply custom logic.
        // A charge that exists but can't be reversed isn't an error: return
        // `voidable` as false with a reason.
      return {
        // Return your response exactly as documented to integrate with Wix.
        // Return value example:
        voidable: false,
        reason: "The membership expired after this charge was made"
      }
    }
});

```

### getMembershipVoidability (self-managed)
Self-managed SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { memberships } from '@wix/ecom/service-plugins';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { memberships },
  // Include the auth strategy and host as relevant
});


async function getMembershipVoidability(request,metadata) {
  const response = await myWixClient.memberships.getMembershipVoidability(request,metadata);
};
```

---