Reputation: 63
Can someone please help me how to get hold of the response once the UPI transaction is completed. I have used this help in Stack Overflow but it is not working: "https://stackoverflow.com/questions/48097332/how-can-we-get-response-from-an-app-which-was-launched-by-another-app".
In my case when I incorporate this it is saying MissingPluginException(No Implementation Method Found).
class _DisplayCartItemState extends State<DisplayCartItem> {
static const platform = const MethodChannel('upi/tez');
Uri uri;
@override
void initState() {
super.initState();
uri = Uri.parse('upi://pay?pa=*****@okhdfcbank&pn=Test App&tn=Payment Done through Foodie App&cu=INR&am=1');
}
_startPaymentTransaction(BuildContext context) async {
if (await canLaunch(uri.toString())) {
try {
final String result = await platform.invokeMethod('launchUpi', <String, dynamic>{"url": uri.toString()});
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(result),
));
print(result);
}catch(e){
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(e.toString()),
));
}
} else {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text("Could not launch the UPI App"),
));
}
}
}
Thanks
Upvotes: 1
Views: 1384
Reputation: 368
void _launchURL() async {
String _url='upi://pay?pa=dinesh@dlanzer&pn=Dinesh&am=1&tn=Test Payment&cu=INR';
var result = await launch(_url);
debugPrint(result.toString());
if (result ==true) {
print("Done");
} else if (result ==false){
print("Fail");
}
}
Try this code
I use url_launcher plugin for open UPI apps.
Deeplink url 'upi://pay?pa=dinesh@dlanzer&pn=Dinesh&am=1&tn=Test Payment&cu=INR'
,
upi
show list of UPI apps you have in your mobile.
pay
is redirect to payment page.
pa
you mention upi address here (please make business upi account and mention here).
am
amount enter here.
tn
just pass massage.
cu
mention which currency you want to make payment
Upvotes: 2