react-native-mobilepay
React-Native Bindings for Danske Bank Mobilepay AppSwitch https://github.com/MobilePayDev/MobilePay-AppSwitch-SDK currently bundling version 1.8.1 of Mobilepay AppSwitch SDK.
Installation
npm i --save react-native-mobilepay
react-native link react-native-mobilepay
iOS
The AppSwitch SDK supports three countries, which corresponds to respective versions of the MobilePay app, and each app has a distinct url scheme:
- MobilePay Denmark:
mobilepay://
- MobilePay Norway:
mobilepayno://
- MobilePay Finland:
mobilepayfi://
1. Enable AppSwitch Open your info.plist find "URL types" entry and add a "URL Identifier" entry with a value matching your bundle identifier fx. "com.trifork.MobilePayFruitShop".
Then add a "URL Schemes" Item with a name matching your app. In this example we use "fruitshop", and you should not add this to your production app - this is just an example! This is the part that enables opening your app from an url.
In this case you are now able to open a browser on your iPhone and type in "fruitshop://" and your app will open.
As of Xcode 7 and iOS9 SDK you must also whitelist the MobilePay URL scheme for the SDK (your merchant app) in order for it to be able to open the MobilePay app. This must be added to your info.plist - see the below screenshot.
2. Open AppDelegate.m and paste the following
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
3. Disable Bitcode
current version of https://github.com/MobilePayDev/MobilePay-AppSwitch-SDK does not support bitcode as discussed here: https://github.com/MobilePayDev/MobilePay-AppSwitch-SDK/pull/9
goto xcode buildsettings and disable bitcode
under build options
for more information see https://github.com/MobilePayDev/MobilePay-AppSwitch-SDK
Examples
// constants are provided to determine if mobilepay is available on user's phone. if MobilePayisMobilePayInstalledDenmark console if MobilePayisMobilePayInstalledNorway console if MobilePayisMobilePayInstalledFinland console
setup configurations
const merchantId = 'APPDK0000000000'const country = MobilePayCOUNTRY_DENMARKconst merchantUrlScheme = 'fruitshop' // last argument is only used for iOS. (send empty string if only building for android) MobilePay
request a payment
const orderId = 'order-1234'const amount = 150 MobilePay
additional configurations
// change country to NorwayMobilePay// or FinlandMobilePay // seconds that you allow the user to spend in the MobilePay app before returning to the merchant app, if exceeded when you try to swipe in Mobile Pay errorcode 8 is returned. Default is 0 = never timeoutMobilePay // seconds spend on the MobilePay receipt screen before returning to the merchant app.MobilePay MobilePayMobilePay