Пример #1
0
        public string GenerateFormRequestSignature(Shop shop, string shoppingCartId, double price)
        {
            var formattedPrice = WSPayHelpers.FormatPrice(price);

            using (var md5Hash = MD5.Create())
            {
                var data      = $"{shop.ShopId}{shop.Secret}{shoppingCartId}{shop.Secret}{formattedPrice}{shop.Secret}";
                var hashBytes = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(data));

                var sBuilder = new StringBuilder();

                foreach (var b in hashBytes)
                {
                    sBuilder.Append(b.ToString("x2"));
                }

                return(sBuilder.ToString());
            }
        }
Пример #2
0
        public string GenerateChangeTransactionStatusSignature(Shop shop, string wsPayOrderId, string stan, string approvalCode, double price)
        {
            var formattedPrice = WSPayHelpers.FormatPrice(price);

            using (var md5Hash = MD5.Create())
            {
                var data      = $"{shop.ShopId}{wsPayOrderId}{shop.Secret}{stan}{shop.Secret}{approvalCode}{shop.Secret}{formattedPrice}{shop.Secret}{wsPayOrderId}";
                var hashBytes = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(data));

                var sBuilder = new StringBuilder();

                foreach (var b in hashBytes)
                {
                    sBuilder.Append(b.ToString("x2"));
                }

                return(sBuilder.ToString());
            }
        }