Tuesday, April 11, 2023

1.How to sum two table value in sql?

Ans:-SELECT (SELECT SUM(London) FROM CASH) + (SELECT SUM(London) FROM CHEQUE) as result

Monday, November 19, 2018

Integrate Google (Gmail) Authentication in Asp.Net MVC 5.0 - OAuth 2.0

TODAY I AM GOING TO SHOW HOW TO AUTHENTICATION GOOGLE IN .NET MVC

STEP ONE:-
CREATE API IN GOOGLE API CLICK HERE


HTML CODE
Take a Button in HTML and give a id Like this

    <button type="button"  id="googleplus"> Login With Google</button>

   I Declare Here a Id name=(googleplus)


JAVA SCRIPT CODE

USE THIS SOURCE FILE FOR GOOGLE API

<script src="~/admin_assets/js/jquery-1.10.2.min.js"></script>
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet" type="text/css">
<script src="https://apis.google.com/js/api:client.js"></script>

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>




<script>
    var googleUser = {};
        var startAppA = function () {
            gapi.load('auth2', function () {
                //Retrieve the singleton for the GoogleAuth library and set up the client.
                auth2 = gapi.auth2.init({
                    client_id: '530xxxxxxxxxxxxxxx-jh8losll6vk05f1ts8ir0ie2qlr7fpsm.apps.googleusercontent.com',
                    secret_key: 'Vci2wXJauQR9KjfYYwz00n06',
                    cookiepolicy: 'single_host_origin',
                });
                attachSignin(document.getElementById('googleplus'));
            });
    };
    function attachSignin(element) {
        auth2.attachClickHandler(element, {},
            function (googleUser) {
            $(".se-pre-con").show();
            console.log(googleUser);
                var profiles = googleUser.getBasicProfile();
                var ReturnUrl = 'http://localhost:55239/Account/ReturnURL';

            //Crate A Bunch Of Object for Search
            var objData = {
                Email: profiles.getEmail(),
                GoogleID: profiles.getId(),
                ProfileURL: profiles.getName(),
            };
            $.ajax({
                type: "POST",
                url: '@Url.Action("ReturnURL", "Account")', here put url like that
                data: objData,
                datatype: "json",
                success: function (data) {
                    if (data == 1) {
                        window.location = '/Account/CreateAccount';
                    }
                    else {
                        alert('This User Name Already Register  Try Anthor Option!');
                    }
                }
            });
                $(".se-pre-con").hide();
            });
    }
</script>
<script>startAppA();</script>



