public async Task <HttpResult <Loja> > CreateTransactionCieloAsync(CieloRequest request, int lojaId)
        {
            var retorno  = new HttpResult <Loja>();
            var response = await _serviceClient.TransacitonAsync(request);

            if (!sucessoCielo.Contains(response.Payment.ReturnCode))
            {
                return(retorno.Set(HttpStatusCode.BadRequest, $"Não foi possível efeturar a transação. Erro: {response.Payment.ReturnCode} - {response.Payment.ReturnMessage}"));
            }

            var loja = await RegistrarTransacao(lojaId);

            loja.Response.RegistroTransacaoCielo = new Collection <RegistroTransacaoCielo>();
            loja.Response.RegistroTransacaoCielo.Add(new RegistroTransacaoCielo
            {
                AuthorizationCode = response.Payment.AuthorizationCode,
                Tid             = response.Payment.Tid,
                PaymentId       = response.Payment.PaymentId,
                ProofOfSale     = response.Payment.ProofOfSale,
                MerchantOrderId = response.MerchantOrderId
            });

            _dbContext.SaveChanges();
            retorno.Response = loja.Response;
            return(retorno);
        }
Beispiel #2
0
        public async Task <CieloResponse> PostSaleTransactionAsync(CieloRequest request, CieloMerchantCredential credential)
        {
            return(await Task.Run(() =>
            {
                var response = new CieloResponse
                {
                    ProofOfSale = "123",
                    Tid = "123456",
                    AuthorizationCode = "123456",
                    PaymentId = Guid.NewGuid()
                };

                if (request.Payment.CreditCard.Holder.Equals("Cielo Error"))
                {
                    response.Status = CieloStatus.Aborted;
                    response.ReturnCode = "70";
                    response.ReturnMessage = "Problemas com o Cartão de Crédito";
                    return response;
                }

                response.Status = CieloStatus.PaymentConfirmed;
                response.ReturnCode = "4";
                response.ReturnMessage = "Operação realizada com sucesso";
                return response;
            }));
        }
Beispiel #3
0
        public BaseService(CieloRequest cielo)
        {
            Cielo = cielo;

            if (string.IsNullOrEmpty(Cielo.Configuration.MerchantId) || string.IsNullOrEmpty(Cielo.Configuration.MerchantKey))
            {
                throw new Exception("Não foram encontradas as configurações para liberação de pagamento, favor verificar no cadastro da unidade/campus!");
            }
        }
Beispiel #4
0
        public async Task <CieloResponse> TransacitonAsync(CieloRequest request)
        {
            var json    = JsonConvert.SerializeObject(request);
            var content = new StringContent(json.ToString(), Encoding.UTF8, "application/json");

            client.DefaultRequestHeaders.Clear();
            client.DefaultRequestHeaders.Add("MerchantKey", _apiCieloOptions.Value.MerchantKey);
            client.DefaultRequestHeaders.Add("MerchantId", _apiCieloOptions.Value.MerchantId);

            var retorno = await client.PostAsync(_apiCieloOptions.Value.Url, content);

            var responseString = await retorno.Content.ReadAsStringAsync();

            return(JsonConvert.DeserializeObject <CieloResponse>(responseString));
        }
Beispiel #5
0
        public async Task <CieloResponse> PostSaleTransactionAsync(CieloRequest request, CieloMerchantCredential credential)
        {
            var cieloSaleUrl = Configuration.GetSection("Endpoints")["CieloApiUrl"];

            var httpContent = new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json");

            using (var client = new HttpClient())
            {
                client.DefaultRequestHeaders.Add("MerchantId", credential.MerchantId.ToString());
                client.DefaultRequestHeaders.Add("MerchantKey", credential.MerchantKey.ToString());

                var httpResponseMessage = await client.PostAsync(cieloSaleUrl + "1/sales/", httpContent);

                var content = await httpResponseMessage.Content.ReadAsStringAsync();

                return(JsonConvert.DeserializeObject <CieloResponse>(content));
            }
        }
Beispiel #6
0
 public SearchTransaction(CieloRequest cielo) : base(cielo)
 {
 }
Beispiel #7
0
 public CapturePartialTransaction(CieloRequest cielo) : base(cielo)
 {
 }
Beispiel #8
0
 public SearchCardBin(CieloRequest cielo) : base(cielo)
 {
 }
 public CancelPartialTransaction(CieloRequest cielo) : base(cielo)
 {
 }
 public CreateTransaction(CieloRequest cielo) : base(cielo)
 {
 }
Beispiel #11
0
 public SaveCard(CieloRequest cielo) : base(cielo)
 {
 }