Wednesday 10 June 2015

How to Integrate Paypal in your Application Using Asp.Net

Follow this two link for more details

http://www.codeproject.com/Articles/19184/Use-of-the-PayPal-payment-system-in-ASP-NET 
http://www.codeproject.com/Tips/474197/PayPal-Gateway-Integration-in-ASP-NET 
http://www.mindstick.com/Articles/41de052a-37e1-41db-aa4c-123313be444a/?How%20to%20integrate%20PayPal%20in%20A 

in config File write the following code 

--------------------------------
<appSettings>
    <add key="token" value="PW1BDVNqVPVanwduF_Tb2Ey91aT1Uhx1kL7HPc-7e8S-6AnUwSSHyasolSe"/>
    <add key="paypalemail" value="snehasish@gmail.com"/>

    <!--Here i used sandbox site url only if you hosted in live change sandbox to live paypal URL-->
    <add key="PayPalSubmitUrl" value="https://www.paypal.com/cgi-bin/webscr"/>

    <add key="FailedURL" value="http://www.xyz.co.in/ProceedToPayment.aspx"/>

    <add key="SuccessURL" value="http://www.xyz.co.in/ProceedToPayment.aspx"/>

</appSettings>
 
Write the code in the code behind page
-----------------------------------
protected void PayWithPayPal(string amount, string itemInfo, string name, 
          string phone, string email, string currency)
{
    string redirecturl = "";

    //Mention URL to redirect content to paypal site
    redirecturl += "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=" + 
                   ConfigurationManager.AppSettings["paypalemail"].ToString();

    //First name i assign static based on login details assign this value
    redirecturl += "&first_name=" + name;

    //City i assign static based on login user detail you change this value
    redirecturl += "&city=bhubaneswar";

    //State i assign static based on login user detail you change this value
    redirecturl += "&state=Odisha";

    //Product Name
    redirecturl += "&item_name=" + itemInfo;

    //Product Name
    redirecturl += "&amount=" + amount;

    //Phone No
    redirecturl += "&night_phone_a=" + phone;

    //Product Name
    redirecturl += "&item_name=" + itemInfo;

    //Address 
    redirecturl += "&address1=" + email;

    //Business contact id
    // redirecturl += "&business=k.tapankumar@gmail.com";

    //Shipping charges if any
    redirecturl += "&shipping=0";

    //Handling charges if any
    redirecturl += "&handling=0";

    //Tax amount if any
    redirecturl += "&tax=0";

    //Add quatity i added one only statically 
    redirecturl += "&quantity=1";

    //Currency code 
    redirecturl += "&currency=" + currency;

    //Success return page url
    redirecturl += "&return=" + 
      ConfigurationManager.AppSettings["SuccessURL"].ToString();

    //Failed return page url
    redirecturl += "&cancel_return=" + 
      ConfigurationManager.AppSettings["FailedURL"].ToString();

    Response.Redirect(redirecturl);
}