This is something not meant for url_launcher or webview to do. On native android, a mobile SDK for the payment gateway is used.
What you need is a flutter plugin/package for this payment gateway. Head on to pub.dev to see if there is a plugin/package available. In the absence of non, you could consider building a plugin off the mobile SDK.
I am using JazzCash Platform for online payment in Pakistan, All I need to do is make a Map<String,String> and redirect user to Jazzcash’s website with the Map.
I checked out Url_Launcher (https://pub.dev/packages/url_launcher) and WebView For Flutter (https://pub.dev/packages/webview_flutter) but both of them are not accepting body as their parameter.
Is there a way to do this in Flutter?
Here is the link for doing it Natively On Android : https://www.youtube.com/watch?v=MsBB80UBxeU
My Map:
var temp = {
"pp_Amount": "1599",
"pp_BillReference": "billRef",
"pp_CustomerEmail": user.email,
"pp_CustomerID": user.userId,
"pp_CustomerMobile": user.phoneNumber,
"pp_Description": "Description of transaction",
"pp_IsRegisteredCustomer": "Yes",
"pp_Language": "EN",
"pp_MerchantID": "######",
"pp_Password": "######",
"pp_ReturnURL": "http//localhost/case.php",
"pp_TxnCurrency": "PKR",
"pp_TxnDateTime": currentDate,
"pp_TxnExpiryDateTime": expDate,
"pp_TxnRefNo": refNo,
"pp_TxnType": "MPAY",
"pp_Version": "2.0",
"ppmpf_1": "1",
"ppmpf_2": "2",
"ppmpf_3": "3",
"ppmpf_4": "4",
"ppmpf_5": "5",
};
URL Launcher Code, I tried sending the data in header, did not worked there either:
Future<void> _launchInBrowser(
String url, Map<String, String> header1) async {
print('In Launch Func: $header1');
if (await canLaunch(url)) {
await launch(
url,
forceSafariVC: false,
forceWebView: false,
headers: header1,
);
} else {
throw 'Could not launch $url';
}
}
It works perfectly fine when I do http.post request but I need it to be redirected in the browser..