resendOtp method

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

Implementation

Future<LokotroOtpResendResponse> resendOtp(LokotroOtpResendRequest request) async {
  try {
    LokotroPayLog.d('payment.resend_otp', {
      'payment_id': request.paymentId,
    });

    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!);

      LokotroPayLog.d('payment.resend_otp.ok', {
        'success': resendResponse.success,
        'status': resendResponse.status,
        'resend_count': resendResponse.resendCount,
      });

      return resendResponse;
    } else {
      throw LokotroPaymentException(
        message: response.message,
        code: 'OTP_RESEND_FAILED',
      );
    }
  } catch (e) {
    LokotroPayLog.m('payment.resend_otp.err', 'resend OTP failed (type=${e.runtimeType})');
    rethrow;
  }
}