PayPal Express checkout returns response as html in MVC.net

I had a test application integrated with Paypal express verification, and it worked fine. But now there is some kind of problem. After successful payment on paypal, when my IPN handler verifies the response, paypal returns the response as an html page instead of "VERIFIED" or "INVALID", and because of this I can not verify the payment. Are there any recent changes to Paypal for express verification? Below is the full code

<form id="Paypal" name="Paypal" action="https://www.sandbox.paypal.com/cgi-bin/webscr"
    method="post">
    @Html.Hidden("cmd", "_xclick")
    @Html.Hidden("business", "myemail@test.com")
    @Html.Hidden("item_name", "Payment for course registration")
    @Html.Hidden("amount", 100 )
    @Html.Hidden("no_shipping", "1")
    @Html.Hidden("return", "http://localhost:49319/cart/IPN")
    @Html.Hidden("rm", "2")
    @Html.Hidden("notify_url", "http://localhost:49319/cart/IPN")
    @Html.Hidden("cancel_return", "http://localhost:49319/cart/PaymentFailure")
    @Html.Hidden("currency_code", "CAD")
    @Html.Hidden("tax_cart", "1")
    @Html.Hidden("custom", "12")
    <div class="checkout-button">
        <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif"
            align="left" style="margin-right: 7px;" />
    </div>
    </form>

IPN Handler Code:

 string paypalUrl = useSandbox ? "https://www.sandbox.paypal.com/cgi-bin/webscr"
            : "https://www.paypal.com/cgi-bin/webscr";


        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(paypalUrl);

        // Set values for the request back
        req.Method = "POST";
        req.ContentType = "application/x-www-form-urlencoded";

        byte[] param = Request.BinaryRead(Request.ContentLength);
        string strRequest = Encoding.ASCII.GetString(param);

        StringBuilder sb = new StringBuilder();
        sb.Append(strRequest);

        foreach (string key in formVals.Keys)
        {
            sb.AppendFormat("&{0}={1}", key, formVals[key]);
        }
        strRequest += sb.ToString();
        req.ContentLength = strRequest.Length;

        //for proxy
        //WebProxy proxy = new WebProxy(new Uri("http://urlort#");
        //req.Proxy = proxy;
        //Send the request to PayPal and get the response
        string response = "";
        using (StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII))
        {

            streamOut.Write(strRequest);
            streamOut.Close();
            using (StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream()))
            {
                response = streamIn.ReadToEnd();
            }
        }

        return response;

Edit: Here is the query string sent to Paypal

= wtgSziM4C5x0SI-9CmKcv2vkSeTLK5P_g6HqzC__YTYkcqziFNcB84p79Ja & myAllTextSubmitID = & CMD = _flow & transaction_subject = 12 & txn_type = web_accept & PAYMENT_DATE = 01% 3A59% 3A21 + + 02% 2C + 2011 + & last_name = & residence_country = & pending_reason = paymentreview & item_name = + + + & payment_gross = & mc_currency = CAD & = pramod_1298956597_biz% 40sumerusolutions.com & payment_type = & protection_eligibility = Ineligible & payer_status = & verify_sign = Ag7LtkvrF1u9.1ScLJwRM4btR1G1A16qsCs-xUl6EpI1rE1UWpodXJsc ; txn_id = 15Y20623GD922445F & payer_email = pramod_1298961722_per% 40sumerusolutions.com & = 0.00 & test_ipn = 1 & first_name = &amp; receiver_email = pramod_1298956597_biz% 40sumerusolutions.com & = 1 & payer_id = Z2MRT3Q9L6E28 & receiver_id = RT3M59WESZHEE & ITEM_NUMBER = & payment_status = Pending & handling_amount = 0,00 & = 0,00 & mc_gross = 850,00 & = 12 & Charset = s-1252 & notify_version = 3,1 & merchant_return_link = + ; form_charset = UTF-8CONTEXT = wtgSziM4C5x0SI-9CmKcv2vkSeTLK5P_g6HqzC__YTYkcqziFNcB84p79Ja & myAllTextSubmitID = & CMD = _flow & transaction_subject = 12 & txn_type = web_accept & PAYMENT_DATE = 01% 3A59% 3A21 + + 02% 2C + 2011 + PDT & last_name = User & residence_country = CA & pending_reason = paymentreview & item_name = + + + & payment_gross = & mc_currency = CAD & = pramod_1298956597_biz% 40sumerusolutions.com & payment_type = ; protection_eligibility = & payer_status = & verify_sign = Ag7LtkvrF1u9.1ScLJwRM4btR1G1A16qsCs-xUl6EpI1rE1UWpodXJsc & txn_id = 15Y20623GD922445F & payer_email = pramod_1298961722_per% 40sumerusolutions.com & = 0.00 & test_ipn = 1 & first_name = &amp; receiver_email = pramod_1298956597_biz% 40sumerusolutions.com & = 1 & payer_id = Z2MRT3Q9L6E28 & receiver_id = RT3M59WESZHEE & ITEM_NUMBER = & payment_status = & handli ng_amount = 0,00 & = 0,00 & mc_gross = 850,00 & = 12 & Charset = -1252 & notify_version = 3,1 & merchant_return_link = + ; form_charset = UTF-8 & CMD = _notify-Validate >

+5
5

Ok. PayPal . . PDT IPN. , PayPal, " , IPN , , 100% ".

Paypal PDT, . , -, :

  • AutoReturn PDT PayPal. : PayPal "" " -" set Auto Return to On URL- Return URL Transfer Data Transfer to on. PDT. ""

  • paypal cmd, business, item_name, amount, return, currency_code, custom.

  • IPN PDT, PDT :

    authToken, txToken, query;       string strResponse;

        authToken = ConfigurationManager.AppSettings["PDTToken"];
    
        //read in txn token from querystring
        txToken = Request.QueryString.Get("tx");
    
    
        query = string.Format("cmd=_notify-synch&tx={0}&at={1}", txToken, authToken);
    
        // Create the request back
        string url = ConfigurationManager.AppSettings["PayPalUrl"];
        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
    
        // Set values for the request back
        req.Method = "POST";
        req.ContentType = "application/x-www-form-urlencoded";
        req.ContentLength = query.Length;
    
        // Write the request back IPN strings
        StreamWriter stOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
        stOut.Write(query);
        stOut.Close();
    
        // Do the request to PayPal and get the response
        StreamReader stIn = new StreamReader(req.GetResponse().GetResponseStream());
        strResponse = stIn.ReadToEnd();
        stIn.Close();            
    
        // If response was SUCCESS, parse response string and output details
        if (strResponse.StartsWith("SUCCESS"))
        {
    
        }
    
+5

html, . , ​​ - , Paypal - - . , HTML?

0

-, Paypal. , , Paypal, , .

, Paypal, , Paypal.

- , :

  • .
  • Paypal,
  • -.

, , , .

, , Paypal. , / , ( , ). , , Paypal, .

  • Paypal
  • - , ().

, API Paypal. Paypal, .

0

, IPN... , "echeck" , VERIFIED, , -, ... , echeck... .

, .

0

IPN #, , ( HTML-, ), , PayPal

cmd=_notify-validate

, , PayPal .

Another thing to make sure is that you pass the variables back when they were received in the IPN request, just add the above command to the top of your message.

I do not use MVC, but I do it with WCF, and it works like a charm.

Hope this helps.

0
source

All Articles