Flutter library for Monri Android/iOS SDK
In pubspec.yaml add
dependencies:
MonriPayments:
git:
url: https://github.com/MonriPayments/flutter-monri-android-ios.gitOn your build.gradle file add this statement to the dependencies section:
buildscript {
//...
dependencies {
classpath 'com.android.tools.build:gradle:7.0.2'
}
}import 'package:MonriPayments/MonriPayments.dart';// ...
final monriPayments = MonriPayments.create();
Future<void> _continuePayment() async {
Map data = {};
// Platform messages may fail, so we use a try/catch PlatformException.
try {
var clientSecret = "client_secret"; // create one on your backend
var arguments = jsonDecode(_getJsonData(
isDevelopment: true,
clientSecret: clientSecret,
cardNumber: "4341792000000044",
cvv: 123,
expirationMonth: 12,
expirationYear: 2030,
cardHolderName: "Adnan Omerovic",
tokenizePan: true
));
data = (await monriPayments.confirmPayment(CardConfirmPaymentParams.fromJSON(arguments))).toJson();
} on PlatformException {
data = {};
}
}
String _getJsonData({
required String clientSecret,
required bool isDevelopment,
required String cardNumber,
required int cvv,
required int expirationMonth,
required int expirationYear,
required String cardHolderName,
required bool tokenizePan
}){
return """
{
"is_development_mode": $isDevelopment,
"authenticity_token": "a6d41095984fc60fe81cd3d65ecafe56d4060ca9", //available on merchant's dashboard
"client_secret": "$clientSecret",
"card": {
"pan": "$cardNumber",
"cvv": "$cvv",
"expiryMonth": "$expirationMonth",
"expiryYear": "$expirationYear",
"tokenize_pan": $tokenizePan
},
"transaction_params": {
"full_name": "$cardHolderName",
"address": "N/A",
"city": "Sarajevo",
"zip": "71000",
"phone": "N/A",
"country": "BA",
"email": "flutter@monri.com",
"custom_params": ""
}
}
""";
}To use Apple Pay, required parameter is merchantID as well as setuping up profile to accept Apple Pay capability.
For more information on how to setup the XCode project, follow native guidelines: Monri iOS Apple Pay Wiki To implement it in flutter, please refer to example project provided with the plugin.
For more information on how to setup the Android project, follow native guidelines: Monri Android Google Pay Wiki To implement it in flutter, please refer to example project provided with the plugin.
This API allows for easy extraction of credit card details using a camera.
First initialize the ScanDocApi:
MonriPayments monriPayments = MonriPayments.create();
monriPayments.initScanDoc(ScanDocApiOptions(scanDocApiBaseUrl: 'REPLACE', userKey: 'REPLACE', subClient: 'REPLACE', acceptTermsAndConditions: true));After initializing, you can call extractScannedCard, validation is not required.
await monriPayments.extractScannedCard(imageBase64, null);When sending configuration as null, default values will be used. Also, please beware that the required image format is Base64 String.
Scanning and extraction example is added to the example project in following screens:
- photo_capture.dart
- preview_screen.dart
- extract_results.dart
For further explanations on configuration and response data, please refer to native documentation:
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT