Flutter library for Monri Android/iOS SDK
In pubspec.yaml add
dependencies:
MonriPayments:
git:
url: https://github.com/MonriPayments/flutter-monri-android-ios.git
On 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": ""
}
}
""";
}
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT