Php Stripe/Laravel-更新Stripe customer会导致GET方法错误
我目前正在尝试在向客户收费之前更新条带客户的默认来源,所有这些都在商店/收费控制器中。如果添加更新方法,则会出现以下错误:Php Stripe/Laravel-更新Stripe customer会导致GET方法错误,php,laravel,stripe-payments,Php,Laravel,Stripe Payments,我目前正在尝试在向客户收费之前更新条带客户的默认来源,所有这些都在商店/收费控制器中。如果添加更新方法,则会出现以下错误: The GET method is not supported for this route. Supported methods: POST. 我不明白GET方法是从哪里来的,除非它来自Stripes update方法,在这种情况下,如果有人知道如何解决这个问题,我希望它:) HTML: 路线: Route::post('/charge', 'items\custome
The GET method is not supported for this route. Supported methods: POST.
我不明白GET方法是从哪里来的,除非它来自Stripes update方法,在这种情况下,如果有人知道如何解决这个问题,我希望它:)
HTML:
路线:
Route::post('/charge', 'items\customerItemController@charge')->name('item.charge');
任何帮助都将不胜感激!谢谢:)您是否尝试过使用
php artisan route:clear
清除缓存路由?我以前遇到过这个问题,这完全是一个骗局。这是一些破坏代码的东西,它导致了这个非常混乱的错误。我发现问题的唯一方法是注释掉控制器中的所有代码,然后逐行取消注释,直到问题出现,然后我知道它在哪里。这是一个真正的痛苦。死机,原来是在充电控制器的请求上使用验证造成的。。不知道为什么,我在签出控制器中使用了验证,它工作得很好:/
public function charge(Request $request)
{
\Stripe\Stripe::setApiKey('my key');
$data = request()->validate([
'name' => 'required|string|min:3|max:30',
'cardName' => 'required|string',
'email' => 'required|email',
'city' => 'string|max:40',
'state' => 'string|max:20',
'customerID' => 'required',
'stripeToken' => 'required',
'_token' => 'required',
'address' => 'string|max:65',
]);
// UPDATING CUSTOMER INFORMATION
\Stripe\Customer::update(
$data['customerID'],
[
'default_source' => $data['stripeToken'],
]
);
dd($customer);
// RETRIEVING SESSION VARIABLES
$checkoutSession = \Stripe\Checkout\Session::retrieve($request->session);
// dd($checkoutSession->display_items[0]->amount);
$amount = $checkoutSession->display_items[0]->amount;
dd($data);
// When it's time to charge the customer again, retrieve the customer ID.
$charge = \Stripe\Charge::create([
'amount' => 1500, // $15.00 this time
'currency' => 'usd',
'customer' => $customer_id, // Previously stored, then retrieved
]);
}
Route::post('/charge', 'items\customerItemController@charge')->name('item.charge');