May 16, 2019
0
Level 18
Laravel Spark Subscription Sucks
Well, the Laravel's Spark subscription checkout page suddenly not working. Sounds generic right? When I try to subscribe a plan, the user created but the subscription isn't created for the user and the page redirects to local.app.name/undefined.
The spark-register-stripe vue component redirects to the Laravel\Spark\Http\Controllers\Auth\Register Controller
<?php
namespace Laravel\Spark\Http\Controllers\Auth;
use Laravel\Spark\Spark;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Laravel\Spark\Events\Auth\UserRegistered;
use Laravel\Spark\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\RedirectsUsers;
use Laravel\Spark\Contracts\Interactions\Auth\Register;
use Laravel\Spark\Contracts\Http\Requests\Auth\RegisterRequest;
class RegisterController extends Controller
{
use RedirectsUsers;
/**
* Create a new authentication controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
$this->redirectTo = Spark::afterLoginRedirect();
}
/**
* Show the application registration form.
*
* @param Request $request
* @return Response
*/
public function showRegistrationForm(Request $request)
{
if (Spark::promotion() && ! $request->filled('coupon')) {
// If the application is running a site-wide promotion, we will redirect the user
// to a register URL that contains the promotional coupon ID, which will force
// all new registrations to use this coupon when creating the subscriptions.
return redirect($request->fullUrlWithQuery([
'coupon' => Spark::promotion()
]));
}
return view('spark::auth.register');
}
/**
* Handle a registration request for the application.
*
* @param RegisterRequest $request
* @return Response
*/
public function register(RegisterRequest $request)
{
Auth::login($user = Spark::interact(
Register::class, [$request]
));
event(new UserRegistered($user));
return response()->json([
// 'redirect' => $this->redirectPath()
'redirect' => '/thankyou'
]);
}
}
How can I hack the subscription? so I can tweak it on my own.
Stripe provides really easy interface for the the subscription.
Please or to participate in this conversation.