예제 #1
0
        public async Task <HttpResponseMessage> Get(string productId, string smsCode, string inDate, string amount, string bankName)
        {
            HttpResponseMessage          message  = null;
            defaultResponseModelWidthVat response = new defaultResponseModelWidthVat();
            _eBarimtRequest ebarimt = new _eBarimtRequest();
            string          token   = HttpContext.Current.Request.Headers["Authorization"].Replace("Bearer ", "").Trim();
            string          req     = string.Format(@"PRODUCT_ID: [{0}], SMSCODE: [{1}], INDATE: [{2}], AMOUNT: [{3}], BANKNAME: [{4}]", productId, smsCode, inDate, amount, bankName);

            LogWriter._chargeProd(TAG, string.Format(@"[>>] Request: ({0}), ", req));
            try
            {
                if (dbconn.idbCheck(out dbres))
                {
                    string userCardNo  = string.Empty;
                    string userAdminNo = string.Empty;
                    if (dbconn.checkToken(token, out userCardNo, out userAdminNo))
                    {
                        string resMon = string.Empty;
                        string resEng = string.Empty;
                        string resCry = string.Empty;
                        if (checkCustomType(userCardNo))
                        {
                            ebarimt.cardNo        = userCardNo;
                            ebarimt.channelNo     = "6";
                            ebarimt.customerEmail = string.Empty;
                            ebarimt.sendEmail     = false;
                            ebarimt.employeeCode  = userAdminNo;
                            ebarimt.organization  = false;
                            ebarimt.customerNo    = string.Empty;
                            var detials = new List <_transactionDetial>();
                            var stock   = new _transactionDetial();
                            stock.barCode     = "8463100";
                            stock.price       = amount;
                            stock.productId   = productId;
                            stock.productName = "Kино сан түрээслэх үйлчилгээ";
                            stock.unit        = "ш";
                            stock.qty         = "1";
                            detials.Add(stock);
                            ebarimt.transaction = detials;
                            string desc = string.Format(@"[Order VOD] Mobile App emerchant {0}", bankName);
                            if (dbconn.chargeAccount(userCardNo, amount, userAdminNo, desc))
                            {
                                if (dbconn.addNvodByCounter(userCardNo, userAdminNo, inDate, smsCode, productId, out resEng, out resMon, out resCry))
                                {
                                    response.isSuccess  = true;
                                    response.resultCode = HttpStatusCode.OK.ToString();
                                    //response.resultMessage = "success";
                                    int    sttCode = 0;
                                    string resp    = string.Empty;
                                    if (httpWorker.http_POST("http://192.168.10.182:5050/vat/getEBarimt", serializer.Serialize(ebarimt), out sttCode, out resp))
                                    {
                                        _eBarimtResponse mta = serializer.Deserialize <_eBarimtResponse>(resp);
                                        if (mta.isSuccess)
                                        {
                                            response.mtaResult = new MTAResult {
                                                merchantId = mta.merchantId, amount = mta.amount, billId = mta.billId, date = mta.resultDate, loterryNo = mta.lotteryNo, qrData = mta.qrData, tax = mta.cityTax, vat = mta.vat
                                            };
                                            response.resultMessage = "success";
                                        }
                                        else
                                        {
                                            response.resultMessage = "Ebarimt гаргахад алдаа гарлаа. Лавлах: 77771434, 1434";
                                        }
                                    }
                                    else
                                    {
                                        response.resultMessage = "Ebarimt гаргахад алдаа гарлаа. Лавлах: 77771434, 1434";
                                    }
                                }
                                else
                                {
                                    response.isSuccess     = false;
                                    response.resultCode    = HttpStatusCode.NotFound.ToString();
                                    response.resultMessage = resMon;
                                }
                            }
                            else
                            {
                                response.isSuccess     = false;
                                response.resultCode    = HttpStatusCode.Conflict.ToString();
                                response.resultMessage = "Данс цэнэглэхэд алдаа гарлаа";
                            }
                        }
                        else
                        {
                            response.isSuccess     = false;
                            response.resultCode    = HttpStatusCode.NotFound.ToString();
                            response.resultMessage = "Дараа төлбөрт хэрэглэгч захиалга хийх боломжгүй.";
                        }
                    }
                    else
                    {
                        response.isSuccess     = false;
                        response.resultCode    = HttpStatusCode.Unauthorized.ToString();
                        response.resultMessage = appConstantValues.MSG_EXPIRED;
                    }
                }
                else
                {
                    response.isSuccess     = false;
                    response.resultCode    = HttpStatusCode.NotFound.ToString();
                    response.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
                    LogWriter._error(TAG, dbres);
                }
            }
            catch (Exception ex)
            {
                response.isSuccess     = false;
                response.resultCode    = HttpStatusCode.NotFound.ToString();
                response.resultMessage = ex.Message;
                exceptionManager.ManageException(ex, TAG);
            }
            message = Request.CreateResponse(HttpStatusCode.OK, response);
            LogWriter._chargeProd(TAG, string.Format("[<<] IP: [{0}], Response: [{1}], Token: [{2}]", httpUtil.GetClientIPAddress(HttpContext.Current.Request), serializer.Serialize(response), token));
            return(message);
        }
