flutter_to_mobilepay 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 46

flutter_to_mobilepay #

Flutter to MobilePay provides easy integration with MobilePay. It uses the MobilePay AppSwitch SDK to switch to the MobilePay app, perform the payment and then return the transaction information back to Flutter.

Flutter to MobilePay works on both Android* and iOS.

* see caveats further down

Warning #

This plugin has not yet been tested with a real merchant id or in a production application.

Usage #

import "package:flutter_to_mobilepay/flutter_to_mobilepay.dart";
import "package:uuid/uuid.dart";

void main() async {
    await MobilePay.initialize(
        merchantID: TestMerchantID.denmark,
        country: Country.denmark,
        urlScheme: "myapp", // iOS only, see installation

class MobilePayButton extends StatelessWidget {
    Widget build(BuildContext context) {
        return RaisedButton(
            child: const Text("Pay with MobilePay"),
            onPressed: () async {

                Payment payment = Payment(
                    orderID: Uuid().v4(),
                    price: 100, // double
                Transaction transaction = await MobilePay.createPayment(payment);
                print("transaction id: ${transaction.id}");
                print("order id: ${transaction.orderID}");
                print("total withdrawn: ${transaction.withdrawnFromCard}");


Installing #

Add the package as a dependency to your project


  # ...
  flutter_to_mobilepay: ^1.0.0

Android should be ready to go, however iOS requires a bit more work.

iOS #

Opening other apps on iOS requires registering their URL schemes (and your own). Add your app's URL scheme to your Info.plist if you haven't already.


<!-- ... -->
        <string> -- your bundle id -- </string>
                -- your url scheme --
This must match the one provided to `MobilePay.initialize(urlScheme: "")`

Documentation: https://developer.apple.com/documentation/uikit/inter-process_communication/allowing_apps_and_websites_to_link_to_your_content/defining_a_custom_url_scheme_for_your_app

If you wish to check if the MobilePay app is installed, you have to add the following URL schemes (or exclude the ones you don't need) to your Info.plist.


<!-- ... -->
    <string>mobilepay</string> <!-- denmark -->
    <string>mobilepayfi</string> <!-- finland -->
    <string>mobilepayno</string> <!-- norway -->

Caveats #

  • The MobilePay AppSwitch SDK does not target the latest Android SDK version. It uses deprecated APIs on newer versions and is not compatible with Android P at all.

Alternatives #

Contributing #

Implementation #

On the native side of things, Flutter to MobilePay is written in Objective C and Java. It does most things by calling the platform with maps as arguments, containing the needed data. However the payments are implemented using an EventChannel stream. This is because the payment callback is sent to the Android activity and iOS app delegate, not the function creating the payment. When the payment callback is received, it transforms it into a map and sends it to Flutter through the EventChannel. createPayment() awaits the payment and returns it to the user.

1.0.0 #

Release, woo-hoo!

  • Works on both Android on iOS
  • Uses the AppSwitch SDK provided by the MobilePay development team


Flutter to MobilePay example #

Screenshot of the example app

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  flutter_to_mobilepay: ^1.0.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:flutter_to_mobilepay/flutter_to_mobilepay.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Oct 11, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance suggestions

The package description is too short. (-18 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies