Redirect to Wix-Managed Pages

Share your feedback
Reach out to us with feedback and suggestions to improve the Wix Headless experience, and join the Headless channel of the Devs on Wix Discord community to discuss features and connect with our growing community of developers.

Wix Headless provides you with the flexibility to create an app or site on any platform and take advantage of Wix's backend business solutions via APIs. However, for certain processes, such as authentication and checkout, you can save time and effort by redirecting visitors to frontend pages Wix implements for you.

For example, your site can temporarily redirect a visitor to a Wix-managed page for authentication or for a checkout process for a Bookings, eCommerce, Events, or Paid Plans transaction. When the process is over, Wix redirects the visitor back to your external site.

For instructions on redirecting to Wix for authorization, login, and logout, see Handle Members with Managed Login.

To take advantage of Wix's checkout services, you need to redirect to a Wix-managed checkout page using the Redirects API.

Prerequisites

Redirect flow

To use Wix-managed checkout services:

  1. Get the data you need for the redirection
  2. Determine the post-flow URL
  3. Use the Redirects API to get a custom redirect session URL
  4. Redirect your visitor to the URL provided
  5. Handle the next stage in your visitor flow

Step 1: Get the data you need for the redirection

Determine which checkout service you need. For example, Bookings, eCommerce, Events, or Paid Plans.

In the documentation for createRedirectSession(), in the options body parameter, find the property matching the checkout type you need. For example, options.eventsCheckout or options.ecomCheckout.

In the property descriptions, find the APIs you can use to get the information you need to pass to createRedirectSession(). For example, for options.ecomCheckout you can use createCheckout() or createCheckoutFromCurrentCart().

Call whichever functions are appropriate for obtaining the data you need for the desired checkout.

Step 2: Determine the post-flow URL

To implement a redirect session, it's essential to identify the destination for visitors on your external site once the Wix-managed flow concludes.

When developing your external site, determine a post-flow URL. This is the URL your visitors will be redirected back to when the Wix-managed flow is over.

For greater customization, you may also provide callback URLs for specific purposes, such as a custom thank you page on your external site. If you don't provide this, a standard page is used. See createRedirectSession() for details.

Note: Wix returns visitors to a URL you provide only if its domain has been authorized in advance. The URL must be under an allowed redirect domain.

Step 3: Use the Redirects API to get a custom redirect session URL

You now have the information you need to generate a URL for a Wix-managed checkout.

To generate the redirect session URL, call createRedirectSession(). Pass the data that is needed for your redirect session type. Also pass your post-flow URL and any optional callback URLs in the callbacks parameter.

For example, if you're performing an eComm checkout, pass the data needed for your checkout in the appropriate property of the options body parameter, such as options.eventsCheckout or options.ecomCheckout. Also pass your post-flow URL and any optional callback URLs in options.callbacks.

Copy
1

The function returns a single-use redirect session URL in redirectSession.fullUrl.

Copy
1

Step 4: Redirect your visitor to the URL provided

Redirect your visitor to the URL returned by createRedirectSession(). The URL contains the information needed for Wix to process the checkout, including the post-flow URL to redirect the visitor back to on your external site.

For example:

Copy
1

Note: You can customize the domain that visitors see when your external site redirects them to Wix-managed pages. Learn how to connect a domain for Wix-managed pages.

Step 5: Handle the next stage in your visitor flow

Wix redirects the visitor back to the URL (or URLs) you provided, so make sure to implement the next stage in your flow at this address.

Upon redirecting back to your site, Wix includes a wixMemberLoggedIn boolean query parameter. If set to true, this indicates that a visitor successfully logged in during the preceding Wix-managed process.

Additionally, Wix passes specific query parameters depending on the checkout type. For details, refer to options.callbacks in createRedirectSession().

Was this helpful?
Yes
No