POST to https://www.sandbox.paypal.com/cgi-bin/webscr gives 500 error , Classic asp
<p>I am working on classic asp to create donation site and payment gateway is paypal.
I have implemented IPN and paypal is sending notification on that notify_url that i pass with form. 
Also payment is also working correctly i.e i can get payment history and IPN history in my sandbox paypal account.</p>

<p>Now the problem is in IPN handler file, when i use sandbox.paypal url to post back to paypal, it give 500 error. Same thing is not true for live paypal url.
Below it the code that will explain better.</p>

<p><strong>Test Form</strong></p>

<pre><code>&lt;form action="zPaypalTest.asp" method="POST"&gt;
&lt;input name="mc_gross" type="hidden" value="500.00" /&gt;
&lt;input name="custom" type="hidden" value="some custom data" /&gt;
&lt;input name="address_status" type="hidden" value="confirmed" /&gt;
&lt;input name="item_number1" type="hidden" value="6" /&gt;
&lt;input name="item_number2" type="hidden" value="4" /&gt;
&lt;input name="payer_id" type="hidden" value="FW5W7ZUC3T4KL" /&gt;
&lt;input name="tax" type="hidden" value="0.00" /&gt;
&lt;input name="address_street" type="hidden" value="1234 Rock Road" /&gt;
&lt;input name="payment_date" type="hidden" value="14:55 15 Jan 07 2005 PST" /&gt;
&lt;input name="payment_status" type="hidden" value="Completed" /&gt;
&lt;input name="address_zip" type="hidden" value="12345" /&gt;
&lt;input name="mc_shipping" type="hidden" value="0.00" /&gt;
&lt;input name="mc_handling" type="hidden" value="0.00" /&gt;
&lt;input name="first_name" type="hidden" value="Jason" /&gt;
&lt;input name="last_name" type="hidden" value="Anderson" /&gt;
&lt;input name="mc_fee" type="hidden" value="0.02" /&gt;
&lt;input name="address_name" type="hidden" value="Jason Anderson" /&gt;
&lt;input name="notify_version" type="hidden" value="1.6" /&gt;
&lt;input name="payer_status" type="hidden" value="verified" /&gt;
&lt;input name="business" type="hidden" value="paypal@emailaddress.com" /&gt;
&lt;input name="address_country" type="hidden" value="United States" /&gt;
&lt;input name="num_cart_items" type="hidden" value="2" /&gt;
&lt;input name="mc_handling1" type="hidden" value="0.00" /&gt;
&lt;input name="mc_handling2" type="hidden" value="0.00" /&gt;
&lt;input name="address_city" type="hidden" value="Los Angeles" /&gt;
&lt;input name="verify_sign" type="hidden" value="AlUbUcinRR5pIo2KwP4xjo9OxxHMAi6.s6AES.4Z6C65yv1Ob2eNqrHm" /&gt;
&lt;input name="mc_shipping1" type="hidden" value="0.00" /&gt;
&lt;input name="mc_shipping2" type="hidden" value="0.00" /&gt;
&lt;input name="tax1" type="hidden" value="0.00" /&gt;
&lt;input name="tax2" type="hidden" value="0.00" /&gt;
&lt;input name="txn_id" type="hidden" value="TESTER" /&gt;
&lt;input name="payment_type" type="hidden" value="instant" /&gt;
&lt;input name="last_name=Borduin" type="hidden" /&gt;
&lt;input name="payer_email" type="hidden" value="test@domain.com" /&gt;
&lt;input name="item_name1" type="hidden" value="Rubber+clog" /&gt;
&lt;input name="address_state" type="hidden" value="CA" /&gt;
&lt;input name="payment_fee" type="hidden" value="0.02" /&gt;
&lt;input name="item_name2" type="hidden" value="Roman sandal" /&gt;
&lt;input name="invoice" type="hidden" value="123456" /&gt;
&lt;input name="quantity" type="hidden" value="1" /&gt;
&lt;input name="quantity1" type="hidden" value="1" /&gt;
&lt;input name="receiver_id" type="hidden" value="5HRS8SCK9NSJ2" /&gt;
&lt;input name="quantity2" type="hidden" value="1" /&gt;
&lt;input name="txn_type" type="hidden" value="web_accept" /&gt;
&lt;input name="mc_gross_1" type="hidden" value="0.01" /&gt;
&lt;input name="mc_currency" type="hidden" value="USD" /&gt;
&lt;input name="mc_gross_2" type="hidden" value="0.01" /&gt;
&lt;input name="payment_gross" type="hidden" value="0.02" /&gt;
&lt;input name="subscr_id" type="hidden" value="PP-1234" /&gt;
&lt;input name="test" type="submit" value="test" /&gt;
&lt;/form&gt;
</code></pre>

