flutter_openmoney

Last updated:

0 purchases

flutter_openmoney Image
flutter_openmoney Images
Add to Cart

Description:

flutter openmoney

Flutter OpenMoney #
Flutter plugin for OpenMoney SDK.

Getting Started
Installation
Usage
API
Example App

Getting Started #
This flutter plugin is a wrapper around openmoney Android SDK.
The following documentation is only focused on the wrapper around native Android SDK. To know more about this SDKs and how to link them within the projects, refer to the following documentation:
Android: https://github.com/eshantmittal/open-payment-android-aar
To initiate payment paymentToken and accessKey are mandatory variables.
paymentToken - Generated in server side. Know more
accessKey - Get from openmoney dashboard
Installation #
This plugin is available on Pub: https://pub.dev/packages/flutter_openmoney
Add this to dependencies in your app's pubspec.yaml
flutter_openmoney: ^0.0.1
copied to clipboard
Note for Android: Make sure that the minimum API level for your app is 19 or higher.
Usage #
Sample code to integrate can be found in example/lib/main.dart.
Import package
import 'package:flutter_openmoney/flutter_openmoney.dart';
copied to clipboard
Create FlutterOpenmoney instance
_flutterOpenmoney = FlutterOpenmoney();
copied to clipboard
Attach event listeners
The plugin uses event-based communication, and emits events when payment fails or succeeds.
The event names are exposed via the constants eventPaymentSuccess, eventPaymentError from the FlutterOpenmoney class.
Use the on(String event, Function handler) method on the FlutterOpenmoney instance to attach event listeners.

_flutterOpenmoney.on(FlutterOpenmoney.eventPaymentSuccess, _handlePaymentSuccess);
_flutterOpenmoney.on(FlutterOpenmoney.eventPaymentError, _handlePaymentError);
copied to clipboard
The handlers would be defined somewhere as

void _handlePaymentSuccess(PaymentSuccessResponse response) {
// Do something when payment succeeds
}

void _handlePaymentError(PaymentFailureResponse response) {
// Do something when payment fails
}
copied to clipboard
To clear event listeners, use the clear method on the FlutterOpenmoney instance.
_flutterOpenmoney.clear(); // Removes all listeners
copied to clipboard
Setup options
var options = PaymentOptions('<ACCESS_KEY_HERE>', '<PAYMENT_TOKEN_HERE>', PaymentMode.sandbox);
copied to clipboard
Checkout
_flutterOpenmoney.initPayment(options.toMap());
copied to clipboard
API #
initPayment(Map<String, String> options)
The options is instance of PaymentOptions class
The options has paymentToken and accessKey as a required property
Convert options to Map object using options.toMap() method
on(String eventName, Function listener)
Register event listeners for payment events.

eventName: The name of the event.
listener: The function to be called. The listener should accept a single argument of the following type:

PaymentSuccessResponse for eventPaymentSuccess
PaymentFailureResponse for eventPaymentError



clear()
Clear all event listeners.
Error Codes
The error codes have been exposed as integers by the FlutterOpenmoney class.
The error code is available as the code field of the PaymentFailureResponse instance passed to the callback.



Error Code
Description




invalidOptions
An issue with options passed in FlutterOpenmoney.initPayment


paymentCancelled
User cancelled the payment


paymentFailed
Payment process failed


unknownError
An unknown error occurred.



Event names
The event names have also been exposed as Strings by the Razorpay class.



Event Name
Description




eventPaymentSuccess
The payment was successful.


eventPaymentError
The payment was not successful.



PaymentSuccessResponse #



Field Name
Type
Description




paymentId
String
The ID for the payment.


paymentTokenId
String
The payment token id.



To confirm payment details refer this link https://docs.bankopen.com/reference/status-check-api-with-token-id
PaymentFailureResponse #



Field Name
Type
Description




code
int
The error code.


message
String
The error message.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.