Exemplo n.º 1
0
        public ActionResult DonationStatus(int DonationId, int DonorId, string DonationStatus, string DonationAmount, string Comments)
        {
            decimal          Amount       = Convert.ToDecimal(DonationAmount);
            Donor_Details    data1        = DonationService.DonationStatus(DonationId, DonorId, Amount, DonationStatus, Comments);
            Donation_Details Donationdata = GenericMethods.GetUserDonations(DonationId);
            View_UserDetails UserDetails  = UserDetailsViewService.GetUserByUserId(DonorId);

            ViewBag.Amount        = data1.Donation_Amount;
            ViewBag.Date          = data1.CreatedOn;
            ViewBag.DonationTitle = Donationdata.Donation_Title;
            ViewBag.DonorName     = UserDetails.FirstName;

            return(View());
        }
Exemplo n.º 2
0
        public Donor_Details DonationStatus(int DonationId, int DonorId, decimal DonationAmount, string DonationStatus, string Comments)
        {
            Donor_Details DonorDetails = new Donor_Details();

            using (var context = _dbContextFactory.CreateConnection())
            {
                Transaction_Details Transaction = new Transaction_Details()
                {
                    Txn_Status    = DonationStatus,
                    Currency_Code = "INR",
                    Comments      = Comments,
                    Txn_Message   = "Transaction Successfully Created.",
                    Txn_Amount    = DonationAmount,
                    Service_Tax   = 0,
                    CreatedOn     = DateTime.Now,
                    CreatedBy     = DonorId,
                    Status        = true
                };
                context.Transaction_Details.Add(Transaction);
                context.SaveChanges();
                long TransactionID = Transaction.Transaction_ID;

                DonorDetails.Donation_ID     = DonationId;
                DonorDetails.Donor_ID        = DonorId;
                DonorDetails.Donation_Amount = DonationAmount;
                DonorDetails.Donation_Status = DonationStatus;
                DonorDetails.Comments        = Comments;
                DonorDetails.Transaction_ID  = TransactionID;
                DonorDetails.CreatedOn       = DateTime.Now;
                DonorDetails.Status          = true;
                context.Donor_Details.Add(DonorDetails);
                context.SaveChanges();

                return(DonorDetails);
            }
        }
Exemplo n.º 3
0
        public ActionResult PaymentGateway(int DonationId, int DonorId, string DonationStatus, string DonationAmount, string Comments)
        {
            decimal          Amount       = Convert.ToDecimal(DonationAmount);
            Donor_Details    data1        = DonationService.DonationStatus(DonationId, DonorId, Amount, DonationStatus, Comments);
            Donation_Details Donationdata = GenericMethods.GetUserDonations(DonationId);
            View_UserDetails UserDetails  = UserDetailsViewService.GetUserByUserId(DonorId);


            string hash_string = string.Empty;

            string[] hashVarsSeq;
            var      Key     = ConfigurationManager.AppSettings["MERCHANT_KEY"];
            Random   rnd     = new Random();
            string   strHash = Generatehash512(rnd.ToString() + DateTime.Now);

            txnid1 = strHash.ToString().Substring(0, 20);

            hashVarsSeq = ConfigurationManager.AppSettings["hashSequence"].Split('|'); // spliting hash sequence from config
            hash_string = "";
            foreach (string hash_var in hashVarsSeq)
            {
                if (hash_var == "key")
                {
                    hash_string = hash_string + ConfigurationManager.AppSettings["MERCHANT_KEY"];
                    hash_string = hash_string + '|';
                }
                else if (hash_var == "txnid")
                {
                    hash_string = hash_string + txnid1;
                    hash_string = hash_string + '|';
                }
                else if (hash_var == "amount")
                {
                    hash_string = hash_string + Convert.ToDecimal(DonationAmount).ToString("g29");
                    hash_string = hash_string + '|';
                }
                else if (hash_var == "productinfo")
                {
                    hash_string = hash_string + Donationdata.Donation_Title;
                    hash_string = hash_string + '|';
                }
                else if (hash_var == "firstname")
                {
                    hash_string = hash_string + UserDetails.FirstName;
                    hash_string = hash_string + '|';
                }
                else if (hash_var == "email")
                {
                    hash_string = hash_string + "*****@*****.**";
                    hash_string = hash_string + '|';
                }
                else
                {
                    hash_string = hash_string + (Request.Form[hash_var] != null ? Request.Form[hash_var] : "");// isset if else
                    hash_string = hash_string + '|';
                }
            }

            hash_string += ConfigurationManager.AppSettings["SALT"];                        // appending SALT
            hash1        = Generatehash512(hash_string).ToLower();                          //generating hash
            action1      = ConfigurationManager.AppSettings["PAYU_BASE_URL"] + "/_payment"; // setting URL

            System.Collections.Hashtable data = new System.Collections.Hashtable();         // adding values in gash table for data post
            data.Add("hash", hash1);
            data.Add("txnid", txnid1);
            data.Add("key", Key);
            string AmountForm = Convert.ToDecimal(DonationAmount).ToString("g29");// eliminating trailing zeros

            data.Add("amount", AmountForm);
            data.Add("firstname", UserDetails.FirstName);
            data.Add("email", "*****@*****.**");
            data.Add("phone", "8985143792");
            data.Add("productinfo", Donationdata.Donation_Title);
            data.Add("surl", "http://www.google.com");
            data.Add("furl", "http://www.google.com");

            string strForm = PreparePOSTForm(action1, data);

            ViewBag.Form = strForm;
            return(View());
        }