# Account Boarding Merchant Agreement

## Overview <a href="#overview" id="overview"></a>

***

In order to be boarded every Merchant needs to agree to Go Plus Terms and Conditions.\
To help Developers integrate Agreement API into their website we are supporting Agreement API through Sola iFields.

### **Integrate Agreement API using ifields** <a href="#integrate-agreement-api-using-ifields" id="integrate-agreement-api-using-ifields"></a>

{% hint style="info" %}
Obtain your ***iFields xKey*** from your Sola [Partner Portal](https://partner.solapayments.com/login) account settings.
{% endhint %}

#### Adding Reference to iFields <a href="#adding-reference-to-ifields" id="adding-reference-to-ifields"></a>

***

**Step 1:** Check the latest stable iFields version here: <https://cdn.cardknox.com/ifields/versions.htm>

**Step 2:** Add the ifields.js file after the \<head> tag on your website:

`<script src=https://cdn.cardknox.com/ifields/**ifields-version-number**/ifields.min.js></script>`

&#x20;

#### Adding iFrame and JavaScript Objects for Merchant Agreement <a href="#adding-iframe-and-javascript-objects-for-merchant-agreement" id="adding-iframe-and-javascript-objects-for-merchant-agreement"></a>

***

**Step 1:** Add the following iFrame JS snippet inside the *\<body>* where Merchant Agreement is desired.

* Make sure you have an attribute `data-ifields-id="agreement"` as part of *\<iframe>* tag

`<iframe id="agreement" class="agreement" data-ifields-id="agreement" src="https://cdn.cardknox.com/ifields/**ifields-version-number**/agreement.htm"></iframe>`

&#x20;

**Step 2:** Create JavaScript function to handle Agreement API callback

```
function handleAgreementResponse(response) {
    let msg = null;
    if (!response) {
        msg = "Failed to load token. No Response";
    } else if (response.status !== iStatus.success) {
        msg = "Failed to load token. "+response.statusText || "No Error description available";
    } else if (!response.token) {
        msg = "Failed to load token. No Token available";
    } else {
        msg = response.token;
    }
    setTimeout(() => {alert(msg)}, 10);
}
```

For `response` object reference refer here: [Agreement Response](#agreement-response)

&#x20;

**Step 3:** Enable Customer Agreement to get the token

There are two ways to get the token:

* Asynchronously (a callback will be performed once the customer agrees to Terms and Conditions)\
  \
  Just add `enableAgreement` call when the document is loaded (`autoAgree` the parameter is set to `true`):

```javascript
document.addEventListener("DOMContentLoaded", function(event) {
    ................ 
    ckCustomerAgreement.enableAgreement({
        iframeField: 'agreement',
        xKey: '<Your ifields xKey>',
        autoAgree: true,
        callbackName: 'handleAgreementResponse'
    });
    ................    
}
```

* Synchronously (Explicitly calling `getToken` function for example on Submit)\
  \
  Add `enableAgreement` call when the document is loaded (`autoAgree` the parameter is set to `false`):

```javascript
document.addEventListener("DOMContentLoaded", function(event) {
    ................ 
    ckCustomerAgreement.enableAgreement({
        iframeField: 'agreement',
        xKey: '<Your ifields xKey>',
        autoAgree: false
    });
    ................    
}
```

\
In your `Submit` function add the following code:

```javascript
ckCustomerAgreement.getToken()
    .then(resp => {
        handleAgreementResponse(resp);
    })
    .catch(err => {
        console.error("Agreement Token Error", exMsg(err));
        handleAgreementResponse(err);
    });
```

### Objects Reference <a href="#objects-reference" id="objects-reference"></a>

***

#### iStatus <a href="#istatus" id="istatus"></a>

```javascript
const iStatus = {
    success: 100,
    unsupported: -100,
    error: -200
}
```

#### Agreement Response  <a href="#agreement-response" id="agreement-response"></a>

**The object holding the response with token from Agreement API.**

| **Name**     | **Type**                                                                                      | **Description**                                                                                                                                                                                                                                     |
| ------------ | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `status`     | [iStatus](/api/account-boarding-api/account-boarding-merchant-agreement.md#objects-reference) | <p>There are 2 possible cases:</p><ul><li>Agreement was accepted and Token was obtained <code>status=iStatus.success</code></li><li>Agreement wasn’t accepted or an error occurred obtaining the token: <code>status=iStatus.error</code></li></ul> |
| `statusText` | String                                                                                        | When `status=iStatus.error` this field will be populated with the reason                                                                                                                                                                            |
| `token`      | String                                                                                        | <p>When <code>status=iStatus.success</code> this field will be populated with <code>token</code><br></p>                                                                                                                                            |


---

# 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.solapayments.com/api/account-boarding-api/account-boarding-merchant-agreement.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.
