# ACH Transactions

The **ACH Transactions** solution lets you accept direct debit and credit payments securely through the Automated Clearing House (ACH) network.

{% hint style="info" %}
Third-party providers such as Paya and DCS supports to process ACH payments and manage reporting.
{% endhint %}

### **Prerequisites** <a href="#prerequisites" id="prerequisites"></a>

To process ACH transactions, ensure you have following:

✅ Integrated JavaScript SDK.

{% hint style="info" %}
See [JavaScript](/guides/payment-processing-solutions/javascript.md) to integrate.
{% endhint %}

✅ API access key issued to you by Xplor Pay.

{% hint style="info" %}
Visit [Let's Get Started - Xplor Pay](https://xplorpay.com/getting-started/) to get API access key.
{% endhint %}

:white\_check\_mark: A sandbox URL for testing the integration.

{% hint style="info" %}
Contact [Xplor Pay Getting Started](https://xplorpay.com/getting-started/) to get Sandbox URL.
{% endhint %}

{% stepper %}
{% step %}

### Set up ACH payment form

To set up the the ACH payment form using the [Add payment form](/guides/payment-processing-solutions/javascript/add-payment-form.md):

1. Add a `<div>` tag to host the ACH payment form.

{% code lineNumbers="true" %}

```javascript
<div id="payment-form"></div>
```

{% endcode %}

2. Include the JavaScript SDK library.

{% code lineNumbers="true" %}

```javascript
<script src="https://gateway-sb.clearent.net/js-sdk/js/clearent-host.js"></script>
```

{% endcode %}

3. Initialize the SDK with your sandbox base URL and public key.

{% code lineNumbers="true" %}

```javascript
<script type="text/javascript">
    ClearentSDK.init({
        "baseUrl": "https://gateway-sb.clearent.net",
        "pk": "YOUR_PUBLIC_KEY"
    });
</script>
```

{% endcode %}

The ACH payment form appears on your webpage with fields for bank account number, routing number, and account type.
{% endstep %}

{% step %}

### Get JSON Web Token

To get a JSON Web Token:

1. Add the `getPaymentToken()` method to your site to receive a success response.

{% code lineNumbers="true" %}

```javascript
ClearentSDK.getPaymentToken().then(
    (result) => {
        console.log("ACH Token Success");
        console.log(result);
    },
    (error) => {
        console.log("ACH Token Error");
        console.log(error);
    }
);
```

{% endcode %}

The response includes a `jwt` field with the tokenized ACH payment authorization.

{% code lineNumbers="true" %}

```javascript
{
   "code": "200",
   "status": "success",
   "exchange-id": "ID-clearent-mobile-jwt-1-c32bfe39-d454-4e34-8b4f-94d850643e48",
   "payload": {
      "mobile-jwt": {
         "jwt": "eyJhbGciOi23UzIh4iJ9...",
         "last-four": "6789"
      },
      "payloadType": "mobile-jwt"
   }
}
```

{% endcode %}
{% endstep %}

{% step %}

### Process ACH payment

To process the ACH payment:

1. Use the POST method.
2. Include the `mobile-jwt` token in the request headers for authentication.

{% hint style="info" %}
See the `jwt` field in the successful response from the JavaScript SDK.
{% endhint %}

3. Send a transaction request to the [ACH Transaction](/api-reference/api/payments/ach/ach-transaction.md) endpoint with required fields.

The success response returns the ACH transaction status as `Pending`, `Approved`, or `Failed` in the `status` field.
{% endstep %}
{% endstepper %}


---

# 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.xplorpay.com/quick-starts/ach-transactions.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.
