我已經設置了一個基本的webhook php頁面,仿照條紋文檔和下面列出。當我從Stripe webhooks儀表板發送測試事件時,條帶響應「測試webhook發送成功」並帶有空白迴應。但是,輸出日誌文件沒有寫入,沒有發送電子郵件,也沒有任何記錄到http服務器錯誤日誌或php錯誤日誌。我的PHP版本是5.3.3。我究竟做錯了什麼?php webhook沒有響應條紋測試事件
<?php
error_reporting(15);
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
require_once('vendor/autoload.php');
\Stripe\Stripe::setApiKey("secret_test_key");
$handle = fopen("webhook.log","a");
// Retrieve the request's body and parse it as JSON
$input = file_get_contents("php://input");
$event_json = json_decode($input);
// Do something with $event_json
if (fwrite($handle, $event_json) === FALSE) {
mail("[email protected]","Cannot write to webhook.log","");
echo "Cannot write to webhook.log";
exit;
}
mail('[email protected]','Webhook Event',$event_json);
header(':', true, 200);
//http_response_code(200); // PHP 5.4 or greater
?>
謝謝Conor。我也許應該提到我已經通過瀏覽器進行測試,並且日誌和電子郵件都可以工作。我也通過ngrok進行了測試並收到了json。使用http和https,條帶響應該測試成功。我還返回了一個條帶確認收到的500錯誤。我很困惑。 – user1142052