C# CODE
   [HttpPost]
   public JsonResult ReturnURL(string Email, string GoogleID, string ProfileURL, Registration_tblModel R)
        {
            Property p = new Property();
            p.Condition1 = GoogleID;
            p.OnTable = "FetechRegbyid";
            Ds = Dl.FetchMaster(p);
            Property info = new JustCallOnline.Models.Property();
            if (p.Condition1 != null)
            {
                if (Ds.Tables[0].Rows.Count > 0)
                {
  info.UserName = Ds.Tables[0].Rows[0]["FullName"].ToString(); HERE I CHECK IS USER ALREADY  REGIS OR NOT
                }
                else
                {
                    R.UserType = "USER";         HERE I PASS THE IN PROPERTY FILED FOR INSERT INTO DATABASE
                    R.FullName = ProfileURL;   
                    R.Emailid = Email;
                    R.Password = GoogleID;
                    R.AccountType = "Vendor";
                    try
                    {
       if (rdev.IU_SPROC<int>("IN_UP_REGISTRATION_TBL", R) > 0) HERE I CALL THE PROCEDURE FOR INSERT
                        {
                            TempData["MSG"] = "Account Created Mail Sent To your Email Id! Check Your Mail Id Wait For Admin Verification";
                            //Login Code
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                    return Json(1, JsonRequestBehavior.AllowGet);

                }
            }
            return Json(0, JsonRequestBehavior.AllowGet);

        }



I THINK THIS ARTICAL HELPFULLY FOR ALL.IF ANY ISSUE PLEASE COMMENT ME. 



Saturday, November 17, 2018

GOOGLE MAP API INTEGRATION 

TODAY I AM GOING TO SHOW DROWN  GOOGLE MAP DYNAMIC IN .NET MVC

STEP 1
CREATE A GMAIL ACCOUNT AND THEN CREATE A MAP API THOUGH THIS LINK
CLICK HERE 

STEP 2
GENERATE A MAP API

STEP 3

CONTROLLER CODE




put your product details url with id to go to details page from map.(where i black the line)


HTML CODE

Design the your page and past this code where you want to show the map

------------------------------------------------------------------------------------------------------------------------
   <div id="dvMap" style="width: 100%; height: 450px;border:0" frameborder="0" allowfullscreen></div>

    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key="PAST YOUR MAP API OR API"></script>
------------------------------------------------------------------------------------------------------------------------
JAVA SCRIPT CODE




THANKS

Friday, November 16, 2018

PAY U MONEY PAYMENT INTEGRATION .NET MVC

NOW I GOING TO START PAY U MONEY PAYMENT INTEGRATION .NET MVC

STEP:--1

CREATE A ACCOUNT IN PAY U MONEY CLICK HERE

GET THE KEY FOR TEST MODE WHEN YOUR SITE GOING LIVE SET URL AS LIVE.



STEP:--2
put merchant key on key place given below
put salt on salt place given below
ADD SUM FIELD IN WEB.CONFIGS




CREATE A HTML FOR PASS THE DYNAMIC AMOUNT FOR PAYMENTS

LIKE THIS:

WHEN CLICK ON BUTTON THEN REDIRECT TO PAY U MONEY PAYMENT GATEWAY.

VIEW OF THIS HTML
---------------------------------

--------------------------------------------------------------------------------------------------------------

CLICK ON PAY NOW AND HITS THE CONTROLLER.

C# code
---------------------

        [HttpPost]
        public ActionResult CheckoutPayu(Property P)
        {
            EncryptDecrypt enc = new EncryptDecrypt();
            HttpCookie loginCookie = Request.Cookies["cookie"];
            if (loginCookie != null)
            {
                P.UserID = enc.Decrypt(loginCookie["Uid"].ToString());
            }
            if (Request.Cookies["CartIdCookie"] != null)
            {
                P.cartid = Request.Cookies["CartIdCookie"].Value.ToString();
            }
            else
            {
                HttpCookie CartIdCookie = new HttpCookie("CartIdCookie");
                P.cartid = Guid.NewGuid().ToString("N");
                CartIdCookie.Value = P.cartid;
                Response.Cookies.Add(CartIdCookie);
            }
            P.Amount = Session["Total"].ToString();
            P.productinfo = "Demo";
            //P.productinfo = Session["ProductName"].ToString();

            string[] hashVarsSeq;
            string hash_string = string.Empty;
            var key = ConfigurationManager.AppSettings["MERCHANT_KEY"];

            if (string.IsNullOrEmpty(Request.Form["txnid"])) // generating txnid
            {
                Random rnd = new Random();
                string strHash = Generatehash512(rnd.ToString() + DateTime.Now);
                txnid1 = strHash.ToString().Substring(0, 20);

            }
            else
            {
                txnid1 = Request.Form["txnid"];
            }
            if (string.IsNullOrEmpty(Request.Form["hash"]))
            {
                if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["MERCHANT_KEY"]) ||
                    string.IsNullOrEmpty(txnid1) ||
                    string.IsNullOrEmpty(Request.Form["Amount"]) ||
                    string.IsNullOrEmpty(Request.Form["firstname"]) ||
                    string.IsNullOrEmpty(Request.Form["email"]) ||
                    string.IsNullOrEmpty(Request.Form["phone"]) ||
                    string.IsNullOrEmpty(Request.Form["DeliveryZip"]) ||
                    string.IsNullOrEmpty(Request.Form["surl"]) ||
                    string.IsNullOrEmpty(Request.Form["furl"]) ||
                    string.IsNullOrEmpty(Request.Form["service_provider"])
                    )
                {
                    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 + P.Amount;//hash_string + Convert.ToDecimal(Request.Form[hash_var]).ToString("g29");
                            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 = hash_string + P.productinfo + '|' + P.FirstName + '|' + P.EmailID + '|' + "f1" + '|' + "f2" + '|' + "f3" + '|' + "f4" + '|' + "f5" + '|' + "" + '|' + "" + '|' + "" + '|' + "" + '|' + "" + '|';


                    hash_string += ConfigurationManager.AppSettings["SALT"];// appending SALT

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

                }
            }
            else if (!string.IsNullOrEmpty(Request.Form["hash"]))
            {
                hash1 = Request.Form["hash"];
                action1 = ConfigurationManager.AppSettings["PAYU_BASE_URL"] + "/_payment";

            }

            if (!string.IsNullOrEmpty(hash1))
            {
                string Zip = P.DeliveryZip;
                string pho = P.ContactNo;
                string Country = P.Country;
                string City = P.City;
                string Addr = P.Address;
                string surl = "http://XXXX/Payment/Success";
                string furl = "http://XXXXX/Payment/Cancle";
                string curl = "http://XXXXX/Payment/Cancle";             
                string lastname = "sURAJ";
                string service_provider = "payu_paisa";
                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 = P.Amount;// eliminating trailing zeros
                data.Add("amount", AmountForm);
                data.Add("firstname", P.FirstName);
                data.Add("email", P.EmailID);
                data.Add("phone", P.ContactNo);
                data.Add("productinfo", P.productinfo);
                data.Add("surl", surl);
                data.Add("furl", furl);
                data.Add("lastname", lastname);
                data.Add("curl", curl);
                data.Add("address1", P.Address);
                data.Add("address2", P.Address);
                data.Add("city", P.City);
                data.Add("state", "WB");
                data.Add("country", P.Country);
                data.Add("zipcode", P.DeliveryZip);
                data.Add("udf1", "f1");
                data.Add("udf2", "f2");
                data.Add("udf3", "f3");
                data.Add("udf4", "f4");
                data.Add("udf5", "f5");
                data.Add("pg", "pg");
                data.Add("service_provider", service_provider);

                P.paymentStatus ="Pending";
                if (Dl.InsertOrder(P) > 0)
                {
                    TempData["MSG"] = "Data Save Successfully";
                }
                else
                {
                    TempData["MSG"] = "Data Not Saved!!!";
                }
                ViewBag.strForm = PreparePOSTForm(action1, data);
            }
            return View();
        }


