Code committed
This commit is contained in:
@@ -377,75 +377,66 @@ class AddtocartProvider extends ChangeNotifier {
|
||||
|
||||
////////////////////////////COD ////////////
|
||||
|
||||
Future<void> paymentCODOrder(
|
||||
BuildContext context,
|
||||
double subtotal,
|
||||
int deliverCharge,
|
||||
String couponId,
|
||||
String addressId,
|
||||
) async {
|
||||
Future<bool> paymentCODOrder(
|
||||
BuildContext context,
|
||||
double subtotal,
|
||||
int deliverCharge,
|
||||
String couponId,
|
||||
String addressId,
|
||||
) async {
|
||||
ispaymentLoader = true;
|
||||
notifyListeners();
|
||||
var data;
|
||||
if (couponId.isNotEmpty) {
|
||||
data = {
|
||||
"addressId": addressId,
|
||||
"paymentMethod": "COD",
|
||||
"paymentStatus": "PENDING",
|
||||
"orderStatus": "PENDING",
|
||||
"subtotal": subtotal,
|
||||
"deliveryCharge": deliverCharge,
|
||||
"transactionId": "phonepe_transaction_123",
|
||||
"couponId": couponId
|
||||
};
|
||||
} else {
|
||||
data = {
|
||||
"addressId": addressId,
|
||||
"paymentMethod": "COD",
|
||||
"paymentStatus": "PENDING",
|
||||
"orderStatus": "PENDING",
|
||||
"subtotal": subtotal,
|
||||
"deliveryCharge": deliverCharge,
|
||||
};
|
||||
}
|
||||
|
||||
print("kjfhxgkljfhg ${data}");
|
||||
var data = {
|
||||
"addressId": addressId,
|
||||
"paymentMethod": "COD",
|
||||
"paymentStatus": "PENDING",
|
||||
"orderStatus": "PENDING",
|
||||
"subtotal": subtotal,
|
||||
"deliveryCharge": deliverCharge,
|
||||
};
|
||||
|
||||
if (couponId.isNotEmpty) {
|
||||
data["couponId"] = couponId;
|
||||
data["transactionId"] = "phonepe_transaction_123";
|
||||
}
|
||||
|
||||
try {
|
||||
var result = await _homeRepo.paymentCODOrder(data);
|
||||
|
||||
return result.fold(
|
||||
(error) {
|
||||
(error) {
|
||||
Fluttertoast.showToast(
|
||||
msg: "${error.message}",
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
backgroundColor: Colors.green,
|
||||
backgroundColor: Colors.red,
|
||||
textColor: Colors.white,
|
||||
fontSize: 14.0,
|
||||
);
|
||||
ispaymentLoader = false;
|
||||
notifyListeners();
|
||||
return false;
|
||||
},
|
||||
(response) {
|
||||
context.clearAndPush(routePath: MyRoutes.SUCCESSPAYMENT);
|
||||
|
||||
(response) {
|
||||
ispaymentLoader = false;
|
||||
notifyListeners();
|
||||
return true;
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
ispaymentLoader = false;
|
||||
notifyListeners();
|
||||
|
||||
Fluttertoast.showToast(
|
||||
msg: "${e}",
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
backgroundColor: Colors.green,
|
||||
backgroundColor: Colors.red,
|
||||
textColor: Colors.white,
|
||||
fontSize: 14.0,
|
||||
);
|
||||
notifyListeners();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user