npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-mobilepay

v1.2.0

Published

React-Native Bindings for Danske Bank Mobilepay AppSwitch iOS + Android

Downloads

11

Readme

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

  1. npm i --save react-native-mobilepay
  2. 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.

add urlscheme to info.plist

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.

whitelist urlscheme in info.plist

2. Open AppDelegate.m and paste the following

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
            options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {


  if ([[RNMobilePayHandler sharedInstance] handleMobilePayPaymentWithUrl:url]) {
    return true;
  }

  return false;
}

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

import MobilePay from 'react-native-mobilepay'

// constants are provided to determine if mobilepay is available on user's phone.

if (MobilePay.isMobilePayInstalledDenmark) {
  console.log('MobilePay is available for Denmark')
}

if (MobilePay.isMobilePayInstalledNorway) {
  console.log('MobilePay is available for Norway')
}

if (MobilePay.isMobilePayInstalledFinland) {
  console.log('MobilePay is available for Finland')
}

setup configurations

import MobilePay from 'react-native-mobilepay'

const merchantId = 'APPDK0000000000'
const country = MobilePay.COUNTRY_DENMARK
const merchantUrlScheme = 'fruitshop' // last argument is only used for iOS. (send empty string if only building for android)

MobilePay.setup(merchantId, country, merchantUrlScheme)

request a payment

import MobilePay from 'react-native-mobilepay'

const orderId = 'order-1234'
const amount = 150

MobilePay.createPayment(orderId, amount).then(
  result => {
    if (!result.isCancelled) {
      console.log(`payment successful order-id: ${result.orderId} transaction-id: ${result.transactionId}`)
    } else {
      console.log(`payment was cancelled`)
    }
  },
  error => {
    console.log('payment failed', error)
  }
)

additional configurations

// change country to Norway
MobilePay.setCountry(MobilePay.COUNTRY_NORWAY)
// or Finland
MobilePay.setCountry(MobilePay.COUNTRY_FINLAND)

// 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 timeout
MobilePay.setTimeoutSeconds(60)

// seconds spend on the MobilePay receipt screen before returning to the merchant app.
MobilePay.setReturnSeconds(10)

MobilePay.setCaptureType(MobilePay.CAPTURE_TYPE_CAPTURE)
MobilePay.setCaptureType(MobilePay.CAPTURE_TYPE_RESERVE)