【发布时间】:2017-10-25 13:13:01
【问题描述】:
我已经建立了一个基本的 webhook php 页面,它以条带文档为模型,并在下面列出。当我从 Stripe webhook 仪表板发送测试事件时,stripe 以空白响应响应“测试 webhook 发送成功”。但是,没有写入输出日志文件,没有发送电子邮件,也没有任何内容记录到 http 服务器错误日志或 php 错误日志中。我的 php 版本是 5.3.3。我做错了什么?
<?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("mike@example.com","Cannot write to webhook.log","");
echo "Cannot write to webhook.log";
exit;
}
mail('mike@example.com','Webhook Event',$event_json);
header(':', true, 200);
//http_response_code(200); // PHP 5.4 or greater
?>
【问题讨论】:
标签: php stripe-payments webhooks