<p><strong>MY IPN handler File</strong>
zPaypalTest.asp</p>

<pre><code>                &lt;%@  language="VBScript" %&gt;
            &lt;%
            Dim Item_name, Item_number, Payment_status, Payment_amount
            Dim Txn_id, Receiver_email, Payer_email
            Dim objHttp, str
            DIM ApplicationRootPath
            ApplicationRootPath = Request.ServerVariables("APPL_PHYSICAL_PATH") 


            ' read post from PayPal system and add 'cmd'
            str = Request.Form&amp; "&amp;cmd=_notify-validate"

            ' post back to PayPal system to validate
            set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
            'Set objHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
            ' set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP.4.0")
            'set objHttp = Server.CreateObject("Microsoft.XMLHTTP")
            'objHttp.open "POST", "https://www.paypal.com/cgi-bin/webscr", false
            objHttp.open "POST", "https://www.sandbox.paypal.com/cgi-bin/webscr", false
            'objHttp.open "POST", "https://www.sandbox.paypal.com/cgi-bin/webscr", false
            'Send response message back to paypal'

            'objHttp.open "POST", "https://ipnpb.paypal.com/cgi-bin/webscr", false
            'objHttp.open "POST", "https://ipnpb.sandbox.paypal.com/cgi-bin/webscr", false

            Response.write "IPN-Sand"
            Response.write "&lt;br/&gt;"

            objHttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
            objHttp.Send str

            Response.write objHttp.status

            if (objHttp.status &lt;&gt; 200 ) then
            ' HTTP error handling
            elseif (objHttp.responseText = "VERIFIED") then
            Response.write "VERIFIED"
            elseif (objHttp.responseText = "INVALID") then
            Response.write "INVALID"
            else
            Response.write "ERROR"

            end if
            set objHttp = nothing
            %&gt;
</code></pre>

<p>Above is the example file.
Here is the code sample that i used. <a href="https://github.com/paypal/ipn-code-samples" rel="nofollow">https://github.com/paypal/ipn-code-samples</a></p>

<p>I test it on localhost IIS and it work fine there too.
So only problem is when i use , </p>

<pre><code>objHttp.open "POST", "https://www.sandbox.paypal.com/cgi-bin/webscr", false
</code></pre>

<p>OR</p>

<pre><code>objHttp.open "POST", "https://ipnpb.sandbox.paypal.com/cgi-bin/webscr", false
</code></pre>

<p>I get 500 server error and this 500 server is only on my server that runs both in http or https, but in localhost IIS it works.
Also 
If i change that url to live url</p>

<pre><code>objHttp.open "POST", "https://www.paypal.com/cgi-bin/webscr", false
</code></pre>

<p>OR</p>

<pre><code>objHttp.open "POST", "https://ipnpb.paypal.com/cgi-bin/webscr", false
</code></pre>

<p>It works.</p>

<p>If i just browse that page in my browser in my server i.e <a href="https://myserver.com/zPaypalTest.asp" rel="nofollow">https://myserver.com/zPaypalTest.asp</a>, it gives error when using sandbox url only.</p>

<p>I am not able to think what is the error here. Why it gives 500 error.</p>

<p>I will be very thankful if any one could give me any clue what's wrong.</p>