instamojo_plus 0.0.7
instamojo_plus: ^0.0.7 copied to clipboard
A Flutter package to integrate Instamojo payment gateway.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:instamojo_plus/instamojo_plus.dart';
// ignore: implementation_imports
import 'package:instamojo_plus/src/model/payment_request.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Instamojo Demo',
theme: ThemeData(primarySwatch: Colors.blue),
home: Homescreen());
}
}
class Homescreen extends StatelessWidget {
Homescreen({
super.key,
});
final paymentRequest = InstamojoPaymentRequest(
purpose: 'Subscription',
amount: double.parse('10'),
buyerName: 'name',
email: 'name@gmail.com',
phone: 'phonenumber',
redirectUrl: 'http://www.example.com/redirect/',
);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Instamojo Demo'),
),
body: Center(
child: ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => PaymentScreen(
clientId: 'clientId',
clientsecret: 'clientsecret',
paymentRequest: paymentRequest,
onPaymentSuccess: (p0) =>
debugPrint('Payment Success: $p0'),
onPaymentError: (p0) => debugPrint('¸ $p0'),
onPaymentCancel: () =>
debugPrint('Payment Cancelled'),
)),
);
},
child: const Text('Do payment'))));
}
}