This commit is contained in:
Hamza-Ayed
2024-07-20 14:18:06 +03:00
parent 27de944c2f
commit bdb910f3c2
14 changed files with 186 additions and 126 deletions

2
.env
View File

@@ -35,8 +35,6 @@ smsPasswordEgypt="J)Vh=qb/@MXrXlBl"
chatGPTkeySeferNew4=zg-vlie-2l1ZlpxiLJ6wQOvbb4TnC9XrxgUEyVQIu6TID4qP4FUUqoS5XrXlBl
anthropicAIkeySeferNew=zg-qbc-qvo39-n4VdMQ5nuJeIYhMN4PDYr7qox3-t2i1Lh7aNTDfYF-Gf8whUJZCs47EeelKn8_UcmUMmiSLaf0UJg0DvUlQrDt-76CRrkQQXrXlBl
llama3Key=kzg_uTXy3e9DBbCQ1FnMGxYwTKysx9US1burxJj4fFwOje4LZBUFKJS1XrXlBl
payMobOutClientSecrret='xyjjRlahJM0Xc38WjApCOh8bvgL9slFpNdM9YeCu9AhLqboKMPtmSvc2N9O4tXxFLV2JAV6stBSTAGFGCVubGe6MNpc7MzJnZ3SiT6GpavBoCLWkUvVbdSDaM0zHvuBOXrXlBl'
payMobOutClient_id='Z05ut48dVkS2gI2zenFFcKsfDKfHAU0WELqKyJ0LXrXlBl'
payMobOutPassword='D2zJFxkE#LN3vz38z2dYxpNfWXrXlBl'
payMobOutUserName='zjujl_qvo_fwjfgjlXrXlBl'
keyOfApp=nqryjp@1737wqnmqqsjyzjujljksvceiXrXlBl

View File

@@ -55,8 +55,8 @@ android {
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 23
targetSdkVersion 34
versionCode 60
versionName '1.5.60'
versionCode 61
versionName '1.5.61'
// manifestPlaceholders = [mapsApiKey: 'android/app/src/main/AndroidManifest.xml']
}

View File

