ストライプのドキュメントでモデル化され、以下にリストされているように、基本的なwebhook PHPページをセットアップしました。ストライプwebhooksダッシュボードからテストイベントを送信すると、ストライプはブランク応答で「Test webhook sent successfully」に応答します。ただし、出力ログファイルには書き込まれません。電子メールは送信されず、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
?>
Thank you Conor。おそらく私はブラウザを通してテストし、ロギングと電子メールの両方がうまくいったと述べていたはずです。私はngrokを通してテストし、jsonを受け取りました。 httpとhttpsの両方で、ストライプはテストが成功したと応答します。私はStripeが受け取ったと認めた500のエラーも返しました。私はうんざりしている。 – user1142052