Solved

IPN online payments setup with sample form

Posted on 2011-03-11
3
414 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
  • 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
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 …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

747 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