httpSigner function

Future<String> httpSigner({
  1. required String rnc,
  2. required String tag,
  3. required String xml,
})

Implementation

Future<String> httpSigner(
    {required String rnc, required String tag, required String xml}) async {
  try {
    var xmlBase64 = base64.encode(utf8.encode(xml));

    var r = await post(Uri.parse('https://ecf.vicortiz.com/sign-xml'),
        headers: {
          'Content-Type': 'application/json',
          'Accept': 'text/plain',
        },
        body: jsonEncode({'rnc': rnc, 'tag': tag, 'xml': xmlBase64}));

    var result = utf8.decode(base64.decode(jsonDecode(r.body)));

    return result;
  } catch (e) {
    throw 'No se pudo firmar el documento\ne';
  }
}