# InLine Checkout methods and parameters

## Overview

Minimize your customers' effort by collecting their order/billing information and passing it to InLine Checkout. Simplify the checkout experience and enable your customers to place orders only by confirming their payment information.

{% hint style="info" icon="lightbulb" %}

#### Related links

Our InLine Checkout enables you to offer a seamless checkout experience for your clients. Download this solution brief to learn how!

<a href="https://www.2checkout.com/lp/2checkout_inline_cart.html" class="button primary" data-icon="book-open-lines">Read more</a>
{% endhint %}

## Advanced InLine Checkout experience

InLine Checkout offers you advanced control over the ordering process, for minimizing the customer's effort during the purchase. You can send the billing and delivery information directly to the cart if they are collected on your website by a shopping cart application. InLine Checkout enables you to:

* Place test orders
* Set coupons codes in cart
* Set the cart language
* Set the cart currency
* Set a redirect URL after a finalized purchase

We recently improved the perceived loading time for the InLine checkout ordering engine by pre-loading the cart iframe. Faster loading time for the InLine cart means an enhanced shopping experience and helps you to increase conversion rates with no other effort on your side. See more details below in the Cart methods table.

## Send information to InLine Checkout

After you integrate the InLine Checkout JavaScript code in your website application, you get access to the library that allows you to add products, control billing and shipping details, and start the checkout process. Follow the instructions below to control the information displayed by InLine Checkout.

### Handling products

Products are handled by the products' service. This service allows you to retrieve the list of added products, add products to cart, remove individual products, or remove all the products from the cart.

Use the methods and product attributes listed below to add/remove products from the cart.

#### Product attributes

<table data-header-hidden="false" data-header-sticky><thead><tr><th width="144">Attributes</th><th>Type / Description</th></tr></thead><tbody><tr><td><code>code</code></td><td><p><strong>String</strong></p><p>Product code assigned by you when creating the product. Required for catalog products.</p></td></tr><tr><td><code>type</code></td><td><p><strong>String</strong></p><p>Product type. Required only for dynamic products. Possible values: [PRODUCT, SHIPPING, TAX]. Default value is PRODUCT.</p></td></tr><tr><td><code>name</code></td><td><p><strong>String</strong></p><p>Product name. Required for dynamic products.</p></td></tr><tr><td><code>price</code></td><td><p><strong>String - for dynamic products</strong></p><p>Product price. It is required for dynamic products. </p><p></p><p><strong>Object - for catalog products with on-the-fly pricing</strong></p><p>Product price; required for catalog products with on-the-fly pricing and includes value and currency.</p></td></tr><tr><td><code>tangible</code></td><td><p><strong>String</strong></p><p>Product tangible flag. Required only for dynamic products. Default value is FALSE.</p></td></tr><tr><td><code>quantity</code></td><td><p><strong>String</strong></p><p>Product quantity. Default value is 1. Required for catalog products with on-the-fly pricing.</p></td></tr><tr><td><code>options</code></td><td><p><strong>Array</strong></p><p>The product price options. It is supported for both catalog and dynamic products. Required for catalog products with on-the-fly pricing.</p><p>Product price options structure for dynamic products:</p><ul><li><strong>Name</strong> (String)- The price option name</li><li><strong>Value</strong> (String, Number, Array of strings or numbers) - The price option value</li><li><strong>Surcharge</strong> (string) - The price option surcharge - applicable only for dynamic products</li></ul><p>Product price options structure for catalog products:</p><ul><li><strong>Name</strong> (String) – The unique code of the pricing OPTION GROUP</li><li><strong>Value</strong> (String) – The unique code of the pricing OPTION</li></ul></td></tr><tr><td><code>recurrence</code></td><td><p><strong>Object</strong></p><p>Required for dynamic products.</p><p>Possible values:</p><ul><li>DAY</li><li>WEEK</li><li>MONTH</li><li>YEAR</li><li>FOREVER (available only for <strong>duration</strong>)</li></ul><p>This parameter is conditioned by two other parameters: duration and <code>renewalPrice</code>.</p></td></tr><tr><td><code>duration</code></td><td><p><strong>Object</strong></p><p>Sets the duration of the recurrence. Required for dynamic products.</p></td></tr><tr><td><code>renewalPrice</code></td><td><p><strong>Integer</strong></p><p>Sets the price to be applied to the renewal order. Required for dynamic products.</p></td></tr></tbody></table>

