25-6-23/1
This commit is contained in:
@@ -188,16 +188,16 @@ Download the Tripz app now and enjoy your ride!
|
||||
(driverInvitationData[index]['driverInviterId']),
|
||||
('500'),
|
||||
);
|
||||
await Get.find<CaptainWalletController>()
|
||||
.addSeferWallet('giftInvitation', ('-1000'));
|
||||
// await Get.find<CaptainWalletController>()
|
||||
// .addSeferWallet('giftInvitation', ('-1000'));
|
||||
NotificationCaptainController().addNotificationCaptain(
|
||||
driverInvitationData[index]['driverInviterId'].toString(),
|
||||
"You have got a gift for invitation".tr,
|
||||
'${"You have 500".tr} ${'LE'}',
|
||||
'${"You have 500".tr} ${'LE'.tr}',
|
||||
false);
|
||||
NotificationController().showNotification(
|
||||
"You have got a gift for invitation".tr,
|
||||
'${"You have 500".tr} ${'LE'}',
|
||||
'${"You have 500".tr} ${'LE'.tr}',
|
||||
'tone1',
|
||||
'');
|
||||
} else {
|
||||
@@ -264,6 +264,7 @@ Download the Tripz app now and enjoy your ride!
|
||||
link: AppLink.updatePassengerGift,
|
||||
payload: {'id': driverInvitationDataToPassengers[index]['id']},
|
||||
);
|
||||
|
||||
// Notify the inviter
|
||||
NotificationCaptainController().addNotificationCaptain(
|
||||
driverInvitationDataToPassengers[index]['passengerInviterId']
|
||||
|
||||
@@ -98,7 +98,7 @@ class LoginDriverController extends GetxController {
|
||||
final random = Random();
|
||||
|
||||
if (random.nextBool()) {
|
||||
// await SecurityHelper.performSecurityChecks();
|
||||
await SecurityHelper.performSecurityChecks();
|
||||
} else {
|
||||
await SecurityChecks.isDeviceRootedFromNative(Get.context!);
|
||||
}
|
||||
@@ -145,20 +145,21 @@ class LoginDriverController extends GetxController {
|
||||
);
|
||||
if (response0.statusCode == 200) {
|
||||
final decodedResponse1 = jsonDecode(response0.body);
|
||||
// Log.print('decodedResponse1: ${decodedResponse1}');
|
||||
Log.print('decodedResponse1: ${decodedResponse1}');
|
||||
|
||||
final jwt = decodedResponse1['jwt'];
|
||||
box.write(BoxName.jwt, X.c(X.c(X.c(jwt, cn), cC), cs));
|
||||
// await box.write(BoxName.hmac, decodedResponse1['hmac']);
|
||||
|
||||
await AppInitializer().getAIKey(Driver.keyOfApp);
|
||||
await AppInitializer().getAIKey(Driver.initializationVector);
|
||||
await Future.delayed(Duration.zero);
|
||||
await EncryptionHelper.initialize();
|
||||
|
||||
await AppInitializer().getAIKey(Driver.payMobApikey);
|
||||
await AppInitializer().getAIKey(Driver.FCM_PRIVATE_KEY);
|
||||
|
||||
await AppInitializer().getAIKey(Driver.initializationVector);
|
||||
await AppInitializer().getAIKey(Driver.keyOfApp);
|
||||
|
||||
// ✅ بعد التأكد أن كل المفاتيح موجودة
|
||||
await EncryptionHelper.initialize();
|
||||
|
||||
await AppInitializer().getKey();
|
||||
} else {}
|
||||
} else {
|
||||
|
||||
@@ -44,7 +44,7 @@ class AccessTokenManager {
|
||||
_accessToken = client.credentials.accessToken;
|
||||
_expiryDate = client.credentials.accessToken.expiry;
|
||||
client.close();
|
||||
Log.print('_accessToken!.data: ${_accessToken!.data}');
|
||||
// Log.print('_accessToken!.data: ${_accessToken!.data}');
|
||||
return _accessToken!.data;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to obtain access token');
|
||||
|
||||
@@ -14,6 +14,7 @@ import '../../constant/box_name.dart';
|
||||
import '../../constant/colors.dart';
|
||||
import '../../constant/style.dart';
|
||||
import '../../main.dart';
|
||||
import '../../print.dart';
|
||||
import '../../views/auth/captin/criminal_documents_page.dart';
|
||||
import '../../views/home/Captin/home_captain/home_captin.dart';
|
||||
import '../../views/home/Captin/orderCaptin/order_speed_request.dart';
|
||||
@@ -180,6 +181,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
'Trip Cancelled. The cost of the trip will be added to your wallet.'
|
||||
.tr, () {
|
||||
box.write(BoxName.rideStatus, 'Cancel');
|
||||
Log.print('rideStatus from 184 : ${box.read(BoxName.rideStatus)}');
|
||||
Get.offAll(HomeCaptain());
|
||||
});
|
||||
// cancelTripDialog1();
|
||||
@@ -341,6 +343,8 @@ class FirebaseMessagesController extends GetxController {
|
||||
title: 'Ok'.tr,
|
||||
onPressed: () {
|
||||
box.write(BoxName.rideStatus, 'Cancel');
|
||||
Log.print(
|
||||
'rideStatus from 347 : ${box.read(BoxName.rideStatus)}');
|
||||
Get.offAll(HomeCaptain());
|
||||
}));
|
||||
}
|
||||
@@ -356,6 +360,8 @@ class FirebaseMessagesController extends GetxController {
|
||||
title: 'Ok'.tr,
|
||||
onPressed: () {
|
||||
box.write(BoxName.rideStatus, 'Cancel');
|
||||
Log.print(
|
||||
'rideStatus from 364 : ${box.read(BoxName.rideStatus)}');
|
||||
Get.offAll(HomeCaptain());
|
||||
}));
|
||||
}
|
||||
@@ -405,7 +411,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
Future<void> onInit() async {
|
||||
super.onInit();
|
||||
try {
|
||||
var encryptedKey = await storage.read(key: 'FCM_PRIVATE_KEY');
|
||||
var encryptedKey = await storage.read(key: BoxName.FCM_PRIVATE_KEY);
|
||||
// Log.print('encryptedKey: ${encryptedKey}');
|
||||
if (encryptedKey != null) {
|
||||
serviceAccountKeyJson =
|
||||
@@ -707,33 +713,40 @@ class FirebaseMessagesController extends GetxController {
|
||||
if (response.statusCode == 200) {
|
||||
print(
|
||||
'Notification sent successfully. Status code: ${response.statusCode}');
|
||||
print('Response body: ${response.body}');
|
||||
} else if (response.statusCode == 404) {
|
||||
// Handle UNREGISTERED token
|
||||
final responseBody = jsonDecode(response.body);
|
||||
final errorCode = responseBody['error']['details']?[0]?['errorCode'];
|
||||
|
||||
if (errorCode == 'UNREGISTERED') {
|
||||
print('Token is unregistered/invalid: $token');
|
||||
// Remove token from your database
|
||||
await removeInvalidToken(token);
|
||||
return; // Don't retry for invalid tokens
|
||||
}
|
||||
} else {
|
||||
print(
|
||||
'Failed to send notification. Status code: ${response.statusCode}');
|
||||
|
||||
print('Response body: ${response.body}');
|
||||
|
||||
if (retryCount > 0) {
|
||||
print('Retrying... Attempts remaining: $retryCount');
|
||||
await Future.delayed(
|
||||
const Duration(seconds: 2)); // Optional delay before retrying
|
||||
return sendNotificationToPassengerTokenCALL(
|
||||
title, body, token, data, tone,
|
||||
await Future.delayed(const Duration(seconds: 2));
|
||||
return sendNotificationToDriverMAP(title, body, token, data, tone,
|
||||
retryCount: retryCount - 1);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error sending notification: $e');
|
||||
if (retryCount > 0) {
|
||||
print('Retrying... Attempts remaining: $retryCount');
|
||||
await Future.delayed(
|
||||
const Duration(seconds: 2)); // Optional delay before retrying
|
||||
return sendNotificationToPassengerTokenCALL(
|
||||
title, body, token, data, tone,
|
||||
retryCount: retryCount - 1);
|
||||
}
|
||||
// ... existing error handling ...
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> removeInvalidToken(String token) async {
|
||||
// Remove token from your database/storage
|
||||
// This prevents future attempts to send to invalid tokens
|
||||
print('Removing invalid token from database: $token');
|
||||
// Your database cleanup logic here
|
||||
}
|
||||
}
|
||||
|
||||
class OverlayContent extends StatelessWidget {
|
||||
|
||||
@@ -522,7 +522,7 @@ class NotificationController extends GetxController {
|
||||
if (data is String) {
|
||||
var orderData = jsonDecode(data);
|
||||
if (orderData is List && orderData.length == 34) {
|
||||
closeOverLay();
|
||||
//closeOverLay();
|
||||
Get.put(HomeCaptainController()).changeRideId();
|
||||
Get.to(() => OrderRequestPage(), arguments: {'myListString': data});
|
||||
} else {
|
||||
@@ -537,7 +537,7 @@ class NotificationController extends GetxController {
|
||||
if (data is String) {
|
||||
var orderData = jsonDecode(data);
|
||||
if (orderData is List && orderData.length == 34) {
|
||||
closeOverLay();
|
||||
//closeOverLay();
|
||||
Get.put(HomeCaptainController()).changeRideId();
|
||||
Get.to(() => OrderRequestPage(), arguments: {'myListString': data});
|
||||
} else {
|
||||
@@ -550,7 +550,7 @@ class NotificationController extends GetxController {
|
||||
|
||||
void _handleADSNotification() {
|
||||
// var orderData = jsonDecode(data);
|
||||
closeOverLay();
|
||||
//closeOverLay();
|
||||
Get.to(
|
||||
() => const NotificationCaptain(),
|
||||
);
|
||||
|
||||
@@ -94,9 +94,9 @@ class CRUD {
|
||||
'X-HMAC-Auth': hmac.toString(),
|
||||
},
|
||||
);
|
||||
Log.print('response.request: ${response.request}');
|
||||
Log.print('response.body: ${response.body}');
|
||||
print(payload);
|
||||
// Log.print('response.request: ${response.request}');
|
||||
// Log.print('response.body: ${response.body}');
|
||||
// print(payload);
|
||||
if (response.statusCode == 200) {
|
||||
var jsonData = jsonDecode(response.body);
|
||||
if (jsonData['status'] == 'success') {
|
||||
@@ -128,11 +128,13 @@ class CRUD {
|
||||
Future<dynamic> postWallet(
|
||||
{required String link, Map<String, dynamic>? payload}) async {
|
||||
var s = await LoginDriverController().getJwtWallet();
|
||||
// Log.print('jwt: ${s}');
|
||||
final hmac = box.read(BoxName.hmac);
|
||||
Log.print('hmac: ${hmac}');
|
||||
// Log.print('hmac: ${hmac}');
|
||||
var url = Uri.parse(link);
|
||||
// Log.print('url: ${url}');
|
||||
try {
|
||||
await LoginDriverController().getJWT();
|
||||
// await LoginDriverController().getJWT();
|
||||
|
||||
var response = await http.post(
|
||||
url,
|
||||
@@ -143,9 +145,9 @@ class CRUD {
|
||||
'X-HMAC-Auth': hmac.toString(),
|
||||
},
|
||||
);
|
||||
print(response.request);
|
||||
Log.print('response.body: ${response.body}');
|
||||
print(payload);
|
||||
// Log.print('response.request:${response.request}');
|
||||
// Log.print('response.body: ${response.body}');
|
||||
// Log.print('payload:$payload');
|
||||
if (response.statusCode == 200) {
|
||||
try {
|
||||
var jsonData = jsonDecode(response.body);
|
||||
@@ -201,9 +203,9 @@ class CRUD {
|
||||
// 'Authorization': 'Bearer ${box.read(BoxName.jwt)}'
|
||||
},
|
||||
);
|
||||
print(response.request);
|
||||
Log.print('response.body: ${response.body}');
|
||||
print(payload);
|
||||
// print(response.request);
|
||||
// Log.print('response.body: ${response.body}');
|
||||
// print(payload);
|
||||
if (response.statusCode == 200) {
|
||||
try {
|
||||
var jsonData = jsonDecode(response.body);
|
||||
@@ -439,22 +441,46 @@ class CRUD {
|
||||
}
|
||||
}
|
||||
|
||||
sendEmail(
|
||||
String link,
|
||||
Map<String, String>? payload,
|
||||
) async {
|
||||
var headers = {
|
||||
Future<void> sendEmail(String link, Map<String, String>? payload) async {
|
||||
// التحقق من صلاحية التوكن
|
||||
String rawJwt = box.read(BoxName.jwt);
|
||||
String token = X
|
||||
.r(X.r(X.r(rawJwt, cn), cC), cs)
|
||||
.toString()
|
||||
.split(AppInformation.addd)[0];
|
||||
|
||||
bool isTokenExpired = JwtDecoder.isExpired(token);
|
||||
if (isTokenExpired) {
|
||||
await LoginDriverController().getJWT();
|
||||
rawJwt = box.read(BoxName.jwt); // تحديث التوكن بعد التجديد
|
||||
token = X
|
||||
.r(X.r(X.r(rawJwt, cn), cC), cs)
|
||||
.toString()
|
||||
.split(AppInformation.addd)[0];
|
||||
}
|
||||
|
||||
// إعداد الهيدر
|
||||
final headers = {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
'Authorization':
|
||||
'Basic ${base64Encode(utf8.encode(AK.basicAuthCredentials))}',
|
||||
"Authorization": "Bearer $token",
|
||||
};
|
||||
var request = http.Request('POST', Uri.parse(link));
|
||||
request.bodyFields = payload!;
|
||||
|
||||
// إعداد الطلب
|
||||
final request = http.Request('POST', Uri.parse(link));
|
||||
request.bodyFields = payload ?? {};
|
||||
request.headers.addAll(headers);
|
||||
|
||||
http.StreamedResponse response = await request.send();
|
||||
// إرسال الطلب
|
||||
final response = await request.send();
|
||||
|
||||
// التحقق من النتيجة
|
||||
if (response.statusCode == 200) {
|
||||
} else {}
|
||||
print("✅ Email sent successfully.");
|
||||
} else {
|
||||
print("❌ Failed to send email. Status: ${response.statusCode}");
|
||||
final responseBody = await response.stream.bytesToString();
|
||||
print("Response body: $responseBody");
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> postFromDialogue({
|
||||
|
||||
@@ -105,7 +105,7 @@ class AI extends GetxController {
|
||||
NotificationController().showNotification(
|
||||
"Code approved".tr, "Code approved".tr, 'tone2', '');
|
||||
// Notification text with dynamic token
|
||||
FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||
Get.put(FirebaseMessagesController()).sendNotificationToDriverMAP(
|
||||
'You have received a gift token!'.tr,
|
||||
'for '.tr + box.read(BoxName.phoneDriver).toString(),
|
||||
jsonDecode(res)['message'][0]['token'].toString(),
|
||||
|
||||
@@ -133,8 +133,8 @@ class LocationController extends GetxController {
|
||||
|
||||
// ✅ إدخال للسيرفر كل دقيقة
|
||||
_insertCounter++;
|
||||
Log.print('_insertCounter: ${_insertCounter}');
|
||||
if (_insertCounter >= 12) {
|
||||
// Log.print('_insertCounter: ${_insertCounter}');
|
||||
if (_insertCounter == 12) {
|
||||
_insertCounter = 0;
|
||||
await CRUD().post(
|
||||
link: box.read(BoxName.serverChosen) + '/ride/location/add.php',
|
||||
|
||||
@@ -247,15 +247,15 @@ class SecurityHelper {
|
||||
await box.write('isTampered', isTampered); // Use await
|
||||
await box.write('isJailBroken', isJailBroken); // Use await
|
||||
|
||||
debugPrint("Security Check Results:");
|
||||
debugPrint("isNotTrust: $isNotTrust");
|
||||
debugPrint("isJailBroken: $isJailBroken");
|
||||
debugPrint("isRealDevice: $isRealDevice");
|
||||
debugPrint("isOnExternalStorage: $isOnExternalStorage");
|
||||
debugPrint("checkForIssues: $checkForIssues");
|
||||
debugPrint("isDevMode: $isDevMode");
|
||||
debugPrint("isTampered: $isTampered");
|
||||
debugPrint("Bundle ID: $bundleId"); // Print the bundle ID
|
||||
// debugPrint("Security Check Results:");
|
||||
// debugPrint("isNotTrust: $isNotTrust");
|
||||
// debugPrint("isJailBroken: $isJailBroken");
|
||||
// debugPrint("isRealDevice: $isRealDevice");
|
||||
// debugPrint("isOnExternalStorage: $isOnExternalStorage");
|
||||
// debugPrint("checkForIssues: $checkForIssues");
|
||||
// debugPrint("isDevMode: $isDevMode");
|
||||
// debugPrint("isTampered: $isTampered");
|
||||
// debugPrint("Bundle ID: $bundleId"); // Print the bundle ID
|
||||
|
||||
// Check for security risks and potentially show a warning
|
||||
if (isJailBroken || isRealDevice == false || isTampered) {
|
||||
|
||||
@@ -40,7 +40,6 @@ class AppInitializer {
|
||||
|
||||
Future<void> initializeApp() async {
|
||||
if (box.read(BoxName.jwt) == null) {
|
||||
Log.print('box.read(BoxName.jwt): ${box.read(BoxName.jwt)}');
|
||||
await LoginDriverController().getJWT();
|
||||
} else {
|
||||
bool isTokenExpired = JwtDecoder.isExpired(X
|
||||
@@ -55,15 +54,18 @@ class AppInitializer {
|
||||
// await getKey();
|
||||
}
|
||||
|
||||
getAIKey(String key1) async {
|
||||
if (box.read(BoxName.firstTimeLoadKey) == null) {
|
||||
var res =
|
||||
await CRUD().get(link: AppLink.getapiKey, payload: {"keyName": key1});
|
||||
if (res != 'failure') {
|
||||
var d = jsonDecode(res)['message'];
|
||||
await storage.write(key: key1, value: d[key1].toString());
|
||||
await Future.delayed(Duration.zero);
|
||||
} else {}
|
||||
Future<void> getAIKey(String key1) async {
|
||||
var res =
|
||||
await CRUD().get(link: AppLink.getapiKey, payload: {"keyName": key1});
|
||||
|
||||
if (res != 'failure') {
|
||||
var d = jsonDecode(res)['message'];
|
||||
final rawValue = d[key1].toString();
|
||||
|
||||
// ✅ اكتبها في storage
|
||||
await storage.write(key: key1, value: rawValue);
|
||||
|
||||
await Future.delayed(Duration.zero);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,10 @@ import '../../../constant/links.dart';
|
||||
import '../../../constant/style.dart';
|
||||
import '../../../constant/table_names.dart';
|
||||
import '../../../main.dart';
|
||||
import '../../../print.dart';
|
||||
import '../../../views/home/my_wallet/walet_captain.dart';
|
||||
import '../../../views/widgets/elevated_btn.dart';
|
||||
import '../../firebase/firbase_messge.dart';
|
||||
import '../../functions/crud.dart';
|
||||
import '../../functions/location_background_controller.dart';
|
||||
import '../../functions/location_controller.dart';
|
||||
@@ -264,7 +266,7 @@ class HomeCaptainController extends GetxController {
|
||||
@override
|
||||
void onInit() async {
|
||||
// await locationBackController.requestLocationPermission();
|
||||
|
||||
Get.put(FirebaseMessagesController());
|
||||
addToken();
|
||||
await getlocation();
|
||||
onButtonSelected();
|
||||
@@ -429,6 +431,7 @@ class HomeCaptainController extends GetxController {
|
||||
|
||||
void changeToAppliedRide(String status) {
|
||||
box.write(BoxName.rideStatus, status);
|
||||
Log.print('rideStatus from homcaptain : ${box.read(BoxName.rideStatus)}');
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import '../../firebase/firbase_messge.dart';
|
||||
import '../../functions/crud.dart';
|
||||
import '../../functions/encrypt_decrypt.dart';
|
||||
import '../../functions/location_controller.dart';
|
||||
import '../../functions/tts.dart';
|
||||
|
||||
class MapDriverController extends GetxController {
|
||||
bool isLoading = true;
|
||||
@@ -174,7 +175,7 @@ class MapDriverController extends GetxController {
|
||||
cancelTripFromDriverAfterApplied() async {
|
||||
if (formKeyCancel.currentState!.validate()) {
|
||||
box.write(BoxName.statusDriverLocation, 'off');
|
||||
FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||
Get.find<FirebaseMessagesController>().sendNotificationToDriverMAP(
|
||||
"Cancel Trip from driver",
|
||||
"Trip Cancelled from driver. We are looking for a new driver. Please wait."
|
||||
.tr,
|
||||
@@ -235,6 +236,8 @@ class MapDriverController extends GetxController {
|
||||
'created_at': DateTime.now().toString(),
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
}, TableName.driverOrdersRefuse);
|
||||
box.write(BoxName.rideStatus, 'Cancel');
|
||||
Log.print('rideStatus from map 240 : ${box.read(BoxName.rideStatus)}');
|
||||
Get.find<HomeCaptainController>().getRefusedOrderByCaptain();
|
||||
Get.offAll(() => HomeCaptain());
|
||||
}
|
||||
@@ -242,6 +245,7 @@ class MapDriverController extends GetxController {
|
||||
|
||||
void startTimerToShowPassengerInfoWindowFromDriver() async {
|
||||
if (box.read(BoxName.rideStatus) == 'Begin') {
|
||||
Log.print('rideStatus from map 248 : ${box.read(BoxName.rideStatus)}');
|
||||
isPassengerInfoWindow = false;
|
||||
} else {
|
||||
isPassengerInfoWindow = true;
|
||||
@@ -298,6 +302,7 @@ class MapDriverController extends GetxController {
|
||||
void driverGoToPassenger() async {
|
||||
changeRideToBeginToPassenger();
|
||||
box.write(BoxName.rideStatus, 'Applied');
|
||||
Log.print('rideStatus from map 304 : ${box.read(BoxName.rideStatus)}');
|
||||
update();
|
||||
await CRUD().post(
|
||||
link: "${AppLink.seferCairoServer}/ride/rides/update.php",
|
||||
@@ -315,7 +320,7 @@ class MapDriverController extends GetxController {
|
||||
}
|
||||
// Get.find<HomeCaptainController>().changeToAppliedRide('Applied');
|
||||
|
||||
FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||
Get.find<FirebaseMessagesController>().sendNotificationToDriverMAP(
|
||||
'Driver Is Going To Passenger'.tr,
|
||||
box.read(BoxName.nameDriver).toString(), //todo name driver
|
||||
tokenPassenger,
|
||||
@@ -392,6 +397,7 @@ class MapDriverController extends GetxController {
|
||||
// todo ride details
|
||||
// Get.find<HomeCaptainController>().changeToAppliedRide('Begin');
|
||||
box.write(BoxName.rideStatus, 'Begin');
|
||||
Log.print('rideStatus from map 399 : ${box.read(BoxName.rideStatus)}');
|
||||
// Get.find<HomeCaptainController>().update();
|
||||
update();
|
||||
await CRUD().post(link: AppLink.updateRides, payload: {
|
||||
@@ -418,7 +424,7 @@ class MapDriverController extends GetxController {
|
||||
'status': 'Begin'
|
||||
});
|
||||
}
|
||||
FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||
Get.find<FirebaseMessagesController>().sendNotificationToDriverMAP(
|
||||
'Trip is Begin'.tr,
|
||||
box.read(BoxName.nameDriver).toString(),
|
||||
tokenPassenger,
|
||||
@@ -584,17 +590,29 @@ class MapDriverController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
void finishRideFromDriver() {
|
||||
Future<void> finishRideFromDriver() async {
|
||||
double distanceToDestination = Geolocator.distanceBetween(
|
||||
latLngPassengerLocation.latitude,
|
||||
latLngPassengerLocation.longitude,
|
||||
latLngPassengerDestination.latitude,
|
||||
latLngPassengerDestination.longitude,
|
||||
Get.find<LocationController>().myLocation.latitude,
|
||||
Get.find<LocationController>().myLocation.longitude,
|
||||
);
|
||||
final originalDistanceM = double.parse(distance.toString()) * 1000;
|
||||
|
||||
if (distanceToDestination > (double.parse(distance.toString()) / 3)) {
|
||||
Log.print('distanceToDestination: ${distanceToDestination}');
|
||||
// 2. احسب المسافة التي قطعها السائق حتى الآن
|
||||
final movedDistanceM = originalDistanceM - distanceToDestination;
|
||||
|
||||
// 3. عتبة ثلث المسافة
|
||||
final oneThirdDistanceM = originalDistanceM / 3;
|
||||
|
||||
// Logging للتتبع
|
||||
Log.print('originalDistanceM: $originalDistanceM');
|
||||
Log.print('distanceToDestinationM: $distanceToDestination');
|
||||
Log.print('movedDistanceM: $movedDistanceM');
|
||||
Log.print('oneThirdDistanceM: $oneThirdDistanceM');
|
||||
|
||||
// 4. إذا لم يقطع السائق ثلث المسافة، نعرض التأكيد
|
||||
if (movedDistanceM < oneThirdDistanceM) {
|
||||
MyDialog().getDialog(
|
||||
'Are you sure to exit ride?'.tr,
|
||||
'',
|
||||
@@ -603,33 +621,39 @@ class MapDriverController extends GetxController {
|
||||
finishRideFromDriver1();
|
||||
},
|
||||
);
|
||||
} else {
|
||||
} /////
|
||||
|
||||
else {
|
||||
final textToSpeechController = Get.put(TextToSpeechController());
|
||||
MyDialog().getDialog(
|
||||
"You haven't moved sufficiently!".tr,
|
||||
'',
|
||||
() => Get.back(),
|
||||
);
|
||||
await textToSpeechController
|
||||
.speakText("You haven't moved sufficiently!".tr);
|
||||
}
|
||||
}
|
||||
|
||||
String paymentToken = '';
|
||||
Future<String> generateTokenDriver(String amount) async {
|
||||
var res = await CRUD().post(link: AppLink.addPaymentTokenDriver, payload: {
|
||||
var res =
|
||||
await CRUD().postWallet(link: AppLink.addPaymentTokenDriver, payload: {
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
'amount': amount.toString(),
|
||||
});
|
||||
var d = jsonDecode(res);
|
||||
var d = (res);
|
||||
return d['message'];
|
||||
}
|
||||
|
||||
String paymentTokenPassenger = '';
|
||||
Future<String> generateTokenPassenger(String amount) async {
|
||||
var res =
|
||||
await CRUD().post(link: AppLink.addPaymentTokenPassenger, payload: {
|
||||
var res = await CRUD()
|
||||
.postWallet(link: AppLink.addPaymentTokenPassenger, payload: {
|
||||
'passengerId': passengerId,
|
||||
'amount': amount.toString(),
|
||||
});
|
||||
var d = jsonDecode(res);
|
||||
var d = (res);
|
||||
return d['message'];
|
||||
}
|
||||
|
||||
@@ -638,6 +662,7 @@ class MapDriverController extends GetxController {
|
||||
isRideStarted = false;
|
||||
isPriceWindow = false;
|
||||
box.write(BoxName.rideStatus, 'Finished');
|
||||
Log.print('rideStatus from map 664 : ${box.read(BoxName.rideStatus)}');
|
||||
|
||||
// Calculate totalCost more concisely
|
||||
if (price < 20) {
|
||||
@@ -699,7 +724,8 @@ class MapDriverController extends GetxController {
|
||||
if (walletChecked == 'true') {
|
||||
paymentToken = await generateTokenPassenger(
|
||||
((-1) * double.parse(paymentAmount)).toString());
|
||||
futures.add(CRUD().post(link: AppLink.addPassengersWallet, payload: {
|
||||
futures
|
||||
.add(CRUD().postWallet(link: AppLink.addPassengersWallet, payload: {
|
||||
'passenger_id': (passengerId),
|
||||
'balance': ((-1) * double.parse(paymentAmount)).toString(),
|
||||
'token': paymentToken,
|
||||
@@ -707,7 +733,7 @@ class MapDriverController extends GetxController {
|
||||
}
|
||||
|
||||
paymentToken = await generateTokenDriver(paymentAmount.toString());
|
||||
futures.add(CRUD().post(link: AppLink.addDrivePayment, payload: {
|
||||
futures.add(CRUD().postWallet(link: AppLink.addDrivePayment, payload: {
|
||||
'rideId': (rideId),
|
||||
'amount': paymentAmount,
|
||||
'payment_method':
|
||||
@@ -720,7 +746,8 @@ class MapDriverController extends GetxController {
|
||||
if (double.parse(passengerWalletBurc) < 0) {
|
||||
final paymentToken1 = await generateTokenPassenger(
|
||||
((-1) * double.parse(passengerWalletBurc)).toString());
|
||||
futures.add(CRUD().post(link: AppLink.addPassengersWallet, payload: {
|
||||
futures
|
||||
.add(CRUD().postWallet(link: AppLink.addPassengersWallet, payload: {
|
||||
'passenger_id': (passengerId),
|
||||
'token': paymentToken1,
|
||||
'balance': ((-1) * double.parse(passengerWalletBurc)).toString()
|
||||
@@ -730,7 +757,8 @@ class MapDriverController extends GetxController {
|
||||
double pointsSubtraction = double.parse(paymentAmount) * (-1) * 0.08;
|
||||
final paymentToken2 =
|
||||
await generateTokenDriver((pointsSubtraction).toStringAsFixed(0));
|
||||
futures.add(CRUD().post(link: AppLink.addDriversWalletPoints, payload: {
|
||||
futures
|
||||
.add(CRUD().postWallet(link: AppLink.addDriversWalletPoints, payload: {
|
||||
'paymentID': 'rideId${(rideId)}',
|
||||
'amount': (pointsSubtraction).toStringAsFixed(0),
|
||||
'paymentMethod': paymentMethod,
|
||||
@@ -743,7 +771,7 @@ class MapDriverController extends GetxController {
|
||||
Get.put(DriverBehaviorController()).sendSummaryToServer(driverId, rideId);
|
||||
|
||||
// Send notification (this likely depends on previous steps)
|
||||
FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||
Get.find<FirebaseMessagesController>().sendNotificationToDriverMAP(
|
||||
"Driver Finish Trip".tr,
|
||||
'${'you will pay to Driver'.tr} $paymentAmount \$',
|
||||
tokenPassenger,
|
||||
@@ -862,7 +890,7 @@ class MapDriverController extends GetxController {
|
||||
// 'driverID': box.read(BoxName.driverID).toString(),
|
||||
// });
|
||||
// Future.delayed(const Duration(milliseconds: 300));
|
||||
// FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||
// Get.find<FirebaseMessagesController>().sendNotificationToDriverMAP(
|
||||
// "Driver Finish Trip".tr,
|
||||
// '${'you will pay to Driver'.tr} $paymentAmount \$',
|
||||
// tokenPassenger,
|
||||
@@ -1362,7 +1390,8 @@ class MapDriverController extends GetxController {
|
||||
void onInit() async {
|
||||
mapAPIKEY = await storage.read(key: BoxName.mapAPIKEY);
|
||||
// Get the passenger location from the arguments.
|
||||
// await argumentLoading();
|
||||
await argumentLoading();
|
||||
Get.put(FirebaseMessagesController());
|
||||
runGoogleMapDirectly();
|
||||
addCustomCarIcon();
|
||||
addCustomPassengerIcon();
|
||||
|
||||
@@ -82,7 +82,7 @@ class CaptainWalletController extends GetxController {
|
||||
//get new driver details
|
||||
isNewTransfer = true;
|
||||
update();
|
||||
var res = await CRUD().getWallet(
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getDriverDetails,
|
||||
payload: {'driver_phone': '+2${newDriverPhoneController.text}'});
|
||||
isNewTransfer = false;
|
||||
@@ -155,7 +155,7 @@ class CaptainWalletController extends GetxController {
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
'amount': amount.toString(),
|
||||
});
|
||||
var d = jsonDecode(res);
|
||||
var d = (res);
|
||||
return d['message'];
|
||||
}
|
||||
|
||||
@@ -168,14 +168,14 @@ class CaptainWalletController extends GetxController {
|
||||
'amount': amount.toString(),
|
||||
'payment_method': paymentMethod.toString(),
|
||||
});
|
||||
var d = jsonDecode(res);
|
||||
var d = (res);
|
||||
// paymentID = d['message'].toString();
|
||||
return d['message'];
|
||||
}
|
||||
|
||||
Future addDriverWallet(String paymentMethod, point, count) async {
|
||||
paymentToken = await generateToken(count);
|
||||
var paymentID = await getPaymentId(paymentMethod, point);
|
||||
var paymentID = await getPaymentId(paymentMethod, point.toString());
|
||||
await CRUD().postWallet(link: AppLink.addDriversWalletPoints, payload: {
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
'paymentID': paymentID.toString(),
|
||||
@@ -245,7 +245,8 @@ class CaptainWalletController extends GetxController {
|
||||
'payment_method': paymentMethod.toString(),
|
||||
'passengerID': paymentMethod,
|
||||
});
|
||||
await addSeferWallet(paymentMethod, (double.parse(point) * -1).toString());
|
||||
await addSeferWallet(paymentMethod,
|
||||
(double.parse(point) * -2).toString()); // deduct 2 from sefer wallet
|
||||
}
|
||||
|
||||
Future addSeferWallet(String paymentMethod, String point) async {
|
||||
@@ -290,7 +291,7 @@ class CaptainWalletController extends GetxController {
|
||||
'paymentMethod': paymentMethod2.toString(),
|
||||
});
|
||||
if (res1 != 'failure') {
|
||||
FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||
Get.find<FirebaseMessagesController>().sendNotificationToDriverMAP(
|
||||
'Transfer',
|
||||
'${'You have transfer to your wallet from'.tr}'
|
||||
'${box.read(BoxName.nameDriver)}',
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:local_auth/local_auth.dart';
|
||||
import 'package:sefer_driver/constant/api_key.dart';
|
||||
import 'package:sefer_driver/constant/box_name.dart';
|
||||
import 'package:sefer_driver/main.dart';
|
||||
import 'package:sefer_driver/views/widgets/error_snakbar.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:secure_string_operations/secure_string_operations.dart';
|
||||
|
||||
import '../../../constant/char_map.dart';
|
||||
import '../../../constant/links.dart';
|
||||
import '../../../views/widgets/mydialoug.dart';
|
||||
import '../../functions/crud.dart';
|
||||
@@ -19,39 +16,8 @@ class PaymobPayout extends GetxController {
|
||||
bool isLoading = false;
|
||||
String dropdownValue = 'etisalat';
|
||||
|
||||
Future<String> getToken() async {
|
||||
var headers = {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
// 'Cookie':
|
||||
// 'csrftoken=74iZJ8XYyuTm5WRq2W4tpWX5eqoJLZVK5QhuDrChWpDtzpgGA269bbCWuEcW85t4'
|
||||
};
|
||||
var payMobOutClientSecrret =
|
||||
X.r(X.r(X.r(await getAIKey(KN.pmobsec), cn), cC), cs);
|
||||
var payMobOutClientId =
|
||||
X.r(X.r(X.r(await getAIKey(KN.pmobid), cn), cC), cs);
|
||||
var body = {
|
||||
'grant_type': 'password',
|
||||
'username': AK.payMobOutUserName,
|
||||
'password': AK.payMobOutPassword,
|
||||
'client_id': payMobOutClientId,
|
||||
'client_secret': payMobOutClientSecrret
|
||||
};
|
||||
var res = await http.post(
|
||||
Uri.parse('https://payouts.paymobsolutions.com/api/secure/o/token/'),
|
||||
headers: headers,
|
||||
body: body,
|
||||
);
|
||||
String token = '';
|
||||
if (res.statusCode == 200) {
|
||||
var decode = jsonDecode(res.body);
|
||||
token = decode['access_token'];
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
int payOutFee = 5;
|
||||
payToDriverWallet(
|
||||
String token, String amount, String issuer, String msisdn) async {
|
||||
payToDriverWallet(String amount, String issuer, String msisdn) async {
|
||||
bool isAvailable = await LocalAuthentication().isDeviceSupported();
|
||||
if (isAvailable) {
|
||||
// Authenticate the user
|
||||
@@ -62,21 +28,18 @@ class PaymobPayout extends GetxController {
|
||||
sensitiveTransaction: true,
|
||||
));
|
||||
if (didAuthenticate) {
|
||||
var headers = {
|
||||
'Authorization': 'Bearer $token',
|
||||
'Content-Type': 'application/json',
|
||||
};
|
||||
var body = json.encode({
|
||||
"amount": amount, //"10.00",
|
||||
"issuer": issuer, //"vodafone",
|
||||
"msisdn": msisdn, // "01023456789"
|
||||
});
|
||||
var res = await http.post(
|
||||
Uri.parse('https://payouts.paymobsolutions.com/api/secure/disburse/'),
|
||||
headers: headers,
|
||||
body: body,
|
||||
);
|
||||
var dec = jsonDecode(res.body);
|
||||
var dec = await CRUD().postWallet(
|
||||
link:
|
||||
'wl.tripz-egypt.com/v1/main/ride/payMob/paymob_driver/paymob_payout.php',
|
||||
payload: {
|
||||
"issuer": issuer,
|
||||
"method": "wallet",
|
||||
"amount": amount, //9.0,
|
||||
"full_name":
|
||||
'${box.read(BoxName.nameDriver)} ${box.read(BoxName.lastNameDriver)}',
|
||||
"msisdn": msisdn, //"01010101010",
|
||||
"bank_transaction_type": "cash_transfer"
|
||||
});
|
||||
if (dec['disbursement_status'] == 'successful') {
|
||||
var paymentToken = await Get.find<CaptainWalletController>()
|
||||
.generateToken(
|
||||
@@ -149,8 +112,8 @@ class PaymobPayout extends GetxController {
|
||||
} else {}
|
||||
}
|
||||
|
||||
payToDriverBankAccount(String token, String amount, String bankCardNumber,
|
||||
String bankCode) async {
|
||||
payToDriverBankAccount(
|
||||
String amount, String bankCardNumber, String bankCode) async {
|
||||
bool isAvailable = await LocalAuthentication().isDeviceSupported();
|
||||
if (isAvailable) {
|
||||
// Authenticate the user
|
||||
@@ -161,12 +124,9 @@ class PaymobPayout extends GetxController {
|
||||
sensitiveTransaction: true,
|
||||
));
|
||||
if (didAuthenticate) {
|
||||
var headers = {
|
||||
'Authorization': 'Bearer $token',
|
||||
'Content-Type': 'application/json',
|
||||
};
|
||||
var body = {
|
||||
"issuer": "bank_card",
|
||||
"method": "bank_card",
|
||||
"amount": amount, //9.0,
|
||||
"full_name":
|
||||
'${box.read(BoxName.nameDriver)} ${box.read(BoxName.lastNameDriver)}',
|
||||
@@ -174,12 +134,11 @@ class PaymobPayout extends GetxController {
|
||||
"bank_code": bankCode, //"CIB",
|
||||
"bank_transaction_type": "cash_transfer"
|
||||
};
|
||||
var res = await http.post(
|
||||
Uri.parse('https://payouts.paymobsolutions.com/api/secure/disburse/'),
|
||||
headers: headers,
|
||||
body: body,
|
||||
var dec = await CRUD().postWallet(
|
||||
link:
|
||||
'wl.tripz-egypt.com/v1/main/ride/payMob/paymob_driver/paymob_payout.php',
|
||||
payload: body,
|
||||
);
|
||||
var dec = jsonDecode(res.body);
|
||||
if (dec['disbursement_status'] == 'successful') {
|
||||
var paymentToken = await Get.find<CaptainWalletController>()
|
||||
.generateToken(
|
||||
@@ -236,8 +195,7 @@ class PaymobPayout extends GetxController {
|
||||
sensitiveTransaction: true,
|
||||
));
|
||||
if (didAuthenticate) {
|
||||
String token = await getToken();
|
||||
await payToDriverWallet(token, amount, issuer, msisdn);
|
||||
await payToDriverWallet(amount, issuer, msisdn);
|
||||
} else {
|
||||
MyDialog().getDialog('Authentication failed'.tr, ''.tr, () {
|
||||
Get.back();
|
||||
@@ -263,8 +221,7 @@ class PaymobPayout extends GetxController {
|
||||
sensitiveTransaction: true,
|
||||
));
|
||||
if (didAuthenticate) {
|
||||
String token = await getToken();
|
||||
await payToDriverBankAccount(token, amount, bankCardNumber, bankCode);
|
||||
await payToDriverBankAccount(amount, bankCardNumber, bankCode);
|
||||
} else {
|
||||
MyDialog().getDialog('Authentication failed'.tr, ''.tr, () {
|
||||
Get.back();
|
||||
|
||||
@@ -65,6 +65,17 @@ class MyTranslation extends Translations {
|
||||
"Order Applied": "تم تطبيق الطلب",
|
||||
|
||||
//firebase above
|
||||
|
||||
"payment_success": "تمت العملية بنجاح",
|
||||
"transaction_id": "رقم العملية",
|
||||
"amount_paid": "المبلغ المدفوع",
|
||||
"bonus_added": "البونص المضاف",
|
||||
"points": "نقطة",
|
||||
"transaction_failed": "فشل العملية",
|
||||
"connection_failed": "فشل الاتصال",
|
||||
"server_error": "خطأ في الخادم",
|
||||
"server_error_message": "حدث خطأ أثناء الاتصال بالخادم",
|
||||
|
||||
"cancel": "إلغاء", "Syria": "سوريا",
|
||||
"Security Warning": "تحذير أمني",
|
||||
"Potential security risks detected. The application will close in @seconds seconds.":
|
||||
@@ -75,7 +86,28 @@ class MyTranslation extends Translations {
|
||||
"Security Warning": "⚠️ تحذير أمني",
|
||||
"Potential security risks detected. The application may not function correctly.":
|
||||
"تم اكتشاف ثغرات أمنية على هذا الجهاز. للحفاظ على أمان بياناتك، سيتم حذف جميع البيانات وإغلاق التطبيق.",
|
||||
"How to use Tripz": "كيفية استخدام Tripz",
|
||||
"What are the order details we provide to you?":
|
||||
"ما هي تفاصيل الطلب التي نوفرها لك؟",
|
||||
"Tripz Wallet Features:\n\nTransfer money multiple times.\nTransfer to anyone.\nMake purchases.\nCharge your account.\nCharge a friend's Tripz account.\nStore your money with us and receive it in your bank as a monthly salary.":
|
||||
"ميزات محفظة Tripz:\n\nتحويل الأموال عدة مرات.\nالتحويل إلى أي شخص.\nإجراء عمليات شراء.\nشحن حسابك.\nشحن حساب Tripz لصديق.\nقم بتخزين أموالك معنا واستلامها في بنكك كراتب شهري.",
|
||||
"What is the feature of our wallet?": "ما هي مميزات محفظتنا؟",
|
||||
"What is Types of Trips in Tripz?": "ما هي أنواع الرحلات في Tripz؟",
|
||||
'''Types of Trips in Tripz:
|
||||
|
||||
Comfort: For cars newer than 2017 with air conditioning.
|
||||
Lady: For girl drivers.
|
||||
Speed: For fixed salary and endpoints.
|
||||
Mashwari: For flexible trips where passengers choose the car and driver with prior arrangements.
|
||||
Raih Gai: For same-day return trips longer than 50km.
|
||||
''': """أنواع الرحلات في Tripz:
|
||||
|
||||
راحة: للسيارات الأحدث من 2017 مع تكييف الهواء.
|
||||
للسائقات الإناث.
|
||||
سبيد: براتب ثابت ونقاط نهاية محددة.
|
||||
مشاوير: للرحلات المرنة حيث يختار الركاب السيارة والسائق باتفاق مسبق.
|
||||
رحّي غاي: للرحلات ذات العودة في نفس اليوم التي تزيد عن 50 كم.
|
||||
""",
|
||||
"I will go now": "هروح دلوقتي",
|
||||
"Yes": "أيوة",
|
||||
"No,I want": "لا، أنا عاوز",
|
||||
|
||||
@@ -67,7 +67,7 @@ class RateController extends GetxController {
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
});
|
||||
|
||||
FirebaseMessagesController().sendNotificationToDriverMAP(
|
||||
Get.find<FirebaseMessagesController>().sendNotificationToDriverMAP(
|
||||
'Wallet Added'.tr,
|
||||
'Wallet Added${(remainingFee).toStringAsFixed(0)}'.tr,
|
||||
Get.find<MapDriverController>().tokenPassenger,
|
||||
|
||||
Reference in New Issue
Block a user