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

rameezisrar's avatar

Subscription isnt working on Spark

I am using the default Spark subscription. I have added a few plans on the SparkServiceProvider. When I try subscribing with a test account card, I only can see the following fields get updated i.e: stripe_id, card_brand, card_last_four, trial_ends_at. But there is nothing added to the subscription table. I want to add a selected subscription the user selected.

0 likes
19 replies
rameezisrar's avatar

On SparkServiceProvider

Spark::plan('HIV Course', 'prod_CllrASP7yk5IxH')
            ->price(59)
            ->features([
                'First', 'Second', 'Third'
            ]);

Where 'prod_CllrASP7yk5IxH' is the ID of the product subscription created on the Stripe. I can see that the customer is added to the stripe account but the subscription table is empty of my system. @Cronix Any help will be much appreciated

Cronix's avatar

How is spark setup? Are you using teams? Do you have trials? It would help to post your SparkServiceProviders booted() method.

1 like
rameezisrar's avatar

On my log i get this error

[2018-04-29 16:24:28] local.ERROR: Could not determine which URL to request: Stripe\Token instance has invalid ID:  {"userId":7,"email":"[email protected]","exception":"[object] (Stripe\Error\InvalidRequest(code: 0): Could not determine which URL to request: Stripe\Token instance has invalid ID:  at /home/abudo/saas_products/jedi.abudo.com/vendor/stripe/stripe-php/lib/ApiResource.php:80)
[stacktrace]

Spark Service Provider

 public function booted()
    {
       
        Spark::useStripe()->noCardUpFront()->trialDays(0);
        Spark::collectBillingAddress();

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

        Spark::plan('HIV', 'prod_CllrASP7yk5IxH')
            ->price(59)
            ->features([
                'First', 'Second', 'Third'
            ]);
        
    }

I am not using team. Only per user subscription @Cronix

Cronix's avatar

Is that a copy/paste? You're missing the closing quote on the 'HIV' plan?

rameezisrar's avatar

@Cronix Customer is created with a stripe id on the 'users' table and the same stripe id is being added on the Stripe Account with that customer but the subscription is not added on the table and I got this error message: '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.'

Cronix's avatar

Is stripe (in the stripe control panel) in test mode? Are you using the test card numbers?

1 like
rameezisrar's avatar

@Cronix Yes i am on test mode and using the test card number which is 4242 42424 4242 4242 4242

Cronix's avatar

In stripe control panel, you have a product defined with the id of prod_CllrASP7yk5IxH?

1 like
rameezisrar's avatar

@Cronix yes the product id is : prod_CllrASP7yk5IxH which contains one plan having an ID : plan_ClltN2pKDBNrKJ with Interval:Monthly.

I have tried using plan id too but i am getting the same result

noahkuhn's avatar

I'm having the same problem, I feel like I looked into this a few months back and the way you set up Subscriptions in Stripe was different. Perhaps I'm wrong, but something is definitely screwy here. I am using the same CC 4242 4242 4242 4242.

For what it's worth, I'm getting some console errors from Stripe. I am on a local install with a self-signed cert.

Refused to execute a script because its hash, its nonce, or 'unsafe-inline' does not appear in the script-src directive of the Content Security Policy.

And when I submit the form, I get a 500 error for /settings/subscription

Failed to load resource: the server responded with a status of 500 (Internal Server Error)
noahkuhn's avatar

I actually got this working by using the "billing plan" ID, not the "product" ID. Took some trial and error. It would be great if the documentation was clearer on how this works. The Spark documentation in general is a bit light, especially compared to the great main Laravel docs.

benbowler's avatar

Actually it's not even the product id it's the plan id within a product.

You create a product, then a price plan and it's that id. If you let Stripe create the ids it will look like plan_XXXXXXXXXXXX.

I just spent half an hour looking at this so thought I'd contribute to anyone out there at the same point in future.

2 likes
garrys07's avatar

Commented this //Spark::noCardUpFront()->trialDays(10);

Used price_ under API ID

Spark::plan('vm_monthly', 'price_1GtC30')
            ->price(10)
            ->features([
                '50', '30 cups', '25000'
            ]);

Worked for me

2 likes
automica's avatar

@garrys07 what test card details did you use? I'm getting the following 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."

with 4242 4242 4242 4242 on both local (homestead) and my dev hosting (which has ssl)

automica's avatar

@garrys07 looks like my issue wasn't card related, rather that I was missing 3 columns from my user table, - the following:

  • stripe_id
  • card_brand
  • card_last_four

with these manually added I able to register.

Bit odd will have to figure out why those aren't there.

automica's avatar

Looks like I'd modified a migration when debugging an issue with Cashier when I first installed, caused by me not reading the docs.

I'd initially missed adding SparkServiceProvider to app.php which meant Cashier::ignoreMigrations() wasnt being called.

All good now though :)

Please or to participate in this conversation.