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
Information to use when creating a new transaction.
Returns
Fulfilled -
Return Type:
NAME
TYPE
DESCRIPTION
Payment provider transaction ID.
Error code supplied by the payment provider if the transaction request fails.
Error message supplied by the payment provider if the transaction request fails.
URL on the payment provider's site to forward the site visitor to for payment processing.
Was this helpful?
1// Place this code in the <my-extension-name>.js file2// in the 'payment-provider' folder of the3// Custom Extensions section on your site.45export const createTransaction = async (options) => {6 //Logic for creating a new transaction with the payment provider.7 return {8 "pluginTransactionId": "1832456-3561234",9 }10};
1// Place this code in the <my-extension-name>.js file2// in the 'payment-provider' folder of the3// Custom Extensions section on your site.45export 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};
1// Place this code in the <my-extension-name>.js file2// in the 'payment-provider' folder of the3// Custom Extensions section on your site.45export const createTransaction = async (options) => {6 //Logic for creating a new transaction with the payment provider.7 return {8 "pluginTransactionId": "1832456-3561234",9 "reasonCode": 500510 }11};
1// Place this code in the <my-extension-name>.js file2// in the 'payment-provider' folder of the3// Custom Extensions section on your site.45export 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};