示例#1
0
        public SSLCommerzInitResponse InitiateTransaction(NameValueCollection PostData, bool GetGateWayList = false)
        {
            PostData.Add("store_id", Store_ID);
            PostData.Add("store_passwd", Store_Pass);

            string response = SendPost(PostData);

            try
            {
                SSLCommerzInitResponse resp = JsonConvert.DeserializeObject <SSLCommerzInitResponse>(response);

                if (resp.status == "SUCCESS")
                {
                    return(resp);
                }
                else
                {
                    throw new Exception("Unable to get data from SSLCommerz. Please contact your manager!");
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message.ToString());
            }
        }
示例#2
0
        public string InitiateTransaction(System.Collections.Specialized.NameValueCollection PostData, bool GetGateWayList = false)
        {
            PostData.Add("store_id", this.Store_ID);
            PostData.Add("store_passwd", this.Store_Pass);
            string response = this.SendPost(PostData);

            try
            {
                SSLCommerzInitResponse resp = JsonConvert.DeserializeObject <SSLCommerzInitResponse>(response);
                if (resp.status == "SUCCESS")
                {
                    if (GetGateWayList)
                    {
                        // We will work on it!
                    }
                    else
                    {
                        return(resp.GatewayPageURL.ToString());
                    }
                }
                else
                {
                    throw new Exception("Unable to get data from SSLCommerz. Please contact your manager!");
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message.ToString());
            }

            return(response);
        }
示例#3
0
        public async Task <IActionResult> OrderDetails([Bind] LiveAnimalDetailsViewModel model)
        {
            NameValueCollection postData = new NameValueCollection();

            //Basic Infos.
            postData.Add("total_amount", model.LiveAnimalDetails.Price.ToString());
            postData.Add("currency", "BDT");
            string ID = Guid.NewGuid().ToString();

            postData.Add("tran_id", ID);

            postData.Add("success_url", "https://farmhut.com.bd/Payment/PaymentCheck");
            postData.Add("fail_url", "https://farmhut.com.bd/Payment/PaymentCheck");
            postData.Add("cancel_url", "https://farmhut.com.bd/Payment/PaymentCheck");

            //Customer Info.
            postData.Add("cus_name", model.Order.Name);
            postData.Add("cus_add1", model.Order.Address);
            postData.Add("cus_phone", model.Order.PhoneNumber);
            postData.Add("cus_email", "*****@*****.**");
            postData.Add("cus_city", "Dhaka");
            postData.Add("cus_postcode", "1000");
            postData.Add("cus_country", "Bangladesh");
            postData.Add("shipping_method", "NO");
            postData.Add("num_of_item", "1");

            postData.Add("emi_option", "0");

            //Product Infos.
            postData.Add("product_name", model.LiveAnimalDetails.Id);
            postData.Add("product_category", model.LiveAnimalDetails.Title);
            postData.Add("product_profile", "general");

            var live = await _liveAnimalService.GetLiveAnimalById(model.LiveAnimalDetails.Id);

            postData.Add("value_a", model.Order.Id);
            postData.Add("value_b", live.Title);
            postData.Add("value_c", live.Category);
            postData.Add("value_d", live.Color);

            _logger.LogInformation($"SSL COmerzzzzzzzzzzzzzzz NmaeValueCollection: {JsonConvert.SerializeObject(postData)}");

            if (live.Sold == false)
            {
                SSLCommerzInitResponse response = _sslCommerzService.InitiateTransaction(postData);
                _logger.LogInformation($"SSL COmerzzzzzzzzzzzzzzz Responseeeeeee: {JsonConvert.SerializeObject(response)}");
                if (response == null)
                {
                    // ERROR PAGE
                    return(RedirectToAction("Index", "Payment"));
                }
                return(Redirect(response.GatewayPageURL));
            }

            return(RedirectToAction("Index", "Home"));
        }
示例#4
0
        public SSLCommerzInitResponse InitiateTransaction(NameValueCollection postData)
        {
            if (postData == null)
            {
                return(null);
            }

            postData.Add("store_id", config.StoreID);
            postData.Add("store_passwd", config.StorePass);

            try
            {
                //string response = this.GetPostResponse(config.SubmitUri, postData);

                byte[] response   = null;
                string requestUrl = $"{SSLCommerzBaseUrl}{config.SubmitUri}";
                logger.LogInformation("Requestttttttttttt: " + requestUrl);

                foreach (string key in postData)
                {
                    logger.LogInformation("{0} {1}", key, postData[key]);
                }

                using (WebClient client = new WebClient())
                {
                    response = client.UploadValues(requestUrl, postData);
                }

                var result = System.Text.Encoding.UTF8.GetString(response);
                SSLCommerzInitResponse resp = JsonConvert.DeserializeObject <SSLCommerzInitResponse>(result);

                if (resp.status != "SUCCESS")
                {
                    logger.LogError("Unable to get data from SSLCommerz. Please contact your manager!");
                }

                return(resp);
            }
            catch (Exception ex)
            {
                logger.LogError(ex, $"InitiateTransaction got exception {ex.Message}");
            }

            return(null);
        }