Пример #1
0
        public async Task <PurchaseResp> Purchase(PurchaseVM purchase)
        {
            PurchaseResp response = new PurchaseResp();

            try
            {
                var sedcAccount = await _manager.SedcAccounts.SingleOrDefault(x => x.IsDefault);

                purchase.userName = sedcAccount.UserName;
                purchase.userPass = sedcAccount.Password;
                string port = (sedcAccount.Port == "80") ? "" : $":{sedcAccount.Port}";
                SEDCOprations.Core = $"{sedcAccount.HttpType}://{sedcAccount.Server}{port}";
                try
                {
                    purchase.userPass   = EncryptionManager.MD5Encrypt(purchase.userName, purchase.userPass, sedcAccount.Key);
                    purchase.verifyCode = EncryptionManager.VDataMD5(purchase.userName, purchase.userPass, purchase.transID,
                                                                     purchase.meterNum, purchase.calcMode, purchase.amount, sedcAccount.Key);
                    var content = Convertor.GetXML(purchase);
                    var resp    = await CallApi(content, SEDCOprations.Core + SEDCOprations.PURCHASE);

                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(resp);
                    response = Convertor.GetPurchaseResp(doc);
                }
                catch (Exception e)
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
            }
            return(response);
        }
Пример #2
0
        public async Task <BalanceResp> Balance(BalanceVM balanceVm)
        {
            BalanceResp response = new BalanceResp();

            try
            {
                var sedcAccount = await _manager.SedcAccounts.SingleOrDefault(x => x.IsDefault);

                balanceVm.userName = sedcAccount.UserName;
                balanceVm.userPass = sedcAccount.Password;
                string port = (sedcAccount.Port == "80") ? "" : $":{sedcAccount.Port}";
                SEDCOprations.Core = $"{sedcAccount.HttpType}://{sedcAccount.Server}{port}";
                try
                {
                    balanceVm.userPass = EncryptionManager.MD5Encrypt(balanceVm.userName, balanceVm.userPass, sedcAccount.Key);
                    var content = Convertor.GetXML(balanceVm);
                    var resp    = await CallApi(content, SEDCOprations.Core + SEDCOprations.BALANCE);

                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(resp);
                    response = Convertor.GetBalanceResp(doc);
                }
                catch (Exception e)
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
            }
            return(response);
        }