Пример #1
0
        public async Task CreateWithCreditCardToken()
        {
            var token = new TokenResponse();

            using (var tokenApi = new EbanxTokenOperationApi())
            {
                var request = new TokenRequest
                {
                    Country         = "BR",
                    CreditCard      = CreaditCardRequestExtention.GetACard(),
                    PaymentTypeCode = "mastercard",
                };

                token = await tokenApi.Create(request);
            }


            var response = new DirectResponse();

            using (var directApi = new EbanxDirectOperationApi())
            {
                var request = new DirectRequest
                {
                    Operation = "request",
                    Mode      = "full",
                    Payment   = new PaymentRequest
                    {
                        Name         = "Customer Name",
                        Email        = "*****@*****.**",
                        AmountTotal  = 500,
                        Zipcode      = "000000",
                        Address      = "Rua X",
                        StreetNumber = "5",
                        City         = "City",
                        State        = "SP",
                        Country      = "BR",
                        PhoneNumber  = "999999999",
                        CreditCard   = new CreditCardRequest
                        {
                            Token = token.Token
                        },
                        CurrencyCode        = "BRL",
                        MerchantPaymentCode = Guid.NewGuid().ToString(),
                        Document            = "29479146002",
                        Instalments         = 1
                    }
                };

                response = await directApi.Create(request);
            }

            Assert.IsTrue(response.Success);
            Assert.IsTrue(response.Payment.TransactionStatus.Success);
        }
Пример #2
0
        public async Task Create()
        {
            var responseDirect = new DirectResponse();

            using (var directApi = new EbanxDirectOperationApi())
            {
                var r = new DirectRequest
                {
                    Operation = "request",
                    Mode      = "full",
                    Payment   = new PaymentRequest
                    {
                        Name                = "Customer Name",
                        Email               = "*****@*****.**",
                        AmountTotal         = 500,
                        Zipcode             = "000000",
                        Address             = "Rua X",
                        StreetNumber        = "5",
                        City                = "City",
                        State               = "SP",
                        Country             = "BR",
                        PhoneNumber         = "999999999",
                        CurrencyCode        = "BRL",
                        MerchantPaymentCode = Guid.NewGuid().ToString(),
                        Document            = "29479146002",
                        Instalments         = 1,
                        PaymentTypeCode     = "boleto",
                        DueDate             = DateTime.Now.AddDays(3).ToString("dd/MM/yyyy"),
                    }
                };

                responseDirect = await directApi.Create(r);

                var response = new CancelResponse();

                var request = new CancelRequest
                {
                    Hash = responseDirect.Payment.Hash
                };

                using (var api = new EbanxCancelOperationApi(request))
                {
                    response = await api.Create();
                }

                Assert.IsFalse(response.Success);
                //Assert.IsTrue(!string.IsNullOrEmpty(token?.Token));
            }
        }
Пример #3
0
        public async Task CreateWithInsufficientFundsCard()
        {
            var response = new DirectResponse();

            using (var directApi = new EbanxDirectOperationApi())
            {
                var request = new DirectRequest
                {
                    Operation = "request",
                    Mode      = "full",
                    Payment   = new PaymentRequest
                    {
                        Name         = "Customer Name",
                        Email        = "*****@*****.**",
                        AmountTotal  = 500,
                        Zipcode      = "000000",
                        Address      = "Rua X",
                        StreetNumber = "5",
                        City         = "City",
                        State        = "SP",
                        Country      = "BR",
                        PhoneNumber  = "999999999",
                        CreditCard   = CreaditCardRequestExtention.GetACard(CreaditCardRequestExtention.CreditCardTestRequestOperation.InsufficientFunds),

                        //PaymentTypeCode = "boleto",
                        SubAccount = new SubAccountRequest
                        {
                            Name     = "SubAccount Name",
                            ImageUrl = "Image Uri"
                        },
                        CurrencyCode        = "BRL",
                        MerchantPaymentCode = Guid.NewGuid().ToString(),
                        Document            = "29479146002",
                        Instalments         = 1
                    }
                };

                response = await directApi.Create(request);
            }

            Assert.IsTrue(response.Success);
            Assert.IsFalse(response.Payment.TransactionStatus.Success);
        }