我想從PayPal獲得IPN工作,但它不斷返回INVALID
而不是VERIFIED
,我看不到我做錯了什麼。PayPal IPN不返回驗證
目前,我有2個PHP文件使用貝寶開發人員網站的示例代碼。代碼似乎運行良好,我使用,所以我可以看到付款被轉移,所以我不明白爲什麼我得到INVALID
。
有人可以看看代碼,因爲我看不到我做錯了什麼。
1. basic_payment.php(在該付款數據發送到貝寶文件)
<?php require_once ("paypalplatform.php"); $actionType = "PAY"; $cancelUrl = "http://[my server details go here]/cancel.php"; $returnUrl = "http://[my server details go here]/success.php"; $currencyCode = "GBP"; $receiverEmailArray = array('[email protected]'); $receiverAmountArray = array('2'); $receiverPrimaryArray = array(); $senderEmail = ""; $feesPayer = ""; $ipnNotificationUrl = "http://[my server details go here]/ipn.php"; $memo = ""; $pin = ""; $preapprovalKey = ""; $reverseAllParallelPaymentsOnError = ""; $trackingId = generateTrackingID(); $receiverInvoiceIdArray = array($trackingId); $resArray = CallPay ($actionType, $cancelUrl, $returnUrl, $currencyCode, $receiverEmailArray, $receiverAmountArray, $receiverPrimaryArray, $receiverInvoiceIdArray, $feesPayer, $ipnNotificationUrl, $memo, $pin, $preapprovalKey, $reverseAllParallelPaymentsOnError, $senderEmail, $trackingId ); $ack = strtoupper($resArray["responseEnvelope.ack"]); if($ack=="SUCCESS") { if ("" == $preapprovalKey) { $cmd = "cmd=_ap-payment&paykey=" . urldecode($resArray["payKey"]); RedirectToPayPal ($cmd); } else { $payKey = urldecode($resArray["payKey"]); $paymentExecStatus = urldecode($resArray["paymentExecStatus"]); } } ?>
2. ipn.php(其偵聽paypals響應該文件)
個<?php $ipn_post_data = $_POST; $url = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; $request = curl_init(); curl_setopt_array($request, array ( CURLOPT_URL => $url, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => http_build_query(array('cmd' => '_notify-validate') + $ipn_post_data), CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_HEADER => FALSE, )); $response = curl_exec($request); $status = curl_getinfo($request, CURLINFO_HTTP_CODE); curl_close($request); $to = "[email protected]"; $from = "[email protected]"; $subject = "response"; $message = "<pre>".print_r($status,true)." - ".print_r($response,true)."</pre>\n"; $header = 'To: Oshirowanen <[email protected]>' . "\r\n"; $header .= 'From: Me <[email protected]>' . "\r\n"; mail($to,$subject,$message,$header); ?>
錯誤消息:
Apache的錯誤日誌 - 沒有錯誤
這就是爲什麼我在ipn.php增加了電子郵件的東西,儘量爭取什麼,它返回:
<pre>200 - INVALID</pre>
任何人都可以看到我做錯了什麼?
PayPal API是否有一個地方告訴你它發送給服務器的內容?我們可以看到這些數據嗎? – David 2012-08-12 20:16:33
@大衛,我已經添加了你請求的代碼。 – oshirowanen 2012-08-12 20:38:31
我已經更新了這個問題,希望能夠更容易理解。 – oshirowanen 2012-08-13 12:19:00