Search.../

connectAccount( )

Retrieves information for connecting a new payment provider account.

Description

This function is called by Wix Payments when you try to connect a custom payment provider from your site's dashboard. When neccessary, 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.

Syntax

function connectAccount(options: ConnectAccountOptions): Promise<ConnectAccountResponse>

connectAccount Parameters

NAME
TYPE
DESCRIPTION
options
ConnectAccountOptions

Information to use when connecting a new payment provider account.

Returns

Fulfilled - Information about the created account.

Return Type:

Promise<ConnectAccountResponse>
NAME
TYPE
DESCRIPTION
credentials
object

Account credentials for making API requests to the payment provider. These credentials are passed to the createTransaction() and refundTransaction() functions to use when sending requests to the provider's API.

accountName
string

Payment provider account name.

reasonCode
number

Code indicating the reason for failure if account creation fails.

errorCode
string

Error code supplied by the payment provider if account creation fails.

errorMessage
string

Error message supplied by the payment provider if account creation fails.

Was this helpful?

Connect an account with basic credentials

Copy Code
1// Place this code in the <my-extension-name>.js file
2// in the 'payment-provider' folder of the
3// Custom Extensions section on your site.
4
5export const connectAccount = async (options) => {
6 //Logic for creating a new payment provider account, if needed.
7 return {
8 "credentials": {
9 "client_id": "1k2k55k3k2llsssl23l45k6",
10 "client_secret": "19x92ujd0-183ec-asddfasdfasd44ger-234"
11 },
12 "accountId": "9123467-a3e5-d4556-ff466742-234dd32dfq3456",
13 "accountName": "jane.brown@example.com"
14 }
15};
Connect an account with numeric and boolean credentials

Copy Code
1// Place this code in the <my-extension-name>.js file
2// in the 'payment-provider' folder of the
3// Custom Extensions section on your site.
4
5export const connectAccount = async (options) => {
6 //Logic for creating a new payment provider account, if needed.
7 return {
8 "credentials": {
9 "client_id": "1k2k55k3k2llsssl23l45k6",
10 "client_secret": "19x92ujd0-183ec-asddfasdfasd44ger-234",
11 "price_includes_tax": "true",
12 "tax_rate": "20"
13 },
14 "accountId": "9123467-a3e5-d4556-ff466742-234dd32dfq3456",
15 "accountName": "jane.brown@example.com"
16 }
17};
Failed connection attempt

Copy Code
1// Place this code in the <my-extension-name>.js file
2// in the 'payment-provider' folder of the
3// Custom Extensions section on your site.
4
5export const connectAccount = async (options) => {
6 //Logic for creating a new payment provider account, if needed.
7 return {
8 'reasonCode': 2009,
9 'errorCode': 'CURRENCY_IS_NOT_SUPPORTED',
10 'errorMessage': 'Currency USD is not supported'
11 }
12};