This commit is contained in:
Hamza-Ayed
2024-09-17 00:31:50 +03:00
parent c24eee9e1d
commit 1b50de9a7c
12 changed files with 199 additions and 157 deletions

View File

@@ -25,6 +25,7 @@ class BoxName {
static const String sosPhoneDriver = "sosPhoneDriver";
static const String passengerID = "pasengerID";
static const String phone = "phone";
static const String phoneWallet = "phoneWallet";
static const String phoneDriver = "phoneDriver";
static const String dobDriver = "dobDriver";
static const String sexDriver = "sexDriver";

View File

@@ -246,10 +246,10 @@ class LoginController extends GetxController {
void onInit() async {
// permissionLocation = await Permission.locationWhenInUse.isGranted;
await getAppTester(AppInformation.appName);
if (isTest == 0 && box.read(BoxName.passengerID) != null) {
await loginUsingCredentials(
box.read(BoxName.passengerID), box.read(BoxName.email));
}
// if (isTest == 0 && box.read(BoxName.passengerID) != null) {
// await loginUsingCredentials(
// box.read(BoxName.passengerID), box.read(BoxName.email));
// }
super.onInit();
}
}

View File

@@ -232,9 +232,10 @@ class RegisterController extends GetxController {
print('WhatsApp message sent to non-Egyptian phone number: $phoneNumber');
}
isLoading = false;
update();
isSent = true;
remainingTime = 300; // Reset to 5 minutes
remainingTime = 300;
update(); // Reset to 5 minutes
startTimer();
}

View File

