|
...
|
...
|
@@ -144,16 +144,16 @@ class PayStripeApi |
|
|
|
{
|
|
|
|
try {
|
|
|
|
// Webhook 签名密钥(从 Stripe 仪表盘获取)
|
|
|
|
// $endpointSecret = 'whsec_garhW2TrCIrduyM3rve9mFS2sn69B9Yt';
|
|
|
|
$endpointSecret = 'whsec_garhW2TrCIrduyM3rve9mFS2sn69B9Yt';
|
|
|
|
// 获取原始请求内容
|
|
|
|
$payload = request()->getContent();
|
|
|
|
// 获取 Stripe 签名头
|
|
|
|
// $sigHeader = request()->header('Stripe-Signature');
|
|
|
|
// // 验证签名
|
|
|
|
// if (!self::verifySignature($payload, $sigHeader, $endpointSecret)) {
|
|
|
|
// http_response_code(400);
|
|
|
|
// throw new \Exception('Invalid signature');
|
|
|
|
// }
|
|
|
|
$sigHeader = request()->header('Stripe-Signature');
|
|
|
|
// 验证签名
|
|
|
|
if (!self::verifySignature($payload, $sigHeader, $endpointSecret)) {
|
|
|
|
http_response_code(400);
|
|
|
|
throw new \Exception('Invalid signature');
|
|
|
|
}
|
|
|
|
$event = json_decode($payload, true);
|
|
|
|
// 获取事件类型
|
|
|
|
$eventType = $event['type'];
|
...
|
...
|
|