resendOtp method

Step 5: Resend OTP (if needed) POST /payments/resend-otp

Implementation

Future<LokotroOtpResendResponse> resendOtp(LokotroOtpResendRequest request) async {
  try {
    if (kDebugMode) {
      debugPrint('[Lokotro Payment] Resending OTP: ${request.toString()}');
    }

    final response = await _httpClient.post<Map<String, dynamic>>(
      '/payments/resend-otp',
      data: request.toJson(),
      parser: (data) => data as Map<String, dynamic>,
    );

    if (response.isSuccess && response.data != null) {
      final resendResponse = LokotroOtpResendResponse.fromJson(response.data!);

      if (kDebugMode) {
        debugPrint('[Lokotro Payment] OTP resent: ${resendResponse.toString()}');
      }

      return resendResponse;
    } else {
      throw LokotroPaymentException(
        message: response.message,
        code: 'OTP_RESEND_FAILED',
      );
    }
  } catch (e) {
    if (kDebugMode) {
      debugPrint('[Lokotro Payment] Resend OTP error: $e');
    }
    rethrow;
  }
}