Laravel 收银员创建客户但不创建订阅
Laravel Cashier creates customer but not subscription
我正在使用 Laravel 5.2,但在部署我的应用程序后,条带结帐不起作用。在 localhost 模式下它可以工作并创建一个订阅的客户,但在生产中它会抛出一个 "InvalidRequest" 错误并且只在 Stripe 中创建一个客户但没有订阅。
apikeys在services、stripe和.env中设置,它获取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'));
应该是评论,但我没有名气做。所以...
在 catch (\Stripe\Error\InvalidRequest $e) {
上包含一个 dd($e->getMessage());
我相信它会给你一个更好的问题提示。
我正在使用 Laravel 5.2,但在部署我的应用程序后,条带结帐不起作用。在 localhost 模式下它可以工作并创建一个订阅的客户,但在生产中它会抛出一个 "InvalidRequest" 错误并且只在 Stripe 中创建一个客户但没有订阅。
apikeys在services、stripe和.env中设置,它获取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'));
应该是评论,但我没有名气做。所以...
在 catch (\Stripe\Error\InvalidRequest $e) {
上包含一个 dd($e->getMessage());
我相信它会给你一个更好的问题提示。