Solved

IPN online payments setup with sample form

Posted on 2011-03-11
3
431 Views
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
0
Comment
Question by:Mark Brady
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
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: 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:
https://cms.paypal.com/cms_content/US/en_US/files/developer/IPNGuide.pdf

Here are the code samples:
https://cms.paypal.com/cgi-bin/marketingweb?cmd=_render-content&content_ID=developer/library_code_ipn_code_samples
0
 
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 !
0
 
LVL 20

Author Closing Comment

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

Featured Post

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

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

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
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…
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.

635 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