How to use PayPal in MVC

Total Post:341

C#  Mvc 
 1243  View(s)
Rate this:
 I want to use paypal in mvc how will do this. please help 
  1. Post:281

    Re: How to use PayPal in MVC


    <!DOCTYPE html>
    <html lang="en">
            <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" />
                <div class="content-wrapper">
                    <div class="float-left">
                        <p class="site-title">@Html.ActionLink("your logo here", "Index", "Home")</p>
                    <div class="float-right">
                            <ul id="menu">
                                <li>@Html.ActionLink("Home", "Index", "Home")</li>
                                <li>@Html.ActionLink("About", "About", "Home")</li>
                                <li>@Html.ActionLink("Contact", "Contact", "Home")</li>
            <div id="body">
                @RenderSection("featured", required: false)
                <section class="content-wrapper main-content clear-fix">
                <div class="content-wrapper">
                    <div class="float-left">
                        <p>&copy; @DateTime.Now.Year - My ASP.NET MVC Application</p>

            @RenderSection("scripts", required: false)



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







    @model PaypalMVC.Models.PayPalModel

        <form id="hiddenform" action=@Model.actionURL>
        @Html.HiddenFor(model => model.cmd)
        @Html.HiddenFor(model =>
        @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)  

        <p style="text-align: center">
                Connecting to Paypal , please wait ...


    <script type="text/javascript" language="javascript">
        $(this.document).ready(function () {
            var form = $("form");



    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";
       = ConfigurationManager.AppSettings["business"];
                this.cancel_return = ConfigurationManager.AppSettings["cancel_return"];
                this.@return = ConfigurationManager.AppSettings["return"];
                if (useSandbox)
                    this.actionURL = ConfigurationManager.AppSettings["test_url"];
                    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"];



        <add key="business" value=""/
        <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="" />
       <add key="Prod_url" value="" />



      Modified On Nov-19-2015 10:33:22 PM