> 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

# listCharges

# Package: @wix/app-management

# Namespace: customCharges

# Method link: https://dev.wix.com/docs/api-reference/app-management/app-billing/custom-charges-service-plugin/list-charges.md

## Introduction

Wix calls this method to retrieve a list of charges for a paid instance
of your app. This happens when Wix creates an invoice or in case the customer
wants to preview how much your app would charge them at the moment.

You must return the charges in the currency that's specified in the request,
you aren't allowed to return more than 5 charges, and their sum must be lower
than the charge limit.

You may not bill customers for any usage that didn’t occur during the period
Wix specifies when retrieving the charges. If Wix discovers that your app has
charged customers for usage outside of an invoice's specified period, we may
take action such as blocking your app from charging the customer, removing
your app from the Wix App Market, revoking your access to the Wix developer
program, or pursuing legal action to recover damages caused by overcharging.
We understand that mistakes can happen and encourage you to contact
[the Wix App Market team](https://devforum.wix.com/kb/en/contact) immediately if you
become aware of any overcharging issues so that we can work together to
resolve the situation.

> **Note:**
> This feature isn't yet available to all users. Your app can have only 1 usage-based plan and no other plans. To add a usage-based plan to your app, [submit a request to add a usage-based plan](https://www.wix.com/support-chatbot?nodeId=25a57397-ccf7-4376-8b74-48d51edf7159&referral=devRels).

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.appManagement.customCharges.listCharges(request, metadata)
 Description: Wix calls this method to retrieve a list of charges for a paid instance of your app. This happens when Wix creates an invoice or in case the customer wants to preview how much your app would charge them at the moment.  You must return the charges in the currency that's specified in the request, you aren't allowed to return more than 5 charges, and their sum must be lower than the charge limit.  You may not bill customers for any usage that didn’t occur during the period Wix specifies when retrieving the charges. If Wix discovers that your app has charged customers for usage outside of an invoice's specified period, we may take action such as blocking your app from charging the customer, removing your app from the Wix App Market, revoking your access to the Wix developer program, or pursuing legal action to recover damages caused by overcharging. We understand that mistakes can happen and encourage you to contact [the Wix App Market team](https://devforum.wix.com/kb/en/contact) immediately if you become aware of any overcharging issues so that we can work together to resolve the situation.  > **Note:** > This feature isn't yet available to all users. Your app can have only 1 usage-based plan and no other plans. To add a usage-based plan to your app, [submit a request to add a usage-based plan](https://www.wix.com/support-chatbot?nodeId=25a57397-ccf7-4376-8b74-48d51edf7159&referral=devRels).
 Method parameters:
   param name: request | type: ListChargesRequest    
        - name: subscriptionId | type: string | description: GUID of the subscription for which Wix retrieves your custom charges. To track usage and billing for apps, we recommend to use `instanceId` instead of the `subscriptionId`.  | validation: format GUID
        - name: currency | type: string | description: Supported values: `AUD`, `BRL`, `CAD`, `EUR`, `GBP`, `ILS`, `INR`, `JPY`, `MXN`, `PLN`, `RUB`, `TRY`, `USD`.  3-letter currency code in [ISO-4217 alphabetic](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) format of your charges to return. Wix may add supported currencies in the future.  | validation: format CURRENCY
        - name: periodStart | type: Date | description: Begin of the period Wix retrieves the app instance's charges for in `YYYY-MM-DDThh:mm:ss.sssZ` format.  
        - name: periodEnd | type: Date | description: End of the period Wix retrieves the app instance's charges for in `YYYY-MM-DDThh:mm:ss.sssZ` format.  
        - name: intent | type: Intent | description: Information about what Wix intends to do with the retrieved charges.  
             - enum:
             -     DISPLAY_ONLY: Inform the customer about how much your app would charge them at the moment. Wix doesn't create an invoice.
             -     CREATE_INVOICE: Create an invoice for the customer.
        - name: reason | type: Reason | description: Why Wix is retrieving the charges. Wix sends `reason` only when `intent` is `CREATE_INVOICE`, and may leave it out even then. Wix may add values in the future, so treat a missing or unknown value as `UNKNOWN_REASON`.  
             - enum:
             -     UNKNOWN_REASON: Wix doesn't specify why it's retrieving the charges. For example, when `intent` is `DISPLAY_ONLY`.
             -     RENEWAL: Wix is issuing the regular invoice for the subscription's next billing cycle.
             -     CANCELLATION: Wix is issuing the final invoice of a subscription that's being canceled.
             -     PLAN_CHANGE: Wix is issuing an invoice because the customer is switching the subscription to a different plan.
   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<ListChargesResponse>
  - name: charges | type: array<ChargeLineItem> | description: Retrieved charges.  Max: 10 charges  | validation: maxItems 10
     - name: _id | type: string | description: GUID of the charge. Make sure to save the charge GUID on your servers for future reference. Identical to `lineItem.chargeId` in the Invoice Created Event.  Max: 64 characters  | validation: maxLength 64
     - name: description | type: string | description: Charge description.  
     - name: amount | type: string | description: Charge amount in the currency that's specified in the request. Use a whole number or separate major and minor units with a dot. For example, `10` or `1.99`. If you return an amount with more minor units than supported according to [ISO-4217](https://en.wikipedia.org/wiki/ISO_4217#Active_codes), Wix truncates the additional minor units.  Min: `0.50`  | validation: format DECIMAL_VALUE
     - name: usagePeriod | type: UsagePeriod | description: Optional usage window for this charge line item. When provided, the invoice line item shows this period instead of the subscription's billing-cycle dates. Both `startDate` and `endDate` must be supplied together — a partial pair is discarded. `startDate` must not be earlier than January 2010 and must not exceed `endDate`.  
        - name: startDate | type: Date | description: Start of the app-provided usage window, in UTC.  
        - name: endDate | type: Date | description: End of the app-provided usage window, in UTC. Must not precede `startDate`.  


```

### Examples

### Example of a `charges` return value
```javascript
import { customCharges } from '@wix/app-management/service-plugins';

customCharges.provideHandlers({

  listCharges: async ( payload ) => {
    const {request, metadata} = payload;
        // Use the `request` and `metadata` received from Wix and
        // apply custom logic.
      return {
        // Return your response exactly as documented to integrate with Wix.
        // Return value example:
        charges: [
          {
            _id: "Some Charge Id 1",
            description: "Setup fee",
            amount: "200.00"
          },
          {
            _id: "Some Charge Id 2",
            description: "Usage charges",
            amount: "300.00"
          }
        ]
      }
    }
});

```

### listCharges (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 { customCharges } from '@wix/app-management/service-plugins';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

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


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

---