The Fattmerchant iOS SDK provides a simple way to accept a payment on your iOS app by providing tokenization of payment methods. By using these tokens instead of card and bank information, you no longer have to worry about sending sensitive card information to your server.
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 Stax platform. You can also choose to have the payment method stored within Stax so you can use it from the Stax API.
Omni
object.TransactionRequest
that holds all necessary data to take a payment.Omni
to take the payment by calling the takeMobileReaderPayment()
method, passing in the TransactionRequest
and a block to run once the payment is complete.Use CocoaPods to install the Fattmerchant iOS SDK.
pod 'Fattmerchant'
to your Podfile
pod install
In order to build and run with the Cardpresent functionality, you must include the following in your project’s Info.plist
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
}
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")
}
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 Stax Virtual Terminal and via the Stax 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)
You can use the Stax API to do so.
Once you get the transaction, you can use the refundMobileReaderTransaction
method to attempt the refund.
// Attain a transaction
var transaction = Transaction()
// Perform refund
omni.refundMobileReaderTransaction(transaction: transaction, completion: { (refundedTransaction) in
// Refund successful!
}, error: { error in
// Error
})