authenticatePayer method

Future<MastercardAuthResponse> authenticatePayer({
  1. required String authId,
  2. required String paRes,
})

Authenticate Payer (Complete 3DS)

Implementation

Future<MastercardAuthResponse> authenticatePayer({
  required String authId,
  required String paRes,
}) async {
  try {
    final requestBody = {
      'authentication': {
        'redirectResponseUrl': paRes,
      },
    };

    final response = await _dio.put(
      '/authentication/$authId',
      data: requestBody,
    );

    return MastercardAuthResponse.fromJson(response.data);
  } on DioException catch (e) {
    throw MastercardException(
      'Payer authentication failed: ${e.message}',
      statusCode: e.response?.statusCode,
      response: e.response?.data,
    );
  } catch (e) {
    throw MastercardException('Payer authentication failed: $e');
  }
}