feat: implement secure OTP-based payout workflow with dynamic fee calculation and improved authentication checks

This commit is contained in:
Hamza-Ayed
2026-07-19 01:51:39 +03:00
parent 5e80c886a0
commit 085b180bdb
11 changed files with 252 additions and 193 deletions
@@ -4,13 +4,14 @@ import 'package:siro_driver/controller/functions/crud.dart';
class PayoutService {
final String _baseUrl =
"https://walletintaleq.intaleq.xyz/v1/main/sms_webhook";
static const double payoutFee = 5000.0; // عمولة السحب الثابتة
static const double payoutFee = 50.0; // عمولة السحب الثابتة
/// دالة لإنشاء طلب سحب جديد على السيرفر
///
/// تعيد رسالة النجاح من السيرفر، أو رسالة خطأ في حال الفشل.
Future<String?> requestPayout({
required String driverId,
required String otp,
walletType,
payoutPhoneNumber,
required double amount,
@@ -23,6 +24,7 @@ class PayoutService {
'amount': amount.toString(),
'phone': payoutPhoneNumber.toString(),
'wallet_type': walletType.toString(),
'otp': otp,
}).timeout(const Duration(seconds: 20));
if (response != 'failure') {
@@ -42,4 +44,24 @@ class PayoutService {
return "حدث خطأ غير متوقع. يرجى المحاولة مرة أخرى.";
}
}
Future<bool> requestOtp({required String phone}) async {
final url = "https://walletintaleq.intaleq.xyz/v1/auth/otp/request.php";
try {
final response = await CRUD().postWallet(link: url, payload: {
'phone_number': phone,
'user_type': 'driver',
'context': 'payout',
}).timeout(const Duration(seconds: 20));
if (response != 'failure') {
final data = (response);
return data['status'] == 'success';
}
return false;
} catch (e) {
debugPrint("Exception during OTP request: $e");
return false;
}
}
}