Appointment Module's payment final changes!

models_removal
Faiz Hashmi 2 years ago
parent 63263801af
commit 057a202ed9

@ -50,13 +50,14 @@ class ApiConsts {
static String ServiceProviderService_Get = "${baseUrlServices}api/ServiceProviders/ServiceProviderService_Get";
static String BranchesAndServices = "${baseUrlServices}api/ServiceProviders/ServiceProviderDetail_Get";
static String GetAllNearBranches = "${baseUrlServices}api/ServiceProviders/ServiceProviderBranchDetail_Get";
static String GetServiceItemAppointmentScheduleSlots = "${baseUrlServices}api/ServiceProviders/ServiceItemAppointmentScheduleSlots_Get";
static String ServiceProvidersAppointmentCreate = "${baseUrlServices}api/ServiceProviders/ServiceProvidersAppointment_Create";
//Appointment APIs
static String serviceProvidersAppointmentGet = "${baseUrlServices}api/ServiceProviders/ServiceProvidersAppointment_Get";
static String serviceCategoryGet = "${baseUrlServices}api/Master/ServiceCategory_Get";
static String serviceItemsGet = "${baseUrlServices}api/ServiceProviders/ServiceItem_Get";
static String GetServiceItemAppointmentScheduleSlots = "${baseUrlServices}api/ServiceProviders/ServiceItemAppointmentScheduleSlots_GetByAppointmentType";
static String ServiceProvidersAppointmentCreate = "${baseUrlServices}api/ServiceProviders/ServiceProvidersAppointmentList_Create";
static String ServiceProviderAppointmentRescheduleCancelAppointment = "${baseUrlServices}api/ServiceProviders/ServiceProviderAppointment_RescheduleCancelAppointment";
//ServiceProvidersServiceID as params
// static String servicesGet = "${baseUrlServices}api/ServiceProviders/Services_Get";

@ -46,6 +46,7 @@ class AppRoutes {
static const String bookProviderAppView = "/bookProviderAppView";
static const String appointmentDetailView = "/appointmentDetailView";
static const String bookAppointmenServicesView = "/bookAppointmenServicesView";
static const String bookAppointmenSchedulesView = "/bookAppointmenSchedulesView";
static const String bookAppointmentsItemView = "/bookAppointmentsItemView";
static const String reviewAppointmentView = "/reviewAppointmentView";
@ -83,12 +84,28 @@ class AppRoutes {
forgetPassword: (context) => const ForgetPasswordPage(),
loginVerification: (context) => const LoginVerificationPage(),
loginWithPassword: (context) => const LoginWithPassword(),
loginMethodSelection: (context) => LoginMethodSelectionPage(ModalRoute.of(context)!.settings.arguments as String),
completeProfile: (context) => CompleteProfilePage(ModalRoute.of(context)!.settings.arguments as RegisterUserRespModel),
loginMethodSelection: (context) =>
LoginMethodSelectionPage(ModalRoute
.of(context)!
.settings
.arguments as String),
completeProfile: (context) =>
CompleteProfilePage(ModalRoute
.of(context)!
.settings
.arguments as RegisterUserRespModel),
verifyPassword: (context) => VerifyPasswordPage(),
confirmNewPasswordPage: (context) => ConfirmNewPasswordPage(ModalRoute.of(context)!.settings.arguments as String),
confirmNewPasswordPage: (context) =>
ConfirmNewPasswordPage(ModalRoute
.of(context)!
.settings
.arguments as String),
changePassword: (context) => const ChangePasswordPage(),
forgetPasswordMethodPage: (context) => ForgetPasswordMethodPage(ModalRoute.of(context)!.settings.arguments as String),
forgetPasswordMethodPage: (context) =>
ForgetPasswordMethodPage(ModalRoute
.of(context)!
.settings
.arguments as String),
changeMobilePage: (context) => ChangeMobilePage(),
changeEmailPage: (context) => const ChangeEmailPage(),
editAccountPage: (context) => const EditAccountPage(),

@ -206,6 +206,22 @@ extension AdPostEnum on int {
}
}
extension AppointmentEnum on int {
AppointmentStatusEnum toAppointmentStatusEnum() {
if (this == 1) {
return AppointmentStatusEnum.booked;
} else if (this == 2) {
return AppointmentStatusEnum.confirmed;
} else if (this == 3) {
return AppointmentStatusEnum.arrived;
} else if (this == 4) {
return AppointmentStatusEnum.cancelled;
} else {
return AppointmentStatusEnum.allAppointments;
}
}
}
extension AdPostStatusToInt on AdPostStatus {
int getIdFromAdPostStatusEnum() {
switch (this) {
@ -246,6 +262,50 @@ extension AdPostStatusToInt on AdPostStatus {
}
}
extension PaymentTypesToInt on PaymentTypes {
int getIdFromPaymentTypesEnum() {
switch (this) {
case PaymentTypes.subscription:
return 1;
case PaymentTypes.appointment:
return 2;
case PaymentTypes.adReserve:
return 3;
case PaymentTypes.ads:
return 4;
case PaymentTypes.request:
return 5;
default:
return 0;
}
}
}
extension AppointmentStatusToInt on AppointmentStatusEnum {
int getIdFromAppointmentStatusEnum() {
switch (this) {
case AppointmentStatusEnum.booked:
return 1;
case AppointmentStatusEnum.confirmed:
return 2;
case AppointmentStatusEnum.arrived:
return 3;
case AppointmentStatusEnum.cancelled:
return 4;
default:
return -1;
}
}
}
extension CreatedByRoleEnumToInt on CreatedByRoleEnum {
int getIdFromCreatedByRoleEnum() {
switch (this) {
@ -390,3 +450,69 @@ extension VehicleAdTypeEnum on int {
}
}
}
extension FormatMonthByName on int {
String getMonthNameByNumber() {
switch (this) {
case 1:
return "January";
case 2:
return "February";
case 3:
return "March";
case 4:
return "April";
case 5:
return "May";
case 6:
return "June";
case 7:
return "July";
case 8:
return "August";
case 9:
return "September";
case 10:
return "October";
case 11:
return "November";
case 12:
return "December";
default:
return "";
}
}
}
extension FormatMonthByNumber on String {
int getMonthNumberByName() {
switch (this) {
case "January":
return 1;
case "February":
return 2;
case "March":
return 3;
case "April":
return 4;
case "May":
return 5;
case "June":
return 6;
case "July":
return 7;
case "August":
return 8;
case "September":
return 9;
case "October":
return 10;
case "November":
return 11;
case "December":
return 12;
default:
return 1;
}
}
}

@ -1,3 +1,6 @@
import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/utils/enums.dart';
class AppointmentListModel {
int? id;
int? serviceSlotID;
@ -9,28 +12,34 @@ class AppointmentListModel {
bool? isPaymentRequired;
int? paymentStatus;
String? paymentStatusText;
String? customerName;
String? customerName;
String? providerName;
String? duration;
String? appointmentDate;
AppointmentStatusEnum? appointmentStatusEnum;
List<ServiceAppointmentItems>? serviceAppointmentItems;
AppointmentListModel(
{this.id,
this.serviceSlotID,
this.appointmentStatusID,
this.appointmentStatusText,
this.serviceProviderID,
this.customerID,
this.isActive,
this.isPaymentRequired,
this.paymentStatus,
this.paymentStatusText,
this.customerName,
this.providerName,
this.duration,
this.appointmentDate,
this.serviceAppointmentItems});
this.serviceSlotID,
this.appointmentStatusID,
this.appointmentStatusText,
this.serviceProviderID,
this.customerID,
this.isActive,
this.isPaymentRequired,
this.paymentStatus,
this.paymentStatusText,
this.customerName,
this.providerName,
this.duration,
this.appointmentDate,
this.serviceAppointmentItems});
@override
String toString() {
return 'AppointmentListModel{id: $id, serviceSlotID: $serviceSlotID, appointmentStatusID: $appointmentStatusID, appointmentStatusText: $appointmentStatusText, serviceProviderID: $serviceProviderID, customerID: $customerID, isActive: $isActive, isPaymentRequired: $isPaymentRequired, paymentStatus: $paymentStatus, paymentStatusText: $paymentStatusText, customerName: $customerName, providerName: $providerName, duration: $duration, appointmentDate: $appointmentDate, appointmentStatusEnum: $appointmentStatusEnum, serviceAppointmentItems: $serviceAppointmentItems}';
}
AppointmentListModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
@ -47,6 +56,7 @@ class AppointmentListModel {
providerName = json['providerName'];
duration = json['duration'];
appointmentDate = json['appointmentDate'];
appointmentStatusEnum = (json['appointmentStatusID'] as int).toAppointmentStatusEnum();
if (json['serviceAppointmentItems'] != null) {
serviceAppointmentItems = <ServiceAppointmentItems>[];
json['serviceAppointmentItems'].forEach((v) {
@ -54,29 +64,6 @@ class AppointmentListModel {
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['serviceSlotID'] = serviceSlotID;
data['appointmentStatusID'] = appointmentStatusID;
data['appointmentStatusText'] = appointmentStatusText;
data['serviceProviderID'] = serviceProviderID;
data['customerID'] = customerID;
data['isActive'] = isActive;
data['isPaymentRequired'] = isPaymentRequired;
data['paymentStatus'] = paymentStatus;
data['paymentStatusText'] = paymentStatusText;
data['customerName'] = customerName;
data['providerName'] = providerName;
data['duration'] = duration;
data['appointmentDate'] = appointmentDate;
if (serviceAppointmentItems != null) {
data['serviceAppointmentItems'] =
serviceAppointmentItems!.map((v) => v.toJson()).toList();
}
return data;
}
}
class ServiceAppointmentItems {
@ -85,11 +72,7 @@ class ServiceAppointmentItems {
String? serviceItemName;
String? serviceItemDescription;
ServiceAppointmentItems(
{this.id,
this.serviceItemID,
this.serviceItemName,
this.serviceItemDescription});
ServiceAppointmentItems({this.id, this.serviceItemID, this.serviceItemName, this.serviceItemDescription});
ServiceAppointmentItems.fromJson(Map<String, dynamic> json) {
id = json['id'];

@ -1,5 +1,6 @@
import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/models/services/item_model.dart';
import 'package:mc_common_app/models/services/service_model.dart';
import 'package:mc_common_app/models/widgets_models.dart';
class CustomTimeDateSlotModel {
@ -11,30 +12,25 @@ class CustomTimeDateSlotModel {
class ServiceAppointmentScheduleModel {
List<ServiceSlotList>? serviceSlotList;
List<ItemData>? serviceItemList;
List<ServiceModel>? servicesListInAppointment;
int? selectedDateIndex;
// String? selectedTimeSlot;
// List<TimeSlotModel>? availableDates;
// List<TimeSlotModel>? availableTimeSlots;
List<CustomTimeDateSlotModel>? customTimeDateSlotList;
CustomTimeDateSlotModel? selectedCustomTimeDateSlotModel;
double? amountToPay;
double? amountTotal;
double? amountRem;
int? appointmentType;
ServiceAppointmentScheduleModel({
this.serviceSlotList,
this.serviceItemList,
this.servicesListInAppointment,
this.selectedDateIndex,
// this.selectedTimeSlot,
// this.availableDates,
// this.availableTimeSlots,
this.customTimeDateSlotList,
this.selectedCustomTimeDateSlotModel,
this.amountToPay,
this.amountTotal,
this.amountRem,
this.appointmentType,
});
List<CustomTimeDateSlotModel> getFormattedDateTimeSlotPackage() {
@ -55,7 +51,11 @@ class ServiceAppointmentScheduleModel {
List<TimeSlotModel> timeslots = [];
for (var element in serviceSlotList!) {
if (element.slotDate == date) {
timeslots.add(TimeSlotModel(slotId: element.id!, slot: element.startTime!, date: element.slotDate!, isSelected: false, allowAppointment: element.bookAppointment! < element.allowAppointment!));
timeslots.add(TimeSlotModel(slotId: element.id!,
slot: element.startTime!,
date: element.slotDate!,
isSelected: false,
allowAppointment: element.bookAppointment! < element.allowAppointment!));
}
}
return timeslots;
@ -65,12 +65,13 @@ class ServiceAppointmentScheduleModel {
var seenSlots = <TimeSlotModel>{};
var slotTimeData = serviceSlotList!
.where((slot) => seenSlots.add(TimeSlotModel(
slot: slot.startTime!,
slotId: slot.id!,
isSelected: false,
date: slot.slotDate!.toFormattedDateWithoutTime(),
)))
.where((slot) =>
seenSlots.add(TimeSlotModel(
slot: slot.startTime!,
slotId: slot.id!,
isSelected: false,
date: slot.slotDate!.toFormattedDateWithoutTime(),
)))
.toList();
List<TimeSlotModel> slotTime = [];
for (var element in slotTimeData) {
@ -99,17 +100,19 @@ class ServiceAppointmentScheduleModel {
//TODO: I WILL START FROM HERE; I NEED TO ONLY PICK THE DISTINCT DATES FROM THE RESPONSE AND THEN BASED ON THE DATE SELECTION I WILL PICK THEIR SLOTS.
//TODO: AFTER THAT, I WILL
ServiceAppointmentScheduleModel.fromJson(Map<String, dynamic> json) {
ServiceAppointmentScheduleModel.fromJson
(Map<String, dynamic> json, {bool isForAppointment = false}) {
if (json['serviceSlotList'] != null) {
serviceSlotList = <ServiceSlotList>[];
json['serviceSlotList'].forEach((v) {
serviceSlotList!.add(ServiceSlotList.fromJson(v));
});
}
if (json['serviceItemList'] != null) {
serviceItemList = <ItemData>[];
json['serviceItemList'].forEach((v) {
serviceItemList!.add(ItemData.fromJson(v));
if (json['serviceList'] != null) {
servicesListInAppointment = <ServiceModel>[];
json['serviceList'].forEach((v) {
servicesListInAppointment!.add(ServiceModel.fromJson(v, isForAppointment: isForAppointment));
});
}
customTimeDateSlotList = getFormattedDateTimeSlotPackage();
@ -117,20 +120,7 @@ class ServiceAppointmentScheduleModel {
selectedDateIndex = null;
amountTotal = json['amountTotal'];
amountRem = json['amountRem'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
if (serviceSlotList != null) {
data['serviceSlotList'] = serviceSlotList!.map((v) => v.toJson()).toList();
}
if (serviceItemList != null) {
data['serviceItemList'] = serviceItemList!.map((v) => v.toJson()).toList();
}
data['amountToPay'] = amountToPay;
data['amountTotal'] = amountTotal;
data['amountRem'] = amountRem;
return data;
appointmentType = json['appointmentType'];
}
}
@ -152,23 +142,22 @@ class ServiceSlotList {
int? modifiedBy;
String? modifiedOn;
ServiceSlotList(
{this.id,
this.branchAppointmentScheduleID,
this.branchAppointmentSchedule,
this.serviceProviderID,
this.slotDate,
this.startTime,
this.endTime,
this.bookAppointment,
this.allowAppointment,
this.slotDurationMinute,
this.appointmentType,
this.isActive,
this.createdBy,
this.createdOn,
this.modifiedBy,
this.modifiedOn});
ServiceSlotList({this.id,
this.branchAppointmentScheduleID,
this.branchAppointmentSchedule,
this.serviceProviderID,
this.slotDate,
this.startTime,
this.endTime,
this.bookAppointment,
this.allowAppointment,
this.slotDurationMinute,
this.appointmentType,
this.isActive,
this.createdBy,
this.createdOn,
this.modifiedBy,
this.modifiedOn});
ServiceSlotList.fromJson(Map<String, dynamic> json) {
id = json['id'];

@ -22,18 +22,18 @@ class ItemModel {
});
factory ItemModel.fromJson(Map<String, dynamic> json) => ItemModel(
messageStatus: json["messageStatus"],
totalItemsCount: json["totalItemsCount"],
data: json["data"] == null ? [] : List<ItemData>.from(json["data"]!.map((x) => ItemData.fromJson(x))),
message: json["message"],
);
messageStatus: json["messageStatus"],
totalItemsCount: json["totalItemsCount"],
data: json["data"] == null ? [] : List<ItemData>.from(json["data"]!.map((x) => ItemData.fromJson(x))),
message: json["message"],
);
Map<String, dynamic> toJson() => {
"messageStatus": messageStatus,
"totalItemsCount": totalItemsCount,
"data": data == null ? [] : List<dynamic>.from(data!.map((x) => x.toJson())),
"message": message,
};
"messageStatus": messageStatus,
"totalItemsCount": totalItemsCount,
"data": data == null ? [] : List<dynamic>.from(data!.map((x) => x.toJson())),
"message": message,
};
}
class ItemData {
@ -52,6 +52,7 @@ class ItemData {
final bool? isAppointmentCustomerLoc;
final double? appointmentPricePercentage;
bool? isUpdateOrSelected;
bool? isHomeSelected;
ItemData({
this.id,
@ -69,37 +70,44 @@ class ItemData {
this.isAppointmentCustomerLoc,
this.appointmentPricePercentage,
this.isUpdateOrSelected,
this.isHomeSelected,
});
factory ItemData.fromJson(Map<String, dynamic> json) => ItemData(
id: json["id"],
name: json["name"],
price: json["price"].toString(),
manufactureDate: json["manufactureDate"],
description: json["description"],
pictureUrl: json["pictureUrl"],
companyId: json["companyID"],
serviceProviderServiceId: json["serviceProviderServiceID"],
serviceProviderServiceDescription: json["serviceProviderServiceDescription"],
isActive: json["isActive"],
isAllowAppointment: json["isAllowAppointment"],
isAppointmentCompanyLoc: json["isAppointmentCompanyLoc"],
isAppointmentCustomerLoc: json["isAppointmentCustomerLoc"],
isUpdateOrSelected: false,
);
id: json["id"],
name: json["name"],
price: json["price"].toString(),
manufactureDate: json["manufactureDate"],
description: json["description"],
pictureUrl: json["pictureUrl"],
companyId: json["companyID"],
serviceProviderServiceId: json["serviceProviderServiceID"],
serviceProviderServiceDescription: json["serviceProviderServiceDescription"],
isActive: json["isActive"],
isAllowAppointment: json["isAllowAppointment"],
isAppointmentCompanyLoc: json["isAppointmentCompanyLoc"],
isAppointmentCustomerLoc: json["isAppointmentCustomerLoc"],
isUpdateOrSelected: false,
isHomeSelected: false,
);
Map<String, dynamic> toJson() => {
"id": id,
"name": name,
"price": price,
"manufactureDate": manufactureDate,
"description": description,
"pictureUrl": pictureUrl,
"companyID": companyId,
"serviceProviderServiceID": serviceProviderServiceId,
"isActive": isActive,
"isAllowAppointment": isAllowAppointment,
"isAppointmentCompanyLoc": isAppointmentCompanyLoc,
"isAppointmentCustomerLoc": isAppointmentCustomerLoc,
};
}
"id": id,
"name": name,
"price": price,
"manufactureDate": manufactureDate,
"description": description,
"pictureUrl": pictureUrl,
"companyID": companyId,
"serviceProviderServiceID": serviceProviderServiceId,
"isActive": isActive,
"isAllowAppointment": isAllowAppointment,
"isAppointmentCompanyLoc": isAppointmentCompanyLoc,
"isAppointmentCustomerLoc": isAppointmentCustomerLoc,
};
@override
String toString() {
return 'ItemData{id: $id, name: $name, price: $price, manufactureDate: $manufactureDate, description: $description, pictureUrl: $pictureUrl, companyId: $companyId, serviceProviderServiceId: $serviceProviderServiceId, serviceProviderServiceDescription: $serviceProviderServiceDescription, isActive: $isActive, isAllowAppointment: $isAllowAppointment, isAppointmentCompanyLoc: $isAppointmentCompanyLoc, isAppointmentCustomerLoc: $isAppointmentCustomerLoc, appointmentPricePercentage: $appointmentPricePercentage, isUpdateOrSelected: $isUpdateOrSelected}';
}
}

@ -19,6 +19,9 @@ class ServiceModel {
bool isExpandedOrSelected;
int providerServiceId;
String providerServiceName;
bool isHomeSelected;
String homeLocation;
double currentTotalServicePrice;
ServiceModel({
this.serviceProviderServiceId,
@ -36,13 +39,15 @@ class ServiceModel {
this.rangePricePerKm,
this.itemsCount,
this.serviceItems,
this.isHomeSelected = false,
this.homeLocation = "",
this.currentTotalServicePrice = 0.0,
required this.isExpandedOrSelected,
required this.providerServiceId,
required this.providerServiceName,
});
factory ServiceModel.fromJson(Map<String, dynamic> json) =>
ServiceModel(
factory ServiceModel.fromJson(Map<String, dynamic> json, {bool isForAppointment = false}) => ServiceModel(
serviceProviderServiceId: json["serviceProviderServiceID"],
providerServiceDescription: json["providerServiceDescription"],
categoryId: json["categoryID"],
@ -57,14 +62,21 @@ class ServiceModel {
customerLocationRange: json["customerLocationRange"],
rangePricePerKm: json["rangePricePerKm"].toString(),
itemsCount: json["itemsCount"],
serviceItems: json["branchServiceItems"] == null ? [] : List<ItemData>.from(json["branchServiceItems"]!.map((x) => ItemData.fromJson(x))),
serviceItems: isForAppointment
? json["serviceItemList"] == null
? []
: List<ItemData>.from(json["serviceItemList"]!.map((x) => ItemData.fromJson(x)))
: json["branchServiceItems"] == null
? []
: List<ItemData>.from(json["branchServiceItems"]!.map((x) => ItemData.fromJson(x))),
isExpandedOrSelected: false,
providerServiceId: 0,
providerServiceName: "",
isHomeSelected: false,
homeLocation: "",
);
Map<String, dynamic> toJson() =>
{
Map<String, dynamic> toJson() => {
"serviceProviderServiceID": serviceProviderServiceId,
"providerServiceDescription": providerServiceDescription,
"categoryID": categoryId,

@ -4,13 +4,16 @@ import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:mc_common_app/classes/consts.dart';
import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/services/my_in_app_browser.dart';
import 'package:mc_common_app/utils/enums.dart';
import 'package:mc_common_app/utils/utils.dart';
abstract class PaymentService {
Future<void> placeAdPayment({
Future<void> placePayment({
required int id,
required int paymentType,
List<int>? appointmentIds,
required PaymentTypes paymentType,
required Function() onSuccess,
required Function() onFailure,
});
@ -44,13 +47,39 @@ class PaymentServiceImp implements PaymentService {
}
@override
Future<void> placeAdPayment({
Future<void> placePayment({
required int id,
required int paymentType,
List<int>? appointmentIds,
required PaymentTypes paymentType,
required Function() onSuccess,
required Function() onFailure,
}) async {
print("PaymentUrl: ${ApiConsts.paymentWebViewUrl}?PaymentType=$paymentType&AdsID=$id");
String urlRequest = "";
switch (paymentType) {
case PaymentTypes.subscription:
urlRequest = "";
break;
case PaymentTypes.appointment:
String appointIds = '';
for (var element in appointmentIds!) {
appointIds = "$appointIds$element:";
}
urlRequest = "${ApiConsts.paymentWebViewUrl}?PaymentType=${paymentType.getIdFromPaymentTypesEnum()}&AppointmentIDs=$appointIds";
break;
case PaymentTypes.adReserve:
urlRequest = "${ApiConsts.paymentWebViewUrl}?PaymentType=${paymentType.getIdFromPaymentTypesEnum()}&AdsID=$id";
break;
case PaymentTypes.ads:
urlRequest = "${ApiConsts.paymentWebViewUrl}?PaymentType=${paymentType.getIdFromPaymentTypesEnum()}&AdsID=$id";
break;
case PaymentTypes.request:
urlRequest = "";
break;
case PaymentTypes.extendAds:
urlRequest = "";
break;
}
print("PaymentUrl: $urlRequest");
myInAppBrowser = MyInAppBrowser(onExitCallback: () {
log("Browser Exited");
}, onLoadStartCallback: (String url) {
@ -58,7 +87,7 @@ class PaymentServiceImp implements PaymentService {
onBrowserLoadStart(onFailure: onFailure, onSuccess: onSuccess, url: url);
});
await myInAppBrowser!.openUrlRequest(
urlRequest: URLRequest(url: Uri.parse("${ApiConsts.paymentWebViewUrl}?PaymentType=$paymentType&AdsID=$id")),
urlRequest: URLRequest(url: Uri.parse(urlRequest)),
options: inAppBrowserOptions,
);
}

@ -78,8 +78,8 @@ enum PaymentMethods {
enum PaymentTypes {
subscription,
appointment,
ads,
adReserve,
ads,
request,
extendAds,
}
@ -141,3 +141,11 @@ enum BranchStatusEnum {
blocked, // 5
deactivated // 6
}
enum AppointmentStatusEnum {
booked,
confirmed,
arrived,
cancelled,
allAppointments,
}

@ -1,5 +1,6 @@
import 'package:flutter/cupertino.dart';
import 'package:mc_common_app/config/routes.dart';
import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/models/payment_models/pay_order_detail_resp_model.dart';
import 'package:mc_common_app/repositories/payments_repo.dart';
import 'package:mc_common_app/services/payments_service.dart';
@ -49,29 +50,72 @@ class PaymentVM extends ChangeNotifier {
return;
}
Future<void> placeThePayment({required int adId, required int paymentTypeId, required BuildContext context}) async {
await paymentService.placeAdPayment(
Future<void> onAdsPaymentSuccess({required BuildContext context, required int currentAdId, required int paymentTypeId}) async {
Utils.showLoading(context);
PayOrderDetailRespModel payOrderDetailRespModel = await paymentRepo.getPayOrderDetails(paymentId: paymentTypeId, adId: currentAdId);
await Future.delayed(const Duration(seconds: 2));
Utils.hideLoading(context);
print("payOrderDetailRespModel: ${payOrderDetailRespModel.toString()}");
if (payOrderDetailRespModel.isPaid == null || !payOrderDetailRespModel.isPaid!) {
Utils.showToast("Payment Failed!");
return;
}
if (payOrderDetailRespModel.isPaid != null && payOrderDetailRespModel.isPaid!) {
Utils.showToast("Payment Successful");
navigateReplaceWithNameUntilRoute(context, AppRoutes.dashboard);
}
}
Future<void> placeThePayment({required int adId, required PaymentTypes paymentTypeEnum, required BuildContext context}) async {
await paymentService.placePayment(
id: currentAdId,
paymentType: paymentTypeId,
paymentType: paymentTypeEnum,
onFailure: () {
Utils.showToast("Payment Failed!");
switch (paymentTypeEnum) {
case PaymentTypes.subscription:
// TODO: Handle this case.
break;
case PaymentTypes.appointment:
// TODO: Handle this case.
break;
case PaymentTypes.adReserve:
// TODO: Handle this case.
break;
case PaymentTypes.ads:
// TODO: Handle this case.
break;
case PaymentTypes.request:
// TODO: Handle this case.
break;
case PaymentTypes.extendAds:
// TODO: Handle this case.
break;
}
},
onSuccess: () async {
Utils.showLoading(context);
PayOrderDetailRespModel payOrderDetailRespModel = await paymentRepo.getPayOrderDetails(paymentId: paymentTypeId, adId: currentAdId);
await Future.delayed(const Duration(seconds: 2));
Utils.hideLoading(context);
print("payOrderDetailRespModel: ${payOrderDetailRespModel.toString()}");
if (payOrderDetailRespModel.isPaid == null || !payOrderDetailRespModel.isPaid!) {
Utils.showToast("Payment Failed!");
return;
}
if (payOrderDetailRespModel.isPaid != null && payOrderDetailRespModel.isPaid!) {
Utils.showToast("Payment Successful");
navigateReplaceWithNameUntilRoute(context, AppRoutes.dashboard);
switch (paymentTypeEnum) {
case PaymentTypes.subscription:
// TODO: Handle this case.
break;
case PaymentTypes.appointment:
// TODO: Handle this case.
break;
case PaymentTypes.adReserve:
// TODO: Handle this case.
break;
case PaymentTypes.ads:
await onAdsPaymentSuccess(context: context, paymentTypeId: paymentTypeEnum.getIdFromPaymentTypesEnum(), currentAdId: currentAdId);
break;
case PaymentTypes.request:
// TODO: Handle this case.
break;
case PaymentTypes.extendAds:
// TODO: Handle this case.
break;
}
},
);
@ -80,25 +124,26 @@ class PaymentVM extends ChangeNotifier {
Future<void> onVisaCardSelected(BuildContext context, PaymentTypes paymentType) async {
currentPaymentType = paymentType;
switch (currentPaymentType) {
case PaymentTypes.appointment:
break;
case PaymentTypes.ads:
if (currentAdId == -1) return;
int paymentType = 3;
await placeThePayment(adId: currentAdId, context: context, paymentTypeId: paymentType);
await placeThePayment(adId: currentAdId, context: context, paymentTypeEnum: paymentType);
break;
case PaymentTypes.adReserve:
if (currentAdId == -1) return;
int paymentType = 4;
await placeThePayment(adId: currentAdId, context: context, paymentTypeId: paymentType);
await placeThePayment(adId: currentAdId, context: context, paymentTypeEnum: paymentType);
break;
case PaymentTypes.extendAds:
if (currentAdId == -1) return;
int paymentType = 6;
await placeThePayment(adId: currentAdId, context: context, paymentTypeId: paymentType);
break;
await placeThePayment(adId: currentAdId, context: context, paymentTypeEnum: paymentType);
break;
case PaymentTypes.request:
// TODO: Handle this case.
@ -106,9 +151,6 @@ class PaymentVM extends ChangeNotifier {
case PaymentTypes.subscription:
// TODO: Handle this case.
break;
case PaymentTypes.appointment:
// TODO: Handle this case.
break;
}
}
}

@ -649,7 +649,7 @@ class BuildAdDetailsActionButtonForMyAds extends StatelessWidget {
});
}
Widget pendingForReviewAction(BuildContext context, {required bool isPendingPost}) {
Widget pendingForReviewAction({required bool isPendingPost}) {
return Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
@ -881,10 +881,10 @@ class BuildAdDetailsActionButtonForMyAds extends StatelessWidget {
case AdPostStatus.rejected:
case AdPostStatus.cancelled:
case AdPostStatus.pendingForPost:
return pendingForReviewAction(context, isPendingPost: true);
return pendingForReviewAction(isPendingPost: true);
case AdPostStatus.pendingForReview:
return pendingForReviewAction(context, isPendingPost: false);
return pendingForReviewAction(isPendingPost: false);
case AdPostStatus.sold:
case AdPostStatus.expired:

@ -26,8 +26,10 @@ class DropdownField extends StatefulWidget {
final List<DropValue>? list;
final DropValue? dropdownValue;
final Function(DropValue) onSelect;
final bool showAppointmentPickerVariant;
final TextStyle? textStyle;
const DropdownField(this.onSelect, {Key? key, this.hint, this.list, this.dropdownValue, this.errorValue = ""}) : super(key: key);
const DropdownField(this.onSelect, {Key? key, this.hint, this.list, this.dropdownValue, this.errorValue = "", this.showAppointmentPickerVariant = false, this.textStyle}) : super(key: key);
@override
State<DropdownField> createState() => _DropdownFieldState();
@ -43,7 +45,6 @@ class _DropdownFieldState extends State<DropdownField> {
@override
void initState() {
super.initState();
}
@override
@ -52,19 +53,20 @@ class _DropdownFieldState extends State<DropdownField> {
return Column(
children: [
Container(
decoration: Utils.containerColorRadiusBorderWidth(MyColors.white, 0, MyColors.darkPrimaryColor, 2),
decoration: widget.showAppointmentPickerVariant ? null : Utils.containerColorRadiusBorderWidth(MyColors.white, 0, MyColors.darkPrimaryColor, 2),
margin: const EdgeInsets.all(0),
padding: const EdgeInsets.only(left: 8, right: 8),
// padding: const EdgeInsets.only(left: 0, right: ),
width: widget.showAppointmentPickerVariant ? 170 : null,
child: DropdownButton<DropValue>(
value: dropdownValue,
icon: const Icon(Icons.keyboard_arrow_down_sharp),
elevation: 16,
iconSize: 16,
iconSize: widget.showAppointmentPickerVariant ? 26 : 16,
iconEnabledColor: borderColor,
iconDisabledColor: borderColor,
isExpanded: true,
style: const TextStyle(color: Colors.black, fontWeight: FontWeight.w600, fontSize: 15),
hint: (widget.hint ?? "").toText(color: borderColor, fontSize: 15),
style: widget.showAppointmentPickerVariant ? widget.textStyle : const TextStyle(color: Colors.black, fontWeight: FontWeight.w600, fontSize: 15),
hint: (widget.hint ?? "").toText(color: widget.showAppointmentPickerVariant ? Colors.black : borderColor, fontSize: widget.showAppointmentPickerVariant ? 18 : 15),
underline: Container(height: 0),
onChanged: (DropValue? newValue) {
setState(() {

Loading…
Cancel
Save