...
There are two REST checkout APIs that we will cover in this tutorial: modern and legacy. Make sure you identify the proper checkout that you’re using. If in doubt, look at the Network tab in your browser development tools and see which XHR URLs your checkout is interacting with.
Modern REST Checkout API
Located at /rest/v2/checkout/ and available through the generated SDKS
Step 1
Before every update of your cart, populate the return URL with the current URL.
Code Block | ||
---|---|---|
| ||
cart.checkout.return_url = window.location.href; |
Step 2
If the URL contains the “returnToken” parameter then call the getCartByReturnToken method on the SDK
Legacy REST Checkout API
Located at /rest/cart
Step 1
Before every update of your cart, populate the return URL with the current URL.
Code Block |
---|
cart.returnUrl = window.location.href; |
Step 2
If the URL contains the “returnToken” parameter then call retrieve the cart by either specifying the query parameter “returnToken” of the request header of “X-UC-Return-Token” when retrieving the cart.
Example JavaScript Code to Read “returnToken” parameter from the URL
This function will return an object where the keys are the parameters on the URL, all properly decoded.
...