#### Product methods

<table><thead><tr><th width="129.00006103515625">Methods</th><th>Description</th></tr></thead><tbody><tr><td><strong>add</strong></td><td>Adds a single product to the list. Use the above list of parameters to add a product to cart.</td></tr><tr><td><strong>remove</strong></td><td>Removes a product from the list.</td></tr><tr><td><strong>addMany</strong></td><td>Adds an array of product objects to the main list.</td></tr><tr><td><strong>removeAll</strong></td><td>Removes all products from the list.</td></tr><tr><td><strong>getAll</strong></td><td>Retrieves the products list.</td></tr></tbody></table>

### Handling billing details

Billing details are handled by the **billing service**. Each billing information is controlled by a setter method.

Use the attributes and methods listed below to control the billing information displayed in the cart. Customers are able to fill in their billing information in the overlay provided by InLine Checkout. In case your shopping cart application collects customer's billing information, use the attributes and methods listed below to pass that information over to the cart.

#### Billing details attributes

<table data-header-hidden="false" data-header-sticky><thead><tr><th width="147.00006103515625">Attributes</th><th>Type / Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><p><strong>String</strong></p><p>Customer billing name. Example: "John Doe".</p></td></tr><tr><td><code>email</code></td><td><p><strong>String</strong></p><p>Customer billing email. Example: "john.doe@email.com".</p></td></tr><tr><td><code>phone</code></td><td><p><strong>String</strong></p><p>Customer billing phone number. Example: "403940281923".</p></td></tr><tr><td><code>country</code></td><td><p><strong>String</strong> </p><p>Customer billing country. Example: "US".</p></td></tr><tr><td><code>city</code></td><td><p><strong>String</strong> </p><p>Customer billing city. Example: "Los Angeles".</p></td></tr><tr><td><code>state</code></td><td><p><strong>String</strong> </p><p>Customer billing state. Example: "California".</p></td></tr><tr><td><code>zip</code></td><td><p><strong>String</strong> </p><p>Customer billing zip code. Example: "90078".</p></td></tr><tr><td><code>address</code></td><td><p><strong>String</strong> </p><p>Customer billing address. Example: "1093 Rodeo Drive".</p></td></tr><tr><td><code>address2</code></td><td><p><strong>String</strong> </p><p>Customer billing additional address information. "293 Postal Box".</p></td></tr><tr><td><code>company-name</code></td><td><p><strong>String</strong></p><p>CompanyName</p><p>When sending the Company name the Company checkout flow will be triggered. Otherwise, the default checkout flow for InLine cart is the individual flow.</p></td></tr><tr><td><code>fiscal-code</code></td><td><p><strong>String</strong></p><p>fiscalCode</p><p>When sending the Fiscal code, the Company checkout flow will be triggered only if also another company flow relevant parameter will be also sent (Company name and/or Tax office). Otherwise, the default checkout flow for InLine cart is the individual flow.</p></td></tr><tr><td><code>tax-office</code></td><td><p><strong>String</strong> </p><p>taxOffice</p><p>When sending the Tax office the Company checkout flow will be triggered. Otherwise, the default checkout flow for InLine cart is the individual flow.</p></td></tr></tbody></table>

#### Billing details methods

<table><thead><tr><th width="333">Methods</th><th>Description</th></tr></thead><tbody><tr><td><strong>setData</strong></td><td>Sets the entire billing data.</td></tr><tr><td><strong>setName</strong></td><td>Sets the billing name.</td></tr><tr><td><strong>setEmail</strong></td><td>Sets the billing email.</td></tr><tr><td><strong>setPhone</strong></td><td>Sets the billing phone.</td></tr><tr><td><strong>setCountry</strong></td><td>Sets the billing country.</td></tr><tr><td><strong>setCity</strong></td><td>Sets the billing city.</td></tr><tr><td><strong>setState</strong></td><td>Sets the billing state.</td></tr><tr><td><strong>setZip</strong></td><td>Sets the billing zip code.</td></tr><tr><td><strong>setAddress</strong></td><td>Sets the billing address.</td></tr><tr><td><strong>setAddress2</strong></td><td>Sets additional billing address information.</td></tr><tr><td><strong>reset</strong></td><td>Resets the billing data.</td></tr><tr><td><strong>setCompanyName</strong></td><td>Sets the billing Company name.</td></tr><tr><td><strong>setFiscalCode</strong></td><td>Sets the billing Fiscal code.</td></tr><tr><td><strong>setTaxCode</strong></td><td>Sets the billing Tax code.</td></tr></tbody></table>

