NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: ntnewbies on October 18, 2017, 03:03:15 AM
-
Hi friends,
I have look into some paypal threads here and webinar video.
What i can summarize is that:
in the embed of the button, i should put the following :
net.setValue of all the settings
net.Post('https://www.paypal.com/cgi-bin/webscr')
and then in get the result = self.page
Now, when the user press the button in my NetForm procedure, it brings me to the paypal checkout page. over there, the user pay either by credit card or paypal. once they are done with the payment, how do i return back to the form with the result?
because if the payment is accepted, then i allow the user to save the form to become a member.
Those paypal integrator specialist, please shed some light.
Many thanks.
Jason
-
Hi Jason,
You must supply in your passed URL a return page of your design.
I use a memory form for this
'&return=https://www.YourWebsite.com/PaymentSuccessful?Your Identifer Field='
I then call a source procedure with the prototype as (NetWebServerWorker p_Web) this
basically waits 20 seconds for a response from paypal which normally takes about a second.
The response should return back to you an approval code for success or be blank for failure.
Ashley
-
Hi Ashley,
Thanks for the reply.
In the source procedure, i use the code notify-validate to post to trigger IPN.
how do i get the result from IPN? Which variable code to use?
-
Jason,
I had to tell PayPal in there setup what to handler to call. I just named it MyIPN_Handler. It is a NetWebPage. If you need a little example code let me know.
Ashley
-
Hi Ashley,
Thank you for patiently replying me.
Example code would be a great help for newbies like me.
My email: j6face@gmail.com
-
me too, osquiabro@gmail.com
-
yes please
logtimer@yahoo.com
-
me tooo :) frank@jerseysoftware.com
-
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
-
Thank you very much Ashley. Tremendous effort there! Greatly appreciated.
I shall try it and let you know.
Jason