示例#1
0
        public void Paid(string notification_type, string operation_id, string label, string datetime, decimal amount, decimal withdraw_amount, string sender, string sha1_hash, string currency, bool codepro)
        {
            string         key              = "DfJ/9D0wTHyVOrL+B0sUQBGF"; // секретный код
            string         paramString      = String.Format("{0}&{1}&{2}&{3}&{4}&{5}&{6}&{7}&{8}", notification_type, operation_id, amount, currency, datetime, sender, codepro.ToString().ToLower(), key, label);
            string         paramStringHash1 = GetHash(paramString);
            StringComparer comparer         = StringComparer.OrdinalIgnoreCase; // создаем класс для сравнения строк

            if (0 == comparer.Compare(paramStringHash1, sha1_hash))             // если хэши идентичны, добавляем данные о заказе в бд
            {
                Payment pay = new Payment()
                {
                    date = Convert.ToDateTime(datetime), operation_Id = operation_id, sender = sender, amount = amount, withdrawAmount = withdraw_amount
                };
                int  id_pay = _context.AddPayment(pay);
                Sale sale   = _context.FindSale(Convert.ToInt32(label));
                sale.id_payment = id_pay;
                sale.status     = "Оплачено";
                _context.UpdateSale(sale);
            }
        }