SteamDiesel
1686
1
Spark

(SOLVED) Stripe Error with Spark - did not set a valid publishable key

Posted 2 years ago by SteamDiesel

Hey Team,

When I enter a credit card number (both test and my own) and try to submit for a subscription, using both the test API keys and my live API keys, in both my homestead and on the live forge server, I get the following error in my console:

js.stripe.com/:3 Uncaught Error: You did not set a valid publishable key. Call Stripe.setPublishableKey() with your publishable key. For more info, see https://stripe.com/docs/stripe.js

    at Function.Stripe.isDoubleLoaded.Stripe.utils.b.validateKey (js.stripe.com/:3)

    at Function.Stripe.token.b.create (js.stripe.com/:2)

    at Function.Stripe.card.c.createToken (js.stripe.com/:2)

    at o.subscribe (app.js:27)

    at Proxy.n (app.js:67)

    at click (eval at Ci (app.js:67), <anonymous>:2:25288)

    at HTMLButtonElement.t (app.js:67)

I have set my keys in the .env and config/services.php with both pk_live and sk_live set correctly. I thought the spark app was supposed to reference these values, so I don't know where it would be looking. all plans have been established in both the app/providers/SparkServiceProvider.php and the stripe plans panel. ID and name are the same, prices are the same. I have a coupon for 99% off, which I have been using, but that doesn't seem to be related. here's my SparkServiceProvider

namespace App\Providers;

use Carbon\Carbon;
use Laravel\Cashier\Cashier;
use Laravel\Spark\Spark;
use Laravel\Spark\Providers\AppServiceProvider as ServiceProvider;

class SparkServiceProvider extends ServiceProvider
{
    /**
     * Your application and company details.
     *
     * @var array
     */
    protected $details = [
        'vendor' => 'xxxxxxxxxx',
        'product' => 'xxxxxxxxxxx',
        'street' => 'xxxxxxxxx',
        'location' => 'xxxxxxxxxx',
        'phone' => 'xxxxxxxxxx',
    ];

    /**
     * The address where customer support e-mails should be sent.
     *
     * @var string
     */
    protected $sendSupportEmailsTo = 'xxxxxx[email protected]';

    /**
     * All of the application developer e-mail addresses.
     *
     * @var array
     */
    protected $developers = [
        //
        '[email protected]'
    ];

    /**
     * Indicates if the application will expose an API.
     *
     * @var bool
     */
    protected $usesApi = false;

    /**
     * Finish configuring Spark for the application.
     *
     * @return void
     */
    public function booted()
    {
        Cashier::useCurrency('aud', '$');

        Spark::useStripe()->noCardUpFront()->teamTrialDays(10);

        //disabled so users can hot switch teams through native spark dashboard.
//        Spark::identifyTeamsByPath();

        Spark::useRoles([
            'fb' => 'User',
            'sales' => 'Sales',

        ]);

        Spark::useTwoFactorAuth();


        Spark::teamPlan('Beta 3', 'BETA3')
            ->price(149)
            ->maxTeamMembers(3)
            ->features([
                '3 team members',
                'Price fixed for 3 years (Beta plans only)',
                'all future features and upgrades'
            ]);

        Spark::teamPlan('Beta 5', 'BETA5')
            ->price(249)
            ->maxTeamMembers(5)
            ->features([
                '5 team members',
                'Price fixed for 3 years (Beta plans only)',
                'all future features and upgrades'
            ]);

        Spark::teamPlan('Beta 7', 'BETA7')
            ->price(349)
            ->maxTeamMembers(7)
            ->features([
                '7 team members',
                'Price fixed for 3 years (Beta plans only)',
                'all future features and upgrades'
            ]);

        Spark::teamPlan('Beta 10', 'BETA10')
            ->price(499)
            ->maxTeamMembers(10)
            ->features([
                '10 team members',
                'Price fixed for 3 years (Beta plans only)',
                'all future features and upgrades'
            ]);



    }
}

Attempted solutions: log out, restarted server, log back in.

I haven't touched the js that runs Spark, I didn't think I should need to. I've just deployed to AWS through Forge. I'm based in Australia. I'm using Stripe for payments with the native spark setup, Stripe account is activated. Laravel 5.4

Is there an undocumented step I should be following after adding the API keys to ensure the js for spark and stripe get my keys?

Please sign in or create an account to participate in this conversation.