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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP/Magento not logging 2 33
Make an ajax call ithat alters url and updates a listview in 1 19
how to use a function in heredoc 5 21
Session timeout 5 13
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

914 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now