verifyOtp method
Implementation
Future<Map<String, dynamic>> verifyOtp(
String txnId, String otp,String accessToken) async {
final url = Uri.parse('https://apidev.ioh.co.id/id-auth/api/v1/id-auth/verifyOtp');
String encryptedOtp = EncryptionService.encryptPhoneNumber(otp);
final headers = {
'Authorization': 'Bearer '+accessToken,
'Content-Type': 'application/json',
'Cache-Control': 'no-cache, no-store, must-revalidate',
'Pragma': 'no-cache',
'Expires': '0',
};
final body = json.encode({
'txnId': txnId,
'otp': encryptedOtp,
});
final response = await http.post(url, headers: headers, body: body);
if (response.statusCode == 200) {
return jsonDecode(response.body);
} else {
throw Exception('Failed to verify OTP: ${response.body}');
}
}