Tuesday, 15 July 2014

How to integrate PayPal in ASP.NET MVC 5?

How to integrate PayPal in ASP.NET MVC 5?

Today i would like to describe here step by step procedure to integrating paypal integration (express checkout) in MVC3 web application using razor view engine.

1)Create new MVC3 internet web application.

2)change Index page under Home section and as per below fig





3) Create paypal model class 



4) Create action in home controller to post data to paypal



here we post item information in form so we can retrieve it using parameter as you can see that value when you debug as per below


in that you need to set following parameters in web.config
  • BusinessAccountKey: business account key for seller
  • UseSandbox: weathere to use sanbox or live
  • CancelURL: return to this when user cancel
  • ReturnURL: return after payment
  • NotifyURL: use for IPN to notify
  • CurrencyCode: transcation in which currency 
to use sandbox you need to create account at https://developer.paypal.com/
and in that you can create business account as well as buyers account to testing as per shown in fig



I have added that in web.config as per below



If you new for paypal integration then first go through this introduction here .

5)create view of this action (empty view) and code as per below



6) Now run the site and click pay with paypal , you will be redirecting to paypal as per below


here you can pay with your personal test account and redirect to back as per app-setting URLs

7) To handle redirected request you need to create following controller and respective views with your logic and message. 
  • RedirectFromPaypal 
  • CancelFromPaypal 
  • NotifyFromPaypal 

8)If you not redirect to your website after payment complete then follow the below steps to set return URL in business account.

a. Click on the business test account id and click enter Sandbox test site 

b. Choose Profile --> More options in the menu under Selling Preferences choose Website Payment Preferences

c. Select Auto Return on radio button to redirect and enter return URL below like http://www.xyz.com if you don't have any domain just enter any valid domain name like your blog URL etc. because its only for testing 

d. Enable on Payment Data Transfer to get payment data return in website and save it.

e. Again go to more option website payment reference and see identity token is generated (under payment data transfer) copy that identity token use it in the website web.config file. 

24 comments:

  1. DOJO Toolkit Online Training, http://www.21cssindia.com/courses/dojo-toolkit-online-training-174.html The 21st Century Software Solutions of India offers one of the Largest conglomerations of Software Training, IT Support, Corporate Training institute in India - +919000444287 - +917386622889 - Visakhapatnam,Hyderabad DOJO Toolkit Online Training, DOJO Toolkit Training, DOJO Toolkit, DOJO Toolkit Online Training| DOJO Toolkit Training| DOJO Toolkit| "Courses at 21st Century Software Solutions
    Talend Online Training -Hyperion Online Training - IBM Unica Online Training - Siteminder Online Training - SharePoint Online Training - Informatica Online Training - SalesForce Online Training - Many more… | Call Us +917386622889 - +919000444287 - contact@21cssindia.com
    Visit: http://www.21cssindia.com/courses.html"

    ReplyDelete
    Replies
    1. IEEE Final Year Project centers make amazing deep learning final year projects ideas for final year students Final Year Projects for CSE to training and develop their deep learning experience and talents.

      IEEE Final Year projects Project Centers in India are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation.

      corporate training in chennai corporate training in chennai

      corporate training companies in india corporate training companies in india

      corporate training companies in chennai corporate training companies in chennai

      I have read your blog its very attractive and impressive. I like it your blog. Digital Marketing Company in Chennai

      Delete
  2. thanks for single item article.

    do you know any good article for multiple items

    ReplyDelete
  3. On step 6, its stops on Redirecting to Paypal. How can i do to proceed to complete payment

    ReplyDelete
  4. if i enter wrong businessaccountkey then also payment successfully done.
    then who receive money ! ?
    we not set here anything seller account no !! how seller will get money !

    ReplyDelete
  5. send me proper way of code and Demo Example of Paypal Intigration

    ReplyDelete
  6. You want to buy the grooving machine price in india to get low cost ask the dealer sendhamarai engineering is one of authorised dealer in india.

    ReplyDelete
  7. Thanks a lot for posting this post, Your post has always been an informative source for me.
    Raw Edge Belt Manufacturers

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. Nice post, Thanks for sharing Get more update at
    .Net Online Course

    ReplyDelete
  10. Nice! you are sharing such helpful and easy to understandable blog. i have no words for say i just say thanks because it is helpful for me.



    Dot Net Training in Chennai | Dot Net Training in anna nagar | Dot Net Training in omr | Dot Net Training in porur | Dot Net Training in tambaram | Dot Net Training in velachery







    ReplyDelete
  11. This review was so good and cool, I never imaging I would be able to get a post like this that is so important about Paypal. Really, over some years I have had people complaining about Paypal, thank you once more for the update you are great in developing contents and informaton.
    https://www.tecteem.com/paypal-login/

    ReplyDelete
  12. If you are looking the latest solution of a payment gateway integration in ASP.NET Web Forms, check out demos:

    - For Stripe https://techtolia.com/Stripe/

    Receive payments from credit or debit cards, Alipay, WeChat Pay, Bancontact, EPS, giropay, iDEAL, Multibanco, Przelewy24, Sofort, Secure Remote Commerce and Payment Request Button (Apple Pay, Google Pay, Microsoft Pay, and the browser Payment Request API) via Stripe.

    - For PayPal https://techtolia.com/PayPal/

    Receive payments from PayPal, PayPal Credit, credit or debit cards, Bancontact, BLIK, eps, giropay, iDEAL, MyBank, Przelewy24, SEPA-Lastschrift, Sofort, Venmo via PayPal.

    ReplyDelete