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); }
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)); } }
private HttpContent CreateContent(Transaction transaction) { var request = new DirectRequest { Action = transaction.Action, Method = transaction.Method, Type = "rpc" }; if (transaction.Parameters != null) { request.JsonData = JToken.FromObject(transaction.Parameters.ToDictionary(i => i.Name, i => i.Value)); } var content = new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json"); return(content); }
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); }
public async Task <DirectResponse> Create(DirectRequest request) { return(await PostAsync <DirectResponse>(request)); }
public DirectResponse handle(DirectRequest request) { return new DirectResponse(request); }