### Handling shipping details

Shipping details are handled by the **shipping service**. Each shipping information is controlled by a setter method.

Use the attributes and methods listed below to control the shipping information displayed in the cart. In case you use a shopping cart application that collects the shipping information, use the attributes and methods listed below to pass that information over to the cart.

#### Shipping details attributes

<table><thead><tr><th width="170">Attributes</th><th>Type / Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><p><strong>String</strong> </p><p>Customer shipping name. Example: "John Doe".</p></td></tr><tr><td><code>email</code></td><td><p><strong>String</strong></p><p>Customer shipping email. Example: "john.doe@email.com".</p></td></tr><tr><td><code>phone</code></td><td><p><strong>String</strong></p><p>Customer shipping phone number. Example: "403940281923".</p></td></tr><tr><td><code>country</code></td><td><p><strong>String</strong></p><p>Customer shipping country. Example: "United States of America".</p></td></tr><tr><td><code>city</code></td><td><p><strong>String</strong></p><p>Customer shipping city. Example: "Los Angeles".</p></td></tr><tr><td><code>state</code></td><td><p><strong>String</strong></p><p>Customer shipping state. Example: "California".</p></td></tr><tr><td><code>zip</code></td><td><p><strong>String</strong></p><p>Customer shipping zip code. Example: "90078".</p></td></tr><tr><td><code>address</code></td><td><p><strong>String</strong></p><p>Customer shipping address. Example: "1093 Rodeo Drive".</p></td></tr><tr><td><code>address2</code></td><td><p><strong>String</strong></p><p>Customer shipping additional address information. "293 Postal Box".</p></td></tr></tbody></table>

#### Shipping details methods

<table><thead><tr><th width="313">Methods</th><th>Description</th></tr></thead><tbody><tr><td><strong>setData</strong></td><td>Sets the entire shipping data.</td></tr><tr><td><strong>setName</strong></td><td>Sets the shipping name.</td></tr><tr><td><strong>setEmail</strong></td><td>Sets the shipping email.</td></tr><tr><td><strong>setPhone</strong></td><td>Sets the shipping phone.</td></tr><tr><td><strong>setCountry</strong></td><td>Sets the shipping country.</td></tr><tr><td><strong>setCity</strong></td><td>Sets the shipping city.</td></tr><tr><td><strong>setState</strong></td><td>Sets the shipping state.</td></tr><tr><td><strong>setZip</strong></td><td>Sets the shipping zip code.</td></tr><tr><td><strong>setAddress</strong></td><td>Sets the shipping address.</td></tr><tr><td><strong>setAddress2</strong></td><td>Sets additional shipping address information.</td></tr><tr><td><strong>reset</strong></td><td>Resets the shipping data.</td></tr></tbody></table>

### Handle the Checkout process

Control the cart behavior by using the **cart service**. Use the **checkout** method to start the **InLine Checkout** experience.

#### Cart attributes