예제 #2
0
        public async Task <HttpResponseMessage> Get(string amount, string cardNo, string customerNo)
        {
            HttpResponseMessage message = new HttpResponseMessage();
            defaultResponseModelWidthVatTablet response = new defaultResponseModelWidthVatTablet();
            _eBarimtRequest ebarimt  = new _eBarimtRequest();
            string          secToken = string.Empty;
            string          ip       = httpUtil.GetClientIPAddress(HttpContext.Current.Request);

            LogWriter._chargeProd(TAG, string.Format(@"[>>] Request: [amount:{0}, card:{1}, customerNo:{2}]", amount, cardNo, customerNo));
            try
            {
                secToken = HttpContext.Current.Request.Headers["Authorization"].Replace("Basic ", "").Trim();
                if (dbconn.idbStatOK())
                {
                    string insId    = string.Empty;
                    string insPhone = string.Empty;
                    if (dbconn.tabletCheckToken(secToken, out insId, out insPhone))
                    {
                        ebarimt.cardNo        = cardNo;
                        ebarimt.channelNo     = "11";
                        ebarimt.customerEmail = string.Empty;
                        ebarimt.sendEmail     = false;
                        ebarimt.employeeCode  = insPhone;
                        if (customerNo != "0")
                        {
                            ebarimt.organization = true;
                            ebarimt.customerNo   = customerNo;
                        }
                        else
                        {
                            ebarimt.organization = false;
                            ebarimt.customerNo   = string.Empty;
                        }
                        var detials = new List <_transactionDetial>();
                        var stock   = new _transactionDetial();
                        stock.barCode     = "8463100";
                        stock.price       = amount;
                        stock.productId   = "8";
                        stock.productName = "Данс цэнэглэх үйлчилгээ";
                        stock.unit        = "ш";
                        stock.qty         = "1";
                        detials.Add(stock);
                        ebarimt.transaction = detials;
                        string desc = string.Format(@"[Charge Account] Installer App");
                        if (dbconn.chargeAccount(cardNo, amount, insPhone, desc, "11"))
                        {
                            response.isSuccess = true;
                            response.errorCode = Convert.ToString((int)HttpStatusCode.OK);
                            int    sttCode = 0;
                            string resp    = string.Empty;
                            if (httpWorker.http_POST("http://192.168.10.182:5050/vat/getEBarimt", serializer.Serialize(ebarimt), out sttCode, out resp))
                            {
                                _eBarimtResponse mta = serializer.Deserialize <_eBarimtResponse>(resp);
                                if (mta.isSuccess)
                                {
                                    response.mtaResult = new MTAResult {
                                        merchantId = mta.merchantId, amount = mta.amount, billId = mta.billId, date = mta.resultDate, loterryNo = mta.lotteryNo, qrData = mta.qrData, tax = mta.cityTax, vat = mta.vat
                                    };
                                    response.resultMessage = "success";
                                }
                                else
                                {
                                    response.resultMessage = "Ebarimt гаргахад алдаа гарлаа. Лавлах: 77771434, 1434";
                                }
                            }
                            else
                            {
                                response.resultMessage = "Ebarimt гаргахад алдаа гарлаа. Лавлах: 77771434, 1434";
                            }
                        }
                        else
                        {
                            response.isSuccess     = false;
                            response.errorCode     = Convert.ToString((int)HttpStatusCode.Conflict);
                            response.resultMessage = "Данс цэнэглэхэд алдаа гарлаа";
                        }
                    }
                    else
                    {
                        response.isSuccess     = false;
                        response.errorCode     = Convert.ToString((int)HttpStatusCode.Unauthorized);
                        response.resultMessage = "Session has expired";
                    }
                }
                else
                {
                    response.isSuccess     = false;
                    response.errorCode     = Convert.ToString((int)HttpStatusCode.InternalServerError);
                    response.resultMessage = "Internal Error";
                }
            }
            catch (Exception ex)
            {
                LogWriter._error(TAG, string.Format(@"Token: [{0}], Exception: [{1}]", secToken, ex.ToString()));
                response.isSuccess     = false;
                response.errorCode     = Convert.ToString((int)HttpStatusCode.InternalServerError);
                response.resultMessage = ex.Message;
            }
            message = Request.CreateResponse(HttpStatusCode.OK, response);
            LogWriter._chargeProd(TAG, string.Format(@"[<<] ClientIp: [{0}], Response: [{1}]", ip, serializer.Serialize(response)));
            return(message);
        }
