Pay by App button
Drop-in UIView that hands the customer off to their bank's app (ABSA, Standard Bank, Capitec, etc.) via a deep link.
The MPPayByApp view lets the customer pay through their bank's mobile app rather than entering card details in your app. The view discovers installed bank apps via their published deep-link schemes; the customer picks one; Scan to PayKit deep-links into that app to complete payment.
For the pure card-in-SDK flow, see Pay-by-Card button.
Prerequisite — LSApplicationQueriesSchemes
Before iOS will let you check whether bank apps are installed, you must declare their schemes in Info.plist:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>masterpass.absa.scheme</string>
<string>masterpass.sbsa.scheme</string>
<string>masterpass.nedbank.scheme</string>
<string>masterpass.spenda.scheme</string>
<string>masterpass.capitec.scheme</string>
<string>masterpass.vodapay.scheme</string>
<string>nedbank</string>
<string>https://www.online.fnb.co.za/banking/mobileservices?codetype=masterpassdeeplink</string>
</array>Without these entries, canOpenURL(_:) returns false even for installed apps — iOS treats omitted schemes as "not installed" for privacy reasons.
Adding the view via Storyboard
- Drag a
UIViewonto your storyboard - Constrain it where you want the button to sit
- Open the Identity Inspector and set the Custom Class to
MPPayByApp - Wire an
@IBOutletin your view controller
@IBOutlet weak var payByApp: MPPayByApp!Set the delegate in viewDidLoad:
override func viewDidLoad() {
super.viewDidLoad()
payByApp.delegate = self
}Handling the tap
Adopt MPPayByAppDelegate and implement didPayByApp(withInfo:). The appInfo dictionary tells the SDK which bank app the customer chose:
extension CheckoutViewController: MPPayByAppDelegate, MPMasterPassDelegate {
func didPayByApp(withInfo appInfo: [AnyHashable: Any]?) {
view.endEditing(true)
let apiKey = "YOUR_API_KEY"
let system = MPSystem.test
let qrCode = "6799782555"
let masterpass = MPMasterPass()
masterpass.checkoutUsingPayByApp(withAPIKey: apiKey,
system: system,
delegate: self,
withAppInfo: appInfo,
application: UIApplication.shared,
qrCode: qrCode,
andCallback: "your.app.scheme://")
}
}Parameters
| Name | Type | Description |
|---|---|---|
apiKey | String | Your Lib Lite API token from the Portal |
system | MPSystem | .live or .test |
delegate | MPMasterPassDelegate | Where the SDK calls back |
appInfo | [AnyHashable: Any] | Routing info for the chosen bank app — passed through from the view's delegate callback |
application | UIApplication | Used to launch the bank-app URL |
qrCode | String | Transaction code from /code (fixed amount) |
andCallback | String | Your app's callback URL scheme — the bank app uses it to return after payment |
The andCallback value should match a URL scheme declared in your app's Info.plist:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>your.app.scheme</string>
</array>
</dict>
</array>Result handling
The result comes back via the standard MPScanToPayDelegate / MPMasterPassDelegate callbacks. See Payments — same methods, same semantics.
Additionally, you'll need to handle the inbound URL when the bank app returns:
// In your AppDelegate or SceneDelegate
func application(_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
// Pass through to the SDK if it's a Scan to Pay callback
if url.scheme == "your.app.scheme" {
// SDK handles this internally — the delegate methods will be called
return true
}
return false
}Supported bank apps
The view discovers bank apps using their published deep-link schemes:
| Bank | Scheme |
|---|---|
| ABSA | masterpass.absa.scheme |
| Standard Bank | masterpass.sbsa.scheme |
| Nedbank | masterpass.nedbank.scheme |
| FNB | (URL-based, not a scheme) |
| Capitec | masterpass.capitec.scheme |
| VodaPay | masterpass.vodapay.scheme |
| Spenda | masterpass.spenda.scheme |
Add or remove from LSApplicationQueriesSchemes to match which apps you want detected.
When no bank apps are installed
The view will be empty / hidden when no supported bank apps are detected. You should provide a fallback (a Pay-by-Card button next to it) so the customer can still pay.
What's next
- Just want the card flow → Pay-by-Card button
- The underlying checkout → Payments
- Result codes → Errors
- App-to-app from the merchant side → App-to-app
Updated 2 days ago
