Search.../

createTransaction( )

Retrieves information about a newly created payment provider transaction.

Description

This function is called by Wix Payments when a site visitor places an order on your site. The code implemented in this function creates a new transaction with a payment provider. The function returns the transaction information, or error information if transaction creation fails. Wix uses the return values from this function to add the new transaction to your 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 createTransaction(options: CreateTransactionOptions): Promise<CreateTransactionResponse>

createTransaction Parameters

NAME
TYPE
DESCRIPTION
options
CreateTransactionOptions

Information to use when creating a new transaction.

Returns

Fulfilled -

Return Type:

Promise<CreateTransactionResponse>
NAME
TYPE
DESCRIPTION
pluginTransactionId
string

Payment provider transaction ID.

reasonCode
number

Code indicating the outcome of the transaction request.

errorCode
string

Error code supplied by the payment provider if the transaction request fails.

errorMessage
string

Error message supplied by the payment provider if the transaction request fails.

redirectUrl
string

URL on the payment provider's site to forward the site visitor to for payment processing.

Was this helpful?

Payment approved instantly

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 createTransaction = async (options) => {
6 //Logic for creating a new transaction with the payment provider.
7 return {
8 "pluginTransactionId": "1832456-3561234",
9 }
10};
Payment declined instantly

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 createTransaction = async (options) => {
6 //Logic for creating a new transaction with the payment provider.
7 return {
8 "pluginTransactionId": "1832456-3561234",
9 "reasonCode": 3012,
10 "errorCode": "INSUFFICIENT_FUNDS",
11 "errorMessage": "Insufficient funds"
12 }
13};
Payment pending

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 createTransaction = async (options) => {
6 //Logic for creating a new transaction with the payment provider.
7 return {
8 "pluginTransactionId": "1832456-3561234",
9 "reasonCode": 5005
10 }
11};
Payment with 3DS verification

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 createTransaction = async (options) => {
6 //Logic for creating a new transaction with the payment provider.
7 return {
8 "pluginTransactionId": "1832456-3561234",
9 "redirectUrl": "https://www.example.com/redirect-from-sale"
10 }
11};