payment handler
This commit is contained in:
@@ -153,8 +153,9 @@ class AddtocartProvider extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
///////////////////////////////////orderPaymnet///////////////////////////
|
||||
|
||||
///////////////////////////////////orderPaymnet///////////////////////////
|
||||
bool ispaymentLoader = false;
|
||||
Future<void> orderPaymnet(
|
||||
BuildContext context,
|
||||
double amount,
|
||||
@@ -168,41 +169,49 @@ class AddtocartProvider extends ChangeNotifier {
|
||||
String addressId,
|
||||
String remarks,
|
||||
) async {
|
||||
ispaymentLoader = true;
|
||||
notifyListeners();
|
||||
|
||||
var data = {
|
||||
{
|
||||
"amount": amount,
|
||||
"currency": currency,
|
||||
"originalAmount": amount,
|
||||
"name": name,
|
||||
"phone": phone,
|
||||
"email": email,
|
||||
"userId": userI,
|
||||
"cartId": cartId,
|
||||
"addressId": addressId,
|
||||
"remarks": remarks
|
||||
}
|
||||
"amount": amount,
|
||||
"currency": currency,
|
||||
"originalAmount": amount,
|
||||
"name": name,
|
||||
"phone": phone,
|
||||
"email": email,
|
||||
"userId": userI,
|
||||
"cartId": cartId,
|
||||
"addressId": addressId,
|
||||
"remarks": remarks
|
||||
};
|
||||
|
||||
print("kjdfhgkj ${data}");
|
||||
|
||||
|
||||
try {
|
||||
var result = await _homeRepo.paymentOrder(data);
|
||||
return result.fold(
|
||||
(error) {
|
||||
ispaymentLoader = false;
|
||||
notifyListeners();
|
||||
},
|
||||
(response) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => PaymentWebView(paymentUrl: ''),
|
||||
),
|
||||
);
|
||||
if (response.data!.instrumentResponse!.redirectInfo != null &&
|
||||
response.data!.instrumentResponse!.redirectInfo != '') {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => PaymentWebView(
|
||||
paymentUrl:
|
||||
response.data!.instrumentResponse!.redirectInfo!.url),
|
||||
),
|
||||
);
|
||||
}
|
||||
ispaymentLoader = false;
|
||||
notifyListeners();
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
ispaymentLoader = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import 'package:grocery_app/src/data/banners.dart';
|
||||
import 'package:grocery_app/src/data/best_dealProduct.dart';
|
||||
import 'package:grocery_app/src/data/check_pin_response.dart';
|
||||
import 'package:grocery_app/src/data/login_response.dart';
|
||||
import 'package:grocery_app/src/data/order_paymnet.dart';
|
||||
import 'package:grocery_app/src/data/product_category.dart';
|
||||
import 'package:grocery_app/src/data/product_details.dart';
|
||||
import 'package:grocery_app/src/data/upload_image.dart';
|
||||
@@ -91,33 +92,28 @@ class ProductRepo {
|
||||
|
||||
return right(productCategory);
|
||||
} on DioException catch (e) {
|
||||
|
||||
var error = CustomDioExceptions.handleError(e);
|
||||
return left(error);
|
||||
}
|
||||
}
|
||||
|
||||
FutureResult<ProductCategory> paymentOrder(
|
||||
data) async
|
||||
{
|
||||
FutureResult<OrderPaymnet> paymentOrder(data) async {
|
||||
try {
|
||||
var response = await _productService.paymentOrder(data);
|
||||
print("kjdfglkjfdgjklfgkldj${data} ${response} ");
|
||||
|
||||
OrderPaymnet productCategory = orderPaymnetFromJson(response.toString());
|
||||
|
||||
ProductCategory productCategory = productCategoryFromJson(response.toString());
|
||||
|
||||
print("lkjdflkjfhgdkhfgkd ");
|
||||
// final String model = response.toString();
|
||||
|
||||
return right(productCategory);
|
||||
} on DioException catch (e) {
|
||||
|
||||
var error = CustomDioExceptions.handleError(e);
|
||||
return left(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
FutureResult<List<Product>> similarProduct(
|
||||
data, BuildContext context, id) async {
|
||||
try {
|
||||
@@ -176,33 +172,30 @@ class ProductRepo {
|
||||
return left(error);
|
||||
}
|
||||
}
|
||||
FutureResult<String> updateProfile(data) async {
|
||||
|
||||
FutureResult<String> updateProfile(data) async {
|
||||
try {
|
||||
var response = await _productService.updateProfile(data);
|
||||
|
||||
print("kdjfgkljfdkjlghflkgjh ${response}");
|
||||
final String model = response.toString();
|
||||
return right(model);
|
||||
final String model = response.toString();
|
||||
return right(model);
|
||||
} on DioException catch (e) {
|
||||
var error = CustomDioExceptions.handleError(e);
|
||||
return left(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
FutureResult<UploadImage> uploadImage(File imageFile)
|
||||
async {
|
||||
FutureResult<UploadImage> uploadImage(File imageFile) async {
|
||||
try {
|
||||
final response = await _productService.uploadImage(imageFile);
|
||||
UploadImage upload=uploadImageFromJson(response.toString());
|
||||
UploadImage upload = uploadImageFromJson(response.toString());
|
||||
return right(upload);
|
||||
} on DioException catch (e) {
|
||||
final error = CustomDioExceptions.handleError(e);
|
||||
return left(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FutureResult<CheckPinResponse> checkPin(data, pin) async {
|
||||
try {
|
||||
@@ -270,7 +263,8 @@ FutureResult<String> updateProfile(data) async {
|
||||
return left(error);
|
||||
}
|
||||
}
|
||||
FutureResult<String> decreaseQuantity(data) async {
|
||||
|
||||
FutureResult<String> decreaseQuantity(data) async {
|
||||
try {
|
||||
var response = await _productService.decreaseQuantity(data);
|
||||
|
||||
@@ -284,9 +278,6 @@ FutureResult<String> decreaseQuantity(data) async {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
FutureResult<WishListModel> gettAllWishList(data) async {
|
||||
try {
|
||||
var response = await _productService.gettAllWishList(data);
|
||||
@@ -337,9 +328,7 @@ FutureResult<String> decreaseQuantity(data) async {
|
||||
var response = await _productService.refresh_token(data);
|
||||
LoginResponse loginResponse = loginResponseFromJson(response.toString());
|
||||
|
||||
if (loginResponse.accessToken != null)
|
||||
{
|
||||
|
||||
if (loginResponse.accessToken != null) {
|
||||
await SharedPrefUtils.setToken(
|
||||
authToken: loginResponse.accessToken ?? "");
|
||||
await SharedPrefUtils.setRefreshToken(
|
||||
@@ -349,10 +338,7 @@ FutureResult<String> decreaseQuantity(data) async {
|
||||
final String model = response.toString();
|
||||
|
||||
return right(model);
|
||||
} on DioException catch (e)
|
||||
{
|
||||
|
||||
|
||||
} on DioException catch (e) {
|
||||
var error = CustomDioExceptions.handleError(e);
|
||||
return left(error);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,9 @@ class ProductService extends ApiService {
|
||||
|
||||
return response;
|
||||
}
|
||||
Future paymentOrder(data) async {
|
||||
|
||||
Future paymentOrder(data) async {
|
||||
print("kdjfgkjjkdfgkjdkfgjkdfgj ${data}");
|
||||
var response = await api.post(APIURL.paymentOrder, data: jsonEncode(data));
|
||||
|
||||
return response;
|
||||
@@ -83,23 +85,25 @@ class ProductService extends ApiService {
|
||||
await api.delete(APIURL.deleteItem + id, data: jsonEncode(data));
|
||||
return response;
|
||||
}
|
||||
Future addAddress(data) async {
|
||||
|
||||
Future addAddress(data) async {
|
||||
var response = await api.post(APIURL.addAddress, data: jsonEncode(data));
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
Future getProfile(data) async {
|
||||
Future getProfile(data) async {
|
||||
var response = await api.get(APIURL.getprofile, data: jsonEncode(data));
|
||||
return response;
|
||||
}
|
||||
|
||||
Future updateProfile(data) async {
|
||||
var response = await api.patch(APIURL.updateProfile, data: jsonEncode(data));
|
||||
var response =
|
||||
await api.patch(APIURL.updateProfile, data: jsonEncode(data));
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
Future<Response> uploadImage(File imageFile,
|
||||
Future<Response> uploadImage(File imageFile,
|
||||
{Map<String, dynamic>? additionalFields}) async {
|
||||
const String url = APIURL.uploadImage;
|
||||
return await api.uploadImage(
|
||||
@@ -109,13 +113,11 @@ class ProductService extends ApiService {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Future getAddress
|
||||
(data) async {
|
||||
var response =
|
||||
await api.get(APIURL.userAddress, data: jsonEncode(data));
|
||||
Future getAddress(data) async {
|
||||
var response = await api.get(APIURL.userAddress, data: jsonEncode(data));
|
||||
return response;
|
||||
}
|
||||
|
||||
Future addToWish(data) async {
|
||||
var response = await api.post(APIURL.addToWish, data: jsonEncode(data));
|
||||
|
||||
@@ -128,7 +130,7 @@ class ProductService extends ApiService {
|
||||
return response;
|
||||
}
|
||||
|
||||
Future decreaseQuantity(data) async {
|
||||
Future decreaseQuantity(data) async {
|
||||
var response = await api.patch(APIURL.addToCart, data: jsonEncode(data));
|
||||
|
||||
return response;
|
||||
|
||||
Reference in New Issue
Block a user