Jump to content


Photo

responding to paypal to terminate re-posts


  • This topic is locked This topic is locked
5 replies to this topic

#1 nathaned

nathaned

    Member

  • Members
  • PipPip
  • 15 posts

Posted 16 November 2002 - 08:17 PM

Besides - PayPal's IPN system re-posts to your script after 1 second, then 2 seconds, 4 seconds, 8 seconds, etc., (up to a 4 hour duration), until we receive a basic HTTP "200 OK" response from your web server or 1.5 days have passed since the initial post.

How do I get paypal's server to receive a basic HTTP "200 OK" response?

I tried updating a table with the txn_id and if it already exists than don't process but there must be another way.... please help.
Nathan

#2 DaveC

DaveC

    Advanced Member

  • Members
  • PipPipPip
  • 37 posts

Posted 17 November 2002 - 11:46 AM

You don't get paypals server to receive a 200 response. A 200 response is the normal page OK message under the HTTP protocol. If the page was not there, a 404 response would be sent.

If the page is there, and the page is OK, a 200 response will be sent (unless you have problems with the page, for example a server error (response is 500) or authentication error etc.

All you have to do is have the page there, let paypal get its response, then you handle the details of your transaction within your page.

Web development - http://www.revilloc.com

#3 Guest(old)

Guest(old)

    Junior Member

  • Members
  • 312 posts

Posted 17 November 2002 - 05:37 PM

That's my understanding but for some reason I receive all the information and do my stuff with it but it keeps sending the information over and over. The page is there. Any ideas? Here is a slimmed down version of my scipt if it helps...

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/connstore.asp" -->

<%

Dim Item_ID 'variable passed back by PayPal


'read post from PayPal system and add 'cmd'
str = Request.Form
Item_ID = Request.Form("Item_Number1")
Payment_status = Request.Form("payment_status")

' Post back to PayPal system to validate
str = str & "&cmd=_notify-validate"
set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP.4.0")
objHttp.open "POST", "https://www.paypal.com/cgi-bin/webscr", false
objHttp.Send str

' Check notification validation
If (Item_ID <> "") then
if (objHttp.status <> 200 ) then
response.Redirect("pagenotavail.htm")
'check to see if it was a purchase made through www.rrrtifax.com
elseif (Payment_status = "PENDING") then
set Cm = Server.CreateObject("ADODB.Command")
Cm.ActiveConnection = MM_connStore_STRING
Cm.CommandText = "UPDATE tblProducts SET SoldFlag = true WHERE Item_ID = '" & Item_ID & "'"
Cm.CommandType = 1
Cm.Execute
response.Redirect("thankyou.htm")
elseif (Payment_status = "FAILED") then
response.Redirect("statusfailed.htm")
elseIf (objHttp.responseText <> "VERIFIED" and Payment_status = "COMPLETED") then


'update the item to sold after a confirmation from paypal
set Cm = Server.CreateObject("ADODB.Command")
Cm.ActiveConnection = MM_connStore_STRING
Cm.CommandText = "UPDATE tblProducts SET SoldFlag = true WHERE Item_ID = '" & Item_ID & "'"
Cm.CommandType = 1
Cm.Execute


'We end the insert into our database table
End If
End If
response.Redirect("thankyou.htm")%>

Nathan

#4 DaveC

DaveC

    Advanced Member

  • Members
  • PipPipPip
  • 37 posts

Posted 18 November 2002 - 04:21 AM

May I suggest that you put a condition around your "post back to system" segment of your code, so that you can run it by hand.

If you have an error on your page, a 200 will not be sent.

The way I handled it is to put an

doit = false
if doit then
do the objhttp stuff
end if

(also change the objHTTP.status line)

then, in your test payment button, set the return url to your IPN script. Go through the motions and you should see the result (or error).

You can of course create a test script to test your own IPN script. I believe there is a thread elsewhere here with a test IPN system.

Web development - http://www.revilloc.com

#5 paypal_pb

paypal_pb

    Advanced Member

  • Members
  • 2,960 posts

Posted 18 November 2002 - 11:13 AM

This line might be causing an error:

Item_ID = Request.Form("Item_Number1")

If you are using Single Item Purchase, it should be:

Item_ID = Request.Form("item_number")

If you are using Shopping Cart it should be:

Item_ID = Request.Form("item_number1")



Patrick Breitenbach
PayPal, Inc.
Dev Net: https://www.paypal.com/pdn

#6 nathaned

nathaned

    Member

  • Members
  • PipPip
  • 15 posts

Posted 20 November 2002 - 12:56 PM

I figured it out, since my code containes a response.redirect, PayPal's server gets a http status at a 300 level not a 200. Took out the redirect and it works.
Nathan




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users