Jump to content

Paypal payment integration into booking form


malkocoglu

Recommended Posts

Hello everyone,

 

I have been  searching on internet about using paypal payment for a minicab booking form  I havebut I couldnt find anything that I could use.

 

What I have;

 

The visitor comes to website and start completing the form. They get a price on the second page and the third page is the process page. The data goes to database and customer gets an email and the website admin gets the booking form in email.

 

What I want to do;

 

I want to enable paypal payment so visitor can pay for the minicab journey online. I need the get this working in a way that visitor gets the second page and sees the price, clicks Book & Pay by paypal button and visitor is redirected to paypal for payment, after payment, all the data enters the database (The variables are about 10-15) and customer gets the email and also lands on the success page. If the payment is not successfull then nothing goes to data base and visitor does not get email and visitor then is redirected to cancellation page.

 

I hope I could explained, Could anyone help me how to do it or where I can find the information I needed.

 

Regards

Link to comment
Share on other sites

what you are asking is "how do i do a basic operation" and that is what the documentation is for.

 

you are going to need to have a specific question or problem with some code you have written in order to get help on a php help forum. all you have stated is what you want and in programming, going from what you want to having the code that does that takes programming and effort.

Link to comment
Share on other sites

Ok, I have the follwing code. I inserted mail() functions to check the process of the codes. Emails come up to Section 3 Completed and stops. So there is a little problem with section 4. I think payment status is not Completed but I am not sure how to check that.

 

Could anyone give me his opinion how to go from here?



<?php

ini_set('log_errors', true);
ini_set('error_log', 'ipn_errors.log');

//connect to database
//$error = "Problem connecting";
//mysql_connect('localhost','_prince','getmeout') or die($error);
//mysql_select_db('hmt_cms') or die($error);

mail('email@gmail.com', 'IPN Progress', 'Section 1 Completed');
   

// read the post from PayPal system and add 'cmd'

$req = 'cmd=_notify-validate';

foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}

mail('email@gmail.com', 'IPN Progress', 'Section 2 Completed');

// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);

mail('email@gmail.com', 'IPN Progress', 'Section 3 Completed');

// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];

if (!$fp) {
mail('email@gmail.com', 'IPN Progress', 'IPN Error 1');
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {

if ($payment_status == "Completed")

{
mail('email@gmail.com', 'IPN Progress', 'Section 4 Completed');

if ($payment_amount==0.01 && $payment_currency=="GBP")
{
mail('email@gmail.com', 'IPN Progress', 'Section 5 Completed');
//$update = mysql_query("UPDATE cms SET premium='1' WHERE email='$payer_email'");

}


}


// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment


}
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
mail('email@gmail.com', 'IPN Progress', 'IPN Error 2');
}
}
fclose ($fp);
}
?>
Edited by malkocoglu
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.