You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
877 B
35 lines
877 B
import 'package:flutter/material.dart';
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
class UpiIntentLauncher extends StatelessWidget {
|
|
const UpiIntentLauncher({super.key});
|
|
|
|
Future<void> pay() async {
|
|
const upiId = '9000950877@ybl'; // supplier UPI
|
|
const name = 'Sneha Supplier';
|
|
const amount = '1.00';
|
|
const note = 'Test Payment';
|
|
|
|
final uri = Uri.parse(
|
|
'upi://pay?pa=$upiId&pn=$name&am=$amount&cu=INR&tn=$note',
|
|
);
|
|
|
|
if (!await launchUrl(uri, mode: LaunchMode.externalApplication)) {
|
|
throw Exception('Could not launch UPI intent');
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text('Pay with UPI')),
|
|
body: Center(
|
|
child: ElevatedButton(
|
|
onPressed: pay,
|
|
child: const Text('Pay ₹1.00'),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|