예제 #3
0
        private bool chargeAccountNoLogin(string _card, string _phone, string amount, string bankName, string isVat, string email, out string message)
        {
            bool ca = false;

            message = string.Empty;
            _eBarimtRequest ebarimt = new _eBarimtRequest();

            try
            {
                bool createVat = isVat == "0" ? true : false;
                ebarimt.cardNo        = _card;
                ebarimt.channelNo     = "6";
                ebarimt.customerEmail = createVat ? email : string.Empty;
                ebarimt.sendEmail     = createVat;
                ebarimt.employeeCode  = _phone;
                ebarimt.organization  = false;
                ebarimt.customerNo    = string.Empty;
                var detials = new List <_transactionDetial>();
                var stock   = new _transactionDetial();
                stock.barCode     = "8463100";
                stock.price       = amount;
                stock.productId   = "8";
                stock.productName = "Данс цэнэглэх үйлчилгээ";
                stock.unit        = "ш";
                stock.qty         = "1";
                detials.Add(stock);
                ebarimt.transaction = detials;
                string desc = string.Format(@"[Charge Account] Mobile App emerchant {0}", bankName);
                if (dbconn.chargeAccount(_card, amount, _phone, desc))
                {
                    ca = true;
                    if (createVat)
                    {
                        int    sttCode = 0;
                        string resp    = string.Empty;
                        if (httpWorker.http_POST("http://192.168.10.182:5050/vat/getEBarimt", serializer.Serialize(ebarimt), out sttCode, out resp))
                        {
                            _eBarimtResponse mta = serializer.Deserialize <_eBarimtResponse>(resp);
                            if (mta.isSuccess)
                            {
                                //response.mtaResult = new MTAResult { merchantId = mta.merchantId, amount = mta.amount, billId = mta.billId, date = mta.resultDate, loterryNo = mta.lotteryNo, qrData = mta.qrData, tax = mta.cityTax, vat = mta.vat };
                                //response.resultMessage = "success";
                                message = "Амжилттай";
                            }
                            else
                            {
                                message = "Ebarimt гаргахад алдаа гарлаа. Лавлах: 77771434, 1434";
                            }
                        }
                        else
                        {
                            message = "Ebarimt гаргахад алдаа гарлаа. Лавлах: 77771434, 1434";
                        }
                    }
                    else
                    {
                        message = "Амжилттай";
                    }
                }
                else
                {
                    message = "Данс цэнэглэхэд алдаа гарлаа. Лавлах: 77771434, 1434";
                }
            }
            catch (Exception ex)
            {
                LogWriter._error(TAG, ex.Message);
            }
            return(ca);
        }
