条纹webhook account.updated不起作用

时间:2017-09-15 23:52:55

标签: php stripe-payments

我正在尝试发送(简单测试)电子邮件,当我收到来自Stripe API的自定义帐户的account.updated调用。我的其他webhooks创建收费并告知客户这样的成功或失败的收费工作,但在这里我得到一个错误500(我可以在自定义帐户的仪表板中看到)并且邮件没有发送,所以我不确定我在这做错了什么。我的代码如下所示:

<?php

require_once('vendor/autoload.php');

// 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
\Stripe\Stripe::setApiKey("sk_test_XXXX");

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

// Verify the event by fetching it from Stripe
$event = \Stripe\Event::retrieve($event_json->id);

// Do something with $event
if ($event->type == 'account.updated') {

// The E-Mail message to send to inform about a succeeded charge
$message = 'test';

// Send the E-Mail
mail('test@example.com', 'We need more info about you!', $message);

}

http_response_code(200); // PHP 5.4 or greater

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

如果您查看自己的网络服务器error.log(通常可从您的托管控制面板或/var/log/访问),您是否会看到有关导致500的原因的详细信息?

可能$event = \Stripe\Event::retrieve($event_json->id);失败吗?

如果事件直接在已关联的帐户中发生,您可能还需要传递account ID才能检索它。

请参阅此处了解更多背景信息, https://stripe.com/docs/connect/webhooks

代码更像是:

$event = \Stripe\Event::retrieve(
array("id" => $event_json->id),
array("stripe_account" => $event_json->account));

https://stripe.com/docs/connect/authentication#authentication-via-the-stripe-account-header