Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8994113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:21:05+00:00 2026-06-15T23:21:05+00:00

Here is my set up, I will try to keep the code short. This

  • 0

Here is my set up, I will try to keep the code short. This is an ASP.NET MVC4 application

I am setting the information here:

    @Html.Hidden("cmd", Model.PayPal.Cmd)
@Html.Hidden("business", Model.PayPal.Business)
@Html.Hidden("return", Model.PayPal.Return)
@Html.Hidden("cancel_return", Model.PayPal.CancelUrl)
@Html.Hidden("notify_url", Model.PayPal.NotifyUrl)
@Html.Hidden("currency_code", Model.PayPal.CurrencyCode)
@Html.Hidden("item_name", Model.PayPal.PlanName)
@Html.Hidden("item_number", Model.Id)

@Html.Hidden("src", Model.PayPal.AutoRecurring)
@Html.Hidden("a3", Model.PayPal.Price)
@Html.Hidden("p3", Model.PayPal.Interval)
@Html.Hidden("t3", Model.PayPal.IntervalType)
@Html.Hidden("txn_type", "subscr_signup")
<input type="image" name="submit"
    src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribe_LG.gif"
    alt="PayPal - The safer, easier way to pay online">
<img alt="" border="0" width="1" height="1"
    src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif">

I set the variables in the controller:

PayPal paypal = new PayPal();
        bool useSanbox = true;

        if (useSanbox)// for test
            paypal.ActionUrl = "https://www.sandbox.paypal.com/cgi-bin/webscr";
        else//real
            paypal.ActionUrl = "https://www.paypal.com/cgi-bin/webscr";

        paypal.Cmd = "_xclick-subscriptions";
        paypal.Business = "david_1355300634_biz@domain.com";
        paypal.CancelUrl = "http://localhost:25914/home/";
        paypal.Return = "http://localhost:25914/home/ipn";
        paypal.NotifyUrl ="http://localhost:25914/home/ipn";
        paypal.AutoRecurring = "1";
        paypal.Price = ctx.SubscriptionPlans.First(x => x.Name == signInModel.SubscritionPlan).Price.ToString();
        paypal.Interval = "1";
        paypal.IntervalType = "M";
        paypal.CurrencyCode = "USD";
        paypal.PlanName = signInModel.SubscritionPlan;
        paypal.Amount = ctx.SubscriptionPlans.First(x => x.Name == signInModel.SubscritionPlan).Price.ToString();

Then I have this IPN Controller action:

//Answer from PayPal
    public ActionResult IPN()
    {
        var signInModel = Session["SignUp"] as SignUp;
        //Post back to either sandbox or live
        string strSandbox = "https://www.sandbox.paypal.com/cgi-bin/webscr";
        //string strLive = "https://www.paypal.com/cgi-bin/webscr";
        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strSandbox);

        //Set values for the request back
        req.Method = "POST";
        req.ContentType = "application/x-www-form-urlencoded";
        byte[] param = Request.BinaryRead(this.Request.ContentLength);
        string strRequest = Encoding.ASCII.GetString(param);
        strRequest += "&cmd=_notify-validate";
        req.ContentLength = strRequest.Length;

        //Send the request to PayPal and get the response
        StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
        streamOut.Write(strRequest);
        streamOut.Close();
        StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream());
        string strResponse = streamIn.ReadToEnd();
        streamIn.Close();

        if (strResponse == "VERIFIED")
        {
            //any param from form
            var text = Request.Form["custom"];
            ctx.SignIns.Add(signInModel);
            ctx.SaveChanges();
            //check the payment_status is Completed
            //check that txn_id has not been previously processed
            //check that receiver_email is your Primary PayPal email
            //check that payment_amount/payment_currency are correct
            //process payment
            return View("RegistrationConfirmation", signInModel);
        }
        else if (strResponse == "INVALID")
        {
            //log for manual investigation
            return View("SignUp", signInModel);
        }
        else
        {
            //log response/ipn data for manual investigation
        }
        //change view
        return View("SignUp", signInModel);
    }

The thing that is throwing me off is I get routed to the paypal sandbox fine, I log in with a test user, confirm the payment amount, and then click return to the site. Returning hits my IPN action, but I get the response that it is “INVALID”. Am I missing a variable here or something? I am relatively new to the api.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:21:06+00:00Added an answer on June 15, 2026 at 11:21 pm

    Another one, cmd=_notify-validate should be the first param value that needs to be sent.

    As per the official docs

    “Verify that your response contains exactly the same IPN variables and values in the same
    order, preceded with cmd=_notify-validate.”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a complicated question, so I will try and keep it as short
ok this is a head wrecker and I will try to keep it brief.
Here I am facing a problem, I will explain: I set up a calendar
Here is the problem from code chef : A set of N dignitaries have
Here is my upsert code: UPDATE LastTicket SET LastTicketNumber=LastTicketNumber+1 OUTPUT INSERTED.LastTicketNumber WHERE CategoryId='1'; IF
I have a question that is more related to how ASP.NET works and will
I have set up an annotation that will be used to keep track of
EDIT: People keep visiting this post which doesn't have much good information so I'll
Ok, my current code is work in progress and probably I will try to
How can i find all subsets of a set using c#? here set is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.