IPN online payments setup with sample form

Posted on 2011-03-11
Last Modified: 2013-12-13
Hi Experts
I have created a website and need to enable online payments. I have a development account with my clients payments company ( I have a form (vouchers.php) attached that I use ajax to send to a processing page to insert into the DB and send an email of the purchase. This works good. At the moment it returns a response via ajax and the customer gets a message on the form. Now, I have a sample form with the code (php) to redirect to a secure payments page. The customer makes the payment and the sample form should get back a success or decline response (like most IPN). My problem is I don't know where to put the sample code and at what point in the chain.

Currently I have the real form and my processing script. I am guessing that the sample code in the sample form should be placed in my real form and that should then go to payments page to make payment. I then need the information along with the payment response to go to my processing page (voucher-process_DEV.php) so I can continue with the whole process (send email and register the sale in the DB).

Can someone help me with getting the right code from the sample form and modifying my actual form (vouchers.php) to complete this entire process? I am lost trying to do it although I wrote all the scripts for the website, this payments stuff is losing me.

I have attached the files
1: vouchers.php // this is my real form. Processed via ajax call.
2: vouchers.js // my javascript functions that process that page. The function that sends the form is "submitform()"
3: voucher-process_DEV.php // this is the final processing script after the payment has been made
4: PxPay_Sample_Curl.php // a sample form with the code to process the payment and get the response
5: // this file is required and has the classes for the PxPay_Sample_Curl.php file

If someone could put the code required inside the sample form in the right place on my form and help set this up it would save me from standing on the freeway and waiting for a big truck to run me over so I don't have to deal with this age old problem any more. 3 Weeks I have been reading their literature on how to do this and I just don't quite get it. Please someone help me with this. I will be eternally greatfull. Will ajax still be able to be used for this or will I need to send it the old fashion way?
 PxPay-Sample-Curl.php vouchers.js vouchers.php voucher-process-DEV.php
Question by:Mark Brady
  • 2
LVL 12

Accepted Solution

jet-black earned 500 total points
ID: 36509560
Hi elvin66,

Actually I don't think the usage of Ajax will affect the code.

The basic is simple:
When your client made a payment, Paypal send the $_POST data to the page which you set (ex:
Using this info, your script will post back this data to Paypal (it is required for the security), then Paypal will send you more info about the transaction.

Read this for the more info:

Here are the code samples:
LVL 20

Author Comment

by:Mark Brady
ID: 36526552
Jet-black I am so sorry I did not respond to you ages ago. I completely forgot about this issue. I ended up getting their sample code to work but took me about two weeks of pulling my hair out and they offered zero assistance. In any case, it is different to the way Paypal setup their IPN code and the method is different slightly.

What happens is there is a class in the script that holds all the information but the only thing I used is the amount to send to their server for processing. Their server processes the payment and sends back and encrypted reply (the return URL is the same form that sent it to them) and they append the URL with their result encrypted like " encoded"

The form then decodes their response and looks for a "1" for success and "0" for failure and from there I was able to process the booking or purchase. A lot of mucking around but I eventually got it to work.

The interesting thing is that when they sent back their response they did not expect my script to send anything back to them for verification.

They are a major online credit card company over here in New Zealand so they must be following the law. It all works so thanks for your comments and sorry again for ignoring them !
LVL 20

Author Closing Comment

by:Mark Brady
ID: 37010103
Thanks I posted how I got it to work but thanks for your suggestions.

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question