I'm using Laravel 5.2 and after deploying my app the stripe checkout doesnt work. In localhost mode it works and creates a customer with subscription but in production it throws an "InvalidRequest" error and only creates a customer in Stripe but without the subscription.
The apikeys are set in services, stripe and .env and it gets the stripeToken.
try {
// Use Stripe's library to make requests...
$user = new User;
$user->name = $request->input('name');
$user->email = $request->input('email');
$user->password = Hash::make($request->input('password'));
$user->created_at = Carbon::now();
$user->save();
$creditCardToken = $request->input('stripeToken');
$user->newSubscription('Silver', 'Silver')->create($creditCardToken);
} catch(\Stripe\Error\Card $e) {
// Since it's a decline, \Stripe\Error\Card will be caught
$error = 'Det verkade vara något fel med ditt kreditkort. Vänligen testa igen.';
return redirect()->back()->with('error', $error);
} catch (\Stripe\Error\RateLimit $e) {
// Too many requests made to the API too quickly
$error = 'Vi upplever för tillfälligt ett högt tryck. Vänligen försök igen om en liten stund.';
return redirect()->back()->with('error', $error);
} catch (\Stripe\Error\InvalidRequest $e) {
// Invalid parameters were supplied to Stripe's API
$error = 'Ops! Något gick fel. Vänligen testa igen';
return redirect()->back()->with('error', $error);
} catch (\Stripe\Error\Authentication $e) {
// Authentication with Stripe's API failed
// (maybe you changed API keys recently)
$error = 'Ops! Något gick fel. Vänligen konktakta kundtjänst så vi kan fixa problemet. Tack!';
return redirect()->back()->with('error', $error);
} catch (\Stripe\Error\ApiConnection $e) {
// Network communication with Stripe failed
$error = 'Ops! Servern är för tillfälligt nere. Vänligen testa inom kort igen.';
//return redirect()->back()->with('error', $error);
} catch (\Stripe\Error\Base $e) {
// Display a very generic error to the user, and maybe send
// yourself an email
$error = 'Ops! Något gick fel.';
//return redirect()->back()->with('error', $error);
} catch (Exception $e) {
// Something else happened, completely unrelated to Stripe
$error = 'Ops! Något gick fel. Vänligen kontakta kundtjänst.';
//return redirect()->back()->with('error', $error);
}
$name = $request->input('name');
return view('checkout.confirmation', compact('plan', 'name'));
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire