Link

iOS Swiped Payments Guide

Mobile Reader Payments

Supercharge your mobile app by quickly adding mobile reader payments using the Omni Mobile SDK. These payments will create invoices, customers, and transaction objects in the Omni platform. You can also choose to have the payment method stored within Omni so you can use it from the Omni API.

How it works

  1. You’ll first need to create an ephemeral key to initialize the Omni object.
  2. Then you’ll create a TransactionRequest that holds all necessary data to take a payment.
  3. Finally, you’ll ask Omni to take the payment by calling the takeMobileReaderPayment() method, passing in the TransactionRequest and a block to run once the payment is complete.

Requirements

  • Xcode 8+
  • iOS 9+
  • Omni Webpayments Token
  • Ephemeral Omni API key

Installation

Use CocoaPods to install the Fattmerchant iOS SDK.

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

Getting Started

Setup Info.plist

In order to build and run with the Cardpresent functionality, you must include the following in your project’s Info.plist

  • NSBluetoothAlwaysUsageDescription: Provide a value here to let your users know why Bluetooth access is required

Initialize

Create an instance of InitParams

var initParams = Omni.InitParams(appId: "fmiossample", apiKey: apiKey, environment: Environment.DEV)

Pass the initParams to Omni.initialize(...), along with a completion lambda and an error lambda

omni = Omni()

log("Attempting initalization...")

// Initialize Omni
omni?.initialize(params: initParams, completion: {
	// Initialized!
}) { (error) in

}

Connect a Mobile Reader

In order to connect a mobile reader, you must first search for a list of available readers

omni.getAvailableReaders { readers ->

}

Once you have the list of available ones, you can choose which one you’d like to connect

omni?.getAvailableReaders(completion: { readers in
	guard !readers.isEmpty else {
		self.log("No readers found")
		return
	}

	var chosenReader = ... // Choose a reader

	omni.connect(reader: chosenReader, completion: { connectedReader in
		self.log("Connected reader: \(connectedReader)")
	}) { (error) in
		// Something went wrong
	}
}) {
	self.log("Couldn't connect to the mobile reader")
}

Take a Payment

To take a payment, simply create a TransactionRequest and pass it along to omni.takeMobileReaderTransaction(...)

// Create an Amount
let amount = Amount(cents: 50)

// Create the TransactionRequest
let request = TransactionRequest(amount: amount)

// Take the payment
omni.takeMobileReaderTransaction(request, { completedTransaction in
    // Payment successful!
}) {
    // Error
}

By default, the PaymentMethod used in the Transaction is tokenized for reuse. This allows the PaymentMethod to be used from the Omni Virtual Terminal and via the Omni API. To opt-out of tokenization, you can set the tokenize field of TransactionRequest to false

// Create a TransactionRequest with no tokenization
let request = TransactionRequest(amount: amount, tokenize: false)

Refund a Payment

You can use the Omni API to do so. Once you get the transaction, you can use the refundMobileReaderTransaction method to attempt the refund.

At this time, you may only refund transactions that were performed on the same device that performed the original transaction

// Attain a transaction
var transaction = Transaction()

// Perform refund
omni.refundMobileReaderTransaction(transaction: transaction, completion: { (refundedTransaction) in
	// Refund successful!
}, error: { error in
	// Error
})