Laravel 收银员 (Stripe) 自定义 Webhook 未收到 $payload
Laravel Cashier (Stripe) Custom Webhook not receiving $payload
我们正在尝试创建一个自定义 webhook 来处理 Laravel 收银员的 Stripe Checkout。问题是我们正在关注 Laravel Cashier 文档,但我们没有收到来自 Stripe 的有效载荷。
我们正在尝试连接到 checkout.session.completed
。
namespace App\Http\Controllers;
use Laravel\Cashier\Http\Controllers\WebhookController as CashierController;
class StripeWebhookController extends CashierController
{
/**
* Handle Checkout Session Completed.
*
* @param array $payload
* @return \Symfony\Component\HttpFoundation\Response
*/
public function handleCheckoutSessionCompleted(array $payload) // Line 12
{
// Code...
}
// Error: ArgumentCountError: Too few arguments to function App\Http\Controllers\StripeWebhookController::handleCheckoutSessionCompleted(), 0 passed in /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Controller.php on line 54 and exactly 1 expected in file /var/www/html/app/Http/Controllers/StripeWebhookController.php on line 12
我们还在 web.php
中创建了路线
use App\Http\Controllers\StripeWebhookController;
Route::post('/stripe/webhook', [StripeWebhookController::class, 'handleCheckoutSessionCompleted']);
我们确实在里面添加了App\Http\Middleware\VerifyCsrfToken
protected $except = [
'stripe/*',
];
最后,我们还在 .env
文件中添加了我们的 webhook 秘密。
改变
Route::post('/stripe/webhook', [StripeWebhookController::class, 'handleCheckoutSessionCompleted']);
为了
Route::post('/stripe/webhook', [StripeWebhookController::class, 'handleWebhook']);
我们正在尝试创建一个自定义 webhook 来处理 Laravel 收银员的 Stripe Checkout。问题是我们正在关注 Laravel Cashier 文档,但我们没有收到来自 Stripe 的有效载荷。
我们正在尝试连接到 checkout.session.completed
。
namespace App\Http\Controllers;
use Laravel\Cashier\Http\Controllers\WebhookController as CashierController;
class StripeWebhookController extends CashierController
{
/**
* Handle Checkout Session Completed.
*
* @param array $payload
* @return \Symfony\Component\HttpFoundation\Response
*/
public function handleCheckoutSessionCompleted(array $payload) // Line 12
{
// Code...
}
// Error: ArgumentCountError: Too few arguments to function App\Http\Controllers\StripeWebhookController::handleCheckoutSessionCompleted(), 0 passed in /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Controller.php on line 54 and exactly 1 expected in file /var/www/html/app/Http/Controllers/StripeWebhookController.php on line 12
我们还在 web.php
use App\Http\Controllers\StripeWebhookController;
Route::post('/stripe/webhook', [StripeWebhookController::class, 'handleCheckoutSessionCompleted']);
我们确实在里面添加了App\Http\Middleware\VerifyCsrfToken
protected $except = [
'stripe/*',
];
最后,我们还在 .env
文件中添加了我们的 webhook 秘密。
改变
Route::post('/stripe/webhook', [StripeWebhookController::class, 'handleCheckoutSessionCompleted']);
为了
Route::post('/stripe/webhook', [StripeWebhookController::class, 'handleWebhook']);