11-02-2010, 10:34 AM
|
#1 (permalink)
|
|
The Visitor
Join Date: Nov 2010
Posts: 1
Thanks: 0
|
Paypal, Payment Standard & IPN
Hi all,
i don't seem to receive the verified status for the below code!
Checkout Page
HTML Code:
<form action='https://www.paypal.com/cgi-bin/webscr' target='_blank' method='post'>
<input type='hidden' name='cmd' value='_cart'>
<input type='hidden' name='upload' value='1'>
<input type='hidden' name='return' value='http://www.xx.com/confirm.php'>
<input type='hidden' name='business' value='xx@xx.com'>
<input type='hidden' name='custom' value='1.141'>
<input type='hidden' name='receipt_id' value='12345'>
<input type='hidden' name='currency_code' value='USD'>
<input type='hidden' name='notify_url' value='http://www.xx.com/confirm.php'>
Confirm Page
PHP Code:
<?php
session_start();
require_once('includes/config/config.inc.php');
$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 ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
$custom = $_POST['custom'];
$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'];
$receipt_id = $_POST['receipt_id'];
if (!$fp){
//Message
}else{
fputs ($fp, $header . $req);
while (!feof($fp)){
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0){
$Itemid = explode(",", $custom);
$size_counter_array = sizeof($Itemid);
foreach($Itemid as $item_new){
$count_len = substr_count($item_new, '.');
list($items_quantity, $item_product_id) = split('[.]', $item_new);
)$QuerySuccess = (bool)@mysql_query("UPDATE store set quantity=(quantity - $items_quantity) WHERE id='".$item_product_id."'");
if(QuerySuccess) echo "Success";
}
}
}else if (strcmp ($res, "INVALID") == 0){
//echo 2;
}
}
fclose ($fp);
setcookie($receipt_id,"", time()-60, "/");
}
?>
Thanks.
|
|
|
|