示例#1
0
        static void CancelTest()
        {
            var cli = new DFactureClient(USERNAME, PASSWORD, DFactureClient.URL_TEST);
            var ret = cli.Cancel("AAA010101AAA", "XAXX010101000", "25D0B1B7-2FAE-4E92-BDE1-CF26AA1FBA22", "81.20",
                                 Convert.ToBase64String(File.ReadAllBytes(CSD_CERTIFICATE_FILE)),
                                 Convert.ToBase64String(File.ReadAllBytes(CSD_PRIVATE_KEY_FILE)),
                                 CSD_PRIVATE_KEY_PWD);

            Console.WriteLine("Cancel: {0}", ret);
        }
示例#2
0
        static bool DFactureCancel(FiscalDocument item)
        {
            var cer = item.Issuer.Certificates.First(x => x.IsActive);
            var cli = new DFactureClient(WebConfig.DFactureUser, WebConfig.DFacturePassword, WebConfig.DFactureUrl);

            try {
                return(cli.Cancel(item.Issuer.Id, item.Recipient, item.StampId, item.Total.ToString(),
                                  Convert.ToBase64String(cer.CertificateData),
                                  Convert.ToBase64String(cer.KeyData),
                                  Encoding.UTF8.GetString(cer.KeyPassword)));
            } catch (DFactureClientException ex) {
                if (ex.Code == "202")                   // UUID Previamente cancelado
                {
                    return(true);
                }

                throw ex;
            }
        }