All I want to do is to create a stripe customer account for every registered user on Laravel.
The problem I'm facing right now is that $new
variable isn't passing to User::create
function.
I'm trying to edit RegisterController.php, here is create() function I'm using:
public function create(array $data)
{
\Stripe\Stripe::setApiKey('sk_test_XXXXXXXXXXXXXXX');
$new = \Stripe\Customer::create([
'email' => $data['email'],
'name' => $data['name'],
'description' => "Contribee.com platform's user",
]);
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'stripe_code' => $new->id,
'password' => Hash::make($data['password']),
]);
}
I've tested this out in my other controller, and $new
outputs generated ID. Everything worked fine.