------------------------------------create in same controller for hash creating -----------------------------------
        public string Generatehash512(string text)
        {

            byte[] message = Encoding.UTF8.GetBytes(text);

            UnicodeEncoding UE = new UnicodeEncoding();
            byte[] hashValue;
            SHA512Managed hashString = new SHA512Managed();
            string hex = "";
            hashValue = hashString.ComputeHash(message);
            foreach (byte x in hashValue)
            {
                hex += String.Format("{0:x2}", x);
            }
            return hex;

        }
------------------------------------create in same controller----------------------------------

        private string PreparePOSTForm(string url, System.Collections.Hashtable data)      // post form
        {
            //Set a name for the form
            string formID = "PostForm";
            //Build the form using the specified data to be posted.
            StringBuilder strForm = new StringBuilder();
            strForm.Append("<form id=\"" + formID + "\" name=\"" +
                           formID + "\" action=\"" + url +
                           "\" method=\"POST\">");

            foreach (System.Collections.DictionaryEntry key in data)
            {

                strForm.Append("<input type=\"hidden\" name=\"" + key.Key +
                               "\" value=\"" + key.Value + "\">");
            }

            strForm.Append("</form>");
            return strForm.ToString();
        } 
NOTE:-DO NOT REMOVE ANY KEYWORD

AFTER CLICK YOU CAN REDIRECT ON PAYMENT PAGE


I THINK THIS DOCUMENT HELP TO YOU INTEGRATE THIS PAYMENT GATEWAY.IF YOU FACE ANY ISSUE PLEASE COMMENT US
THANK YOU

Thursday, November 15, 2018

Paytm Payment Gateway in .Net MVC



Paytm Payment Gateway Integration with  .Net MVC

In this article, I’m going to write about how to Integrate Paytm Payment Gateway with NET MVC 5


Step 1 – Create Paytm Payment Gateway Sandbox Account

you can simply create paytm business production or sandbox account from this link  Click here

This link is for paytm integration documentation where you found a request and response parameters  Click here

Step 2 – Create New Project In Visual Studio 2015 or More 


Install paytm.dll CLICK HERE FOR DOWNLOAD DLL

Step 3 – Save Merchant Key and Id of Payment Gateway

      Create a class in project and past this code


  
Create a class in Model and past this code

Create a anther class in Model and past this code 
 New Model for Payment response

Step 4 – Create view page for User send amount to paytm
Step 5 – Create Home Controller