@@ -495,34 +495,70 @@ class FirebaseMessagesController extends GetxController {
void sendNotificationToPassengerToken(
String title, body, token, List<String> map, String tone) async {
try {
String serviceAccountKeyJson = '''{
"type": "service_account",
"project_id": "ride-b1bd8",
"private_key_id": "75e817c0b902db2ef35edf2c2bd159dec1f13249",
"private_key": "-----BEGIN PRIVATE KEY-----\\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQD0zH9TQGDQHUv3\\na3/JAD1UKPwAp3wNKT0a6fxiIzjI3JxQWI30QvZCcfl6CdMhIcydX1ncSaYTcEeC\\n/AdPVCPkqyJx1YIGGg6P/mRzCWeaN8fsp6z250m5vcObDCZc3dbJEkepbep+6FPY\\n21m3KO+AHh1glgsTGZOTm5xiU8NGXpdk2QEh8wpiIIlR/HuKw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E5Bj\\nsWiPpYyvWvpYX0nA3G7dzX0hqgQN/mkIjbnWDArp3IcNZNJIvBSM2Yxb7EAXbU0n\\njo6DAkp5Pa2VO+WDNlFZbvW/sf8xjeOCt44WPa6d7nVgIIpbQXRngZoopKW3/jTP\\n/FmQT8McFXmGxZ5belsAsdetSGW9icbLUerTGQ0CgYEAmf/G8Ag3XxmqTXvvHuv2\\n14OP7WnrVqkEMnydrftEwn4peXd/Lz+/GYX5Zc4ZoNgbN8IvZ5z0+OmRsallsbiW\\nBw0/tc68CjzxXOvReWxDluUopqWVGj5tlGqE5xUDku9SWJSxbkiQ3rqutzBdPXpr\\noqHwPyDrmK/Zgqn+uiIm4Ck=\\n-----END PRIVATE KEY-----\\n",
"client_email": "firebase-adminsdk-o2wqi@ride-b1bd8.iam.gserviceaccount.com",
"client_id": "111210077025005706623",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-o2wqi%40ride-b1bd8.iam.gserviceaccount.com",
"universe_domain": "googleapis.com"
}
'''; // As defined above
// Initialize AccessTokenManager
final accessTokenManager = AccessTokenManager(serviceAccountKeyJson);
// Obtain an OAuth 2.0 access token
final accessToken = await accessTokenManager.getAccessToken();
// Log.print('accessToken: ${accessToken}');
// Send the notification
final response = await http.post(
Uri.parse('https://fcm.googleapis.com/fcm/send'),
Uri.parse(
'https://fcm.googleapis.com/v1/projects/ride-b1bd8/messages:send'),
headers: <String, String>{
'Content-Type': 'application/json',
'Authorization': 'key=${AK.serverAPI}'
'Authorization': 'Bearer $accessToken',
},
body: jsonEncode({
'notification': <String, dynamic>{
'title': title,
'body': body,
'sound': tone
'message': {
'token': token,
'notification': {
'title': title,
'body': body,
},
'android': {
'notification': {
'sound': tone,
},
},
'apns': {
'payload': {
'aps': {
'sound': tone,
},
},
},
},
'data': {
'passengerList': map,
},
'priority': 'high',
'to': token,
}),
);
if (response.statusCode == 200) {
// Notification sent successfully
print(
'Notification sent successfully. Status code: ${response.statusCode}');
print('Response body: ${response.body}');
} else {
// Handle error response
'Failed to send notification. Status code: ${response.statusCode}';
print(
'Failed to send notification. Status code: ${response.statusCode}');
print('Response body: ${response.body}');
}
} catch (e) {
// Handle other exceptions
print('Error sending notification: $e');
}
}

View File

@@ -1769,7 +1769,7 @@ class MapPassengerController extends GetxController {
'northeastLon': bounds.northeast.longitude.toString(),
});
break;
case 'Balash':
case 'Awfar Car':
res = await CRUD()
.get(link: AppLink.getCarsLocationByPassengerBalash, payload: {
'southwestLat': bounds.southwest.latitude.toString(),

View File

@@ -7,6 +7,7 @@ class MyTranslation extends Translations {
"Update Available": "تحديث متوفر",
'Phone number must be exactly 11 digits long':
"رقم الهاتف يجب أن يكون بطول 11 رقماً",
'Insert Wallet phone number': 'أدخل رقم هاتف المحفظة',
"Phone number isn't an Egyptian phone number":
"رقم الهاتف ليس رقم هاتف مصري",
"A new version of the app is available. Please update to the latest version.":

View File

@@ -31,6 +31,7 @@ class PaymentController extends GetxController {
bool isPromoSheetDialogue = false;
final formKey = GlobalKey<FormState>();
final promo = TextEditingController();
final walletphoneController = TextEditingController();
double totalPassenger = Get.find<MapPassengerController>().totalPassenger;
int? selectedAmount = 0;
List<dynamic> totalPassengerWalletDetails = [];
@@ -762,44 +763,45 @@ class PaymentController extends GetxController {
billingData: PaymobBillingData(),
onPayment: (PaymobResponse response) {},
);
if (response!.responseCode == 'APPROVED') {
Get.defaultDialog(
barrierDismissible: false,
title: 'Payment Successful'.tr,
titleStyle: AppStyle.title,
// backgroundColor: AppColor.greenColor,
content: Text(
'The payment was approved.'.tr,
style: AppStyle.title,
),
confirm: MyElevatedButton(
kolor: AppColor.greenColor,
title: 'OK'.tr,
onPressed: () async {
Get.back();
method();
},
),
);
} else {
Get.defaultDialog(
barrierDismissible: false,
// backgroundColor: AppColor.redColor,
title: 'Payment Failed'.tr,
content: Text(
'The payment was not approved. Please try again.'.tr,
textAlign: TextAlign.center,
style: AppStyle.title,
),
confirm: MyElevatedButton(
title: 'OK'.tr,
kolor: AppColor.redColor,
onPressed: () async {
Get.back();
},
),
);
if (response!.success == true && response.responseCode == '200') {
if (response!.responseCode == 'APPROVED') {
Get.defaultDialog(
barrierDismissible: false,
title: 'Payment Successful'.tr,
titleStyle: AppStyle.title,
// backgroundColor: AppColor.greenColor,
content: Text(
'The payment was approved.'.tr,
style: AppStyle.title,
),
confirm: MyElevatedButton(
kolor: AppColor.greenColor,
title: 'OK'.tr,
onPressed: () async {
Get.back();
method();
},
),
);
} else {
Get.defaultDialog(
barrierDismissible: false,
// backgroundColor: AppColor.redColor,
title: 'Payment Failed'.tr,
content: Text(
'The payment was not approved. Please try again.'.tr,
textAlign: TextAlign.center,
style: AppStyle.title,
),
confirm: MyElevatedButton(
title: 'OK'.tr,
kolor: AppColor.redColor,
onPressed: () async {
Get.back();
},
),
);
}
}
}
} catch (e) {

View File

@@ -144,7 +144,7 @@ class PaymobPaymentWallet {
}) async {
final Map<String, dynamic> data = {
"source": {
"identifier": box.read(BoxName.phone).toString(),
"identifier": box.read(BoxName.phoneWallet).toString(),
"subtype": "WALLET",
},
"payment_token": paymentToken,
@@ -269,7 +269,7 @@ class PaymobBillingDataWallet {
"email": box.read(BoxName.email) ?? box.read(BoxName.emailDriver),
"first_name": box.read(BoxName.name) ?? box.read(BoxName.nameDriver),
"last_name": box.read(BoxName.name) ?? box.read(BoxName.nameDriver),
"phone_number": box.read(BoxName.phone) ?? box.read(BoxName.phoneDriver),
"phone_number": box.read(BoxName.phoneWallet),
"apartment": apartment ?? "NA",
"floor": floor ?? "NA",
"building": building ?? "NA",

View File

@@ -77,9 +77,9 @@ void main() async {
userTokenExpiration: 200,
iFrameID: 837992,
);
PaymobPaymentWallet.instance.initialize(
apiKey: AK
.payMobApikey, // from dashboard Select Settings -> Account Info -> API Key
apiKey: AK.payMobApikey,
integrationID: int.parse(AK.integrationIdPayMobWallet),
userTokenExpiration: 200,
iFrameID: 837992,

View File

@@ -27,7 +27,7 @@ class MyTextForm extends StatelessWidget {
children: [
Text(
label.tr,
style: TextStyle(
style: const TextStyle(
color: CupertinoColors.label,
fontSize: 16,
fontWeight: FontWeight.w600,