<table><thead><tr><th width="248">Attributes</th><th>Type / Description</th></tr></thead><tbody><tr><td><code>source</code></td><td><p><strong>String</strong></p><p>Sale originating source. Example: "YouTube Channel".</p></td></tr><tr><td><code>language</code></td><td><p><strong>String</strong></p><p>Cart language code. Example: "FR".</p></td></tr><tr><td><code>currency</code></td><td><p><strong>String</strong></p><p>Cart currency code. Example: "USD".</p></td></tr><tr><td><code>test</code></td><td><p><strong>Boolean</strong></p><p>Test order flag. Possible values:</p><ul><li><strong>true</strong> for test orders</li><li><strong>false</strong> for real orders</li></ul></td></tr><tr><td><code>setReturnMethod</code></td><td><p><strong>String</strong></p><p>Sets the <code>ReturnMethod</code> object. URL to which customer is redirected after a successful payment. Example: https://www.merchant-website.com/.</p></td></tr><tr><td><code>coupon</code></td><td><p><strong>String</strong></p><p>Order promotion coupon. Example: "50%off".</p></td></tr><tr><td><code>token</code></td><td><p><strong>String</strong></p><p>Token for the authorization code.</p></td></tr><tr><td><code>expiration</code></td><td><p><strong>String</strong> </p><p>The expiration date for the authorization.</p></td></tr><tr><td><code>orderExternalRef</code></td><td><p><strong>String</strong></p><p>The unique identifier of an order placed in the 2Checkout system, mirroring the reference you're using to manage order data in your system.</p></td></tr><tr><td><code>CustomerReference</code></td><td><p><strong>Integer</strong></p><p>The 2Checkout system generates default customer numerical (integer) IDs automatically for all orders containing products that feature subscriptions. Can be used for new acquisitions aggregating new subscriptions under an existing Customer account.</p></td></tr><tr><td><code>ExternalCustomerReference</code></td><td><p><strong>String</strong></p><p>The external customer reference.</p></td></tr><tr><td><code>autoAdvance</code></td><td><p><strong>Boolean</strong></p><p>Auto-advanced flag. </p><p>Possible values:</p><ul><li><strong>true</strong> for auto-advance</li><li><strong>false</strong> for cart flow without auto-advance</li></ul></td></tr></tbody></table>

#### Cart methods

<table><thead><tr><th width="277">Methods</th><th>Description</th></tr></thead><tbody><tr><td><strong>register*</strong></td><td><p>Makes the products, billing, shipping, cart and formParser services available. </p><p>These services are unavailable unless this method is called.</p></td></tr><tr><td><strong>checkout</strong></td><td>Starts the cart service which displays the overlay payment form.</td></tr><tr><td><strong>addCoupon</strong></td><td>Adds a coupon to the coupons list.</td></tr><tr><td><strong>addCoupons</strong></td><td>Adds coupons in the cart from a list array.</td></tr><tr><td><strong>removeCoupon</strong></td><td>Removes a coupon from the coupons list.</td></tr><tr><td><strong>removeCoupons</strong></td><td>Clears all coupons from the cart instance.</td></tr><tr><td><strong>setSource</strong></td><td>Sets the order source.</td></tr><tr><td><strong>setCurrency</strong></td><td>Sets the currency on the cart instance.</td></tr><tr><td><strong>setLanguage</strong></td><td>Sets the language code for the order.</td></tr><tr><td><strong>setReturnMethod</strong></td><td><p>Sets the ReturnMethod object by calling TwoCoInlineCart.cart.setReturnMethod({url, type}). </p><p>URL to which customer is redirected after a successful payment. Example: <a href="https://www.merchant-website.com/">https://www.merchant-website.com</a>.</p></td></tr><tr><td><strong>setTest</strong></td><td>Send <strong>true</strong> for placing a test order.</td></tr><tr><td><strong>setLoaderState</strong></td><td>Handles the overlay window visibility.</td></tr><tr><td><strong>setIframeState</strong></td><td>Handles the loader visibility.</td></tr><tr><td><strong>reloadCart</strong></td><td>Reloads the cart instance.</td></tr><tr><td><strong>setOrderExternalRef</strong></td><td>Sets the order external reference.</td></tr><tr><td><strong>setCustomerReference</strong></td><td>Sets 2Checkout customer reference.</td></tr><tr><td><strong>setExternalCustomerReference</strong></td><td>Sets external customer reference.</td></tr><tr><td><strong>setCartLockedFlag</strong></td><td><p><strong>Boolean</strong></p><p>Lock cart flag. Possible values:</p><ul><li><strong>true</strong> </li><li><strong>false</strong></li></ul></td></tr><tr><td><strong>setIframeLoad</strong></td><td>One string parameter: 'immediate' or 'delayed'. Additionally, the InLine cart can also be set by using TwoCoInlineCart',{"app":{"merchant":"MERCHANT_CODE", "iframeLoad": "immediate"} instead of TwoCoInlineCart.setup.setIframeLoad.</td></tr><tr><td><strong>setIframeLoadDelay</strong></td><td>One number parameter; sets the time in milliseconds. Modify the pre-loading time of the cart iframe by adding a delay using the TwoCoInlineCart.setup.setIframeLoadDelay method.</td></tr><tr><td><strong>setReset</strong></td><td><p><strong>Boolean</strong></p><p>Erases all previous cart sessions from the customer's browser upon opening a new cart to avoid overlapping of the buy-link parameters. Possible values:</p><ul><li><strong>true</strong> </li><li><strong>false</strong> </li></ul></td></tr><tr><td><strong>cart.setAutoAdvance</strong></td><td>Sets the auto-advanced cart behavior. If all mandatory checkout parameters are prefilled, the shopper is advanced to the payment details page.</td></tr><tr><td><strong>addAdditionalField</strong></td><td>Sets an additional field for your account.</td></tr></tbody></table>

