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',

      amount: {

        total: 500,

        currencyCode: 'USD',

      }

    });

  }

  catch (e) {

    // handle error

  }

}