feat: implement secure OTP-based payout workflow with dynamic fee calculation and improved authentication checks
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user