I am developing a Flutter application where I need to integrate Paytm for payments. I have encountered issues with both the flutter_upi_india package and directly launching Paytm via URL schemes (paytm://). Here are the specifics of the problem:
Problem Description:
Using flutter_upi_india Package:
When attempting UPI payments using the flutter_upi_india package, transactions fail consistently across all payments apps (e.g., Paytm, PhonePe).
Direct URL Launch (url_launcher):
Trying to initiate payments by launching Paytm using url_launcher with the paytm:// URL scheme also results in failures.
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
class PaymentScreen extends StatelessWidget {
final String paytmQrCode = "paytmqr2810050501011uduvuiplds0@paytm&pn=Paytm%20Merchant&paytmqr=2810050501011UDUVUIPLDS0"; // Replace with actual Paytm QR code
final String transactionRefId = "txn123456789"; // Replace with a unique transaction reference ID
final String transactionNote = "Payment for Order"; // Replace with transaction note
final String amount = "100.00"; // Replace with the transaction amount in string format
final String currency = "INR"; // Replace with the currency code
void initiatePayment() async {
// Constructing the Paytm QR URI
Uri uri = Uri.parse(
"paytm://wallet/pay?mId=paytm&pa=$paytmQrCode&tid=$transactionRefId&tn=$transactionNote&am=$amount&cu=$currency");
if (await canLaunch(uri.toString())) {
await launch(uri.toString());
} else {
throw 'Could not launch $uri';
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Pay via Paytm'),
),
body: Center(
child: ElevatedButton(
onPressed: () {
initiatePayment();
},
child: Text('Pay with Paytm'),
),
),
);
}
}
Expected Outcome:
I expect the app to launch Paytm or other payment apps correctly when initiating a payment transaction. The user should be able to complete the payment seamlessly.
Request for Assistance:
I would appreciate any insights, solutions, or suggestions on how to resolve this issue and successfully integrate Paytm payments into my Flutter app. Thank you for your help!