Can I integrate the mPOS SDK in a Swift App?

Yes, you can work with the mPOS SDK entirely in Swift.
To install the mPOS SDK:
  • Make sure to update the SDK to the latest released version.
  • Use Xcode 14 or higher and an iOS project targeting iOS 15 or higher.
  • Add this command in your
    Podfile
    : and run
    pod install
    :
source 'https://github.com/CocoaPods/Specs.git' source 'https://github.com/visa/mpos.sdk.ios.pods.git' use_frameworks! target :"your-app-target>" do pod 'payworks', '' pod 'payworks.paybutton', '' end
Next, you must import the Payworks library module, then all the associated APIs will be available. After CocoaPods are installed, Swift will work out of the box.
Here is an example of a normal view controller:
import UIKit import mpos_core class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. payworksExample() } func payworksExample() { let transactionProvider = MPMpos.transactionProvider(for: .TEST, merchantIdentifier: "test", merchantSecretKey: "test") let transactionParameters = MPTransactionParameters.charge(withAmount: NSDecimalNumber(string: "10"), currency: .GBP) { (optionals) in // optionals } let accessory = MPAccessoryParameters.mock() let _ = transactionProvider.startTransaction(with: transactionParameters, accessoryParameters: accessory, processParameters: nil) { (transactionProcess, transaction) in // do something } statusChanged: { (transactionProcess, transaction, transactionProcessDetails) in print(transactionProcessDetails.information[0]) print(transactionProcessDetails.information[1]) // do something } actionRequired: { (transactionProcess, transaction, transactionAction, transactionActionSupport) in // do something } completed: { (transactionProcess, transaction, transactionProcessDetails) in // do something } } }