iOS Bank Payments Guide


  • Xcode 8+
  • iOS 9+
  • Omni Webpayments Token


Use CocoaPods to install the Fattmerchant iOS SDK.

  1. Install CocoaPods
  2. Add pod 'Fattmerchant' to your Podfile
  3. Run pod install

Create a PaymentMethod

To accept a payment, you’ll need to collect information from the customer and tokenize it to create an Omni PaymentMethod. You will then be able to use this PaymentMethod with Fattmerchant’s Omni API to run the transaction.


You’ll first need to setup the FattmerchantApi for usage. Set the webPaymentsToken field on the shared FattmerchantConfiguration instance. All new FattmerchantApi instances will then use that configuration by default.

import UIKit
import Fattmerchant

class AppDelegate: UIResponder, UIApplicationDelegate {

  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    FattmerchantConfiguration.shared.webPaymentsToken = "mywebpaymentstoken"
    // ...
    return true

Alternatively, you may create a configuration object and pass it to the new FattmerchantApi instance as you need it.

let configuration = FattmerchantConfiguration(webPaymentsToken: "mywebpaymentstoken")
let fattClient = FattmerchantApi(configuration: configuration)

Collect payment information

You first want to collect bank account information and populate a BankAccount object.

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

Create the PaymentMethod

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

let fattClient = FattmerchantApi(webPaymentsToken: "mywebpaymentstoken")
fattClient.tokenize(card) { (response) in
  if case let .success(paymentMethod) = response {
	  // You can now use `paymentMethod` with the Fattmerchant Omni API


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

let bankAccount = BankAccount.testBankAccount()

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

let failingBankAccount = BankAccount.failingTestBankAccount()

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

Bank routing & account 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 Omni API. this will allow you to create a transaction with the payment method. payment_method_id is a required field, where you will need to pass in the id of the payment method that you received from the tokenize(:) method. You can use this PaymentMethod anywhere that you need in the Omni API.

Here is an example:

/// This is a sample request body for Omni POST /charge
struct ChargeRequestBody: Codable {
  struct Meta: Codable {
    var tax: Double
    var subtotal: Double
  var total: Double
  var payment_method_id: String
  var pre_auth: Bool = false
  var meta: Meta

func takePayment(dollars: Double, paymentMethodId: String) {
  // Create URLRequest
  let chargeRoute = URL(string: "")!
  var request = URLRequest(url: chargeRoute)
  request.httpMethod = "POST"

  // Add headers
  request.setValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization")
  request.setValue("application/json", forHTTPHeaderField: "Accept")
  request.setValue("application/json", forHTTPHeaderField: "Content-Type")

  // Add body
  let body = ChargeRequestBody(total: dollars,
                               payment_method_id: paymentMethodId,
                               meta: ChargeRequestBody.Meta(tax: 0.0, subtotal: dollars))
  request.httpBody = try! JSONEncoder().encode(body)

  // Send request
  let task = URLSession(configuration: .ephemeral).dataTask(with: request) { (data, response, error) in
    if let data = data {
      // data should have the PaymentMethod