예제 #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="transaction"></param>
 /// <param name="configParser"></param>
 /// <returns></returns>
 private List <Domain.Models.Providers.Cielo.Item> GetItems(Domain.Models.Application.Transaction transaction, ConfigParser configParser)
 {
     try
     {
         var item = new List <Domain.Models.Providers.Cielo.Item>();
         //
         for (int index = 0; index < transaction.Products.Length; index++)
         {
             item.Add(new Domain.Models.Providers.Cielo.Item
             {
                 Sku              = transaction.Products[index].Id,
                 Name             = transaction.Products[index].Name,
                 Type             = configParser.GetValue("FraudAnalysis.Cart.Items", "Type"),
                 Risk             = configParser.GetValue("FraudAnalysis.Cart.Items", "Risk"),
                 Quantity         = transaction.Products[index].Quantity,
                 UnitPrice        = GetAmount(transaction.Products[index].UnitPrice),
                 TimeHedge        = configParser.GetValue("FraudAnalysis.Cart.Items", "TimeHedge"),
                 HostHedge        = configParser.GetValue("FraudAnalysis.Cart.Items", "HostHedge"),
                 PhoneHedge       = configParser.GetValue("FraudAnalysis.Cart.Items", "PhoneHedge"),
                 GiftCategory     = configParser.GetValue("FraudAnalysis.Cart.Items", "GiftCategory"),
                 VelocityHedge    = configParser.GetValue("FraudAnalysis.Cart.Items", "VelocityHedge"),
                 NonSensicalHedge = configParser.GetValue("FraudAnalysis.Cart.Items", "NonSensicalHedge"),
                 ObscenitiesHedge = configParser.GetValue("FraudAnalysis.Cart.Items", "ObscenitiesHedge"),
             });
         }
         //
         return(item);
     }
     catch
     {
         throw;
     }
 }
예제 #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="transaction"></param>
 /// <returns></returns>
 private Domain.Models.Providers.Cielo.FraudAnalysis GetFraudAnalysis(Domain.Models.Application.Transaction transaction)
 {
     try
     {
         //
         if (UseFraudAnalysis &&
             transaction.Payment.Type == Domain.Enums.PaymentType.CreditCard)
         {
             return(new Domain.Models.Providers.Cielo.FraudAnalysis
             {
                 Cart = GetCart(transaction, FraudAnalysisConfig),
                 Browser = GetBrowser(transaction.Browser),
                 Sequence = FraudAnalysisConfig.GetValue("FraudAnalysis", "Sequence"),
                 Provider = FraudAnalysisConfig.GetValue("FraudAnalysis", "Provider"),
                 FingerPrintId = transaction.Browser.FingerPrintId ?? Guid.NewGuid().ToString(),
                 VoidOnHighRisk = bool.Parse(FraudAnalysisConfig.GetValue("FraudAnalysis", "VoidOnHighRisk")),
                 TotalOrderAmount = GetAmount(transaction.Payment.Amount),
                 SequenceCriteria = FraudAnalysisConfig.GetValue("FraudAnalysis", "SequenceCriteria"),
                 CaptureOnLowRisk = bool.Parse(FraudAnalysisConfig.GetValue("FraudAnalysis", "CaptureOnLowRisk"))
             });
         }
         else
         {
             return(null);
         }
     }
     catch
     {
         throw;
     }
 }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="transaction"></param>
        /// <returns></returns>
        private Domain.Models.Providers.Cielo.Payment GetPayment(Domain.Models.Application.Transaction transaction)
        {
            try
            {
                if (transaction.Payment == null)
                {
                    return(null);
                }
                //
                switch (transaction.Payment.Type)
                {
                case Domain.Enums.PaymentType.CreditCard:
                    return(CreateCreditCardTransaction(transaction));

                case Domain.Enums.PaymentType.DebitCard:
                    //TODO
                    return(CreateDebitCardTransaction(transaction));

                case Domain.Enums.PaymentType.BarCode:
                    //TODO
                    return(CreateBarCodeTransaction(transaction));

                default:
                    throw new Exception();
                }
            }
            catch
            {
                throw;
            }
        }
예제 #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cieloMessages"></param>
 /// <returns></returns>
 public Domain.Models.Application.TransactionResult GetTransactionError(Domain.Models.Application.Transaction transaction,
                                                                        List <Domain.Models.Providers.Cielo.CieloMessages> cieloMessages)
 {
     try
     {
         //
         var _errorMessages = GetErrorMessages(cieloMessages);
         //
         return(new Domain.Models.Application.TransactionResult
         {
             OrderId = transaction.OrderId,
             Status = Domain.Enums.TransactionStatus.Error,
             Amount = transaction.Payment.Amount,
             ExtraResultSet = new Domain.Models.Application.ExtraResultSet
             {
                 ProviderResponse = JsonConvert.SerializeObject(_errorMessages),
                 ErrorMessages = _errorMessages
             }
         });
         //
     }
     catch
     {
         throw;
     }
 }
