This library allows your app users to pay directly via their bank app. You can implement this into your app and save money on transaction fees to card companies. It's also very convenient for users. It's a Kotlin Multiplatform library, targeting both Android & iOS.
The library was created with a significant contribution from Alza.cz a.s. It's also used by Settle Up app.
Currently, we support only banks that accept the SPAYD format, known as "QR payment" in the Czech Republic. The list of tested bank apps can be found here. We welcome pull requests about new bank support. Or open an issue if you found something about supported bank.
Add this to your dependencies:
implementation 'io.stepuplabs.pvba:pvba-android:<latest-version>'
val payViaBankAppResolver = SpaydPayViaBankAppResolver(application, fileProviderAuthority, bankAppPackages)
where:
application
is the Application contextfileProviderAuthority
is the authority of your file provider. If your app doesn't have one, create one similar to the sample app.bankAppPackages
is the list of supported bank app package names. It uses this list as default, but it's optional. However, it's recommended to pass this list dynamically via some service like Firebase Remote Config. This way, you can turn the support on/off for a specific bank without updating the app.
payViaBankAppResolver.isPayViaBankAppSupported()
This is false
if the user doesn't have any supported bank app installed. It's recommended to hide the feature.
You can get the icon of a supported bank app by calling:
payViaBankAppResolver.getSupportedBankAppIcon()
It's recommended to show this icon on the payment button to improve UX. If this method returns null, show some fallback icon or no icon at all.
val result = payViaBankAppResolver.payViaBankApp(spayd, navigationParams)
where:
spayd
is the string containing the payment information in a SPAYD format. We recommend our library for generating SPAYD on Android,navigationParams
should contain a WeakReference of your Activity to avoid memory leaks,result
is a Result class. If it's successful, the bank app has been successfully opened. Failure could be caused by two exceptions:BankAppOpeningException
is a problem with opening the bank app's Activity. You can get more details in the Exceptions'cause
.QrCodeFileException
is a problem with providing the file via a file provider. It's likely caused by a bad file provider configuration. You can get more details in the Exceptions'cause
.
Add dependency using Swift Package Manager:
Go to you project and select Package Dependencies, click +
in the lower left corner and add https://github.com/stepuplabs/bank-app-payment-poc.git
in the upper right corner of the presented dialog (marked "Search or Enter Package URL").
Add a new entry into dependencies
: .package(url: "https://github.com/stepuplabs/bank-app-payment-poc.git", from: "<latest-version>"),
Where appropriate, create an instance of SpaydPayViaBankAppResolver
and call .payViaBankApp()
on it.
SpaydPayViaBankAppResolver().payViaBankApp(spayd: spayd, navParams: NavigationParameters)
where:
spayd
is a string containing the payment information in the SPAYD format. We recommend our library for generating SPAYD on iOS.navParams
is a new instance ofNavigationParameters()
. iOS doesn't need it, it's there just for compatibility with Android.
On Android, the library uses intent APIs. Some bank apps can be opened directly with an intent containing the SPAYD string. Other bank apps accept images with a QR code containing SPAYD. If there is just one supported app, the QR code is not visible to the user and the bank app is opened directly. If the user has multiple supported bank apps, the system dialog is shown. The QR code is visible there and the user has to select their preferred bank app.
On iOS, the library generates the QR code and opens a sheet to share the QR code to another app. The user can then pick the bank app that can decode the QR code and pre-fill a payment order. If the bank app does not support sharing images, the user can save the generated QR code in their photo library and open it within the bank app for the same purpose. Bank app icons is not supported on iOS due to system limitation.
It's preferred to accept Intent with SPAYD payload:
<receiver android:name=".YourSpaydReceiver" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data android:mimeType="application/x-shortpaymentdescriptor" />
</intent-filter>
</receiver>
In your receiver, get SPAYD payload via intent.getStringExtra("spayd")
.
Support accepting an image with QR code containing SPAYD.
We would like to add support to more banks and markets, such as banks supporting the EPC code format.
Any contributions via pull requests are welcome.