public AuthResponse(string username, tokenResponse tokenData)
 {
     Username    = username;
     Token       = tokenData.token;
     ExpireInSec = tokenData.expiresIn;
     Role        = tokenData.role;
 }
        ////////// TOKEN GENERATION CODE //////////
        private tokenResponse generateJwtToken(string Username, string Role)
        {
            var tokenHandler    = new JwtSecurityTokenHandler();
            var key             = Encoding.ASCII.GetBytes(appSettings.Secret);
            var tokenDescriptor = new SecurityTokenDescriptor
            {
                Subject = new ClaimsIdentity(new Claim[]
                {
                    new Claim(ClaimTypes.Name, Username.ToString()),
                    new Claim(ClaimTypes.Role, Role.ToString())
                }),
                Expires            = DateTime.UtcNow.AddDays(2),
                SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature)
            };
            var token     = tokenHandler.CreateToken(tokenDescriptor);
            var tokenData = new tokenResponse
            {
                token      = tokenHandler.WriteToken(token),
                issueTime  = token.ValidFrom,
                expiryTime = token.ValidTo,
                expiresIn  = (token.ValidTo - token.ValidFrom).TotalSeconds,
                role       = Role
            };

            return(tokenData);
        }
        public LiquidAdapter PreparePaymentPageViewData()
        {
            var shaparakSetting = _settingService.GetSetting <ShaprakGateWaySetting>();

            if (shaparakSetting is null)
            {
                throw new ArgumentException(nameof(ShaprakGateWaySetting));
            }

            var orderId       = GetCurrentUserPaymentProccessingOrderId();
            var order         = _orderDataService.Query.First(x => x.Id == orderId);
            var paymentAmount = Convert.ToInt32(order.OrderTotal).ToString();

            TokensClient client = new TokensClient();

            tokenResponse tokenResp = client.MakeToken(paymentAmount, shaparakSetting.MerchantId, order.Id.ToString(), order.PaymentTrackNumber, "", _urlHelper.Action("Index", "Payment", null, HttpContext.Current.Request.Url.Scheme), "");

            return(new PaymentPageLiquidViewData()
            {
                ClientToken = tokenResp.token,
                MerchantId = shaparakSetting.MerchantId,
                PaymentId = order.PaymentTrackNumber
            });
        }