Skip to content

Repository files navigation

monext_flutter_sdk

Flutter plugin bridging Monext's native Android/iOS payment SDKs to a unified Dart API.

A Dart call to MonextPayment.startPayment(...) hosts Monext's native payment UI full-screen on top of the Flutter app (a dedicated Activity on Android, a modally-presented view on iOS), initializes the native SDK with the given session token/environment/appearance, and relays the payment outcome back to Dart once the flow completes. See docs/ for the architecture and design decisions behind this, and Project Setup Requirements for what a consuming app needs to configure beyond adding this dependency.

Dart API

import 'package:monext_flutter_sdk/monext.dart';

await MonextPayment.initialize();

await MonextPayment.startPayment(
  sessionToken: sessionToken,
  environment: MonextEnvironment.production,
  appearance: const MonextAppearance(headerTitle: 'Pay now'),
  onPaymentResult: (result) {
    // Raw MonextPaymentResult wire value (e.g. "captured", "failed",
    // "cancelled"); decode with MonextPaymentResult.fromValue.
  },
);
  • MonextPayment.initialize() sets up the plugin and is idempotent: calling it again is a no-op.
  • MonextPayment.startPayment(...) transmits sessionToken, environment and the optional appearance, language, googlePayConfiguration and applePayConfiguration to native code as a structured message. All of these are optional and any field left unset (including a whole parameter) falls back to the native SDK's own default. googlePayConfiguration is ignored on iOS and applePayConfiguration is ignored on Android — each platform only has the matching wallet button, and passing one costs nothing on the platform that ignores it. Enabling either wallet button for real also requires native project setup this plugin can't do on its own — see Google Pay Setup and Apple Pay Setup. onPaymentResult is invoked once, later, with the raw value native code sends when the payment flow completes; it applies no validation or transformation of its own, and is not invoked if startPayment itself throws. Calling startPayment again while a previous call is still in progress cancels that previous request: only the latest call's outcome is ever relayed to onPaymentResult.
  • It throws MonextPaymentNotInitializedException if called before initialize(), an ArgumentError if sessionToken is empty, a MonextPaymentChannelUnavailableException if no native handler is registered for the MethodChannel, and a MonextPaymentNativeException if the native SDK rejects the request synchronously (e.g. an invalid or expired session token), carrying its raw errorCode and message.

Try it

The example app is a runnable test screen with a session token field, an environment picker and a Buy button wired to startPayment. See example/README.md for how to run it and get a test session token.

About

Monext payment system Flutter lib

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages