Can I integrate the mPOS SDK in a Swift App?

Yes, you can work with the mPOS SDK entirely in Swift.

To install it, add the following command in your podfile and run pod install

Remember to update the SDK to the latest released version. You also need to use Xcode 12 and an iOS project targeting iOS 13 or above.

source 'https://github.com/CocoaPods/Specs.git'
source 'https://bitbucket.org/payworks/io.payworks.repo.pods.git'
use_frameworks!

target :"<your-app-target>" do
    pod 'payworks',           ''
    pod 'payworks.paybutton', ''
end

Once cocoapods are installed, Swift will work out of the box. You just need to import the module of Payworks library and all Api's will be available. A normal view controller should look like this:

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
        }

    }

}

Can we help you?

If you cannot find your answer, contact us and we'll get in touch with you soon.