/// <summary> /// /// </summary> /// <param name="transaction"></param> /// <returns></returns> private async Task <TransactionResult> BarCodeTransactionAsync(Transaction transaction, Domain.Enums.TransactionType action) { switch (ConfigGlobal.GetValue("Payment", "BarCodeProvider").ToLower()) { case "cielo": return(await CieloProviderAsync(transaction, action)); default: throw new Exception("Provider not set"); } }
protected SecurityTokenResult GetSubscribersToken(ApplicationDetails appAuth) { try { SecurityKey = new SymmetricSecurityKey(Encoding.Default.GetBytes(ConfigGlobal.GetValue("Application", "AppSecretKey"))); TokenHandler = new JwtSecurityTokenHandler(); if (appAuth != null && appAuth.AppId > 0) { ///Criamos uma identidade ClaimsIdentity claimsIdentity = new ClaimsIdentity(); ///Claim de acesso Collection <Claim> claims = new Collection <Claim> { new Claim(ClaimTypes.PrimarySid, appAuth.AppId.ToString()), new Claim(ClaimTypes.SerialNumber, appAuth.AppUid.ToString()), new Claim(ClaimTypes.UserData, appAuth.AppDescription.ToString()), new Claim(ClaimTypes.Role, ((int)appAuth.Owner).ToString()), new Claim("AccountStatus", ((int)appAuth.AccountStatus).ToString()), }; ///Configura os Token var tokenDescriptor = new SecurityTokenDescriptor { Issuer = ConfigGlobal.GetValue("Application", "Issuer"), Subject = claimsIdentity, SigningCredentials = new SigningCredentials(SecurityKey, SecurityAlgorithms.HmacSha256, SecurityAlgorithms.Sha256Digest) }; ///Gera o Token e retorna a string SecurityToken token = TokenHandler.CreateToken(tokenDescriptor); var tokenString = TokenHandler.WriteToken(token); ///Retorna return(new SecurityTokenResult { Create = DateTime.UtcNow, Token = tokenString, Expires = DateTime.UtcNow.AddHours(1), }); } else { return(null); } } catch { return(null); } }
/// <summary> /// /// </summary> /// <param name="transaction"></param> /// <param name="action"></param> /// <returns></returns> private async Task <TransactionResult> ChargeBackTransactionAsync(Transaction transaction, Domain.Enums.TransactionType action) { try { string provider; var order = await TransactionDB.GetLogTransactionByOrderIdAsync(transaction.OrderId); // switch (Enum.Parse(typeof(Domain.Enums.PaymentType), order.PaymentType)) { case Domain.Enums.PaymentType.CreditCard: provider = ConfigGlobal.GetValue("Payment", "CreditCardProvider").ToLower(); break; case Domain.Enums.PaymentType.DebitCard: provider = ConfigGlobal.GetValue("Payment", "DebitCardProvider").ToLower(); break; default: throw new Exception("Payment type not set"); } // switch (provider) { case "cielo": return(await CieloProviderAsync(transaction, action)); default: throw new Exception("Provider not set"); } } catch { throw; } }