Ok, let's give it a try.
Create a NetWebPage in your app, this will be called when PP has processed your request.
In Local Data I put these variables;
loc:poststr STRING(10000)
workstr STRING(10000)
workline STRING(120)
strlen LONG
MyQ QUEUE
ValueName STRING(40)
ActualValue STRING(40)
END
In your NetWebPage IPN Handler that you setup in PP, in the "Before Header" embed I put this code;
loc:poststr = p_web.RequestData.DataString
DO GetData !See below Routine
IF RECORDS(MyQ) THEN
IF p_web.GetValue('payment_status') <> 'Completed' THEN
DO SomeRoutine !here I add the data to a IPN SQL log file
!I then fetch the record I want to update to mark as payment rejected
ELSE
DO SomeRoutine !here I add the data to a IPN SQL log file
!I then fetch the record I want to update to mark as payment paid
!using the 'item_number' that I sent to pay PP
CLEAR(pro:Record)
pro:job_id = p_web.GetValue('item_number')
IF NOT Access:myproduction.Fetch(pro:PRIMARY) THEN
pro:order_completed = 1
pro:approval_code = p_web.GetValue('txn_id')
pro:order_paid = 1
pro:amount_paid = p_web.GetValue('mc_gross')
Access:myproduction.Update()
END
END
END
GetData ROUTINE
DATA
ST StringTheory
x LONG
CODE
FREE(MyQ)
ST.SetValue(loc:poststr)
ST.Split('<13,10>')
ST.RemoveLines()
LOOP x = 1 TO ST.Records()
workstr = ST.GetLine(x)
IF INSTRING('mc_gross',CLIP(workstr),1,1) THEN
ST.SetValue(workstr)
strlen = 0
ST.Split('&')
ST.RemoveLines()
LOOP x = 1 TO ST.Records()
workline = ST.GetLine(x)
strlen = 0
strlen = ST.Instring('=') !INSTRING('=',CLIP(workline),1,1)
IF strlen THEN
MyQ.ValueName = workline[1: strlen - 1]
MyQ.ActualValue = workline[strlen + 1, LEN(CLIP(workline))]
ADD(MyQ)
END
END
SORT(MyQ,+MyQ.ValueName)
ST.FreeLines()
LOOP x = 1 TO RECORDS(MyQ)
GET(MyQ,x)
p_web.SetValue('<39>'&CLIP(MyQ.ValueName)&'<39>',CLIP(MyQ.ActualValue))
END
ELSE
IF x = ST.Records() THEN
loc:poststr = CLIP(loc:poststr) & '&cmd=_notify-validate'
END
END
END
EXIT
Hope this helps it took me about a 2 weeks to get this right.
Ashley