使用laravel 5.1并按照https://laravel.com/docs/5.1/billing
中的步骤操作除了提供者需要2个密钥
'key' => env('STRIPE_KEY'),
'secret' => env('STRIPE_SECRET'),
我在.env文件中将其设置为
STRIPE_KEY=@my_stripe_test_publishable_key
STRIPE_SECRET=@my_stripe_test_secret_key
我的控制器代码是
$creditCardToken = $request->stripeToken; //from stripe documentation
//because the documentation didnt include how to get this variable
$user = User::find(1);
$user->subscription('monthly')->create($creditCardToken);
$user->trial_ends_at = Carbon::now()->addDays(14);
$user->save();
每次尝试订阅时都会出现错误。即使没有$ creditCardToken变量
StripeGateway.php第71行中的ErrorException:
传递给Laravel \ Cashier \ StripeGateway :: __ construct()的参数1必须是Laravel \ Cashier \ Contracts \ Billable的实例,App \ User的实例,在C:\ wamp \ www \ lifesaver \ vendor \中调用laravel \ cashier \ src \ Laravel \ Cashier \ Billable.php第58行并定义