Log in

View Full Version : how to do a IPN?



VistaBoy
04-08-2007, 03:52 AM
Hello can some one tell me how to make a php paypal IPN like say they pay x money and it will update a table in my database like or insert a row to a table if you know what i mean?

Baving
04-08-2007, 09:26 AM
Use paypal api

VistaBoy
04-08-2007, 09:34 AM
Okay as i do not know what paypal api and some one told me it good to use IPN for what i want. so can some one help.

Etusivu
08-08-2007, 10:04 AM
I would also consider using PDT as well. Does this help you out? (http://paypal.lithium.com/pdn/board/message?board.id=basicpayments&message.id=368)

RichardKnox
08-08-2007, 11:19 AM
Code one or get a verified account and get a paypal API from th paypal sie (only verified accounts).

VistaBoy
11-08-2007, 11:53 AM
okay i am so lost now as you all say APi , PDT and all so ill ask i just want a script that will like say you pay money and it will like add data to a mysql data base like points or some thing now can i do that?

Invent
11-08-2007, 04:40 PM
IPN is the service. API is the download-able script to make your site interact with PayPal.

VistaBoy
12-08-2007, 12:13 AM
would some thing like this work


<?php
$conn = mysql_connect("****","****","*****");
mysql_select_db(******) or die(mysql_error());
$req = 'cmd=_notify-validate';

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

$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 ('www.sandbox.paypal.com', 80, $errno, $errstr, 30);

$item_name = test
$payment_status = complete
$payment_amount = 1.00
$payment_currency = USD
$receiver_email = *****************
$payer_email = ************************
if (!$fp) {
echo "There was a problem connecting to the IPN server, check your port status.";
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
if ($payment_status != "completed") or ($receiver_email != "[email protected]") or ($payment_amount != "payment amount here")
{
echo "No paying";
}
else
{
mysql_query("INSERT INTO `goods` (`username`, `key`, `downloadlink`) VALUES('hello', '55453234', 'http://blah.zip')") or die(mysql_error());
}
}
else if (strcmp ($res, "INVALID") == 0) {
echo ('oh well');
}
}
fclose ($fp);
}
?>

Want to hide these adverts? Register an account for free!