---
updatedAt: 2026-09-04T11:22:09.000Z
agentTools:
  projectIndex: https://docs.us.zip.co/llms.txt
---

# API Javascript SDK Implementation

The JavaScript SDK is a client-side initiated version of our [Gateway API](https://docs.us.zip.co/docs/custom-integration-guide#gateway-api) integration. It removes the need for a full-page redirect by managing the in-context rendering of the Zip checkout flow in a modal, the same way our Virtual Checkout solution does currently.

Zip takes care of the initial authorization API call through the openCheckout method, which is used with a custom DOM element, and will launch checkout in a popup window (or iframe depending on provided parameters). Read more below.

Zip communicates the results via a Webhook to a predefined endpoint on the merchant side, additionally to return the result on the client-side.

Each consecutive operation, such as void, capture, refund, or other, must be completed on the server side. Please refer to [our API documentation](https://docs.us.zip.co/docs/custom-integration-guide).

# Flow Diagrams

***

Depending on how the capture model works for an order, there may be no need to make additional calls to our API to complete an order.

**Auto capture**\
This will enable minimal server-side integration, and the order will be completed after the consumer has completed the Zip checkout flow. This also means that the installment plan will start right away and the order will be captured immediately upon order placement. This is recommended for instant orders or digital goods.

![](https://files.readme.io/162bfcd-API_Js_lib2x_1.png "API Js lib@2x (1).png")

<br />

**Delayed capture**\
This use-case is targeted for payment with a delay between the initial authorization and the order capture. This can also be used if the order requires multiple captures on the same authorization. The installment plan will start on the initial authorization, not on the capture. [Please refer to our API documentation](https://docs.us.zip.co/docs/custom-integration-guide#capture-an-order).

![](https://files.readme.io/e2e2336-API_Js_lib2x_2.png "API Js lib@2x (2).png")

# Implementation Guide

***

## Client-side

The client-side integration requires the following:

1. A reference to our CDN-hosted JavaScript library [see example](https://docs.us.zip.co/docs/api-javascript-sdk#section-javascript-reference) .
2. A signature that is computed server-side [see example](https://docs.us.zip.co/docs/api-javascript-sdk#calculating-the-signature--code-examples)
3. An HTML element to attach the click event that will trigger the openCheckout function. This element can be a custom HTML element, the Zip payment widget, or the Zip second chance widget.
4. JavaScript to attach one or more callback functions to customize the payment flow and handle checkout completion, including any potential errors.

> 📘 Using a Zip widget to initiate checkout
>
> Set the attribute `integrationType='api'`. Without this attribute, the payment flow defaults to a **Virtual Checkout**, and the `window.quadpay.apiCheckout` methods will not be available

<h3>Javascript Reference</h3>

There are two environments available, and you'll receive unique credentials for each:

* **Sandbox (Test) - US:** `https://cdn.sand.us.zip.co/v1/zip.js`
* **Production - US:** `https://cdn.us.zip.co/v1/zip.js`

Adding the sandbox script will automatically integrate with our sandbox services for testing. Importing the production script will result in real transactions.

The script can be loaded by adding a tag like:

```html
<script src="https://cdn.us.zip.co/v1/zip.js" type="text/javascript"></script>
```

The script can be added anywhere in the body or head area and loaded asynchronously. If loaded asynchronously, be sure to wait for its load to complete before invoking any operations against the library.

<h3>Start Checkout</h3>

Start the Zip checkout by calling `openCheckout`, typically in response to events like `click` or `keyDown` on a DOM element.

Zip provides a Branded button asset by using:

```html
<zip-button id="QPButton" integrationType="api></zip-button>
```

The below example is a button element, but this can be anything from radio buttons, drop-downs, or images.

```html
<input type="button" id="ZipButton" value="Pay with Zip"/>
```

#### Open Checkout Function

The openCheckout function is attached to a DOM element and initiates the Zip checkout flow with the [requestBody](https://docs.us.zip.co/docs/api-javascript-sdk#requestbody) and [signature](https://docs.us.zip.co/docs/api-javascript-sdk#calculating-the-signature--code-examples) input. An example is below:

```javascript
const zipButton = document.getElementById('ZipButton')

zipButton.addEventListener('click', () => {
  window.quadpay.apiCheckout.openCheckout(requestBody, signature)
})
```
```jsx React
const handleClick = () => {
  window.quadpay.apiCheckout.openCheckout(requestBody, signature)
}

const handleKeyDown = () => {
  if (event.key === 'Enter') {
    window.quadpay.apiCheckout.openCheckout(requestBody, signature)
  }
}

<input 
  type="button"
  id="ZipButton"
  value="Pay with Zip"
  onClick={handleClick}
  onKeyDown={(event) =>  handleKeyDown(event)}
></input>
```

> 🚧 Potential Pitfall!
>
> Be sure that the call to `openCheckout(requestBody, signature)` exists in the same context as the `onClick` handler. Calling `openCheckout()` in a callback or Promise might prevent the pop-up from appearing on some browsers.

### SDK Methods

These methods handle events by passing them to their assigned callback functions, which may be called asynchronously.

#### onComplete

The `onComplete` method runs when a customer completes the Zip checkout. It receives the [Zip Response](https://docs.us.zip.co/docs/api-javascript-sdk#zip-response). In the [Express flow](https://docs.us.zip.co/docs/express-checkout), the `shippingAddress`([Address](https://docs.us.zip.co/docs/api-javascript-sdk#address)) object will also be sent.

```javascript
/**
 * @param {Object} result - The result object
 * @param {Object} result.customer - The Customer object
 * @param {Object} result.object - The Zip order object
 * @param {Object} [result.shippingAddress] - Address object (only on Express Checkout)
 */

window.quadpay.apiCheckout.onComplete((result) => {
  // your code goes here
});
```

#### onClose

`onClose` is an optional method that runs when a customer closes the Zip checkout window or their session times out. It receives a string describing why the checkout was closed.

```javascript
/**
 * @param {string} message - A message explaining why checkout was closed
 */

window.quadpay.apiCheckout.onClose((message) => {
  // your code goes here
})
```

#### onError

`onError` is an optional method that runs if the [requestBody](https://docs.us.zip.co/docs/api-javascript-sdk#requestbody) passed to `startCheckout()` fails validation. It receives an array of strings describing which attributes failed validation.

```javascript
/**
 * @param {string[]} errors - An array of error messages
 */

window.quadpay.apiCheckout.onError((errors) => {
  // your code goes here
})
```

## Server-side

To enable secure communication between the SDK and our server, all operations are secured with an HMAC-SHA256 one-way hash that is performed using a shared secret key. **The key is provided by Zip and will differ depending on the environment used.** The Signatures are generated based on the requests **to sign the entire Zip requestBody object.**

**JSON RequestBody example:**

```json
{
        "merchantId": "[Insert merchant Id]",
        "merchantReference": "your-unique-order-id",
        "order": {}, // Order object reference can be found below
        "callbackUrl": "your-url-for-callbacks",
        "capture": "true"
}
```

[block:parameters]
{
  "data": {
    "h-0": "Properties",
    "h-1": "Type",
    "h-2": "Optional/Required",
    "h-3": "Description",
    "0-0": "merchantId",
    "0-1": "GUID",
    "0-2": "Required",
    "0-3": "Your identifier provided by Zip",
    "1-0": "merchantReference",
    "1-1": "String",
    "1-2": "Required",
    "1-3": "A unique order ID from the merchant",
    "2-0": "order ([see model](https://docs.us.zip.co/docs/api-javascript-sdk#object-models))",
    "2-1": "Order object",
    "2-2": "Required",
    "2-3": "A custom object representing the order. Example below.",
    "3-0": "callbackUrl",
    "3-1": "String",
    "3-2": "Optional",
    "3-3": "A URL that will receive the webhook request about the result of this operation.  \nIf capture is set to true, a callbackUrl is required to verify the order details.",
    "4-0": "capture",
    "4-1": "Boolean",
    "4-2": "Required (default true)",
    "4-3": "Indicated is the order will be auto-captured or additional operations for capture will be completed to capture."
  },
  "cols": 4,
  "rows": 5,
  "align": [
    "left",
    "left",
    "left",
    "left"
  ]
}
[/block]

### Calculating the Signature — Code Examples

Implementing this is language specific. Here are examples that can generate these hashes for you:

```csharp
/// Takes the secret key and the JSON in string format
public string Compute(string secretKey, string json)
{
    var bytes = Encoding.UTF8.GetBytes(json);
    return this.Compute(secretKey, bytes);
}

/// If your entire request body is passed in as bytes (e.g. POST JSON request), this will give you the correct hash
public string Compute(string secretKey, byte[] bytes)
{
    using (var hmacsha256 = new HMACSHA256(Encoding.UTF8.GetBytes(secretKey)))
    {
        var hash = hmacsha256.ComputeHash(bytes);
        return Convert.ToBase64String(hash);
    }
}
```
```php
$signature = base64_encode(hash_hmac('sha256', $data, $secret, true));
```
```javascript Node.js
import crypto from 'crypto'

const data = JSON.stringify(requestBody);
const key = 'your_api_key_here';
const signature = crypto
	.createHmac('sha256', key)
	.update(data)
	.digest('base64');
```
```python
import hmac
import hashlib
import base64
import json

request_body = {"key": "value"}  # Replace with actual data
data = json.dumps(request_body)
key = 'your_api_key_here'

signature = base64.b64encode(
    hmac.new(key.encode(), data.encode(), hashlib.sha256).digest()
).decode()

print(signature)

```
```go Go
package main

import (
    "crypto/hmac"
    "crypto/sha256"
    "encoding/base64"
    "encoding/json"
    "fmt"
)

func main() {
    requestBody := map[string]interface{}{"key": "value"} // Replace with actual data
    data, _ := json.Marshal(requestBody)
    key := "your_api_key_here"

    h := hmac.New(sha256.New, []byte(key))
    h.Write(data)

    signature := base64.StdEncoding.EncodeToString(h.Sum(nil))
}

```
```ruby
require 'openssl'
require 'base64'
require 'json'

request_body = { key: 'value' } # Replace with actual data
data = request_body.to_json
key = 'your_api_key_here'

digest = OpenSSL::HMAC.digest('sha256', key, data)
signature = Base64.strict_encode64(digest)

```

<br />

### Webhooks

Zip provides an async webhook message for events when a consumer completes the Zip checkout flow and when API calls are completed.

**Webhook message format**\
[Authorization (at user completion of Zip checkout)](https://docs.us.zip.co/docs/custom-integration-guide#authorize-an-order)

<br />

## Example code

```javascript
// retrieve server-side computed signature
const signature = await fetch('/calculate-signature')

// format order object
const order = {
  amount: 123.45,
  curency: 'USD',
  shippingAmount: 10,
  taxAmount: 13.45,
  email: 'name@email.com',
  firstName: 'John',
  lastName: 'Doe',
  phoneNumber: '+15555555555',
  billingAddress: {
    line1: '123 street',
    address2: '',
    city: 'New York',
    state: 'NY',
    postalCode: '10001',
    country: 'US'
  },
  lineItems: [
    {
      name: 'Item Name',
      description: 'Item description',
      quantity: 1,
      price: 123.45,
      sku: '12345678',
    },
  ]
}

// format Zip checkout request body
const requestBody = {
  merchantId: '[Insert merchant Id]',
  merchantReference: 'merchant-order-id', // Unique order id from Merchant
  order,
  callbackUrl: 'http://merchant-url',
  capture: true,
  checkoutFlow: 'standard'
}

// initiate checkout method
window.quadpay.apiCheckout.openCheckout(requestBody, signature)

// runs when Zip checkout completes
window.quadpay.apiCheckout.onComplete((result) => {
  // your code goes here
})

// runs when Zip checkout popup is closed or session times out
window.quadpay.apiCheckout.onClose((message) => {
  // your code goes here
})

// runs when requestBody validation fails in openCheckout()
window.quadpay.apiCheckout.onError((errors) => {
  // your code goes here
})
```

# Functions

***

### focusCheckout

This method allows you to programmatically bring focus to the pop-up window once checkout has been opened.

```javascript
window.quadpay.apiCheckout.focusCheckout()
```

### closeCheckout

This method force-closes the Zip checkout window and ends the user's Zip session.

```javascript
window.quadpay.apiCheckout.closeCheckout()
```

# Object Models

***

## Order

[block:html]
{
  "html": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n  <title>API Documentation</title>\n  <style>\n    body {\n      font-family: Arial, sans-serif;\n      padding: 20px;\n    }\n\n    .container {\n      max-width: 1200px;\n      margin: auto;\n      display: grid;\n      grid-template-columns: 1.25fr 1fr;\n      gap: 20px;\n    }\n\n    .toggle-buttons {\n      display: flex;\n      gap: 10px;\n      margin-bottom: 20px;\n    }\n\n    /* Hide radio buttons */\n    input[type=\"radio\"] {\n      display: none;\n    }\n\n    /* Style labels as toggle buttons */\n    .toggle-buttons label {\n      cursor: pointer;\n      padding: 10px 20px;\n      border: 1px solid #6542BE;\n      border-radius: 8px;\n      background-color: #e0e0e0;\n      color: #333;\n      transition: background-color 0.3s;\n    }\n\n    /* Active state styling */\n    input[type=\"radio\"]:checked + label {\n      background-color: #6542BE;\n      color: white;\n    }\n\n    /* Content sections styling */\n    .section {\n      padding: 15px;\n      background-color: #e5dff7;\n      border-radius: 10px;\n      margin-top: 10px;\n    }\n\n    .json-section, .definition-section {\n      padding: 20px;\n      border-radius: 8px;\n      font-size: 14px;\n      border: 1px solid #6542BE;\n      background-color: #f9f9f9;\n      height: fit-content;\n      width: fit-content;\n      margin-top: 0;\n    }\n\n    .json-section {\n      font-family: monospace;\n      white-space: pre-wrap;\n      overflow-wrap: break-word;\n      /* background-color: #c9b3ff; */\n      padding: 1em 3em;\n      font-size: 12px;\n    }\n\n    h2 {\n      font-size: 18px;\n      margin-bottom: 0;\n      grid-column: span 2;\n    }\n\n    .attribute {\n      margin-bottom: 15px;\n      border-bottom: 1px solid #6542BE;\n      padding-bottom: 15px;\n    }\n\n    .attribute-header {\n      margin-bottom: .5rem;\n    }\n\n    .attribute-header span {\n      font-weight: bold;\n      background-color: #c9b3ff;\n      padding: 0.25rem 0.5rem;\n      border-radius: 8px;\n    }\n\n    .toggle-buttons-wrapper {\n      display: flex;\n      justify-content: space-between;\n      width: 20em;\n    }\n\n    .object-details {\n      margin-top: .5rem;\n    }\n\n    .object-definition ul li {\n      margin-top: .25rem;\n    }\n\n    a {\n      text-decoration: none !important;\n      font-weight: bold;\n      color: black;\n    }\n\n    a:hover {\n      cursor: pointer;\n    }\n\n    .last-item {\n      border-bottom: none;\n    }\n\n    .json-key {\n      color: #6542BE;\n      font-weight: 600;\n    }\n\n    .json-string {\n      color: #032f62;\n    }\n\n    .json-number {\n      color: #d73a49;\n    }\n  </style>\n</head>\n<body>\n  <div class=\"container\">\n    <div class=\"definition-section section\">\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>currency</span> <strong>(required)</strong> · string<br>\n        </div>\n        The currency code the order is in\n      </div>\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>amount</span> <strong>(required)</strong> · number<br>\n        </div>\n        The amount of the order. It should include all fees, taxes, shipping, and discount codes calculated in its value.\n      </div>\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>firstName</span> · string<br>\n        </div>\n        Customer's first name.\n      </div>\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>lastName</span> · string<br>\n        </div>\n        Customer's last name.\n      </div>\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>email</span> · string<br>\n        </div>\n        Customer's email address\n      </div>\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>phone</span> · string<br>\n        </div>\n        Customer's 11-digit phone number\n      </div>\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>shippingAddress</span> · <a href=\"#address\">Address</a><br>\n        </div>\n        Customer's shipping address information in the form of an Address object \n        <details class=\"object-details\">\n          <summary>Show properties</summary>\n          <div class=\"object-definition\">\n            <ul>\n              <li><strong>line1: </strong> (required) Primary billing address information</li>\n              <li><strong>line2: </strong> Secondary billing address information</li>\n              <li><strong>city: </strong> (required) City of customer's billing address</li>\n              <li><strong>state: </strong> (required) State of customer's billing address in ISO 3166-2: US format</li>\n              <li><strong>country: </strong> (required) Country of customer's billing address in ISO3166-2 (two letter country code)</li>\n              <li><strong>postalCode: </strong> (required) 5 digit state postal/zip code</li>\n            </ul>\n          </div>\n        </details>\n      </div>\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>billingAddress</span> · <a href=\"#address\">Address</a><br>\n        </div>\n        Customer's billing address information in the form of an Address object \n        <details class=\"object-details\">\n          <summary>Show properties</summary>\n          <div class=\"object-definition\">\n            <ul>\n              <li><strong>line1: </strong> (required) Primary shipping address information</li>\n              <li><strong>line2: </strong> Secondary shipping address information</li>\n              <li><strong>city: </strong> (required) City of customer's shipping address</li>\n              <li><strong>state: </strong> (required) State of customer's shipping address in ISO 3166-2: US format</li>\n              <li><strong>country: </strong> (required) Country of customer's shipping address in ISO3166-2 (two letter country code)</li>\n              <li><strong>postalCode: </strong> (required) 5 digit state postal/zip code</li>\n            </ul>\n          </div>\n        </details>\n      </div>\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>taxAmount</span> · number<br>\n        </div>\n        The tax amount of the order.\n      </div>\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>shippingAmount</span> · number<br>\n        </div>\n        The shipping amount of the order.\n      </div>\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>lineItems</span> · array of <a href=\"#lineitem\">LineItem</a><br>\n        </div>\n        The amount of the order. It should include all fees, taxes, shipping, and discount codes calculated in its value.\n        <details class=\"object-details\">\n          <summary>Show properties</summary>\n          <div class=\"object-definition\">\n            <ul>\n              <li><strong>name: </strong> The name of the item</li>\n              <li><strong>description: </strong> The description of the item (max character length 100)</li>\n              <li><strong>quantity: </strong> The quantity of the item in the order</li>\n              <li><strong>price: </strong> The price of 1 item</li>\n              <li><strong>sku: </strong> The Stock Keeping Unit number</li>\n              <li><strong>isPreOrder: </strong> Whether the item is a pre-order item</li>\n              <li><strong>releaseDate: </strong> The anticipated shipment date of the item</li>\n            </ul>\n          </div>\n        </details>\n      </div>\n      <div class=\"attribute last-item\">\n        <div class=\"attribute-header \">\n          <span>description</span> · string<br>\n        </div>\n        The description of the order\n      </div>\n    </div>\n    <div class=\"json-section section json-example\">\n{\n  <span class=\"json-key\">amount</span>: <span class=\"json-number\">25.50</span>,\n  <span class=\"json-key\">currency</span>: <span class=\"json-string\">\"USD\"</span>,\n  <span class=\"json-key\">firstName</span>: <span class=\"json-string\">\"John\"</span>,\n  <span class=\"json-key\">lastName</span>: <span class=\"json-string\">\"Doe\"</span>,\n  <span class=\"json-key\">email</span>: <span class=\"json-string\">\"johndoe@mail.com\"</span>,\n  <span class=\"json-key\">phone</span>: <span class=\"json-string\">\"123-456-7889\"</span>,\n  <span class=\"json-key\">shippingAddress</span>: {\n    <span class=\"json-key\">line1</span>: <span class=\"json-string\">\"101 Test Street\"</span>,\n    <span class=\"json-key\">line2</span>: <span class=\"json-string\">\"Unit 101\"</span>,\n    <span class=\"json-key\">city</span>: <span class=\"json-string\">\"New York City\"</span>,\n    <span class=\"json-key\">state</span>: <span class=\"json-string\">\"NY\"</span>,\n    <span class=\"json-key\">country</span>: <span class=\"json-string\">\"USA\"</span>,\n    <span class=\"json-key\">postalCode</span>: <span class=\"json-string\">\"10001\"</span>\n  },\n  <span class=\"json-key\">billingAddress</span>: {\n    <span class=\"json-key\">line1</span>: <span class=\"json-string\">\"101 Test Street\"</span>,\n    <span class=\"json-key\">line2</span>: <span class=\"json-string\">\"Unit 101\"</span>,\n    <span class=\"json-key\">city</span>: <span class=\"json-string\">\"New York City\"</span>,\n    <span class=\"json-key\">state</span>: <span class=\"json-string\">\"NY\"</span>,\n    <span class=\"json-key\">country</span>: <span class=\"json-string\">\"USA\"</span>,\n    <span class=\"json-key\">postalCode</span>: <span class=\"json-string\">\"10001\"</span>\n  },\n  <span class=\"json-key\">taxAmount</span>: <span class=\"json-number\">0.00</span>,\n  <span class=\"json-key\">shippingAmount</span>: <span class=\"json-number\">10.00</span>,\n  <span class=\"json-key\">lineItems</span>: [\n    {\n      <span class=\"json-key\">name</span>: <span class=\"json-string\">\"T-Shirt\"</span>,\n      <span class=\"json-key\">description</span>: <span class=\"json-string\">\"Item description\"</span>,\n      <span class=\"json-key\">quantity</span>: <span class=\"json-number\">1</span>,\n      <span class=\"json-key\">price</span>: <span class=\"json-number\">25.50</span>,\n      <span class=\"json-key\">sku</span>: <span class=\"json-string\">\"SKU123\"</span>,\n      <span class=\"json-key\">isPreOrder</span>: <span class=\"json-boolean\">false</span>,\n      <span class=\"json-key\">releaseDate</span>: <span class=\"json-null\">null</span>\n    }\n  ],\n  <span class=\"json-key\">description</span>: <span class=\"json-string\">\"Order description\"</span>\n}\n    </div>\n  </div>\n</body>\n</html>\n"
}
[/block]

## Address

[block:html]
{
  "html": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n  <title>API Documentation</title>\n  <style>\n    body {\n      font-family: Arial, sans-serif;\n      padding: 20px;\n    }\n\n    .container {\n      max-width: 1200px;\n      margin: auto;\n      display: grid;\n      grid-template-columns: 1.25fr 1fr;\n      gap: 20px;\n    }\n\n    .toggle-buttons {\n      display: flex;\n      gap: 10px;\n      margin-bottom: 20px;\n    }\n\n    /* Hide radio buttons */\n    input[type=\"radio\"] {\n      display: none;\n    }\n\n    /* Style labels as toggle buttons */\n    .toggle-buttons label {\n      cursor: pointer;\n      padding: 10px 20px;\n      border: 1px solid #6542BE;\n      border-radius: 8px;\n      background-color: #e0e0e0;\n      color: #333;\n      transition: background-color 0.3s;\n    }\n\n    /* Active state styling */\n    input[type=\"radio\"]:checked + label {\n      background-color: #6542BE;\n      color: white;\n    }\n\n    /* Content sections styling */\n    .section {\n      padding: 15px;\n      background-color: #e5dff7;\n      border-radius: 10px;\n      margin-top: 10px;\n    }\n\n    .json-section, .definition-section {\n      padding: 20px;\n      border-radius: 8px;\n      font-size: 14px;\n      border: 1px solid #6542BE;\n      background-color: #f9f9f9;\n      height: fit-content;\n      width: fit-content;\n      margin-top: 0;\n    }\n\n    .json-section {\n      font-family: monospace;\n      white-space: pre-wrap;\n      overflow-wrap: break-word;\n      /* background-color: #c9b3ff; */\n      padding: 1em 3em;\n      font-size: 12px;\n    }\n\n    h2 {\n      font-size: 18px;\n      margin-bottom: 0;\n      grid-column: span 2;\n    }\n\n    .attribute {\n      margin-bottom: 15px;\n      border-bottom: 1px solid #6542BE;\n      padding-bottom: 15px;\n    }\n\n    .attribute-header {\n      margin-bottom: .5rem;\n    }\n\n    .attribute-header span {\n      font-weight: bold;\n      background-color: #c9b3ff;\n      padding: 0.25rem 0.5rem;\n      border-radius: 8px;\n    }\n\n    .toggle-buttons-wrapper {\n      display: flex;\n      justify-content: space-between;\n      width: 20em;\n    }\n\n    .object-details {\n      margin-top: .5rem;\n    }\n\n    .object-definition ul li {\n      margin-top: .25rem;\n    }\n\n    a {\n      text-decoration: none !important;\n      font-weight: bold;\n      color: black;\n    }\n\n    a:hover {\n      cursor: pointer;\n    }\n\n    .last-item {\n      border-bottom: none;\n    }\n\n    .json-key {\n      color: #6542BE;\n      font-weight: 600;\n    }\n\n    .json-string {\n      color: #032f62;\n    }\n\n    .json-number {\n      color: #d73a49;\n    }\n  </style>\n</head>\n<body>\n  <div class=\"container\">\n    <div class=\"definition-section section\">\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>line1</span> <strong>(required)</strong> · string<br>\n        </div>\n        Primary address information\n      </div>\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>line2</span> · string<br>\n        </div>\n        Secondary address information\n      </div>\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>city</span> <strong>(required)</strong> · string<br>\n        </div>\n        City of address\n      </div>\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>state</span> <strong>(required)</strong> · string<br>\n        </div>\n        State of address in ISO3166-2 (US) format\n      </div>\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>country</span> <strong>(required)</strong> · string<br>\n        </div>\n        Country of address in ISO3166-2 (two letter country code)\n      </div>\n      <div class=\"attribute last-item\">\n        <div class=\"attribute-header\">\n          <span>postalCode</span> <strong>(required)</strong> · string<br>\n        </div>\n        5 digit state postal code\n      </div>\n    </div>\n    <div class=\"json-section section json-example\">\n{\n  <span class=\"json-key\">line1</span>: <span class=\"json-string\">\"101 Test Street\"</span>,\n  <span class=\"json-key\">line2</span>: <span class=\"json-string\">\"Unit 101\"</span>,\n  <span class=\"json-key\">city</span>: <span class=\"json-string\">\"New York City\"</span>,\n  <span class=\"json-key\">state</span>: <span class=\"json-string\">\"NY\"</span>,\n  <span class=\"json-key\">country</span>: <span class=\"json-string\">\"USA\"</span>,\n  <span class=\"json-key\">postalCode</span>: <span class=\"json-string\">\"10001\"</span>\n}\n    </div>\n  </div>\n</body>\n</html>\n"
}
[/block]

## LineItem

[block:html]
{
  "html": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n  <title>API Documentation</title>\n  <style>\n    body {\n      font-family: Arial, sans-serif;\n      padding: 20px;\n    }\n\n    .container {\n      max-width: 1200px;\n      margin: auto;\n      display: grid;\n      grid-template-columns: 1.25fr 1fr;\n      gap: 20px;\n    }\n\n    .toggle-buttons {\n      display: flex;\n      gap: 10px;\n      margin-bottom: 20px;\n    }\n\n    /* Hide radio buttons */\n    input[type=\"radio\"] {\n      display: none;\n    }\n\n    /* Style labels as toggle buttons */\n    .toggle-buttons label {\n      cursor: pointer;\n      padding: 10px 20px;\n      border: 1px solid #6542BE;\n      border-radius: 8px;\n      background-color: #e0e0e0;\n      color: #333;\n      transition: background-color 0.3s;\n    }\n\n    /* Active state styling */\n    input[type=\"radio\"]:checked + label {\n      background-color: #6542BE;\n      color: white;\n    }\n\n    /* Content sections styling */\n    .section {\n      padding: 15px;\n      background-color: #e5dff7;\n      border-radius: 10px;\n      margin-top: 10px;\n    }\n\n    .json-section, .definition-section {\n      padding: 20px;\n      border-radius: 8px;\n      font-size: 14px;\n      border: 1px solid #6542BE;\n      background-color: #f9f9f9;\n      height: fit-content;\n      width: fit-content;\n      margin-top: 0;\n    }\n\n    .json-section {\n      font-family: monospace;\n      white-space: pre-wrap;\n      overflow-wrap: break-word;\n      /* background-color: #c9b3ff; */\n      padding: 1em 3em;\n      font-size: 12px;\n    }\n\n    h2 {\n      font-size: 18px;\n      margin-bottom: 0;\n      grid-column: span 2;\n    }\n\n    .attribute {\n      margin-bottom: 15px;\n      border-bottom: 1px solid #6542BE;\n      padding-bottom: 15px;\n    }\n\n    .attribute-header {\n      margin-bottom: .5rem;\n    }\n\n    .attribute-header span {\n      font-weight: bold;\n      background-color: #c9b3ff;\n      padding: 0.25rem 0.5rem;\n      border-radius: 8px;\n    }\n\n    .toggle-buttons-wrapper {\n      display: flex;\n      justify-content: space-between;\n      width: 20em;\n    }\n\n    .object-details {\n      margin-top: .5rem;\n    }\n\n    .object-definition ul li {\n      margin-top: .25rem;\n    }\n\n    a {\n      text-decoration: none !important;\n      font-weight: bold;\n      color: black;\n    }\n\n    a:hover {\n      cursor: pointer;\n    }\n\n    .last-item {\n      border-bottom: none;\n    }\n\n    .json-key {\n      color: #6542BE;\n      font-weight: 600;\n    }\n\n    .json-string {\n      color: #032f62;\n    }\n\n    .json-number {\n      color: #d73a49;\n    }\n  </style>\n</head>\n<body>\n  <div class=\"container\">\n    <div class=\"definition-section section\">\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>name</span> · string<br>\n        </div>\n        The name of the item\n      </div>\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>description</span> · string<br>\n        </div>\n        The description of the item (max character length 100)\n      </div>\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>quantity</span> · number<br>\n        </div>\n        The quantity of the item in the order\n      </div>\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>price</span> · number<br>\n        </div>\n        The price of one item\n      </div>\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>sku</span> · string<br>\n        </div>\n        The Stock Keeping Unit number\n      </div>\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>isPreOrder</span> · boolean<br>\n        </div>\n        Whether the item is a pre-order item\n      </div>\n      <div class=\"attribute last-item\">\n        <div class=\"attribute-header\">\n          <span>releaseDate</span> · Date<br>\n        </div>\n        The anticipated shipment date of the item\n      </div>\n    </div>\n    <div class=\"json-section section json-example\">\n{\n  <span class=\"json-key\">name</span>: <span class=\"json-string\">\"T-Shirt\"</span>,\n  <span class=\"json-key\">description</span>: <span class=\"json-string\">\"Item description\"</span>,\n  <span class=\"json-key\">quantity</span>: <span class=\"json-number\">1</span>,\n  <span class=\"json-key\">price</span>: <span class=\"json-number\">25.50</span>,\n  <span class=\"json-key\">sku</span>: <span class=\"json-string\">\"SKU123\"</span>,\n  <span class=\"json-key\">isPreOrder</span>: <span class=\"json-boolean\">false</span>,\n  <span class=\"json-key\">releaseDate</span>: <span class=\"json-null\">null</span>\n}\n      </div>\n  </div>\n</body>\n</html>\n"
}
[/block]

## requestBody

[block:html]
{
  "html": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n  <title>API Documentation</title>\n  <style>\n    body {\n      font-family: Arial, sans-serif;\n      padding: 20px;\n    }\n\n    .container {\n      max-width: 1200px;\n      margin: auto;\n      display: grid;\n      grid-template-columns: 1.25fr 1fr;\n      gap: 20px;\n    }\n\n    .toggle-buttons {\n      display: flex;\n      gap: 10px;\n      margin-bottom: 20px;\n    }\n\n    /* Hide radio buttons */\n    input[type=\"radio\"] {\n      display: none;\n    }\n\n    /* Style labels as toggle buttons */\n    .toggle-buttons label {\n      cursor: pointer;\n      padding: 10px 20px;\n      border: 1px solid #6542BE;\n      border-radius: 8px;\n      background-color: #e0e0e0;\n      color: #333;\n      transition: background-color 0.3s;\n    }\n\n    /* Active state styling */\n    input[type=\"radio\"]:checked + label {\n      background-color: #6542BE;\n      color: white;\n    }\n\n    /* Content sections styling */\n    .section {\n      padding: 15px;\n      background-color: #e5dff7;\n      border-radius: 10px;\n      margin-top: 10px;\n    }\n\n    .json-section, .definition-section {\n      padding: 20px;\n      border-radius: 8px;\n      font-size: 14px;\n      border: 1px solid #6542BE;\n      background-color: #f9f9f9;\n      height: fit-content;\n      width: fit-content;\n      margin-top: 0;\n    }\n\n    .json-section {\n      font-family: monospace;\n      white-space: pre-wrap;\n      overflow-wrap: break-word;\n      /* background-color: #c9b3ff; */\n      padding: 1em 3em;\n      font-size: 12px;\n    }\n\n    h2 {\n      font-size: 18px;\n      margin-bottom: 0;\n      grid-column: span 2;\n    }\n\n    .attribute {\n      margin-bottom: 15px;\n      border-bottom: 1px solid #6542BE;\n      padding-bottom: 15px;\n    }\n\n    .attribute-header {\n      margin-bottom: .5rem;\n    }\n\n    .attribute-header span {\n      font-weight: bold;\n      background-color: #c9b3ff;\n      padding: 0.25rem 0.5rem;\n      border-radius: 8px;\n    }\n\n    .toggle-buttons-wrapper {\n      display: flex;\n      justify-content: space-between;\n      width: 20em;\n    }\n\n    .object-details {\n      margin-top: .5rem;\n    }\n\n    .object-definition ul li {\n      margin-top: .25rem;\n    }\n\n    a {\n      text-decoration: none !important;\n      font-weight: bold;\n      color: black;\n    }\n\n    a:hover {\n      cursor: pointer;\n    }\n\n    .last-item {\n      border-bottom: none;\n    }\n\n    .json-key {\n      color: #6542BE;\n      font-weight: 600;\n    }\n\n    .json-string {\n      color: #032f62;\n    }\n\n    .json-number {\n      color: #d73a49;\n    }\n  </style>\n</head>\n<body>\n  <div class=\"container\">\n    <div class=\"definition-section section\">\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>merchantId</span> <strong>(required)</strong> · string<br>\n        </div>\n        The merchant ID provided by Zip\n      </div>\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>merchantReference</span> <strong>(required)</strong> · string<br>\n        </div>\n        The order ID on the merchant's platform. \n      </div>\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>order</span> <strong>(required)</strong> · <a href=\"#order\">Order</a><br>\n        </div>\n        The order object\n      </div>\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>callbackUrl</span> <strong>(required)</strong> · string<br>\n        </div>\n        The URL that Zip will send event webhooks too. These webhooks are the result of API requests made to Zip. \n      </div>\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>capture</span> <strong>[default: true]</strong> · boolean<br>\n        </div>\n        This boolean tells Zip whether the order should be treated as Auto or Delayed capture. \n      </div>\n      <div class=\"attribute last-item\">\n        <div class=\"attribute-header\">\n          <span>checkoutFlow</span> <strong>(required)</strong> · \"standard\" | \"express\"<br>\n        </div>\n        This string tells Zip whether the transaction should be opened in our Standard or Express checkout flow\n      </div>\n    </div>\n    <div class=\"json-section section json-example\">\n{\n  <span class=\"json-key\">merchantId</span>: <span class=\"json-string\">\"xxxx-xxxx-xxxx-xxxx\"</span>,\n  <span class=\"json-key\">merchantReference</span>: <span class=\"json-string\">\"123ABC\"</span>,\n  <span class=\"json-key\">order</span>: <span class=\"json-string\">{} as <a href=\"#order\"><strong>Order</strong></a></span>,\n  <span class=\"json-key\">callbackUrl</span>: <span class=\"json-string\">\"my-merchant.com/zip-callback\"</span>,\n  <span class=\"json-key\">capture</span>: <span class=\"json-number\">true</span>,\n  <span class=\"json-key\">checkoutFlow</span>: <span class=\"json-string\">\"standard\"</span>\n}\n    </div>\n  </div>\n</body>\n</html>\n"
}
[/block]

## Zip Checkout Response

[block:html]
{
  "html": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n  <title>API Documentation</title>\n  <style>\n    body {\n      font-family: Arial, sans-serif;\n      padding: 20px;\n    }\n\n    .container {\n      max-width: 1200px;\n      margin: auto;\n      display: grid;\n      grid-template-columns: 1.25fr 1fr;\n      gap: 20px;\n    }\n\n    .toggle-buttons {\n      display: flex;\n      gap: 10px;\n      margin-bottom: 20px;\n    }\n\n    /* Hide radio buttons */\n    input[type=\"radio\"] {\n      display: none;\n    }\n\n    /* Style labels as toggle buttons */\n    .toggle-buttons label {\n      cursor: pointer;\n      padding: 10px 20px;\n      border: 1px solid #6542BE;\n      border-radius: 8px;\n      background-color: #e0e0e0;\n      color: #333;\n      transition: background-color 0.3s;\n    }\n\n    /* Active state styling */\n    input[type=\"radio\"]:checked + label {\n      background-color: #6542BE;\n      color: white;\n    }\n\n    /* Content sections styling */\n    .section {\n      padding: 15px;\n      background-color: #e5dff7;\n      border-radius: 10px;\n      margin-top: 10px;\n    }\n\n    .json-section, .definition-section {\n      padding: 20px;\n      border-radius: 8px;\n      font-size: 14px;\n      border: 1px solid #6542BE;\n      background-color: #f9f9f9;\n      height: fit-content;\n      width: fit-content;\n      margin-top: 0;\n    }\n\n    .json-section {\n      font-family: monospace;\n      white-space: pre-wrap;\n      overflow-wrap: break-word;\n      /* background-color: #c9b3ff; */\n      padding: 1em 3em;\n      font-size: 12px;\n    }\n\n    h2 {\n      font-size: 18px;\n      margin-bottom: 0;\n      grid-column: span 2;\n    }\n\n    .attribute {\n      margin-bottom: 15px;\n      border-bottom: 1px solid #6542BE;\n      padding-bottom: 15px;\n    }\n\n    .attribute-header {\n      margin-bottom: .5rem;\n    }\n\n    .attribute-header span {\n      font-weight: bold;\n      background-color: #c9b3ff;\n      padding: 0.25rem 0.5rem;\n      border-radius: 8px;\n    }\n\n    .toggle-buttons-wrapper {\n      display: flex;\n      justify-content: space-between;\n      width: 20em;\n    }\n\n    .object-details {\n      margin-top: .5rem;\n    }\n\n    .object-definition ul li {\n      margin-top: .25rem;\n    }\n\n    a {\n      text-decoration: none !important;\n      font-weight: normal;\n      color: #6542be;\n    }\n\n    a:hover {\n      cursor: pointer;\n    }\n\n    .last-item {\n      border-bottom: none;\n    }\n\n    .json-key {\n      color: #6542BE;\n      font-weight: 600;\n    }\n\n    .json-string {\n      color: #032f62;\n    }\n\n    .json-number {\n      color: #d73a49;\n    }\n  </style>\n</head>\n<body>\n  <div class=\"container\">\n    <div class=\"definition-section section\">\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>customer</span> · Customer<br>\n        </div>\n        The Customer object sent from Zip\n        <details class=\"object-details\">\n            <summary>Show properties</summary>\n            <div class=\"object-definition\">\n              <ul>\n                <li><strong>address1: </strong> Primary shipping address information</li>\n                <li><strong>address2: </strong> Secondary shipping address information</li>\n                <li><strong>city: </strong> City of customer's shipping address</li>\n                <li><strong>country: </strong> Country of customer's shipping address in ISO3166-2 (two letter country code)</li>\n                <li><strong>email:</strong> Customer's email address</li>\n                <li><strong>fistName:</strong> Customer's first name</li>\n                <li><strong>lastName:</strong> Customer's last name</li>\n                <li><strong>phoneNumber:</strong> Customer's 10 digit phone number</li>\n                <li><strong>postalCode: </strong> 5 digit state postal/zip code</li>\n                <li><strong>state: </strong> State of customer's shipping address in ISO 3166-2: US format</li>\n              </ul>\n            </div>\n          </details>\n      </div>\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>order</span> · OrderResponse<br>\n        </div>\n        The Order object sent from Zip\n        <details class=\"object-details\">\n            <summary>Show properties</summary>\n            <div class=\"object-definition\">\n              <ul>\n                <li><strong>amount: </strong> The order amount</li>\n                <li><strong>currency: </strong> The currency code</li>\n                <li><strong>isSuccess: </strong> Whether Zip successfully captured the order</li>\n                <li><strong>isTest: </strong> Whether the order was captured in sandbox or production</li>\n                <li><strong>merchantId:</strong> Merchant's Zip ID</li>\n                <li><strong>merchantReference:</strong> Merchant's order ID</li>\n                <li><strong>orderId:</strong> Zip's order ID</li>\n                <li><strong>timestamp:</strong> Timestamp when order was processed</li>\n              </ul>\n            </div>\n          </details>\n      </div>\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>shippingAddress</span> (If Express checkout) · Address<br>\n        </div>\n        The shipping Address sent from Zip\n                <details class=\"object-details\">\n            <summary>Show properties</summary>\n            <div class=\"object-definition\">\n                <ul>\n                    <li><strong>line1: </strong> Primary shipping address information</li>\n                    <li><strong>line2: </strong> Secondary shipping address information</li>\n                    <li><strong>city: </strong> City of customer's shipping address</li>\n                    <li><strong>state: </strong> State of customer's shipping address in ISO 3166-2: US format</li>\n                    <li><strong>postalCode: </strong> 5 digit state postal/zip code</li>\n                    <li><strong>country: </strong> Country of customer's shipping address in ISO3166-2 (two letter country code)</li>\n                  </ul>\n            </div>\n          </details>\n      </div>\n      <div class=\"attribute\">\n        <div class=\"attribute-header\">\n          <span>success</span> · boolean<br>\n        </div>\n        Signifies whether Zip successfully processed the order\n      </div>\n    </div>\n    <div class=\"json-section section json-example\">\n{\n    <span class=\"json-key\">customer</span>: {\n        <span class=\"json-key\">address1</span>: <span class=\"json-string\">\"101 N Test Street\"</span>,\n        <span class=\"json-key\">address2</span>: <span class=\"json-number\">undefined</span>,\n        <span class=\"json-key\">city</span>: <span class=\"json-string\">\"New York City\"</span>,\n        <span class=\"json-key\">country</span>: <span class=\"json-string\">\"US\"</span>,\n        <span class=\"json-key\">email</span>: <span class=\"json-string\">\"johndoe@gmail.com\"</span>,\n        <span class=\"json-key\">firstName</span>: <span class=\"json-string\">\"John\"</span>\n        <span class=\"json-key\">lastName</span>: <span class=\"json-string\">\"Doe\"</span>\n        <span class=\"json-key\">phoneNumber</span>: <span class=\"json-string\">\"(123)123-1234\"</span>      \n        <span class=\"json-key\">postalCode</span>: <span class=\"json-string\">\"12345\"</span>      \n        <span class=\"json-key\">state</span>: <span class=\"json-string\">\"NY</span>      \n    }\n    <span class=\"json-key\">order</span>: {\n        <span class=\"json-key\">amount</span>: <span class=\"json-number\">149.99</span>,\n        <span class=\"json-key\">currency</span>: <span class=\"json-string\">\"USD\"</span>,\n        <span class=\"json-key\">isSuccess</span>: <span class=\"json-number\">true</span>,\n        <span class=\"json-key\">isTest</span>: <span class=\"json-number\">false</span>,\n        <span class=\"json-key\">merchantId</span>: <span class=\"json-string\">1234-1234-1234-1234</span>,\n        <span class=\"json-key\">merchantReference</span>: <span class=\"json-string\">\"XYZ123\"</span>\n        <span class=\"json-key\">orderId</span>: <span class=\"json-string\">\"XYZABC-123-5432\"</span>\n        <span class=\"json-key\">timestamp</span>: <span class=\"json-number\">2024-05-25T12:30:00</span>      \n    }\n    <span class=\"json-key\">shippingAddress</span>: {\n        <span class=\"json-key\">line1</span>: <span class=\"json-string\">\"101 N Test Street\"</span>,\n        <span class=\"json-key\">line2</span>: <span class=\"json-string\">\"Unit 101\"</span>,\n        <span class=\"json-key\">city</span>: <span class=\"json-string\">\"New York City\"</span>,\n        <span class=\"json-key\">state</span>: <span class=\"json-string\">\"NY</span>     \n        <span class=\"json-key\">postalCode</span>: <span class=\"json-string\">\"12345\"</span>      \n        <span class=\"json-key\">country</span>: <span class=\"json-string\">\"US\"</span>     \n    },\n    <span class=\"json-key\">success</span>: <span class=\"json-number\">true</span>\n}\n    </div>\n  </div>\n</body>\n</html>\n"
}
[/block]