mamo_business_sdk 1.0.3 mamo_business_sdk: ^1.0.3 copied to clipboard
Mamo Business SDK for Flutter
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:mamo_business_sdk/mamo_business_sdk.dart';
void main() {
runApp(const MaterialApp(home: MyApp()));
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
late MamoPaymentSessionController controller;
@override
void initState() {
super.initState();
String link = "https://business.mamopay.com/widget/pay/mostafa-827c56";
controller = MamoPaymentSessionController(
sessionLink: link,
onPaymentSuccess: (session) async {
print("Payment Success");
print("session is " + session.status);
print("session id " + session.transactionId);
await Future.delayed(const Duration(seconds: 4), () {
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (context) => const ConfirmationScreen()),
);
});
},
);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Mamo SDK Checkout app'),
),
body: Center(
child: MamoPaymentSessionView(controller: controller),
),
),
);
}
}
class ConfirmationScreen extends StatelessWidget {
const ConfirmationScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Order Confrimation"),
),
body: Center(
child: Text("Order confirmed "),
),
);
}
}