> 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

# Method name: connectAccount(options: ConnectAccountOptions, context: Context)

# Method package: wixPayments

# Method menu location: wixPayments --> PaymentProvider --> connectAccount

# Method Link: https://dev.wix.com/docs/velo/events-service-plugins/payments/service-plugins/wix-payments/payment-provider/connect-account.md

# Method Description:

Retrieves information for connecting a new payment provider account.

This function is called by Wix Payments when you try to connect a custom payment provider from your site's dashboard. 
When necessary, the code implemented in this function creates a new account on the payment provider's side. The function
returns the payment provider account information, or error information if account creation fails.
Wix uses the return values from this function when connecting the payment provider to the site.

>**Note:** This function has a second parameter called `context`. This parameter is for internal Wix use only. 
>You don't need to use it in your code.

### Where to find `connectAccount()`
When you [add the Payment Provider service plugin](https://dev.wix.com/docs/develop-websites/articles/code-tutorials/wix-pay/tutorial-payment-provider-custom-extension.md#step-1-create-a-new-payment-provider-extension), 
a folder is automatically added to your site. Use the `.js` file in the folder to write the custom code for your payment provider. 

For more information on customizing your payment provider, see [Tutorial: Payment Provider Service Plugin](https://dev.wix.com/docs/develop-websites/articles/code-tutorials/wix-pay/tutorial-payment-provider-custom-extension.md#my-extension-namejs).



# Method Code Examples:

*** Note: do not assume any prop names or enum values other than the ones in the example.

## Connect an account with basic credentials

```javascript
// Place this code in the <my-plugin-name>.js file
// in the 'payment-provider' folder of the 
// Service Plugins section on your site.

export const connectAccount = async (options) => {
  //Logic for creating a new payment provider account, if needed.  
  return {
    "credentials": {
      "client_id": "1k2k55k3k2llsssl23l45k6",
      "client_secret": "19x92ujd0-183ec-asddfasdfasd44ger-234"
    },
    "accountId": "9123467-a3e5-d4556-ff466742-234dd32dfq3456",
    "accountName": "jane.brown@example.com"
  }
};
```

## Connect an account with numeric and boolean credentials

```javascript
// Place this code in the <my-plugin-name>.js file
// in the 'payment-provider' folder of the 
// Service Plugins section on your site.

export const connectAccount = async (options) => {
  //Logic for creating a new payment provider account, if needed.  
    return {
      "credentials": {
        "client_id": "1k2k55k3k2llsssl23l45k6",
        "client_secret": "19x92ujd0-183ec-asddfasdfasd44ger-234",
        "price_includes_tax": "true",
        "tax_rate": "20"
      },
      "accountId": "9123467-a3e5-d4556-ff466742-234dd32dfq3456",
      "accountName": "jane.brown@example.com"
    }
};
```

## Failed connection attempt

```javascript
// Place this code in the <my-plugin-name>.js file
// in the 'payment-provider' folder of the 
// Service Plugins section on your site.

export const connectAccount = async (options) => {
  //Logic for creating a new payment provider account, if needed.  
  return {
    'reasonCode': 2009,
    'errorCode': 'CURRENCY_IS_NOT_SUPPORTED',
    'errorMessage': 'Currency USD is not supported'
  } 
};
```

---