> 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

## Resource: Introduction

## Article: Introduction

## Article Link: https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/additional-fees/additional-fees-service-plugin/introduction.md

## Article Content:

# About the Wix eCommerce Additional Fees Service Plugin

<blockquote class="important">

__Important:__ 
When developing websites or building apps with Blocks, use [Velo service plugins](https://dev.wix.com/docs/velo/events-service-plugins/about-events-service-plugins-and-the-sdk.md).

</blockquote>

As an additional fees calculation provider, you can integrate with Wix to allow merchants to request and use your services on their Wix sites.
The additional fees you calculate are then included on the site's cart and checkout pages.  

The integration is done via an app in the Wix App Market and by implementing the Additional Fees [service plugin](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/backend-extensions/service-plugins/about-service-plugin-extensions.md). After the app is installed on a site, Wix calls your service whenever the site needs to calculate additional fees for a transaction.  


Using the service plugin, you can design your app to calculate various additional fees for the merchant's customers, including:
+ Fragile packaging fees
+ Shipping insurance fees
+ Item warranty fees
+ Gift wrapping fees
+ Carbon offset fees

Learn more about [service plugin extensions](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/backend-extensions/service-plugins/about-service-plugin-extensions.md).


## Before you begin

It's important to note that when Wix calls your implementation of the Calculate Additional Fees method, the app must return fees in the same currency as the Wix site. Extract the `currency` for a site from the request to ensure the correct currency is used in your calculation.

## How it works

### When Wix calls your service

Wix calls your Calculate Additional Fees implementation in the following scenarios:

+ When a site visitor views their cart
+ When a site visitor begins the checkout process
+ When cart contents change during checkout (items added, removed, or quantities updated)
+ When shipping information changes during checkout

Each call includes comprehensive information about the cart, including line items, applied discounts, shipping details, and buyer information.

### What Wix does with your response

The additional fees you return are:

+ Displayed as separate line items on the cart and checkout pages
+ Added to the order total calculation
+ Included in the final order when the purchase is completed
+ Subject to tax calculation if you mark them as taxable

Site visitors see each fee with the name you provide, along with the fee amount.

### Performance requirements

Your implementation must respond within 3 seconds. If your service takes longer or returns an error:

+ Wix proceeds without additional fees
+ The site visitor won't see any fees on their cart or checkout
+ The order completes without your fees applied

To meet this requirement, consider:

+ Using cached fee calculations when possible
+ Avoiding synchronous calls to external services
+ Implementing timeout handling in your code
+ Testing your service under load

### Request context

Each request includes:

+ `lineItems`: Products in the cart with quantities, prices, and catalog references
+ `shippingAddress`: Delivery address (useful for location-based fees)
+ `buyerDetails`: Customer contact information
+ `appliedDiscounts`: All coupons and discounts applied to the cart
+ `shippingInfo`: Selected shipping method and costs
+ `purchaseFlowId`: Type of checkout flow (standard or express)
+ `subtotal`: Cart total before fees, shipping, and tax

Use this information to calculate fees based on your business logic. For example:

+ Calculate fragile packaging fees only for breakable items
+ Apply carbon offset fees based on shipping distance
+ Adjust gift wrapping fees based on the number of items

### Associating fees with line items

When returning fees, you can optionally specify which line items each fee applies to using the `lineItemIds` field. This is useful for:

+ Applying item-specific fees (such as warranty or insurance for certain products)
+ Proportional tax calculation when fees are taxable
+ Providing detailed breakdowns in order reports

If you don't specify `lineItemIds`, the fee applies to the entire order.


::::tabs
:::REST_TAB

## Get started

To enable Wix to communicate with your app:

1. Go to [Extensions](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/about-extensions.md) in your app's dashboard.
1. Click **Create Extension** in the top right.
1. Filter by **eCommerce** in the left menu, then find **Ecom Additional Fees** and click **Create**.
1. Provide the following configuration in the JSON editor and then click **Save**.

    | Name            | Type   | Description                                                                                                                                                                                                                                                                                                     |
    |-----------------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
    | `deploymentUri` | string | **Required.** Base URI where the endpoints are called. Wix eCommerce appends the endpoint path to the base URI. For example, to call the Calculate Additional Fees endpoint at `https://my-additional-fees.com/v1/calculateAdditionalFees`, the base URI you provide here is `https://my-additional-fees.com/`. |
    | `filter`        | Struct | An optional [WQL filter](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-the-wix-api-query-language.md) to apply to the payload passed to Calculate Additional Fees implementer. When provided, only requests that match the filter are forwarded to the implementer.                                                                                                                                                 |

:::
:::SDK_TAB

## Get started

**Self-hosted implementations:**

To enable Wix to communicate with your app:

1. Go to [Extensions](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/about-extensions.md) in your app's dashboard.
1. Click **Create Extension** in the top right.
1. Filter by **eCommerce** in the left menu, then find **Ecom Additional Fees** and click **Create**.
1. Provide the following configuration in the JSON editor and then click **Save**.

    | Name            | Type   | Description                                                                                                                                                                                                                                                                                                     |
    |-----------------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
    | `deploymentUri` | string | **Required.** Base URI where the endpoints are called. Wix eCommerce appends the endpoint path to the base URI. For example, to call the Calculate Additional Fees endpoint at `https://my-additional-fees.com/v1/calculateAdditionalFees`, the base URI you provide here is `https://my-additional-fees.com/`. |
    | `filter`        | Struct | An optional [WQL filter](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-the-wix-api-query-language.md) to apply to the payload passed to Calculate Additional Fees implementer. When provided, only requests that match the filter are forwarded to the implementer.                                                                                                                                                 |

Define handler functions using [`additionalFees.provideHandlers()`](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/self-hosting/supported-extensions/backend-extensions/add-self-hosted-service-plugin-extensions-with-the-sdk.md#step-4--define-handler-functions):

| Function                    | Required       |
|-----------------------------|----------------|
| [`calculateAdditionalFees()`](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/additional-fees/additional-fees-service-plugin/calculate-additional-fees.md)    | Yes            |

### Self-hosted: Basic code structure

```js
import { createClient } from '@wix/sdk';
import { additionalFees } from '@wix/ecom/service-plugins'

const wixClient = createClient({
  auth: {
    appId: <YOUR_APP_ID>,
    publicKey: <YOUR_APP_PUBLIC_KEY>
  },
  modules: { additionalFees }
});

wixClient.additionalFees.provideHandlers({
  calculateAdditionalFees: async (payload) => {

    const { request, metadata } = payload;

    // Add your logic here

  }
});

// Implement a router to process all requests
express.post('/plugins-and-webhooks/*', (req, res) => {
  wixClient.process(req);
});
```

**CLI implementations:**

Learn how to [implement a service plugin with the CLI and the SDK](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/wix-cli/supported-extensions/backend-extensions/service-plugins/add-service-plugin-extensions-with-the-cli.md).

Define handler functions using [`additionalFees.provideHandlers()`](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/self-hosting/supported-extensions/backend-extensions/add-self-hosted-service-plugin-extensions-with-the-sdk.md#step-4--define-handler-functions):

| Function                    | Required       |
|-----------------------------|----------------|
| [`calculateAdditionalFees()`](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/additional-fees/additional-fees-service-plugin/calculate-additional-fees.md)    | Yes            |

### CLI: Basic code structure

```js
import { additionalFees } from '@wix/ecom/service-plugins'

additionalFees.provideHandlers({
  calculateAdditionalFees: async (payload) => {

    const {request, metadata} = payload;

    // Add your logic here

  }
});
```

:::
::::


## See also
+ [About Service Plugin Extensions](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/backend-extensions/service-plugins/about-service-plugin-extensions.md)
+ [Add a Service Plugin Extension With the CLI](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/wix-cli/supported-extensions/backend-extensions/service-plugins/add-service-plugin-extensions-with-the-cli.md)
+ [Add a Self-hosted Service Plugin With the SDK](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/self-hosting/supported-extensions/backend-extensions/add-self-hosted-service-plugin-extensions-with-the-sdk.md)
+ [Add Self-hosted Service Plugin Extensions with REST](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/self-hosting/supported-extensions/backend-extensions/add-self-hosted-service-plugin-extensions-with-rest.md)