[英]stripe webhook account.updated is not working
我收到來自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
謝謝您的幫助!
如果查看Web服務器的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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.