I am trying to load the stripe iframe so a customer can checkout with stripe but I cant get it to load because of a 404 not found error
I added the route to web.php
Route::post('admin/checkout/checkoutStripeCredit', ['as' => 'admin.checkout.checkoutStripeCredit', 'uses' => 'CheckoutController@loadStripeCreditForm']);
Heres the code to the CheckoutController
public function loadStripeCreditForm(Request $request) {
if(!Session::has('credit_details')) {
return redirect()
->route('admin.checkout.show')
->with('flash_error', 'Your session has expired, please try again.');
}
try {
$credit_details = Session::get('credit_details');
header('Content-Type: application/json');
$stripe = new \Stripe\StripeClient(env('STRIPE_SECRETKEY'));
$product = $stripe->products->create([
'name' => 'Editor World Credit'
]);
$price = $stripe->prices->create([
'product' => $product->id,
'unit_amount' => $credit_details['credit_amount'] * 100,
'currency' => 'usd'
]);
$callback_url = route('admin.checkout.successStripeCredit');
$checkout_session = $stripe->checkout->sessions->create([
'mode' => 'payment',
'ui_mode' => 'embed',
'line_items' => [
[
'price' => $price->id,
'quantity' => 1
]
],
'metadata' => [
'user_id' => json_encode(Auth::user()->id)
],
'success_url' => $callback_url . '?session_id={CHECKOUT_SESSION_ID}',
'cancel_url' => route('admin.checkout.cancel'),
'invoice_creation' => ['enabled' => true]
]);
session(['checkout_session_id' => $checkout_session->id]);
echo json_encode(array('clientSecret' => $checkout_session->client_secret));
}
catch (Exception $x) {
EWLogHelper::create('STRIPE_SUBMIT_ERROR', ['msg' => $x->getMessage(), 'trace' => $x->getTrace()]);
return redirect()->back()->with('flash_error', $x->getMessage());
}
}
when I make post request to /admin/checkout/checkoutStripeCredit it gives me a 404 error. What am I doing wrong.