我已經包括了我想在這裏測試,但因爲我是新來的貝寶,我不知道如何調試貝寶爲例,沙箱,則幫助我,所以儘管:(貝寶噩夢
它看起來像付款已經被處理和接受,我現在要做的就是更新mysql表格,就在"if($payment_amount==10.00&&$payment_currency=='GBP'){"
之下的標記下面的行上。我已經在phpmyadmin上測試了我的mysql,它的作用就像一個魅力,它只是其他的東西可能是錯誤的這裏:(
PayPal按鈕
<form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
<input type="hidden" name="cmd" value="_xclick-subscriptions" />
<input type="hidden" name="business" value="[email]" />
<input type="hidden" name="item_name" value="New Subscription" />
<input type="hidden" name="first_name" value="<?php echo $arr['user']['fname']; ?>" />
<input type="hidden" name="last_name" value="<?php echo $arr['user']['lname']; ?>" />
<input type="hidden" name="address1" value="<?php echo $arr['user']['add1']; ?>" />
<input type="hidden" name="address2" value="<?php echo $arr['user']['add2']; ?>" />
<input type="hidden" name="city" value="<?php echo $arr['user']['town']; ?>" />
<input type="hidden" name="zip" value="<?php echo $arr['user']['postcode']; ?>" />
<input type="hidden" name="email" value="[client_email]" />
<input type="hidden" name="currency_code" value="GBP" />
<input type="hidden" name="no_shipping" value="1" />
<input type="image" src="http://www.paypal.com/en_US/i/btn/btn_subscribe_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" />
<input type="hidden" name="recurring" value="1" />
<input type="hidden" name="a3" value="10.00" />
<input type="hidden" name="p3" value="1" />
<input type="hidden" name="t3" value="Y" />
<input type="hidden" name="src" value="1" />
<input type="hidden" name="sra" value="1" />
<input type="hidden" name="item_number" value="<?php echo $arr['user']['id'] ?>" />
<input type="hidden" name="return" value="<?php echo site_url.'account/' ?>" />
<input type="hidden" name="cancel_return" value="<?php echo site_url.'account/' ?>" />
<input type="hidden" name="notify_url" value="<?php echo site_url.'account/ipn.php' ?>" />
</form>
貝寶IPN處理程序
<?php
// UPDATED LINE BELOW
mail("[myemail]", "PP",'initiated', "From:sup[email protected]");
// 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";
}
// 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.paypal.com', 443, $errno, $errstr, 30);
// $fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
$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'];
$business = $_POST['business'];
$payer_email = $_POST['payer_email'];
// $payer_email = $_POST['payer_email'];
if (!$fp) {
// echo 'Error 101 23';
// die();
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
$data['paypal_receivers_email'] = '[email]';
if($payment_status=='Completed' && $receiver_email == $data['paypal_receivers_email'] &&$receiver_email){
if($payment_amount==10.00&&$payment_currency=='GBP'){
//successfully// now update db :)// <== this is where im strugling it does not seem to come down here at all.
}
}
// 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
}
}
fclose ($fp);
}
?>
我認爲沙盒包含一個日誌/調試功能,我記得在那裏看到,但不是很確定,你可以檢查。還要檢查要調試的電子郵件是否在另一個頁面上工作,甚至可能更好地嘗試使用file_put_contents登錄文件,然後檢查日誌,有時電子郵件會轉到批量文件夾,您不希望被旁邊的問題分散注意力。 –