Пример #1
0
        internal static CreditCardData GetCreditCardByToken(CustomerPaymentTokenizer tokenizer)
        {
            try
            {
                Log.Info($"Create Search for instant buy key {tokenizer.Token}");

                var serviceClient = new GatewayServiceClient(merchantKey, hostUri);

                Guid instantBuyKey = Guid.Parse(tokenizer.Token);

                Log.Info($"Make request for instant buy key {tokenizer.Token}");
                var httpResponse = serviceClient.CreditCard.GetInstantBuyData(instantBuyKey);

                if (httpResponse.HttpStatusCode == HttpStatusCode.OK
                    && httpResponse.Response.CreditCardDataCollection.Any() == true)
                {
                    return httpResponse.Response.CreditCardDataCollection.FirstOrDefault();
                }

                return default(CreditCardData);
            }
            catch (System.Exception ex)
            {
                Log.Error($"Request Error for instant buy key {tokenizer.Token}", ex);
                throw ex;
            }
            finally
            {
                Log.Info($"End Request for instant buy key {tokenizer.Token}");
            }

        }
        public CustomerPayment GetCustomerPaymentByToken(CustomerPaymentTokenizer tokenizer)
        {
            try
            {
                Log.Info($"Consultando o cartões de credito com o token {tokenizer.Id} para o usuário {tokenizer.IdCustomer}");

                var creditCard = MundiPagg.MundiPaggProxy.GetCreditCardByToken(tokenizer);

                if (creditCard == null)
                    return null;

                CustomerPayment payment = new CustomerPayment();
                payment.CreditCardNumber = creditCard.MaskedCreditCardNumber;
                payment.CreditCardBrand = (CreditCardBrandEnum)((int)creditCard.CreditCardBrand);
                payment.InstantBuy = creditCard.InstantBuyKey;
                payment.SecurityCode = tokenizer.SecurityCode;

                return payment;
                
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, ex);
                throw;
            }
            finally
            {
                Log.Info($"Finalizando a consulta o cartões de credito com o token {tokenizer.Id} para o usuário {tokenizer.IdCustomer}");
            }

        }
Пример #3
0
        internal static CreditCardData GetCreditCardByToken(CustomerPaymentTokenizer tokenizer)
        {
            try
            {
                Log.Info($"Create Search for instant buy key {tokenizer.Token}");

                var serviceClient = new GatewayServiceClient(merchantKey, hostUri);

                Guid instantBuyKey = Guid.Parse(tokenizer.Token);

                Log.Info($"Make request for instant buy key {tokenizer.Token}");
                var httpResponse = serviceClient.CreditCard.GetInstantBuyData(instantBuyKey);

                if (httpResponse.HttpStatusCode == HttpStatusCode.OK &&
                    httpResponse.Response.CreditCardDataCollection.Any() == true)
                {
                    return(httpResponse.Response.CreditCardDataCollection.FirstOrDefault());
                }

                return(default(CreditCardData));
            }
            catch (System.Exception ex)
            {
                Log.Error($"Request Error for instant buy key {tokenizer.Token}", ex);
                throw ex;
            }
            finally
            {
                Log.Info($"End Request for instant buy key {tokenizer.Token}");
            }
        }
Пример #4
0
        public CustomerPayment GetCustomerPaymentByToken(CustomerPaymentTokenizer tokenizer)
        {
            try
            {
                Log.Info($"Consultando o cartões de credito com o token {tokenizer.Id} para o usuário {tokenizer.IdCustomer}");

                var creditCard = MundiPagg.MundiPaggProxy.GetCreditCardByToken(tokenizer);

                if (creditCard == null)
                {
                    return(null);
                }

                CustomerPayment payment = new CustomerPayment();
                payment.CreditCardNumber = creditCard.MaskedCreditCardNumber;
                payment.CreditCardBrand  = (CreditCardBrandEnum)((int)creditCard.CreditCardBrand);
                payment.InstantBuy       = creditCard.InstantBuyKey;
                payment.SecurityCode     = tokenizer.SecurityCode;

                return(payment);
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, ex);
                throw;
            }
            finally
            {
                Log.Info($"Finalizando a consulta o cartões de credito com o token {tokenizer.Id} para o usuário {tokenizer.IdCustomer}");
            }
        }
        private void ProcessTransaction(AzureMessage azureMessage)
        {
            var jsonPayment = (string)azureMessage.ExtraData["payment"];
            var jsonTicket  = (string)azureMessage.ExtraData["ticket"];

            CustomerPayment payment  = JsonConvert.DeserializeObject <CustomerPayment>(jsonPayment);
            CustomerTicket  ticket   = JsonConvert.DeserializeObject <CustomerTicket>(jsonTicket);
            Customer        customer = this.customerService.GetCustomerById(new Guid(azureMessage.SenderUserId));

            ticket.IdEvent    = ticket.Event.Id;
            ticket.IdCustomer = customer.Id;

            Guid instantBuy;

            if (MundiPaggProxy.ProcessPayment(ticket, payment, out instantBuy))
            {
                var ticketUpdate = this.customerTicketService.GetTicketById(ticket.Id);
                ticketUpdate.Status = ticket.Status;

                this.customerTicketService.Update(ticketUpdate);
                this.SendEmail(ticket, customer);

                if (payment.KeepSave)
                {
                    if (!customer.PaymentTokenizer.Any(x => x.Token == instantBuy.ToString()))
                    {
                        var customerToken = new CustomerPaymentTokenizer()
                        {
                            Id           = Guid.NewGuid(),
                            IdCustomer   = customer.Id,
                            SecurityCode = payment.SecurityCode,
                            Token        = instantBuy.ToString()
                        };

                        customer.PaymentTokenizer.Add(customerToken);
                        this.customerService.Update(customer);
                    }
                }
            }
        }
        private void ProcessTransaction(AzureMessage azureMessage)
        {

            var jsonPayment = (string)azureMessage.ExtraData["payment"];
            var jsonTicket = (string)azureMessage.ExtraData["ticket"];

            CustomerPayment payment = JsonConvert.DeserializeObject<CustomerPayment>(jsonPayment);
            CustomerTicket ticket = JsonConvert.DeserializeObject<CustomerTicket>(jsonTicket);
            Customer customer = this.customerService.GetCustomerById(new Guid(azureMessage.SenderUserId));

            ticket.IdEvent = ticket.Event.Id;
            ticket.IdCustomer = customer.Id;

            Guid instantBuy;

            if (MundiPaggProxy.ProcessPayment(ticket, payment, out instantBuy))
            {
                var ticketUpdate = this.customerTicketService.GetTicketById(ticket.Id);
                ticketUpdate.Status = ticket.Status;

                this.customerTicketService.Update(ticketUpdate);
                this.SendEmail(ticket, customer);

                if (payment.KeepSave)
                {
                    if (!customer.PaymentTokenizer.Any(x => x.Token == instantBuy.ToString()))
                    {
                        var customerToken = new CustomerPaymentTokenizer()
                        {
                            Id = Guid.NewGuid(),
                            IdCustomer = customer.Id,
                            SecurityCode = payment.SecurityCode,
                            Token = instantBuy.ToString()
                        };

                        customer.PaymentTokenizer.Add(customerToken);
                        this.customerService.Update(customer);
                    }
                }
            }

        }