Accept an ACH Payment

Creating a Payment Method

You first want to collect credit card information and populate a BankAccount object.

val bankAccount = BankAccount(personName = "Jim Parsnip",  
    	bankType = "savings",  
    	bankAccount = "9876543210",  
    	bankRouting = "021000021",  
    	addressZip = "32822")

Once you have a BankAccount object, create a TransactionRequest object with it and pass it to Omni’s pay method.

let transactionRequest = TransactionRequest(amount: Amount(cents: 3), bankAccount: bankAccount)  
omni?.pay(transactionRequest: transactionRequest, completion: { completedTransaction ->  
  self.log("Finished transaction successfully")  
}, error: { error ->  
  self.log(error)  
})

Tokenizing a Bank Card


Once you have a BankAccount object, call the tokenize(:) method on the Omni object and pass a listener to be notified once tokenization is complete.

omni.tokenize(card, completion: { (paymentMethod) in

}) { error in

}

Testing

If you’d like to try tokenization without real payment information, you can use the BankAccount.testBankAccount() methods to get a test bank account.

val bankAccount = BankAccount.testBankAccount()

If you want to test failures, you can use the following method:

val failingBankAccount = BankAccount.failingTestBankAccount()

Or you can create the BankAccount object with the following testing payment information:

Test Routing and Banking Numbers

Routing #: 021000021
Account #: 9876543210

To test failing bank accounts, use the given routing number and any other account number.

Taking a Payment

Now that you have the token representing the payment method, you can use the POST /charge resource on the Stax API to create a transaction with it. payment_method_id is a required field, where you must pass in the ID of the payment method you received from the tokenize(:) method.