> 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 # ListEligibleMemberships # Package: memberships # Namespace: MembershipsSPI # Method link: https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/payments/memberships/memberships-service-plugin/list-eligible-memberships.md ## Introduction This method retrieves eligible memberships from your app. --- ## REST API ### Schema ``` Method: listEligibleMemberships Description: This method retrieves eligible memberships from your app. URL: null Method: POST # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: memberId, lineItems, lineItems.catalogReference, lineItems.catalogReference.appId Method parameters: param name: lineItems | type: array | description: The line items for which to list eligible memberships. | required: true - name: id | type: string | description: Line item GUID. - name: catalogReference | type: CatalogReference | description: Catalog and item reference info. | required: true - name: catalogItemId | type: string | description: GUID of the item within the catalog it belongs to. - name: appId | type: string | description: GUID of the app providing the catalog. You can get your app's GUID from its page in the [app dashboard](https://dev.wix.com/dc3/my-apps/). For items from Wix catalogs, the following values always apply: + Wix Stores: `"215238eb-22a5-4c36-9e7b-e7c08025e04e"` + Wix Bookings: `"13d21c63-b5ec-5912-8397-c3a5ddb27a97"` + Wix Restaurants: `"9a5d83fd-8570-482e-81ab-cfa88942ee60"` | required: true - name: options | type: object | description: Additional item details in `key:value` pairs. Use this optional field for more specificity with item selection. The values of the `options` field differ depending on which catalog is providing the items. For Wix Stores products, learn more about integrating with [Catalog V3](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v3/e-commerce-integration.md) or [Catalog V1](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v1/catalog/e-commerce-integration.md), depending on [the version the site uses](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-versioning/introduction.md). - name: serviceProperties | type: ServiceProperties | description: Properties of the service. When relevant, contains information such as date and number of participants. - name: scheduledDate | type: string | description: Date and time the service is to be provided, in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations) format. For example, the start time of a class. - name: numberOfParticipants | type: integer | description: The number of people participating in the service. For example, the number of people attending a class or the number of people per hotel room. - name: rootCatalogItemId | type: string | description: Root catalog item GUID. The value will usually be the same as `catalogReference.catalogItemId`. In cases when these are not the same, this field will return the actual GUID of the item in the catalog. For example, for Wix bookings, the value of `catalogReference.catalogItemId` is the booking GUID, but `rootCatalogItemId` is set to the service GUID. param name: memberId | type: memberId | description: Member GUID. Do not retrieve this from the request context. In some cases the caller is not a member, but a user who is using the membership on behalf of a member. | required: true param name: selectedMemberships | type: SelectedMemberships - name: memberships | type: array | description: Selected memberships. - name: id | type: string | description: Membership GUID. - name: lineItemIds | type: array | description: IDs of the line items this membership applies to. Return type: ListEligibleMembershipsResponse - name: eligibleMemberships | type: array | description: List of memberships that are eligible for the given member and line items. - name: id | type: string | description: Membership GUID. - name: name | type: MembershipName | description: Membership name. - name: original | type: string | description: Membership name. - name: translated | type: string | description: Translated membership name. Defaults to `original` when not provided. - name: lineItemIds | type: array | description: Line item GUIDs this membership applies to. - name: credits | type: MembershipPaymentCredits | description: Total and remaining membership credits. - name: total | type: integer | description: Membership's initial value. - name: remaining | type: integer | description: Membership's remaining value. - name: expirationDate | type: string | description: Membership expiration date. - name: additionalData | type: object | description: Additional data about this membership. - name: invalidMemberships | type: array | description: List of memberships owned by the member, but cannot be used due to the reason provided. - name: membership | type: Membership | description: The membership that is invalid and cannot be used. - name: reason | type: string | description: Reason why this membership is invalid. - name: selectedMemberships | type: array | description: List of selected memberships and which line items they apply to. - name: id | type: string | description: Membership GUID. - name: lineItemIds | type: array | description: IDs of the line items this membership applies to. Possible Errors: HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: INVALID_SELECTION | Description: The provided membership selection is invalid HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: INSUFFICIENT_BALANCE | Description: The selected memberships do not have enough balance to cover the line items. ``` ### Examples ### List Eligible Memberships Get list of all member's memberships, that are applicable for given line item. ```curl curl -X POST \ 'https://provider.example.com/v1/list-eligible-memberships' \ -H 'user-agent: Wix' \ -H 'accept-encoding: gzip, deflate' \ -H 'content-type: text/plain; charset=utf-8' \ --data-binary '{ "lineItems": [ { "id": "00000000-0000-0000-0000-000000000001", "catalogReference": { "catalogItemId": "68f71a63-d406-49bd-942f-b70865e72d99", "appId": "13d21c63-b5ec-5912-8397-c3a5ddb27a97" }, "rootCatalogItemId": "8e02a329-893c-46d4-9d52-c45aed5ecf32" } ] }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.memberships.MembershipsSPI.listEligibleMemberships(request, metadata) Description: This method retrieves eligible memberships from your app. Method parameters: 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. - 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. - name: memberId | type: string | description: GUID of a site visitor that has logged in to the site. - name: wixUserId | type: string | description: GUID of a Wix user (site owner, contributor, etc.). - name: appId | type: string | description: GUID of an app. - name: languages | type: array | 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. param name: request | type: ListEligibleMembershipsRequest - name: lineItems | type: array | description: The line items for which to list eligible memberships. - name: _id | type: string | description: Line item GUID. - name: catalogReference | type: CatalogReference | description: Catalog and item reference info. - name: catalogItemId | type: string | description: GUID of the item within the catalog it belongs to. - name: appId | type: string | description: GUID of the app providing the catalog. You can get your app's GUID from its page in the [app dashboard](https://dev.wix.com/dc3/my-apps/). For items from Wix catalogs, the following values always apply: + Wix Stores: `"215238eb-22a5-4c36-9e7b-e7c08025e04e"` + Wix Bookings: `"13d21c63-b5ec-5912-8397-c3a5ddb27a97"` + Wix Restaurants: `"9a5d83fd-8570-482e-81ab-cfa88942ee60"` - name: options | type: object | description: Additional item details in `key:value` pairs. Use this optional field for more specificity with item selection. The values of the `options` field differ depending on which catalog is providing the items. For Wix Stores products, learn more about integrating with [Catalog V3](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v3/e-commerce-integration.md) or [Catalog V1](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v1/catalog/e-commerce-integration.md), depending on [the version the site uses](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-versioning/introduction.md). - name: serviceProperties | type: ServiceProperties | description: Properties of the service. When relevant, contains information such as date and number of participants. - name: scheduledDate | type: Date | description: Date and time the service is to be provided, in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations) format. For example, the start time of a class. - name: numberOfParticipants | type: integer | description: The number of people participating in the service. For example, the number of people attending a class or the number of people per hotel room. - name: rootCatalogItemId | type: string | description: Root catalog item GUID. The value will usually be the same as `catalogReference.catalogItemId`. In cases when these are not the same, this field will return the actual GUID of the item in the catalog. For example, for Wix bookings, the value of `catalogReference.catalogItemId` is the booking GUID, but `rootCatalogItemId` is set to the service GUID. - name: memberId | type: string | description: Member GUID. Do not retrieve this from the request context. In some cases the caller is not a member, but a user who is using the membership on behalf of a member. - name: selectedMemberships | type: SelectedMemberships | description: The selected payment memberships and which line items they apply to. When not provided, your implementation is expected to return the default selection. When provided, your implementation is expected to validate and return it. - name: memberships | type: array | description: Selected memberships. - name: _id | type: string | description: Membership GUID. - name: lineItemIds | type: array | description: IDs of the line items this membership applies to. Return type: PROMISE - name: eligibleMemberships | type: array | description: List of memberships that are eligible for the given member and line items. - name: _id | type: string | description: Membership GUID. - name: name | type: MembershipName | description: Membership name. - name: original | type: string | description: Membership name. - name: translated | type: string | description: Translated membership name. Defaults to `original` when not provided. - name: lineItemIds | type: array | description: Line item GUIDs this membership applies to. - name: credits | type: MembershipPaymentCredits | description: Total and remaining membership credits. - name: total | type: integer | description: Membership's initial value. - name: remaining | type: integer | description: Membership's remaining value. - name: expirationDate | type: Date | description: Membership expiration date. - name: additionalData | type: object | description: Additional data about this membership. - name: invalidMemberships | type: array | description: List of memberships owned by the member, but cannot be used due to the reason provided. - name: membership | type: Membership | description: The membership that is invalid and cannot be used. - name: reason | type: string | description: Reason why this membership is invalid. - name: selectedMemberships | type: array | description: List of selected memberships and which line items they apply to. - name: _id | type: string | description: Membership GUID. - name: lineItemIds | type: array | description: IDs of the line items this membership applies to. Possible Errors: HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: INVALID_SELECTION | Description: The provided membership selection is invalid HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: INSUFFICIENT_BALANCE | Description: The selected memberships do not have enough balance to cover the line items. ``` ### Examples ### listEligibleMemberships ```javascript import { memberships } from '@wix/ecom/service-plugins'; async function listEligibleMemberships(request,metadata) { const response = await memberships.listEligibleMemberships(request,metadata); }; ``` ### listEligibleMemberships (with elevated permissions) ```javascript import { memberships } from '@wix/ecom/service-plugins'; import { auth } from '@wix/essentials'; async function myListEligibleMembershipsMethod(request,metadata) { const elevatedListEligibleMemberships = auth.elevate(memberships.listEligibleMemberships); const response = await elevatedListEligibleMemberships(request,metadata); } ``` ### listEligibleMemberships (self-hosted) Self-hosted 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 listEligibleMemberships(request,metadata) { const response = await myWixClient.memberships.listEligibleMemberships(request,metadata); }; ``` ---