Reputation: 83
I want to integrate PayPal Gateway in my website. I want a return URL with required parameter like other payment gateway have, which returns some parameter saying payment successful and transaction ID etc.
Upvotes: 0
Views: 6703
Reputation: 488
for return Url see..
for Html variable see
for mvc integration of paypal see
you can download NopCommerce2.8 or http://nopcommerce.codeplex.com/ with source code. It has implemented Paypal (all methods) and manyothers payment gateway.
http://www.superstarcoders.com/blogs/posts/paypal-with-asp-net-mvc.aspx
http://blog.liamcavanagh.com/2012/06/how-to-use-paypal-with-asp-net-mvc/
see about "custom" html variable...
i got dirty way ...in "return" html variable to pass id ... /Event/RedirectFromPaypal?eventId=26 ..
Upvotes: 0
Reputation: 800
In web.config
<appSettings>
<add key="token" value="PW1BDVNqVPVanwduF_Tb2Ey91aT1Uhx1kL7HPc-7e8S-6AnUwSSHyasolSe"/>
<add key="paypalemail" value="@gmail.com"/>
<add key="PayPalSubmitUrl" value="https://www.paypal.com/cgi-bin/webscr"/>
<add key="FailedURL" value="http://www.mrsoft.co.in/ProceedToPayment.aspx"/>
<add key="SuccessURL" value="http://www.mrsoft.co.in/ProceedToPayment.aspx"/>
</appSettings>
Code
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 += "¤cy=" + 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);
}
Upvotes: 3