# 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](https://app.gitbook.com/s/yN9CLsR8tlS8G8avRMB5/payment-processing-solutions/javascript "mention") 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](https://app.gitbook.com/s/yN9CLsR8tlS8G8avRMB5/payment-processing-solutions/javascript/add-payment-form "mention"):

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](https://app.gitbook.com/s/j9heLdoDRsfnChUQohvj/api/payments/ach/ach-transaction "mention") endpoint with required fields.

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