Ver código fonte

Propagate name and email changes to Stripe

tags/v0.1.0
Immanuel Onyeka 3 anos atrás
pai
commit
6973d4d8e5
1 arquivos alterados com 5 adições e 1 exclusões
  1. +5
    -1
      app/Http/Controllers/UserController.php

+ 5
- 1
app/Http/Controllers/UserController.php Ver arquivo

@@ -34,7 +34,7 @@ class UserController extends Controller
$user->active = true;
$user->password = Hash::make($request->password);
$user->customer_id = Customer::create(['email' =>
$request->email], 'metadata' => ['user_id' => $user->id])->id;
$request->email], 'name' => $request->name, 'metadata' => ['user_id' => $user->id])->id;
$user->save();

event(new Registered($user));
@@ -100,8 +100,10 @@ class UserController extends Controller
$validated = $request->validate([
'name' => 'required|max:30'
]);
Stripe::setApiKey(env('STRIPE_SECRET'));
$user = Auth::user();
$user->name = $request->name;
Customer::update($user->customer_id, ['name' => $request->name]);
$user->save();
return $user;
}
@@ -120,6 +122,7 @@ class UserController extends Controller
}

public function resetEmail(Request $request) {
Stripe::setApiKey(env('STRIPE_SECRET'));
if (! $request->hasValidSignature()) {
abort(401);
}
@@ -135,6 +138,7 @@ class UserController extends Controller
$user = User::find($request->user);
$user->email = $request->email;
$user->save();
Customer::update($user->customer_id, ['name' => $request->email]);

return view('email-changed');
}


Carregando…
Cancelar
Salvar