---
title: "How to use PayPal in MVC"  
description: "How to use PayPal in MVC"  
author: "Anonymous User"  
published: 2015-11-19  
updated: 2015-11-19  
canonical: https://www.mindstick.com/forum/33613/how-to-use-paypal-in-mvc  
category: ".net"  
tags: ["c#", "mvc"]  
reading_time: 3 minutes  

---

# How to use PayPal in MVC

I want to use [paypal](https://www.mindstick.com/news/1342/paypal-reports-major-loss-in-q4-revenue) in [mvc](https://www.mindstick.com/forum/155803/define-cache-profile-in-mvc) how will do this. please help

## Replies

### Reply by rachel gomez

## Steps to use PayPal in MVC

1. Run your web application in the web browser now.
2. And load the Paypal Index action.
3. You just need to append the URL of the web application and add '/Paypal' at the end of that URL.
4. As soon as you hit enter, it will execute the Index action because Index is the default action of any controller in MVC

## Regards,

## Rachel Gomez

### Reply by rachel gomez

**Steps to use PayPal in MVC**

1. Run your web application in the web browser now.
2. And load the Paypal Index action.
3. You just need to append the URL of the web application and add '/Paypal' at the end of that URL.
4. As soon as you hit enter, it will execute the Index action because Index is the default action of any controller in MVC

## This may help you,

## Rachel Gomez

### Reply by Anonymous User

```
_Layout.cshtml<!DOCTYPE html><html lang="en">    <head>        <meta charset="utf-8" />        <title>@ViewBag.Title - My ASP.NET MVC Application</title>        <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />        <meta name="viewport" content="width=device-width" />        @Styles.Render("~/Content/css")        @Scripts.Render("~/bundles/modernizr")    </head>    <body>        <header>            <div class="content-wrapper">                <div class="float-left">                    <p class="site-title">@Html.ActionLink("your logo here", "Index", "Home")</p>                </div>                <div class="float-right">                                        <nav>                        <ul id="menu">                            <li>@Html.ActionLink("Home", "Index", "Home")</li>                            <li>@Html.ActionLink("About", "About", "Home")</li>                            <li>@Html.ActionLink("Contact", "Contact", "Home")</li>                        </ul>                    </nav>                </div>            </div>        </header>        <div id="body">            @RenderSection("featured", required: false)            <section class="content-wrapper main-content clear-fix">                @RenderBody()            </section>        </div>        <footer>            <div class="content-wrapper">                <div class="float-left">                    <p>&copy; @DateTime.Now.Year - My ASP.NET MVC Application</p>                </div>            </div>        </footer>        @Scripts.Render("~/bundles/jquery")        @RenderSection("scripts", required: false)    </body></html>
```

```
Index.cshtml @{    ViewBag.Title = "Home Page";}@using (Html.BeginForm("ValidateCommand", "PayPal")){    <div>        <table >            <tr>                <td>                    product Name:                </td>                <td>                    <input type="text" name="product" value="Xolo Mobile" readonly />                </td>            </tr>            <tr>                <td>                   Total Price:                </td>                <td>                    $<input type="text" name="totalPrice" value="14800" readonly />                </td>            </tr>            <tr>                <td>                </td>                <td>                    <input type="submit" name="btnConfirm" value="Check Out with Paypal" />                </td>            </tr>        </table>    </div>}     
```

```
ValidateCommand.cshtml@model PaypalMVC.Models.PayPalModel<body>    <form id="hiddenform" action=@Model.actionURL>    @Html.HiddenFor(model => model.cmd)    @Html.HiddenFor(model => model.business)    @Html.HiddenFor(model => model.no_shipping)    @Html.HiddenFor(model => model.@return)    @Html.HiddenFor(model => model.cancel_return)    @Html.HiddenFor(model => model.notify_url)    @Html.HiddenFor(model => model.currency_code)    @Html.HiddenFor(model => model.item_name)    @Html.HiddenFor(model => model.amount)       </form>    <p style="text-align: center">        <h3>            Connecting to Paypal , please wait ...        </h3>    </p></body> @Scripts.Render("~/bundles/jquery")<script type="text/javascript" language="javascript">    $(this.document).ready(function () {        var form = $("form");        form.submit();    });   </script>
```

```
PayPalModel using System.Configuration;namespace PaypalMVC.Models{    public class PayPalModel    {        public string cmd { get; set; }        public string business { get; set; }        public string no_shipping { get; set; }        public string @return { get; set; }        public string cancel_return { get; set; }        public string notify_url { get; set; }        public string currency_code { get; set; }        public string item_name { get; set; }        public string amount { get; set; }        public string actionURL { get; set; }                public PayPalModel(bool useSandbox)        {            this.cmd = "_xclick";            this.business = ConfigurationManager.AppSettings["business"];            this.cancel_return = ConfigurationManager.AppSettings["cancel_return"];            this.@return = ConfigurationManager.AppSettings["return"];            if (useSandbox)            {                this.actionURL = ConfigurationManager.AppSettings["test_url"];            }            else            {                this.actionURL = ConfigurationManager.AppSettings["Prod_url"];            }            // We can add parameters here, for example OrderId, CustomerId, etc....            this.notify_url = ConfigurationManager.AppSettings["notify_url"];            // We can add parameters here, for example OrderId, CustomerId, etc....            this.currency_code = ConfigurationManager.AppSettings["currency_code"];        }    }} Web.config <appSettings>        <add key="business" value="leyegora-facilitator@yahoo.fr"/>      <add key="IsSandbox" value="false" />    <add key="currency_code" value="USD" />    <add key="return" value="http://localhost/PayPal/RedirectFromPaypal" />    <add key="cancel_return" value="http://localhost/PayPal/CancelFromPaypal" />    <add key="notify_url" value="http://localhost/PayPal/NotifyFromPaypal" />       <add key="test_url" value="https://www.sandbox.paypal.com/cgi-bin/webscr" />   <add key="Prod_url" value="https://www.sandbox.paypal.com/cgi-bin/webscr" />     </appSettings>  
```

```

```

```

```


---

Original Source: https://www.mindstick.com/forum/33613/how-to-use-paypal-in-mvc

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