@@ -4,9 +4,10 @@ import '../env/env.dart';
import 'char_map.dart';
class AK {
static final String publishableKey =
static final String publishableKeyStripe =
X.r(X.r(X.r(Env.stripePublishableKe, cn), cC), cs);
static final String secretKey = X.r(X.r(X.r(Env.secretKey, cn), cC), cs);
static final String secretKeyStripe =
X.r(X.r(X.r(Env.secretKey, cn), cC), cs);
static final String basicAuthCredentials =
X.r(X.r(X.r(Env.basicAuthCredentials, cn), cC), cs);
static final String basicCompareFaces =
@@ -61,10 +62,7 @@ class AK {
static final String anthropicAIkeySeferNew =
X.r(X.r(X.r(Env.anthropicAIkeySeferNew, cn), cC), cs);
static final String llama3Key = X.r(X.r(X.r(Env.llama3Key, cn), cC), cs);
static final String payMobOutClientSecrret =
X.r(X.r(X.r(Env.payMobOutClientSecrret, cn), cC), cs);
static final String payMobOutClient_id =
X.r(X.r(X.r(Env.payMobOutClient_id, cn), cC), cs);
static final String payMobOutPassword =
X.r(X.r(X.r(Env.payMobOutPassword, cn), cC), cs);
static final String payMobOutUserName =
@@ -73,3 +71,8 @@ class AK {
///////////
static final String keyOfApp = X.r(X.r(X.r(Env.keyOfApp, cn), cC), cs);
}
class KN {
static const String pmobsec = 'PAYMOBOUTCLIENTSECRET';
static const String pmobid = 'PAYMOBOUTCLIENT_ID';
}

View File

@@ -55,6 +55,7 @@ class AppLink {
static String getRides = "$ride/rides/get.php";
static String getRideOrderID = "$ride/rides/getRideOrderID.php";
static String getRideStatus = "$ride/rides/getRideStatus.php";
static String getapiKey = "$ride/apiKey/get.php";
static String getRideStatusBegin = "$ride/rides/getRideStatusBegin.php";
static String getRideStatusFromStartApp =
"$ride/rides/getRideStatusFromStartApp.php";

View File

@@ -27,8 +27,6 @@ class CRUD {
'Basic ${base64Encode(utf8.encode(AK.basicAuthCredentials.toString()))}',
},
);
print(response.request);
print(response.body);
// if (response.statusCode == 200) {
var jsonData = jsonDecode(response.body);
if (jsonData['status'] == 'success') {
@@ -194,7 +192,7 @@ class CRUD {
body: payload,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
'Authorization': 'Bearer ${AK.secretKey}',
'Authorization': 'Bearer ${AK.secretKeyStripe}',
},
);
if (response.statusCode == 200) {
@@ -220,9 +218,6 @@ class CRUD {
'Basic ${base64Encode(utf8.encode(AK.basicAuthCredentials))}',
},
);
// print(response.request);
// print(response.body);
// print(payload);
var jsonData = jsonDecode(response.body);
if (response.statusCode == 200) {
if (jsonData['status'] == 'success') {

View File

@@ -16,9 +16,12 @@ import 'package:image_picker/image_picker.dart';
import 'package:http/http.dart' as http;
import 'package:image/image.dart' as img;
import 'package:path_provider/path_provider.dart';
import 'package:secure_string_operations/secure_string_operations.dart';
import '../../constant/api_key.dart';
import '../../constant/char_map.dart';
import '../../constant/colors.dart';
import '../../print.dart';
import 'tts.dart';
import 'upload_image.dart';
@@ -157,44 +160,45 @@ class AI extends GetxController {
),
],
);
} else if (responseIdEgyptDriverLicense['national_number'] !=
responseIdEgyptBack['nationalID']) {
Get.defaultDialog(
barrierDismissible: false,
title: 'ID Mismatch',
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.warning, size: 48, color: Colors.red),
const SizedBox(height: 16),
Text(
"The national number on your drivers license does not match the one on your ID document. Please verify and provide the correct documents."
.tr,
textAlign: TextAlign.center,
style: AppStyle.title,
),
const SizedBox(height: 16),
IconButton(
onPressed: () async {
await Get.find<TextToSpeechController>().speakText(
"The national number on your drivers license does not match the one on your ID document. Please verify and provide the correct documents."
.tr,
);
},
icon: const Icon(Icons.volume_up),
),
],
),
actions: [
TextButton(
onPressed: () {
Get.back();
},
child: const Text('OK'),
),
],
);
}
// else if (responseIdEgyptDriverLicense['national_number'] !=
// responseIdEgyptBack['nationalID']) {
// Get.defaultDialog(
// barrierDismissible: false,
// title: 'ID Mismatch'.tr,
// content: Column(
// mainAxisSize: MainAxisSize.min,
// children: [
// const Icon(Icons.warning, size: 48, color: Colors.red),
// const SizedBox(height: 16),
// Text(
// "The national number on your drivers license does not match the one on your ID document. Please verify and provide the correct documents."
// .tr,
// textAlign: TextAlign.center,
// style: AppStyle.title,
// ),
// const SizedBox(height: 16),
// IconButton(
// onPressed: () async {
// await Get.find<TextToSpeechController>().speakText(
// "The national number on your drivers license does not match the one on your ID document. Please verify and provide the correct documents."
// .tr,
// );
// },
// icon: const Icon(Icons.volume_up),
// ),
// ],
// ),
// actions: [
// TextButton(
// onPressed: () {
// Get.back();
// },
// child: const Text('OK'),
// ),
// ],
// );
// }
// else if (responseCriminalRecordEgypt['FullName'] !=
// responseIdEgyptDriverLicense['name_arabic']) {
// Get.defaultDialog(
@@ -304,7 +308,6 @@ class AI extends GetxController {
var status1 = jsonDecode(res);
isLoading = false;
update();
print(res);
// Handle response
if (status1['status'] == 'success') {
isDriverSaved = true;
@@ -471,13 +474,13 @@ class AI extends GetxController {
// if (imagePath == 'driver_license') {
// await ImageController().choosFaceFromDriverLicense(linkPHP, 'face');
// }
await Future.delayed(const Duration(seconds: 2));
var extractedString =
await CRUD().arabicTextExtractByVisionAndAI(imagePath: imagePath);
var json = jsonDecode(extractedString);
var textValues = CRUD().extractTextFromLines(json);
print('textValues: ${textValues}');
DocumentType detectedType = checkDocumentType(textValues);
String expectedDocument = getExpectedDocument(imagePath);
@@ -496,7 +499,6 @@ class AI extends GetxController {
await Get.put(AI()).anthropicAI(textValues, prompt, imagePath);
}
} catch (e) {
print('Error in allMethodForAI: $e');
MyDialog().getDialog('error'.tr, 'error_processing_document'.tr, () {
Get.back();
});
@@ -681,7 +683,6 @@ class AI extends GetxController {
if (response.statusCode == 200) {
var responseData = jsonDecode(utf8.decode(response.bodyBytes));
// Process the responseData as needed
print(responseData);
responseForComplaint = jsonDecode(responseData['content'][0]['text']);
}
@@ -697,7 +698,7 @@ class AI extends GetxController {
]
}
];
var k = X.r(X.r(X.r(await getAIKey('CLAUDAISEFER'), cn), cC), cs);
var requestBody = jsonEncode({
"model": "claude-3-haiku-20240307",
"max_tokens": 1024,
@@ -709,7 +710,7 @@ class AI extends GetxController {
final response = await http.post(
Uri.parse('https://api.anthropic.com/v1/messages'),
headers: {
'x-api-key': AK.anthropicAIkeySeferNew,
'x-api-key': k,
'anthropic-version': '2023-06-01',
'content-type': 'application/json'
},
@@ -719,7 +720,6 @@ class AI extends GetxController {
if (response.statusCode == 200) {
var responseData = jsonDecode(utf8.decode(response.bodyBytes));
// Process the responseData as needed
print(responseData);
if (idType == 'car_back') {
responseIdCardDriverEgyptBack =
jsonDecode(responseData['content'][0]['text']);
@@ -1417,10 +1417,16 @@ Output the extracted information in the following JSON formate and make date for
if (res != 'failure') {
var d = jsonDecode(res)['message'];
prompts = d;
// print('prompts: ${prompts}');
} else {
print(res);
}
} else {}
}
getAIKey(String key) async {
var res =
await CRUD().get(link: AppLink.getapiKey, payload: {"keyName": key});
if (res != 'failure') {
var d = jsonDecode(res)['message'];
return d[key].toString();
} else {}
}
@override

View File

@@ -108,7 +108,7 @@ class CaptainWalletController extends GetxController {
link: AppLink.getAllPaymentFromRide,
payload: {'driverID': box.read(BoxName.driverID)},
);
isLoading = false;
// isLoading = false;
if (res != 'failure') {
walletDate = jsonDecode(res);
totalAmount = walletDate['message'][0]['total_amount'] ?? '0';
@@ -120,11 +120,14 @@ class CaptainWalletController extends GetxController {
totalAmountVisa = walletDateVisa['message'][0]['diff'] ?? '0';
update();
} else {
totalAmount = "0";
totalAmountVisa = "0";
}
}
Future getCaptainWalletFromBuyPoints() async {
isLoading = true;
// isLoading = true;
update();
var res = await CRUD().get(
@@ -134,8 +137,7 @@ class CaptainWalletController extends GetxController {
isLoading = false;
// update();
walletDriverPointsDate = jsonDecode(res);
if (walletDriverPointsDate['message'][0]['driverID'].toString() ==
box.read(BoxName.driverID).toString()) {
if (res != 'failure') {
double totalPointsDouble = double.parse(
walletDriverPointsDate['message'][0]['total_amount'].toString());
totalPoints = totalPointsDouble.toStringAsFixed(0);

View File

@@ -4,9 +4,12 @@ import 'package:SEFER/constant/api_key.dart';
import 'package:SEFER/constant/box_name.dart';
import 'package:SEFER/constant/colors.dart';
import 'package:SEFER/main.dart';
import 'package:SEFER/print.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 '../../functions/crud.dart';
import 'captain_wallet_controller.dart';
@@ -21,12 +24,16 @@ class PaymobPayout extends GetxController {
// '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': AK.payMobOutClient_id,
'client_secret': AK.payMobOutClientSecrret
'client_id': payMobOutClientId,
'client_secret': payMobOutClientSecrret
};
var res = await http.post(
Uri.parse('https://payouts.paymobsolutions.com/api/secure/o/token/'),
@@ -61,11 +68,12 @@ class PaymobPayout extends GetxController {
var dec = jsonDecode(res.body);
if (dec['disbursement_status'] == 'successful') {
var paymentToken = await Get.find<CaptainWalletController>()
.generateToken(((-1) * (double.parse(dec['amount'])) - payOutFee)
.toStringAsFixed(0));
.generateToken(
((-1) * (double.parse(dec['amount'].toString())) - payOutFee)
.toStringAsFixed(0));
await CRUD().post(link: AppLink.addDrivePayment, payload: {
'rideId': DateTime.now().toIso8601String(),
'amount': ((-1) * (double.parse(dec['amount'])) - payOutFee)
'amount': ((-1) * (double.parse(dec['amount'].toString())) - payOutFee)
.toStringAsFixed(0),
'payment_method': 'payout',
'passengerID': 'myself',
@@ -87,7 +95,7 @@ class PaymobPayout extends GetxController {
'${'Transaction successful'.tr} ${dec['amount']}',
backgroundColor: AppColor.greenColor);
Get.find<CaptainWalletController>().getCaptainWalletFromRide();
Get.find<CaptainWalletController>().refreshCaptainWallet();
} else if (dec['disbursement_status'] == 'failed') {
Get.snackbar('Transaction failed'.tr, 'Transaction failed'.tr,
backgroundColor: AppColor.redColor);
@@ -112,6 +120,15 @@ class PaymobPayout extends GetxController {
});
}
getAIKey(String key) async {
var res =
await CRUD().get(link: AppLink.getapiKey, payload: {"keyName": key});
if (res != 'failure') {
var d = jsonDecode(res)['message'];
return d[key].toString();
} else {}
}
payToDriverBankAccount(String token, String amount, String bankCardNumber,
String bankCode) async {
var headers = {
@@ -127,13 +144,46 @@ 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,
)
.then((value) {});
var res = await http.post(
Uri.parse('https://payouts.paymobsolutions.com/api/secure/disburse/'),
headers: headers,
body: body,
);
var dec = jsonDecode(res.body);
if (dec['disbursement_status'] == 'successful') {
var paymentToken = await Get.find<CaptainWalletController>()
.generateToken(
((-1) * (double.parse(dec['amount'].toString())) - payOutFee)
.toStringAsFixed(0));
await CRUD().post(link: AppLink.addDrivePayment, payload: {
'rideId': DateTime.now().toIso8601String(),
'amount': ((-1) * (double.parse(dec['amount'].toString())) - payOutFee)
.toStringAsFixed(0),
'payment_method': 'payout',
'passengerID': 'myself',
'token': paymentToken,
'driverID': box.read(BoxName.driverID).toString(),
});
await Get.find<CaptainWalletController>()
.addSeferWallet('payout fee myself', payOutFee.toString());
await updatePaymentToPaid(box.read(BoxName.driverID).toString());
await sendEmail(
box.read(BoxName.driverID).toString(),
amount,
box.read(BoxName.phoneDriver).toString(),
box.read(BoxName.nameDriver).toString(),
'Wallet',
box.read(BoxName.emailDriver).toString());
Get.snackbar('Transaction successful'.tr,
'${'Transaction successful'.tr} ${dec['amount']}',
backgroundColor: AppColor.greenColor);
Get.find<CaptainWalletController>().refreshCaptainWallet();
} else if (dec['disbursement_status'] == 'failed') {
Get.snackbar('Transaction failed'.tr, 'Transaction failed'.tr,
backgroundColor: AppColor.redColor);
}
}
Future payToWalletDriverAll(

View File

@@ -4,6 +4,7 @@ class MyTranslation extends Translations {
@override
Map<String, Map<String, String>> get keys => {
"ar": {
'ID Mismatch': "عدم تطابق الرقم التعريفي",
"face detect": "كشف الوجه",
"Face Detection Result": "نتيجة كشف الوجه",
"false": "خطأ",

View File

@@ -65,7 +65,7 @@ void main() async {
await AC().gAK();
Stripe.publishableKey = AK.publishableKey;
Stripe.publishableKey = AK.publishableKeyStripe;
if (Platform.isAndroid || Platform.isIOS) {
await Firebase.initializeApp(

13
lib/print.dart Normal file
View File

@@ -0,0 +1,13 @@
import 'dart:developer' as developer;
class Log {
Log._();
static void print(String value, {StackTrace? stackTrace}) {
developer.log(value, name: 'LOG', stackTrace: stackTrace);
}
static Object? inspect(Object? object) {
return developer.inspect(object);
}
}

View File

@@ -5,12 +5,15 @@ import 'package:SEFER/views/widgets/my_circular_indicator_timer.dart';
import 'package:SEFER/views/widgets/my_textField.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:secure_string_operations/secure_string_operations.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../../../constant/char_map.dart';
import '../../../../constant/colors.dart';
import '../../../../constant/links.dart';
import '../../../../constant/style.dart';
import '../../../../controller/functions/package_info.dart';
import '../../../../controller/functions/upload_image.dart';
import '../../../../print.dart';
import '../../../widgets/my_scafold.dart';
class EgyptCardAI extends StatelessWidget {

View File

@@ -1,6 +1,5 @@
import 'package:SEFER/constant/box_name.dart';
import 'package:SEFER/main.dart';
import 'package:SEFER/views/auth/captin/cards/egypt_card_a_i.dart';
import 'package:flutter/material.dart';
import 'package:flutter_font_icons/flutter_font_icons.dart';
import 'package:get/get.dart';
@@ -27,30 +26,18 @@ GetBuilder<HomeCaptainController> leftMainMenuCaptainIcons() {
// borderRadius: BorderRadius.circular(15)),
// child: IconButton(
// onPressed: () {
// AC credentials = AC();
// // String apikey = AK.passwordPayMob;
// // String convertedStringN = credentials.c(
// // credentials.c(credentials.c(apikey, cs), cC), cn);
// // String retrievedStringS = credentials.r(
// // credentials.r(credentials.r(convertedStringN, cn), cC),
// // cs);
// // //
// // if (retrievedStringS ==
// // 'apikey') {
// // }
// // key.forEach((key, apiKey) {
// // Get.to(() => SmsSignupEgypt());
// // keys.forEach((key, apiKey) {
// // String apikey = Env.basicAuthCredentials;
// // String retrievedStringS = credentials.r(
// // credentials.r(credentials.r(apikey, cn), cC), cs);
// // String encryptedApiKey =
// // X.c(X.c(X.c(retrievedStringS, cs), cC), cn);
// String apikey = AK.secretKeyStripe;
// Log.print('apikey: ${apikey}');
// // String decryptedApiKey =
// // X.r(X.r(X.r(encryptedApiKey, cn), cC), cs);
// String encryptedApiKey = X.c(X.c(X.c(apikey, cs), cC), cn);
// Log.print('encryptedApiKey: ${encryptedApiKey}');
// String decryptedApiKey =
// X.r(X.r(X.r(encryptedApiKey, cn), cC), cs);
// Log.print('decryptedApiKey: ${decryptedApiKey}');
// // if (decryptedApiKey == retrievedStringS) {
// // } else {
@@ -65,9 +52,9 @@ GetBuilder<HomeCaptainController> leftMainMenuCaptainIcons() {
// )),
// ),
const SizedBox(
height: 5,
),
// const SizedBox(
// height: 5,
// ),
AnimatedContainer(
duration: const Duration(microseconds: 200),
width: controller.widthMapTypeAndTraffic,
@@ -173,24 +160,24 @@ GetBuilder<HomeCaptainController> leftMainMenuCaptainIcons() {
),
),
),
AnimatedContainer(
duration: const Duration(microseconds: 200),
width: controller.widthMapTypeAndTraffic,
decoration: BoxDecoration(
color: AppColor.secondaryColor,
border: Border.all(color: AppColor.blueColor),
borderRadius: BorderRadius.circular(15)),
child: IconButton(
onPressed: () async {
Get.to(() => EgyptCardAI());
},
icon: const Icon(
FontAwesome5.grin_tears,
size: 29,
color: AppColor.blueColor,
),
),
),
// AnimatedContainer(
// duration: const Duration(microseconds: 200),
// width: controller.widthMapTypeAndTraffic,
// decoration: BoxDecoration(
// color: AppColor.secondaryColor,
// border: Border.all(color: AppColor.blueColor),
// borderRadius: BorderRadius.circular(15)),
// child: IconButton(
// onPressed: () async {
// Get.to(() => EgyptCardAI());
// },
// icon: const Icon(
// FontAwesome5.grin_tears,
// size: 29,
// color: AppColor.blueColor,
// ),
// ),
// ),
],
)),
);

View File

@@ -1,3 +1,4 @@
import 'package:SEFER/print.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
@@ -37,7 +38,7 @@ class CardSeferWalletDriver extends StatelessWidget {
// BoxName.lastTimeCaptainWalletCashOut, lastRequestTime);
// box.write(BoxName.cvvCode, 1111);
if (double.parse(
Get.find<CaptainWalletController>().totalAmountVisa) >
Get.find<CaptainWalletController>().totalAmountVisa) >=
20) {
Get.defaultDialog(
barrierDismissible: false,
@@ -95,7 +96,7 @@ class CardSeferWalletDriver extends StatelessWidget {
if (captainWalletController.formKey.currentState!
.validate()) {
if (double.parse(Get.find<CaptainWalletController>()
.totalAmountVisa) >
.totalAmountVisa) >=
20) {
Get.back();
String amountAfter5LE = (double.parse(