6/1/1
This commit is contained in:
@@ -420,7 +420,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
//android/app/src/main/res/raw/iphone_ringtone.wav
|
||||
void sendNotificationToPassengerToken(
|
||||
String title, body, token, List<String> map) async {
|
||||
try {
|
||||
@@ -458,6 +458,43 @@ class FirebaseMessagesController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
void sendNotificationToPassengerTokenCALL(
|
||||
String title, body, token, List<String> map) async {
|
||||
try {
|
||||
final response = await http.post(
|
||||
Uri.parse('https://fcm.googleapis.com/fcm/send'),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'key=${AK.serverAPI}'
|
||||
},
|
||||
body: jsonEncode({
|
||||
'notification': <String, dynamic>{
|
||||
'title': title,
|
||||
'body': body,
|
||||
'sound': 'iphone_ringtone.wav'
|
||||
},
|
||||
'data': {
|
||||
'passengerList': map,
|
||||
},
|
||||
'priority': 'high',
|
||||
'to': token,
|
||||
}),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
// Notification sent successfully
|
||||
print('Notification sent successfully');
|
||||
} else {
|
||||
// Handle error response
|
||||
print(
|
||||
'Failed to send notification. Status code: ${response.statusCode}');
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle other exceptions
|
||||
print('sendNotification() error: $e');
|
||||
}
|
||||
}
|
||||
|
||||
void sendNotificationToAnyWithoutData(
|
||||
String title, String body, String token) async {
|
||||
try {
|
||||
|
||||
@@ -38,8 +38,8 @@ class CallController extends GetxController {
|
||||
// Set up an instance of Agora engine
|
||||
setupVoiceSDKEngine();
|
||||
// join();
|
||||
FirebaseMessagesController().sendNotificationToPassengerToken(
|
||||
'Call Income from Passenger',
|
||||
FirebaseMessagesController().sendNotificationToPassengerTokenCALL(
|
||||
'Call Income',
|
||||
'${'You have call from driver'.tr} ${box.read(BoxName.nameDriver)}',
|
||||
Get.find<MapDriverController>().tokenPassenger,
|
||||
[
|
||||
@@ -79,8 +79,8 @@ class CallController extends GetxController {
|
||||
},
|
||||
onUserJoined: (RtcConnection connection, int remoteUid, int elapsed) {
|
||||
// Get.snackbar("Remote user uid:$remoteUid joined the channel", '');
|
||||
status = '${Get.find<MapDriverController>().passengerName}'
|
||||
' joined'
|
||||
status = '${Get.find<MapDriverController>().passengerName} '
|
||||
'joined'
|
||||
.tr;
|
||||
remoteUid = remoteUid;
|
||||
update();
|
||||
@@ -88,7 +88,7 @@ class CallController extends GetxController {
|
||||
onUserOffline: (RtcConnection connection, int? remoteUid,
|
||||
UserOfflineReasonType reason) {
|
||||
// Get.snackbar("Remote user uid:$remoteUid left the channel", '');
|
||||
status = 'Call left'.tr;
|
||||
status = 'Call Left'.tr;
|
||||
remoteUid = null;
|
||||
update();
|
||||
},
|
||||
|
||||
@@ -48,9 +48,9 @@ class CRUD {
|
||||
required String uid,
|
||||
}) async {
|
||||
var uid = box.read(BoxName.phone) ?? box.read(BoxName.phoneDriver);
|
||||
var res = await http.get(
|
||||
Uri.parse(
|
||||
'https://repulsive-pig-rugby-shirt.cyclic.app/token?channelName=$channelName'),
|
||||
var res = await http.get(Uri.parse(
|
||||
// 'https://repulsive-pig-rugby-shirt.cyclic.app/token?channelName=$channelName'),
|
||||
'https://orca-app-b2i85.ondigitalocean.app/token?channelName=$channelName'),
|
||||
headers: {'Authorization': 'Bearer ${AK.agoraAppCertificate}'});
|
||||
|
||||
if (res.statusCode == 200) {
|
||||
|
||||
@@ -398,6 +398,15 @@ class MapDriverController extends GetxController {
|
||||
'passengerID': passengerId,
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
});
|
||||
|
||||
var res1 =
|
||||
await CRUD().post(link: AppLink.addDriversWalletPoints, payload: {
|
||||
'paymentID': 'rideId$rideId',
|
||||
'amount': (costOfWaiting5Minute).toStringAsFixed(0),
|
||||
'paymentMethod': 'wait',
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
});
|
||||
print(res1);
|
||||
if (res != 'failure') {
|
||||
Get.snackbar(
|
||||
'You will get cost of your work for this trip'.tr,
|
||||
@@ -515,6 +524,7 @@ class MapDriverController extends GetxController {
|
||||
'passengerId': passengerId,
|
||||
'rideId': rideId,
|
||||
'price': price.toString(),
|
||||
'walletChecked': walletChecked
|
||||
});
|
||||
// Get.back();
|
||||
// }
|
||||
@@ -581,15 +591,19 @@ class MapDriverController extends GetxController {
|
||||
? (i ~/ 60) +
|
||||
(recentDistanceToDash *
|
||||
Get.find<HomeCaptainController>().comfortPrice)
|
||||
: carType == 'Mashwari'
|
||||
: carType == 'Delivery'
|
||||
? (i ~/ 60) +
|
||||
(recentDistanceToDash *
|
||||
Get.find<HomeCaptainController>().deliveryPrice)
|
||||
: (i ~/ 60) +
|
||||
(recentDistanceToDash *
|
||||
Get.find<HomeCaptainController>()
|
||||
.mashwariPrice); // $1 for each minute + $4 for each km
|
||||
price = (price * .10) + price; // Add 10% tax
|
||||
: carType == 'Rayeh Gai'
|
||||
? (i ~/ 60) +
|
||||
(recentDistanceToDash *
|
||||
Get.find<HomeCaptainController>().speedPrice)
|
||||
: (i ~/ 60) +
|
||||
(recentDistanceToDash *
|
||||
Get.find<HomeCaptainController>()
|
||||
.mashwariPrice); // $1 for each minute + $4 for each km
|
||||
price = (price * double.parse(kazan)) + price; // Add 10% tax
|
||||
speed = Get.find<LocationController>().speed * 3.6;
|
||||
progressTimerRideBegin = i / durationOfRide;
|
||||
remainingTimeTimerRideBegin = durationOfRide - i;
|
||||
|
||||
@@ -79,6 +79,22 @@ class OrderRequestController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
void getSQL() async {
|
||||
DateTime today = DateTime.now();
|
||||
int todayDay = today.day;
|
||||
|
||||
String driverId = box.read(BoxName.driverID).toString();
|
||||
|
||||
String customQuery = '''
|
||||
SELECT *
|
||||
FROM ${TableName.driverOrdersRefuse}
|
||||
WHERE driver_id = '$driverId'
|
||||
AND created_at LIKE '%$todayDay%'
|
||||
''';
|
||||
List<Map<String, dynamic>> results = await sql.getCustomQuery(customQuery);
|
||||
print(results);
|
||||
}
|
||||
|
||||
void startTimer(String driverID, orderID) async {
|
||||
for (int i = 0; i <= duration; i++) {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
|
||||
@@ -17,6 +17,7 @@ class CaptainWalletController extends GetxController {
|
||||
String totalAmountVisa = '0';
|
||||
String totalPoints = '0';
|
||||
final amountFromBudgetController = TextEditingController();
|
||||
final issurWallet = TextEditingController();
|
||||
|
||||
payFromBudget() async {
|
||||
if (formKey.currentState!.validate()) {
|
||||
|
||||
120
lib/controller/home/payment/paymob_payout.dart
Normal file
120
lib/controller/home/payment/paymob_payout.dart
Normal file
@@ -0,0 +1,120 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:SEFER/constant/box_name.dart';
|
||||
import 'package:SEFER/constant/colors.dart';
|
||||
import 'package:SEFER/main.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '../../../constant/links.dart';
|
||||
import '../../functions/crud.dart';
|
||||
import 'captain_wallet_controller.dart';
|
||||
|
||||
class PaymobPayout extends GetxController {
|
||||
bool isLoading = false;
|
||||
|
||||
Future<String> getToken() async {
|
||||
var headers = {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
// 'Cookie':
|
||||
// 'csrftoken=74iZJ8XYyuTm5WRq2W4tpWX5eqoJLZVK5QhuDrChWpDtzpgGA269bbCWuEcW85t4'
|
||||
};
|
||||
var body = {
|
||||
'grant_type': 'password',
|
||||
'username': 'sefer_api_checker',
|
||||
'password': '#c3pSwbUxOKpQnr5hHZAgpkSW',
|
||||
'client_id': 'kmNWU5gKsL8LKVhsJFbOGTEb3YQ5sQhvBoB8pqoW',
|
||||
'client_secret':
|
||||
'htV6nFANLDd658ueTEuMrIqwjcXsocMXmBLAYof7FuutBcSxdTdoNqFl3EAvO6zrOgGPLdiMrofNp2V9ASVRpjoSlFjDNRzY7hfPunAJEgf2N5ZUuknN4QniaqIZvaNt'
|
||||
};
|
||||
var res = await http.post(
|
||||
Uri.parse(
|
||||
'https://stagingpayouts.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'];
|
||||
}
|
||||
print('token = $token');
|
||||
return token;
|
||||
}
|
||||
|
||||
payToDriverWallet(
|
||||
String token, String amount, String issuer, String msisdn) async {
|
||||
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://stagingpayouts.paymobsolutions.com/api/secure/disburse/'),
|
||||
headers: headers,
|
||||
body: body,
|
||||
);
|
||||
print(jsonDecode(res.body));
|
||||
print('-----');
|
||||
var dec = jsonDecode(res.body);
|
||||
if (dec['disbursement_status'] == 'successful') {
|
||||
await CRUD().post(link: AppLink.addDriverpayment, payload: {
|
||||
'rideId': DateTime.now().toIso8601String(),
|
||||
'amount': ((-1) * double.parse(dec['amount'])).toStringAsFixed(0),
|
||||
'payment_method': 'payout',
|
||||
'passengerID': 'myself',
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
});
|
||||
Get.snackbar('Transaction successful'.tr,
|
||||
'${'Transaction successful'.tr} ${dec['amount']}',
|
||||
backgroundColor: AppColor.greenColor);
|
||||
Get.find<CaptainWalletController>().getCaptainWalletFromRide();
|
||||
} else if (dec['disbursement_status'] == 'failed') {
|
||||
Get.snackbar('Transaction successful'.tr, 'Transaction failed'.tr,
|
||||
backgroundColor: AppColor.redColor);
|
||||
}
|
||||
}
|
||||
|
||||
payToDriverBankAccount(String token, String amount, String bankCardNumber,
|
||||
String bankCode) async {
|
||||
var headers = {
|
||||
'Authorization': 'Bearer $token',
|
||||
'Content-Type': 'application/json',
|
||||
};
|
||||
var body = {
|
||||
"issuer": "bank_card",
|
||||
"amount": amount, //9.0,
|
||||
"full_name": box.read(BoxName.nameDriver).toString(),
|
||||
"bank_card_number": bankCardNumber, //"1111-2222-3333-4444",
|
||||
"bank_code": bankCode, //"CIB",
|
||||
"bank_transaction_type": "cash_transfer"
|
||||
};
|
||||
var res = await http
|
||||
.post(
|
||||
Uri.parse(
|
||||
'https://stagingpayouts.paymobsolutions.com/api/secure/disburse/'),
|
||||
headers: headers,
|
||||
body: body,
|
||||
)
|
||||
.then((value) {
|
||||
print(value);
|
||||
});
|
||||
}
|
||||
|
||||
Future payToWalletDriverAll(
|
||||
String amount, String issuer, String msisdn) async {
|
||||
String token = await getToken();
|
||||
await payToDriverWallet(token, amount, issuer, msisdn);
|
||||
}
|
||||
|
||||
Future payToBankDriverAll(
|
||||
String amount, String bankCardNumber, String bankCode) async {
|
||||
String token = await getToken();
|
||||
await payToDriverBankAccount(token, amount, bankCardNumber, bankCode);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,27 @@ class MyTranslation extends Translations {
|
||||
@override
|
||||
Map<String, Map<String, String>> get keys => {
|
||||
"ar": {
|
||||
"Transaction failed": "فشل المعاملة",
|
||||
"Wallet Type": "نوع المحفظة",
|
||||
"Enter your wallet number": "أدخل رقم محفظتك",
|
||||
"The Amount is less than": "المبلغ أقل من",
|
||||
"Cash Out": "صرف",
|
||||
"Transaction successful": "تمت العملية بنجاح",
|
||||
"Do you want to collect your earnings?":
|
||||
"هل تريد استلام أموالك؟", // Corrected grammar
|
||||
"Total wallet is ": "إجمالي المحفظة هو ",
|
||||
"Remainder": "المتبقي",
|
||||
"Call Page": "صفحة المكالمة",
|
||||
"Call End": "إنهاء المكالمة",
|
||||
"Call Left": "مكالمات متبقية",
|
||||
"Rayeh Gai": "رايح جاي ",
|
||||
"cost is ": " التكلفة هي ",
|
||||
"Total budgets on month": "إجمالي الميزانيات لهذا الشهر",
|
||||
"Counts of budgets on days": "عدد الميزانيات حسب الأيام",
|
||||
"Wallet Added": "تم إضافة المحفظة",
|
||||
"The price must be over than ": "يجب أن يكون السعر أكثر من ",
|
||||
"Total Cost": "إجمالي التكلفة",
|
||||
"This Trip Cancelled": "تم إلغاء هذه الرحلة",
|
||||
"Total price from ": "إجمالي السعر من ",
|
||||
"Wallet Add": "إضافة إلى المحفظة",
|
||||
"Press here": "اضغط هنا",
|
||||
@@ -567,7 +588,7 @@ class MyTranslation extends Translations {
|
||||
"Best choice for comfort car and flexible route and stops point":
|
||||
"أفضل خيار للسيارة المريحة والطريق المرن ونقطة التوقف",
|
||||
"Insert": "إدراج",
|
||||
' Total weekly points is ': ' تفاصيل الرصيد التشغيل ',
|
||||
' Total weekly points is ': " مجموع النقاط الأسبوعية هو ",
|
||||
'you can buy ': 'يمكنك شراء',
|
||||
"Which method you will pay": 'أي طريقة الدفع تفضل',
|
||||
"This is for delivery or a motorcycle.":
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'package:SEFER/constant/colors.dart';
|
||||
import 'package:SEFER/controller/firebase/firbase_messge.dart';
|
||||
import 'package:SEFER/controller/home/captin/map_driver_controller.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -14,10 +16,11 @@ import 'package:SEFER/views/widgets/elevated_btn.dart';
|
||||
class RateController extends GetxController {
|
||||
double selectedRateItemId = -1;
|
||||
TextEditingController comment = TextEditingController();
|
||||
TextEditingController passenggerPayAmount = TextEditingController();
|
||||
TextEditingController passengerPayAmount = TextEditingController();
|
||||
String? rideId, passengerId, driverId, price;
|
||||
late GlobalKey<FormState> formKey;
|
||||
bool ispassengerWantWalletFromDriver = false;
|
||||
String walletChecked = '';
|
||||
@override
|
||||
void onInit() {
|
||||
formKey = GlobalKey<FormState>();
|
||||
@@ -25,7 +28,7 @@ class RateController extends GetxController {
|
||||
rideId = Get.arguments['rideId'];
|
||||
driverId = Get.arguments['driverId'];
|
||||
price = Get.arguments['price'];
|
||||
|
||||
walletChecked = Get.arguments['walletChecked'];
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@@ -38,16 +41,52 @@ class RateController extends GetxController {
|
||||
if (formKey.currentState!.validate()) {
|
||||
var priceOfTrip =
|
||||
double.parse(Get.find<MapDriverController>().paymentAmount);
|
||||
double remainingFee =
|
||||
double.parse(passenggerPayAmount.text) - priceOfTrip;
|
||||
await CRUD().post(link: AppLink.addPassengersWallet, payload: {
|
||||
'passenger_id': passengerId,
|
||||
'balance': remainingFee.toString()
|
||||
}).then((value) {
|
||||
if (value != 'failure') {
|
||||
Get.snackbar('Wallet Add', '');
|
||||
}
|
||||
});
|
||||
double remainingFee = double.parse(passengerPayAmount.text) - priceOfTrip;
|
||||
if (remainingFee > 0) {
|
||||
await CRUD().post(link: AppLink.addPassengersWallet, payload: {
|
||||
'passenger_id': passengerId,
|
||||
'balance': remainingFee.toString()
|
||||
}).then((value) async {
|
||||
if (value != 'failure') {
|
||||
Get.snackbar('Wallet Added'.tr, '',
|
||||
backgroundColor: AppColor.greenColor);
|
||||
|
||||
await CRUD().post(link: AppLink.addDriverpayment, payload: {
|
||||
'rideId': 'remain$rideId',
|
||||
'amount': remainingFee.toString(),
|
||||
'payment_method': 'Remainder',
|
||||
'passengerID': passengerId,
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
});
|
||||
|
||||
double pointsSubstraction = 0;
|
||||
pointsSubstraction = remainingFee * (-1); // for eygpt /100
|
||||
var res = await CRUD()
|
||||
.post(link: AppLink.addDriversWalletPoints, payload: {
|
||||
'paymentID': 'rideId$rideId',
|
||||
'amount': (pointsSubstraction).toStringAsFixed(0),
|
||||
'paymentMethod': 'Remainder',
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
});
|
||||
|
||||
FirebaseMessagesController().sendNotificationToAnyWithoutData(
|
||||
'Wallet Added',
|
||||
'Wallet Added'.tr,
|
||||
Get.find<MapDriverController>().tokenPassenger);
|
||||
walletChecked == 'true';
|
||||
update();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Get.defaultDialog(
|
||||
title: '${'The price must be over than '.tr}$priceOfTrip',
|
||||
middleText: '',
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Ok'.tr,
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user