public void IssueChargeCarnet()
        {
            BoletoFacil boletoFacil = GetBoletoFacil();
            Charge      charge      = Charge;

            charge.Installments = 3;

            ChargeResponse response = boletoFacil.IssueCharge(charge);

            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
            Assert.AreEqual(3, response.Data.Charges.Length);
            Assert.IsInstanceOfType(response.Data.Charges[0], typeof(Charge));
            Assert.IsInstanceOfType(response.Data.Charges[1], typeof(Charge));
            Assert.IsInstanceOfType(response.Data.Charges[2], typeof(Charge));
            Assert.AreEqual("101", response.Data.Charges[0].Code);
            Assert.AreEqual("102", response.Data.Charges[1].Code);
            Assert.AreEqual("103", response.Data.Charges[2].Code);
            Assert.AreEqual(StartDate.Date, response.Data.Charges[0].DueDate.Date);
            Assert.AreEqual(StartDate.Date.AddMonths(1), response.Data.Charges[1].DueDate.Date);
            Assert.AreEqual(StartDate.Date.AddMonths(2), response.Data.Charges[2].DueDate.Date);
            Assert.AreEqual(BaseUrl, response.Data.Charges[0].Link.Substring(0, BaseUrl.Length));
            Assert.AreEqual(BaseUrl, response.Data.Charges[1].Link.Substring(0, BaseUrl.Length));
            Assert.AreEqual(BaseUrl, response.Data.Charges[2].Link.Substring(0, BaseUrl.Length));
            Assert.AreEqual("03399.63290 64000.001014 00236.601027 8 67150000004115", response.Data.Charges[0].PayNumber);
            Assert.AreEqual("03399.63290 64000.001014 00236.601027 8 67250000004115", response.Data.Charges[1].PayNumber);
            Assert.AreEqual("03399.63290 64000.001014 00236.601027 8 67350000004115", response.Data.Charges[2].PayNumber);
        }
        void IssueCharge()
        {
            Payer payer = new Payer();

            payer.Name    = "Pagador teste - SDK .NET";
            payer.CpfCnpj = "18415256930";

            Charge charge = new Charge();

            charge.Description  = "Cobrança teste gerada pelo SDK .NET";
            charge.Amount       = 176.45m;
            charge.Payer        = payer;
            charge.PaymentTypes = new PaymentType[] { PaymentType.BOLETO, PaymentType.CREDIT_CARD };

            try
            {
                ChargeResponse response = boletoFacil.IssueCharge(charge);
                ShowObjectResponseHeader();
                foreach (Charge c in response.Data.Charges)
                {
                    Console.WriteLine("");
                    Console.WriteLine(c);
                }
                ShowResponseSerialized(response);
            }
            catch (BoletoFacilException e)
            {
                HandleException(e);
            }
            finally
            {
                DoneMessage();
            }
        }
        public void IssueChargeUniqueMandatoryFields()
        {
            BoletoFacil boletoFacil = GetBoletoFacil();
            Charge      charge      = Charge;

            ChargeResponse response = boletoFacil.IssueCharge(charge);

            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
            Assert.AreEqual(1, response.Data.Charges.Length);
            Assert.IsInstanceOfType(response.Data.Charges[0], typeof(Charge));
            Assert.AreEqual("101", response.Data.Charges[0].Code);
            Assert.AreEqual(StartDate.Date, response.Data.Charges[0].DueDate.Date);
            Assert.AreEqual(BaseUrl, response.Data.Charges[0].Link.Substring(0, BaseUrl.Length));
            Assert.AreEqual("03399.63290 64000.001014 00236.601027 8 67150000025000", response.Data.Charges[0].PayNumber);
        }
        public void IssueChargeWithProxy()
        {
            BoletoFacil boletoFacil = GetBoletoFacil();

            boletoFacil.SetProxy("http://localhost", "username", "password");
            Assert.IsTrue(boletoFacil.UseProxy);
            Charge charge = Charge;

            ChargeResponse response = boletoFacil.IssueCharge(charge);

            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
            Assert.AreEqual(1, response.Data.Charges.Length);
            Assert.IsInstanceOfType(response.Data.Charges[0], typeof(Charge));
            Assert.AreEqual("101", response.Data.Charges[0].Code);
            Assert.AreEqual(StartDate.Date, response.Data.Charges[0].DueDate.Date);
            Assert.AreEqual(BaseUrl, response.Data.Charges[0].Link.Substring(0, BaseUrl.Length));
            Assert.AreEqual("03399.63290 64000.001014 00236.601027 8 67150000025000", response.Data.Charges[0].PayNumber);
        }
        public void IssueChargeErrorNoPayer()
        {
            BoletoFacil boletoFacil = GetBoletoFacil();
            Charge      charge      = Charge;

            charge.Payer = null;

            BoletoFacilRequestException response = AssertException <BoletoFacilRequestException>(() => boletoFacil.IssueCharge(charge));

            AssertError(response, "Parâmetro obrigatório 'payerName' não está presente");
        }
        public void IssueChargeErrorInvalidAmount()
        {
            BoletoFacil boletoFacil = GetBoletoFacil();
            Charge      charge      = Charge;

            charge.Amount = 0;

            BoletoFacilRequestException response = AssertException <BoletoFacilRequestException>(() => boletoFacil.IssueCharge(charge));

            AssertError(response, "Valor mínimo para cobrança é de R$ 2,50");
        }