> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# GetCheckoutURL

# Package: purchaseFlow

# Namespace: CartService

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/purchase-flow/cart-v2/get-checkout-url.md

## Permission Scopes:
Read Carts V2 (PII): SCOPE.ECOM.READ-CARTS-V2_LIMITED

## Introduction

Retrieves the checkout URL for the cart.

By default, this is the standard Wix checkout page.
If `customCheckoutUrl` is set, it overrides the default and is returned as the checkout URL.

---

## REST API

### Schema

```
 Method: getCheckoutUrl
 Description: Retrieves the checkout URL for the cart.  By default, this is the standard Wix checkout page. If `customCheckoutUrl` is set, it overrides the default and is returned as the checkout URL.
 URL: https://www.wixapis.com/ecom/v2/carts/{cartId}/get-checkout-url
 Method: POST
 Method parameters:
   param name: currencyCode | type: currencyCode | description: Checkout currency parameter to append as a query param  | validation: format CURRENCY
 Return type: GetCheckoutURLResponse
  - name: checkoutUrl | type: string | description: The checkout URL.  | validation: format WEB_URL

 Possible Errors:
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: SITE_NOT_PUBLISHED | Description: The site isn't published.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: CHECKOUT_PAGE_NOT_FOUND | Description: Couldn't find the checkout page.


```

### Examples

### Get Checkout URL
Retrieves the checkout page URL for a cart.

```curl
curl -X POST \
'https://www.wixapis.com/ecom/v2/carts/ca727402-f531-4bcf-ab09-db70ea0bd008/get-checkout-url' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.ecom.cartV2.getCheckoutUrl(cartId, options)
 Description: Retrieves the checkout URL for the cart.  By default, this is the standard Wix checkout page. If `customCheckoutUrl` is set, it overrides the default and is returned as the checkout URL.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  cartId
 Method parameters: 
   param name: cartId | type: string | description: GUID of the Cart to calculate. | required: true | validation: format GUID
   param name: options | type: GetCheckoutURLOptions  none  
        - name: currencyCode | type: string | description: Checkout currency parameter to append as a query param  | validation: format CURRENCY
 Return type: PROMISE<GetCheckoutURLResponse>
  - name: checkoutUrl | type: string | description: The checkout URL.  | validation: format WEB_URL

 Possible Errors:
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: SITE_NOT_PUBLISHED | Description: The site isn't published.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: CHECKOUT_PAGE_NOT_FOUND | Description: Couldn't find the checkout page.


```

### Examples

### Get a cart"s checkout URL
```javascript
import { cartV2 } from "@wix/ecom";

async function getCheckoutURL() {
  const response = await cartV2.getCheckoutURL(
    "ca727402-f531-4bcf-ab09-db70ea0bd008",
  );
}

/* Promise resolves to:
 * {
 *   "checkoutUrl": "https://www.mystore.com/checkout?checkoutId=ca727402-f531-4bcf-ab09-db70ea0bd008"
 * }
 */

```

### getCheckoutUrl (self-hosted)
Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { cartV2 } from '@wix/ecom';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { cartV2 },
  // Include the auth strategy and host as relevant
});


async function getCheckoutUrl(cartId,options) {
  const response = await myWixClient.cartV2.getCheckoutUrl(cartId,options);
};
```

---