예제 #5
0
 public async Task <Domain.Models.Application.TransactionResult> SinglePay([FromBody] Domain.Models.Application.Transaction transaction)
 {
     try
     {
         return(await Application
                .Transactions
                .SinglePayment
                .Create(Configuration)
                .PayAsync(transaction));
     }
     catch
     {
         throw;
     }
 }
예제 #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="transaction"></param>
 /// <param name="configParser"></param>
 /// <returns></returns>
 private Domain.Models.Providers.Cielo.Cart GetCart(Domain.Models.Application.Transaction transaction, ConfigParser configParser)
 {
     try
     {
         return(new Domain.Models.Providers.Cielo.Cart
         {
             Type = configParser.GetValue("FraudAnalysis.Cart", "Type"),
             Items = GetItems(transaction, configParser)
         });
     }
     catch
     {
         throw;
     }
 }
예제 #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="transaction"></param>
 /// <returns></returns>
 private Domain.Models.Providers.Cielo.Payment CreateDebitCardTransaction(Domain.Models.Application.Transaction transaction)
 {
     try
     {
         return(new Domain.Models.Providers.Cielo.Payment
         {
             Type = "DebitCard",
             Authenticate = transaction.Payment.Authenticate,
         });
     }
     catch
     {
         throw;
     }
 }
예제 #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="transaction"></param>
 /// <returns></returns>
 public Domain.Models.Providers.Cielo.Customer GetCustomer(Domain.Models.Application.Transaction transaction)
 {
     try
     {
         if (transaction.Customer == null)
         {
             return(null);
         }
         //
         return(GetCustomer(transaction.Customer));
     }
     catch
     {
         throw;
     }
 }
예제 #9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="transaction"></param>
 /// <returns></returns>
 public Domain.Models.Providers.Cielo.Transaction GetTransaction(Domain.Models.Application.Transaction transaction, bool useFraudAnalysis = false)
 {
     try
     {
         //
         UseFraudAnalysis = useFraudAnalysis;
         //
         return(new Domain.Models.Providers.Cielo.Transaction
         {
             Payment = GetPayment(transaction),
             Customer = GetCustomer(transaction),
             MerchantOrderId = transaction.OrderId
         });
     }
     catch
     {
         throw;
     }
 }
예제 #10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="transaction"></param>
 /// <returns></returns>
 private Domain.Models.Providers.Cielo.Payment CreateBarCodeTransaction(Domain.Models.Application.Transaction transaction)
 {
     try
     {
         return(new Domain.Models.Providers.Cielo.Payment
         {
             Type = "Boleto",
             Amount = GetAmount(transaction.Payment.Amount),
             Address = transaction.Customer.Address.ToString(),
             Provider = ConfigCielo.GetValue("Provider.Configuration.FileLocation", "BarCodeProvider"),
             Assignor = transaction.Payment.SoftDescriptor,
             BoletoNumber = transaction.Payment.BarCode.Identity.ToString(),
             Instructions = transaction.Payment.BarCode.Instructions,
             Demonstrative = transaction.Payment.BarCode.Demonstrative,
             ExpirationDate = transaction.Payment.BarCode.ExpirationDate.ToString("yyyy-MM-dd"),
             Identification = NumericOnly(transaction.Customer.Identity).ToString()
         });
     }
     catch
     {
         throw;
     }
 }
예제 #11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="transaction"></param>
 /// <returns></returns>
 private Domain.Models.Providers.Cielo.Payment CreateCreditCardTransaction(Domain.Models.Application.Transaction transaction)
 {
     try
     {
         return(new Domain.Models.Providers.Cielo.Payment
         {
             Type = "CreditCard",
             Amount = GetAmount(transaction.Payment.Amount),
             Capture = true,
             Interest = GetInterest(transaction.Payment.Interest),
             CreditCard = GetCreditCard(transaction.Payment.CreditCard),
             Authenticate = transaction.Payment.Authenticate,
             Installments = GetInstallments(transaction.Payment.Installments),
             FraudAnalysis = GetFraudAnalysis(transaction),
             SoftDescriptor = transaction.Payment.SoftDescriptor,
             IsCryptoCurrencyNegotiation = transaction.Payment.IsCryptoCurrencyNegotiation,
         });
     }
     catch
     {
         throw;
     }
 }
예제 #12
0
 public async Task <string> GetCardToken(Domain.Models.Application.Transaction transaction)
 {
     return(await Task.Run(() => { return transaction.ToString(); }));
 }