예제 #4
0
        private bool upgradeProduct(string _card, string _phone, string toProductId, string amount, string bankName, out string message)
        {
            bool up = false;

            message = string.Empty;
            _eBarimtRequest ebarimt = new _eBarimtRequest();

            try
            {
                ebarimt.cardNo        = _card;
                ebarimt.channelNo     = "6";
                ebarimt.customerEmail = string.Empty;
                ebarimt.sendEmail     = false;
                ebarimt.employeeCode  = _phone;
                ebarimt.organization  = false;
                ebarimt.customerNo    = string.Empty;
                var detials = new List <_transactionDetial>();
                var stock   = new _transactionDetial();
                stock.barCode     = "8463100";
                stock.price       = amount;
                stock.productId   = "8";
                stock.productName = "Багц ахиулах үйлчилгээ";
                stock.unit        = "ш";
                stock.qty         = "1";
                detials.Add(stock);
                ebarimt.transaction = detials;
                //---
                localConvertProdcutMdl convProd = new localConvertProdcutMdl();
                convProd.BranchId       = "286";
                convProd.Channel        = "6";
                convProd.cardNo         = _card;
                convProd.ConvertProduct = toProductId;
                convProd.Pay_type       = "0";
                convProd.Username       = _phone;
                string convJson      = serializer.Serialize(convProd);
                string localResponse = string.Empty;
                if (httpUtil.httpCall_POST_local(convJson, "processProduct", out localResponse))
                {
                    LogWriter._qPay(TAG, string.Format("[Upgrade Product] Local Service Response: [{0}]", localResponse));
                    var convObj = serializer.Deserialize <localCheckProductResponse>(localResponse);
                    if (convObj.issuccess)
                    {
                        up = true;
                        int    sttCode = 0;
                        string resp    = string.Empty;
                        if (httpWorker.http_POST("http://192.168.10.182:5050/vat/getEBarimt", serializer.Serialize(ebarimt), out sttCode, out resp))
                        {
                            _eBarimtResponse mta = serializer.Deserialize <_eBarimtResponse>(resp);
                            if (mta.isSuccess)
                            {
                                //response.mtaResult = new MTAResult { merchantId = mta.merchantId, amount = mta.amount, billId = mta.billId, date = mta.resultDate, loterryNo = mta.lotteryNo, qrData = mta.qrData, tax = mta.cityTax, vat = mta.vat };
                                //response.resultMessage = "success";
                                message = "Амжилттай";
                            }
                            else
                            {
                                message = "Ebarimt гаргахад алдаа гарлаа. Лавлах: 77771434, 1434";
                            }
                        }
                        else
                        {
                            message = "Ebarimt гаргахад алдаа гарлаа. Лавлах: 77771434, 1434";
                        }
                    }
                    else
                    {
                        message = "Багц ахиулахад алдаа гарлаа. Лавлах: 77771434, 1434";
                    }
                }
                else
                {
                    message = "Багц ахиулахад алдаа гарлаа. Лавлах: 77771434, 1434";
                }
            }
            catch (Exception ex)
            {
                LogWriter._error(TAG, ex.Message);
            }
            return(up);
        }
예제 #5
0
        private bool chargeProduct(string card, string phone, string productId, string month, string amount, string bankName, out string message)
        {
            bool cp = false;

            message = string.Empty;
            _eBarimtRequest ebarimt = new _eBarimtRequest();

            try
            {
                ebarimt.cardNo        = card;
                ebarimt.channelNo     = "6";
                ebarimt.customerEmail = string.Empty;
                ebarimt.sendEmail     = false;
                ebarimt.employeeCode  = phone;
                ebarimt.organization  = false;
                ebarimt.customerNo    = string.Empty;
                var detials = new List <_transactionDetial>();
                var stock   = new _transactionDetial();
                stock.barCode     = "8463100";
                stock.price       = amount;
                stock.productId   = productId;
                stock.productName = "Үйлчилгээ идэвхжүүлэх";
                stock.unit        = "сар";
                stock.qty         = month;
                detials.Add(stock);
                ebarimt.transaction = detials;
                string desc = string.Format(@"[Charge Product] Mobile App emerchant {0}", bankName);
                if (dbconn.chargeProduct(productId, month, phone, amount, desc, card, "6"))
                {
                    cp = true;
                    int    sttCode = 0;
                    string resp    = string.Empty;
                    if (httpWorker.http_POST("http://192.168.10.182:5050/vat/getEBarimt", serializer.Serialize(ebarimt), out sttCode, out resp))
                    {
                        _eBarimtResponse mta = serializer.Deserialize <_eBarimtResponse>(resp);
                        if (mta.isSuccess)
                        {
                            //response.mtaResult = new MTAResult { merchantId = mta.merchantId, amount = mta.amount, billId = mta.billId, date = mta.resultDate, loterryNo = mta.lotteryNo, qrData = mta.qrData, tax = mta.cityTax, vat = mta.vat };
                            //response.resultMessage = "success";
                            message = "Амжилттай";
                        }
                        else
                        {
                            message = "Ebarimt гаргахад алдаа гарлаа. Лавлах: 77771434, 1434";
                        }
                    }
                    else
                    {
                        message = "Ebarimt гаргахад алдаа гарлаа. Лавлах: 77771434, 1434";
                    }
                }
                else
                {
                    cp      = false;
                    message = "Багц сунгахад алдаа гарлаа. Лавлах: 77771434, 1434";
                }
            }
            catch (Exception ex)
            {
                LogWriter._error(TAG, ex.Message);
                message = ex.Message;
            }
            return(cp);
        }