[HttpPost]
        public ActionResult About(WebApplication2.Models.Request r)
        {
            String callbackUrl = "http://localhost:57380/Home/PaytmResponse";
            string marchantkey = Class1.marchantkey;
            Dictionary<String, String> paytmParams = new Dictionary<String, String>();
            paytmParams.Add("MID", Class1.marchantId);
            paytmParams.Add("CHANNEL_ID", "WEB");
            paytmParams.Add("WEBSITE", "WEBSTAGING");
            paytmParams.Add("CUST_ID", "1");
            paytmParams.Add("MOBILE_NO", r.Mobail);
            paytmParams.Add("EMAIL", r.Email);
            paytmParams.Add("ORDER_ID", "23343ewe34");
            paytmParams.Add("INDUSTRY_TYPE_ID", "Retail");
            paytmParams.Add("TXN_AMOUNT", r.Amount);
            paytmParams.Add("CALLBACK_URL", callbackUrl);
            string paytmChecksum = paytm.CheckSum.generateCheckSum(Class1.marchantkey, paytmParams);
            string transactionURL = "https://securegw-stage.paytm.in/theia/processTransaction";

            try
            {
                string outputHTML = "<html>";
                outputHTML+=("<head>");
                outputHTML+=("<title>Merchant Checkout Page</title>");
                outputHTML+=("</head>");
                outputHTML += ("<body>");
                outputHTML += "<center><h1>Please do not refresh this page...</h1></center>";
                outputHTML += "<form method='post' action='" + transactionURL + "' name='f1'>";
                outputHTML += "<table border='1'>";
                outputHTML += "<tbody>";
                foreach (string key in paytmParams.Keys)
                {
                    outputHTML += "<input type='hidden' name='" + key + "' value='" + paytmParams[key] + "'>'";
                }
                outputHTML += "<input type='hidden' name='CHECKSUMHASH' value='" + paytmChecksum + "'>";
                outputHTML += "</tbody>";
                outputHTML += "</table>";
                outputHTML += "<script type='text/javascript'>";     
                outputHTML += "document.f1.submit();";
                outputHTML += "</script>";
                outputHTML += "</form>";
                outputHTML += "</body>";
                outputHTML += "</html>";
                
                ViewBag.list = outputHTML;
                return View("PaymentPage");
            }
            catch (Exception ex)
            {
                Response.Write("Exception message: " + ex.Message.ToString());
            }
            return View();

        }

Step 6 – Make new view page 

Create the view page and show view-bag html form.





@Html.Raw(ViewBag.list)



First Preview
------------------------------------

 fill all the filed and click save button and go to paytm payment page with the parameter.


Second Preview
------------------------------------


NOTE:-ALL THE PARAMETERS PASS DYNAMIC THROUGH CONTROLLER
                I JUST PASS THE VALUE STATIC.

I think this document helpfully for all. if any issue please comment me for improve my coding.

Wednesday, November 14, 2018

PAYPAL PAYMENT GETWAY INTERGATION IN .NET MVC

PAYMENT GATEWAY INTEGRATION






HTML CODE

 Call the paypal page on click
------------------------------------
<a href="javascript:void(0)" onclick="myFunction()" class="btn btn-success btn-outline-rounded green">Pay With Paypal</a>
-------------------------------------------------------------------------------------------------------------------------
                       
Paypal page html
-------------------
Live url
-----------------
@*<form id="hiddenform" action="https://www.paypal.com/cgi-bin/webscr">*@
-------------------------------------
sandbox url
--------------------
<form id="hiddenform" action="https://www.sandbox.paypal.com/cgi-bin/webscr">
----------------------------
HTML FORM
-------------------
    <input type="hidden" name="cmd" value="_xclick">
    <input type="hidden" name="amount" value="@Convert.ToDecimal(Session["Total"])"> Put Amount
    <input type="hidden" name="currency_code" value="GBP">currency
    <input type="hidden" name="item_name" value="Product">
    <input type="hidden" name="business" value="xxxxxxx@gmail.com">client paypal id
    <input type="hidden" name="return" value="http://localhost:64642/AddPost/PaySuccess">success url
    <input type="hidden" name="cancel_return" value="http://localhost:64642/Paypal/Cancle">cancel_return url   
</form>
-----------------------javascript code for call the button-----------------------------
<script>
    function myFunction() {
        document.getElementById("hiddenform").submit();
    }
</script>

Total value pass from controller

1.How to sum two table value in sql? Ans:- SELECT ( SELECT SUM ( London ) FROM CASH ) + ( SELECT SUM ( London ) FROM CHEQUE ) a...