Retrieve cart attributes from InLine Checkout by using get methods: **getTest, getLanguage, getCurrency, getSource, getCoupons, getSuccessURL, getCustomerReference, getExternalCustomerReference, getCartLockedFlag.**

**\***&#x57;hen inserting the JavaScript code snippet from your [Control Panel](https://secure.2checkout.com/cpanel/integration.php?flow=InlineCart) into your e-commerce website, you will get access to the library that allows you to add products, control billing and shipping details, and start the checkout process, without having to call the register() method.

## Subscribe to shopping cart events

To subscribe to shopping cart events you need to call the events service subscribe method with the event name as the first argument and a callback function as the second argument.

1. 'cart:opened' - triggers when the shopping cart is opened.
2. 'cart:closed' - triggers when the shopping cart is closed.
3. 'payment:finalized' - triggers when the payment has finalized.
4. 'fulfillment:finalized' - triggers when the fulfillment is completed.

```javascript
TwoCoInLineCart.events.subscribe('cart:opened', function () {
    console.log('cart:opened triggered');
});
```

## Samples

### Sample request for catalog products

```java
TwoCoInlineCart.setup.setMerchant('merchantCode'); // your Merchant code
TwoCoInlineCart.register();

TwoCoInlineCart.billing.setCountry('US'); // customer billing country
TwoCoInlineCart.billing.setName('John Doe'); // customer billing Name
TwoCoInlineCart.billing.setEmail('john.doe@email.com'); // customer email address
TwoCoInlineCart.billing.setCompanyName('<company name>')
TwoCoInlineCart.billing.setFiscalCode('<fiscal code>')
TwoCoInlineCart.billing.setTaxOffice('<tax office>')
TwoCoInlineCart.cart.setReset(true); // erase previous cart sessions

TwoCoInlineCart.shipping.setName('Jane Doe'); // customer Delivery name
TwoCoInlineCart.shipping.setEmail('jane.doe@email.com'); // customer Delivery email

TwoCoInlineCart.products.add({
    code: 'the-2co-product-code',
    quantity: 3
    options: [{
       name: 'color',
       value: 'red'
   }]
});

TwoCoInlineCart.products.addMany([
    {
        type: 'PRODUCT',
        name: 'product 1',
        price: 10,
        tangible: true,
        quantity: 1,
    },
    {
        type: 'PRODUCT',
        name: 'product 2',
        price: 30,
        tangible: true,
        quantity: 1,
    }
]);

TwoCoInlineCart.cart.addCoupon('50%OFF'); // discount code
TwoCoInlineCart.cart.setCurrency('GBP'); // order currency
TwoCoInlineCart.cart.setLanguage('fr'); // language code
TwoCoInlineCart.cart.setOrderExternalRef('1231231'); // order external reference
TwoCoInlineCart.cart.setExternalCustomerReference('ID123extern'); // external customer reference
TwoCoInlineCart.cart.checkout(); // start checkout process
```

### Sample request for dynamic products

```java
TwoCoInlineCart.setup.setMerchant('merchantCode'); // your merchant code
TwoCoInlineCart.setup.setMode('DYNAMIC'); // product type
TwoCoInlineCart.register();

TwoCoInlineCart.cart.setCurrency('USD'); // order currency

TwoCoInlineCart.products.add({
name        : 'A test dynamic product',
recurrence:{
    unit: 'WEEK',
    length: 2
},
duration: {
    unit: 'YEAR',
    length: 1
},
renewalPrice: 100.99
});
TwoCoInlineCart.cart.checkout(); //start checkout process
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.2checkout.com/shopping-carts/inline/inline-checkout-methods-and-parameters.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
