createAndRedirectToCheckout( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Creates a new checkout based on the checkout template and redirects to the new checkout page.

Before using this function, you must have a checkout template available. Create a checkout template with createCheckoutTemplate().

To build a URL that uses this function, follow this format: https://www.wixapis.com/ecom/v1/checkout-templates/{checkoutTemplateId}/create-and-redirect-to-checkout?siteId={siteId}

To create a checkout but not automatically redirect to the checkout page, use createCheckoutFromTemplate().

Method Declaration
Copy
function createAndRedirectToCheckout(
  checkoutTemplateId: string,
  siteId: string,
): Promise<RawHttpResponse>;
Method Parameters
checkoutTemplateIdstringRequired

ID of the checkout template to use to create a checkout.


siteIdstringRequired

ID of the site associated with the checkout template.

Returns
Return Type:Promise<RawHttpResponse>
JavaScript
import { checkoutTemplates } from "wix-ecom-backend"; async function createAndRedirectToCheckout(checkoutTemplateId, siteId) { try { const result = await checkoutTemplates.createAndRedirectToCheckout( checkoutTemplateId, siteId, ); return result; } catch (error) { console.error(error); // Handle the error } }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?