payment handler
This commit is contained in:
@@ -80,6 +80,8 @@ class _CardCheckoutScreenState extends State<CardCheckoutScreen> {
|
||||
Expanded(
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
print("kjdhfkhjghjkdf");
|
||||
|
||||
paymentProvider.orderPaymnet(
|
||||
context,
|
||||
widget.amount,
|
||||
@@ -99,10 +101,12 @@ class _CardCheckoutScreenState extends State<CardCheckoutScreen> {
|
||||
color: APPCOLOR.lightGreen,
|
||||
borderRadius: BorderRadius.circular(10)),
|
||||
child: Center(
|
||||
child: Text(
|
||||
"Continue",
|
||||
style: context.customRegular(Colors.white, 16),
|
||||
),
|
||||
child: paymentProvider.ispaymentLoader
|
||||
? CircularProgressIndicator()
|
||||
: Text(
|
||||
"Continue",
|
||||
style: context.customRegular(Colors.white, 16),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -908,8 +908,9 @@ class _MycartState extends State<Mycart> {
|
||||
// }
|
||||
|
||||
Widget cartPlace() {
|
||||
return Consumer<AddtocartProvider>(builder: (context, provider, child) {
|
||||
print("jdhfgkdfkjg ${provider.allitem.createdAt}");
|
||||
return Consumer<AddtocartProvider>(builder: (context, provider, child)
|
||||
{
|
||||
|
||||
if (provider.isLoaddcartItem) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(left: 120),
|
||||
@@ -1186,10 +1187,12 @@ class _AddressBottomSheetState extends State<AddressBottomSheet> {
|
||||
"prxvsvxvice ${double.parse(paymentProvider.allitem.subtotal.toString())} ${paymentProvider.selecteUserName} ${paymentProvider.selectedAddress} ${paymentProvider.selecteEmail} ${paymentProvider.selecteUserPhone}");
|
||||
return ElevatedButton.icon(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return CardCheckoutScreen(
|
||||
amount: double.parse( paymentProvider.allitem.subtotal.toString()),
|
||||
amount: double.parse(
|
||||
paymentProvider.allitem.subtotal.toString()),
|
||||
currency: "INR",
|
||||
originalAmount: double.parse(
|
||||
paymentProvider.allitem.subtotal.toString()),
|
||||
@@ -1205,7 +1208,6 @@ class _AddressBottomSheetState extends State<AddressBottomSheet> {
|
||||
|
||||
// showPaymentMethodBottomSheet(context);
|
||||
// context.push(MyRoutes.SELECTPAYMENTSCREEN);
|
||||
//Navigator.pop(context);
|
||||
},
|
||||
label: Text(
|
||||
"Continue",
|
||||
|
||||
@@ -1,3 +1,36 @@
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||
|
||||
// class PaymentWebView extends StatefulWidget {
|
||||
// final String paymentUrl;
|
||||
|
||||
// PaymentWebView({required this.paymentUrl});
|
||||
|
||||
// @override
|
||||
// _PaymentWebViewState createState() => _PaymentWebViewState();
|
||||
// }
|
||||
|
||||
// class _PaymentWebViewState extends State<PaymentWebView> {
|
||||
// InAppWebViewController? webViewController;
|
||||
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Scaffold(
|
||||
// appBar: AppBar(title: Text("Complete Your Payment")),
|
||||
// body: InAppWebView(
|
||||
// initialUrlRequest: URLRequest(url: WebUri.uri(Uri.parse(widget.paymentUrl))),
|
||||
// onWebViewCreated: (controller)
|
||||
// {
|
||||
// webViewController = controller;
|
||||
// },
|
||||
// onLoadStop: (controller, url) async
|
||||
// {
|
||||
// print("Payment page loaded: $url");
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||
|
||||
@@ -12,19 +45,62 @@ class PaymentWebView extends StatefulWidget {
|
||||
|
||||
class _PaymentWebViewState extends State<PaymentWebView> {
|
||||
InAppWebViewController? webViewController;
|
||||
bool isErrorPage = false; // Track error state
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text("Complete Your Payment")),
|
||||
body: InAppWebView(
|
||||
initialUrlRequest: URLRequest(url: WebUri.uri(Uri.parse(widget.paymentUrl))),
|
||||
onWebViewCreated: (controller) {
|
||||
webViewController = controller;
|
||||
},
|
||||
onLoadStop: (controller, url) async {
|
||||
print("Payment page loaded: $url");
|
||||
},
|
||||
body: Stack(
|
||||
children: [
|
||||
Visibility(
|
||||
visible: !isErrorPage, // Show WebView only if there's no error
|
||||
child: InAppWebView(
|
||||
initialUrlRequest:
|
||||
URLRequest(url: WebUri.uri(Uri.parse(widget.paymentUrl))),
|
||||
onWebViewCreated: (controller) {
|
||||
webViewController = controller;
|
||||
},
|
||||
onLoadStop: (controller, url) async {
|
||||
print("Payment page loaded: $url");
|
||||
},
|
||||
onReceivedHttpError: (controller, request, response)
|
||||
{
|
||||
if (response.statusCode == 404)
|
||||
{
|
||||
setState(() {
|
||||
isErrorPage = true;
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
if (isErrorPage) _buildErrorPage(context), // Show custom error page
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildErrorPage(BuildContext context) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.error_outline, color: Colors.red, size: 80),
|
||||
SizedBox(height: 10),
|
||||
Text("Payment Failed",
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
|
||||
SizedBox(height: 10),
|
||||
Text("Something went wrong. Please try again.",
|
||||
textAlign: TextAlign.center),
|
||||
SizedBox(height: 20),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context); // Navigate back to previous screen
|
||||
},
|
||||
child: Text("Go Back"),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user