NetTalk Central

Author Topic: Paypal Button  (Read 4441 times)

ntnewbies

  • Full Member
  • ***
  • Posts: 169
    • View Profile
    • Email
Paypal Button
« 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

astahl

  • Sr. Member
  • ****
  • Posts: 308
    • View Profile
    • Email
Re: Paypal Button
« Reply #1 on: October 24, 2017, 03:14:10 AM »
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


ntnewbies

  • Full Member
  • ***
  • Posts: 169
    • View Profile
    • Email
Re: Paypal Button
« Reply #2 on: October 24, 2017, 11:22:59 PM »
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?

astahl

  • Sr. Member
  • ****
  • Posts: 308
    • View Profile
    • Email
Re: Paypal Button
« Reply #3 on: October 25, 2017, 09:08:46 AM »
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

ntnewbies

  • Full Member
  • ***
  • Posts: 169
    • View Profile
    • Email
Re: Paypal Button
« Reply #4 on: October 25, 2017, 06:38:02 PM »
Hi Ashley,
Thank you for patiently replying me.
Example code would be a great help for newbies like me.
My email: j6face@gmail.com

osquiabro

  • Hero Member
  • *****
  • Posts: 668
    • View Profile
    • Email
Re: Paypal Button
« Reply #5 on: October 26, 2017, 02:52:22 AM »
me too, osquiabro@gmail.com

Richard I

  • Sr. Member
  • ****
  • Posts: 381
    • View Profile
    • Email
Re: Paypal Button
« Reply #6 on: October 28, 2017, 12:18:42 AM »
yes please
logtimer@yahoo.com

frankacosta

  • Newbie
  • *
  • Posts: 21
    • View Profile
    • Email
Re: Paypal Button
« Reply #7 on: October 29, 2017, 10:44:09 AM »
me tooo :)  frank@jerseysoftware.com

astahl

  • Sr. Member
  • ****
  • Posts: 308
    • View Profile
    • Email
Re: Paypal Button
« Reply #8 on: October 30, 2017, 06:50:23 AM »
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

ntnewbies

  • Full Member
  • ***
  • Posts: 169
    • View Profile
    • Email
Re: Paypal Button
« Reply #9 on: October 30, 2017, 06:10:32 PM »
Thank you very much Ashley. Tremendous effort there! Greatly appreciated.
I shall try it and let you know.


Jason