ACH Bank Transfer

Take a bank account payment via ACH Bank Transfer

Usage

Code playground

index.html

Payments

Returned by Square.payments(appId, locationId).

Use this object to instantiate Payment methods. Learn more on the Payments page.

Methods

payments.js
JS
JavaScript

const payments = Square.payments(appId, locationId);

ACH

The ACH Payment Method

When initializing the ACH payment method, the developer is expected to provide a redirectURI and transactionID.

Methods

aCH.js
JS
JavaScript

const ach = await payments.ach({

  redirectURI: window.location.href,

  transactionId: 'my-distinct-transaction-id',

)};



const achButton = document.getElementById('ach-button')

const buyerNameField = document.getElementById('buyer-name-field');



ach.addEventListener('ontokenization', (event) => {

  const { tokenResult, error } = event.detail;



  if (error) {

    const errorMessage = `Tokenization failed with status: ${error}`;

    throw new Error(errorMessage);

  }



  if (tokenResult.status === 'OK') {

    console.log('got payment token: ', tokenResult.token);

  }

});



achButton.onclick = () => {

  try {

    await ach.tokenize({

      accountHolderName: buyerNameField.value,

      intent: 'CHARGE',

      total: {

        amount: 500,

        currencyCode: 'USD',

      }

    });

  }

  catch (e) {

    // handle error

  }

}