N
nick
Guest
Hey guys. Here is the code for paypal IPN thing.
checkout.php
Now for the IPN script:
notify.php
Enjoy and have fun.
checkout.php
PHP:
<?php
include("Includes/functions.php");
$dbc = dbconnect();
$pageid = $QUERY_STRING;
if ($QUERY_STRING == "")
{
$pageid = 1;
}
$arr = explode("x", $pageid);
$hid = $arr[0];
$catid = $arr[1];
$site_url = "http://www.hehehahahaha.com";
$order_total = 10;
$order_total = number_format($order_total, 2, ".", ",");
$order_id = "$hid" . "x" . "$catid";
$r = mysql_query("Select * from tblhost WHERE HID = '$hid'");
while ( $row = mysql_fetch_array ( $r ) )
{
$my_sFirstName = $row['User'];
$my_sLastName = $row['User'];
$hemail = $row['Email'];
$hname = $row['Host'];
}
$my_clientEmail = $hemail;
$business_paypal = "xxxxx@xxxxx.com";
$currency_id = "USD";
$sdate = time();
$r = mysql_query("INSERT INTO tblsponser (HID, CID, Sdate) VALUES ('$hid', '$catid', '$sdate')");
//redirect to paypal
header("location:https://www.paypal.com/xclick?business=$business_paypal&item_name=$hname$order_id&first_name=$my_sFirstName&last_name=$my_sLastName&email=$my_clientEmail&item_number=1&custom=$hid&amount=$order_total¤cy_code=$currency_id¬ify_url=$site_url/notify.php&return=$site_url/thankyou.php");
?>
Now for the IPN script:
notify.php
PHP:
<?php
// Assign posted variables to local variables
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
$payer_status = $_POST['payer_status'];
$payment_gross = $_POST['payment_gross'];
$payment_fee = $_POST['payment_fee'];
$payment_date = $_POST['payment_date'];
$payment_type = $_POST['payment_type'];
$payment_status = $_POST['payment_status'];
$pending_reason = $_POST['pending_reason'];
$txn_id = $_POST['txn_id'];
$txn_type = $_POST['txn_type'];
$custom = $_POST['custom'];
if ($_REQUEST['payment_status'] == "Completed" || $_REQUEST['payment_status'] == "Pending") {
//Query for the payment recieved
include("Includes/functions.php");
$dbc = dbconnect();
$hid = $custom;
$r = mysql_query("Update tblsponser SET Payment = 'Y' WHERE HID = '$hid'");
////////////////////////////////////////
}
?>
Enjoy and have fun.