条带-“发送测试Webhook”有效,但未登录“ Webhook尝试”列表中

时间:2019-03-28 16:12:14

标签: php stripe-payments webhooks

我正在使用Stripe API和webhooks将付款链接到我的网站。我在https://mywebsite.com/hook.php有一个webhook侦听器。当我通过Stripe开发人员仪表板发送测试Webhook时,收到了预期的hello world响应。

enter image description here

但是,在我的Webhook尝试列表中,未记录此请求(此请求在此列表中的最后一个请求之后约2小时发送。

enter image description here

这是我的PHP Webhook代码:

<?php 

error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once('/var/www/html/vendor/autoload.php');

\Stripe\Stripe::setApiKey("sk_test_CHANGEDFORTHISSOQUESTION"); //test

// Retrieve the request's body and parse it as JSON
$payload = @file_get_contents("php://input");

// Return a response to acknowledge receipt of the event
http_response_code(200);
echo("hello world");
$endpoint_secret = "whsec_CHANGEDFORTHISSOQUESTION"; //test
$sig_header = $_SERVER["HTTP_STRIPE_SIGNATURE"];
$event = null;

try {
  $event = \Stripe\Webhook::constructEvent(
    $payload, $sig_header, $endpoint_secret
  );

    // Do something with $event_json

} catch(\UnexpectedValueException $e) {
  // Invalid payload
  http_response_code(400); // PHP 5.4 or greater
  exit();
} catch(\Stripe\Error\SignatureVerification $e) {
  // Invalid signature
  http_response_code(400); // PHP 5.4 or greater
  exit();
}

0 个答案:

没有答案
相关问题