Managing PayPal IPN calls via a Workflow (PHP + testing via ngrok)

Hi All
Prefer not to resort to custom PHP so before i try, anyone got a sample Wappler API based IPN handler they would be prepared to share (yes, that is very lazy of me) for confirmation of payment transactions?
Customer specifies PHP and PayPal so not got a lot of flexibility.

Thanks
Brian

2 Likes

i might just also revert to just using php .....

maybe this will help if you cant get the API in Wappler going

Thanks Mozzi
Put API idea on hold, guess it’s going to have to be a custom module but I have other priorities

This turned out to be really easy.

Firstly take the sample code from github

and save it into a file unchanged. In this case i created a folder called IPN and called the file ipn.php

image

NOTE at this stage i am running through ngrok as the PayPal IPN simulator does not work with localhost. You could simply deploy to Production and use the production URL for the page and test live

I then create an API action and call the php page via an API call

As the IPN call is effectively just a validation/ handshake no inputs or outputs are required; what the call does is return all the required data via PPOST variables. Calling this API call populates these variables.
I create just two for demo purposes.

image

All the fields which can be used are listed in the PayPal IPN documents
I can then access those POST variables within a database action

so i have a simple table
image
and a database insert

I then go to the IPN simulator in the PayPal developers site and add the ngrok address pointing to the API action (don’t forget Localhost won’t work!)

Click send

image

You should see the confirmation at the top of the page

and the data should be added to your database table


Once testing is completed your production web address should be substituted for the ngrok address in the API action and on PayPal

I have not added validation to keep things simple but the IPN returns a field payment_status which returns the state of the transaction

image
In production this his should be checked immediately after the API call before processing the data returned.

Will post a Node version tomorrow which is even simple by using a custom module

3 Likes