Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lpangm03's avatar

Issues with subscribing, changing subscription and unsubscribing.

Hey guys, I just bought a copy of Spark and am running into an issue that doesn't seem to be common, at least I haven't found anyone else that has the same issue. Hoping someone here might be able to help.

Ok so I have my test subscriptions setup in SparkServiceProvider.php and I have a copy of these setup in Stripe as well. I am using Stripe's test card, and when I subscribe I get this error "We had trouble validating your card. It's possible your card provider is preventing us from charging the card. Please contact your card provider or customer support.". My console shows: VM687:1 POST http://spark-test.dev/settings/subscription 500 (Internal Server Error)

In stripe, the subscription is there and it says the charge went through. The JSON response body looks good, no problem. Now back on my spark site, if I refresh the browser then it shows that my current plan is the one I just subscribed to.

I get the same thing if I try to cancel or if I try to change the subscription, the 500 server error.

This is the Laravel error screen for settings/subscription:

in RouteCollection.php line 251 at RouteCollection->methodNotAllowed(array('POST', 'PUT', 'DELETE')) in RouteCollection.php line 238 at RouteCollection->getRouteForMethods(object(Request), array('POST', 'PUT', 'DELETE')) in RouteCollection.php line 176 at RouteCollection->match(object(Request)) in Router.php line 533 at Router->findRoute(object(Request)) in Router.php line 512 at Router->dispatchToRoute(object(Request)) in Router.php line 498 at Router->dispatch(object(Request)) in Kernel.php line 174 at Kernel->Illuminate\Foundation\Http{closure}(object(Request)) in Pipeline.php line 30 at Pipeline->Illuminate\Routing{closure}(object(Request)) in CheckForMaintenanceMode.php line 46 at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 148 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in Pipeline.php line 53 at Pipeline->Illuminate\Routing{closure}(object(Request)) in Pipeline.php line 102 at Pipeline->then(object(Closure)) in Kernel.php line 149 at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116 at Kernel->handle(object(Request)) in index.php line 53

0 likes
5 replies
EventFellows's avatar

Check your request type. The error says methodNotAllowed(array('POST', 'PUT', 'DELETE' so maybe you are trying a GET or PATCH?

Chrome Developer Tools would probably give you more clues on where to look. did you setup the webhook correctly.

lpangm03's avatar

That's what isn't making much sense to me, EventFellows - All I've done so far is following along with Taylor's first video: https://laracasts.com/series/laravel-spark/episodes/1

At the part where his shows the subscription going through, mine returns a 500 server error. So just to be clear, I didn't modify any of the request type, it's all out of the box stuff.

EventFellows's avatar

there might be different issues:

  • as far as I know taylor made his video for Version 1 of Spark, if you just installed it now you probably have Version 4 (there have been some changes, so things might not be 100% identical)
  • when I go to settings/subscription I get the same error (because it is a GET request and there is no route for it).

BUT if you click on the navigation menu in spark you will hit settings#/subscription which should work as it is a GET request to settings on the subscription tab ( mind the # in the middle).

lpangm03's avatar

I'm not sure it really matters what version his video is for. Just to be clear, the ONLY thing that I did was add subscriptions.

    Spark::freePlan()
        ->features([
            'First', 'Second', 'Third'
        ]);

    Spark::plan('Base Test Plan', 'provider-id-0')
        ->price(1)
        ->features([
            'First', 'Second', 'Third'
        ]);

    Spark::plan('Test Plan 1', 'provider-id-1')
        ->price(10)
        ->features([
            'First', 'Second', 'Third'
        ]);

    Spark::plan('Test Plan 2', 'provider-id-2')
        ->price(50)
        ->features([
            'First', 'Second', 'Third'
        ]);

    Spark::plan('Test Plan 3', 'provider-id-3')
        ->price(100)
        ->features([
            'First', 'Second', 'Third'
        ]);

Then I went to Stripe and make sure these same subscriptions were built there, and entered my API key into the .env file. Nothing else was done. I am not trying to browse directly to /settings/subscriptions, I am click on the button that says "Switch", and the on the pop up I click "Yes, I'm sure".

I can pull down from scratch again, enter my API key, create the subscription that comes with Spark, making zero changes to it, and I will still have the same issue.

lpangm03's avatar

Updating this thread with the solution, I was able to figure out what is happening.

/vendor/laravel/cashier/src/Billable.php is where there mistake is. The code comes like this:

public function subscription($subscription = 'default')
{
    return $this->subscriptions->sortByDesc(function ($value) {
        return $value->created_at->getTimestamp();
    })
    ->first(function ($key, $value) use ($subscription) {
        return $value->name === $subscription;
    });
}

The solution is to swap $key, $value. ->first(function ($value, $key) use ($subscription) {

Please or to participate in this conversation.