Go Premium for a chance to win a PS4. Enter to Win


IPN online payments setup with sample form

Posted on 2011-03-11
Medium Priority
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 (http://www.paymentexpress.com/). 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: PxPay_Curl.inc.php // 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 PxPay-Curl.inc.php vouchers.js vouchers.php voucher-process-DEV.php
Question by:Mark Brady
  • 2
LVL 12

Accepted Solution

jet-black earned 2000 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: http://www.yourdomain.com/your_ipn_script.php).
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 "www.mysite.com/myForm.php?result=blahblahblah 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
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…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

877 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