Setting up products with Spike

Products are non-recurring purchases. The user can add one or more products to their shopping cart and checkout with a single click. This makes it easy for you to sell bundles of credits, or other products from within Spike.

Displaying the products view

The page to buy products will show up automatically once there is at least one product set up. You can either add it via config/spike.php configuration file, or by providing a custom product resolver.

Hiding the products view

If you would like to hide the products page completely, set the 'products' to an empty array:

'products' => [],

Adding products via config

In order to make a product available for purchase, you simply add an associative array to the config/spike.php configuration file. You can add as many products as you'd like.

use Opcodes\Spike\CreditAmount;

'products' => [
        'id' => 'standard_pack',
        'name' => 'Standard pack',
        'short_description' => 'Great value for occasional use',
        'payment_provider_price_id' => 'price_xxxxxxxx3',
        'price_in_cents' => 1000,
        'provides' => [

    // other products...

Here's a rundown of the attributes:

idyesIdentifier of the product. Must be unique.
nameyesThe name of the product that will be visible to the user.
short_descriptionnoA short description of the product that will be visible to the user.
payment_provider_price_idyesStripe's or Paddle's price_id for this product. Learn how to set up Stripe products.
price_in_centsyesThe price of the product in cents. This will be visible to the user in a friendly format.
providesnoAn array of providables that are provided upon purchase of this product.

Archiving old products

It's OK to remove any outdated products from the config/spike.php configuration. But if you would like to keep them there for reference, but hide them from the users, you can archive a product by setting the archived flag to true.

'products' => [
        'id' => 'standard_pack',
        'name' => 'Standard pack',
        'archived' => true,    // <== add this line
        // other attributes...

Thank you page

When a user completes the purchase of credits, they will be shown a "Thank you" page in Spike. You can redirect from that page to a different page of your choice after any duration of your choice.

You can do so by adding this line to your AppServiceProvider::boot() method:

// Will redirect the user to "/custom-thank-you-page" after 5 seconds.
Spike::redirectAfterProductPurchaseTo('/custom-thank-you-page', 5);

The first parameter even accepts a callback which will receive the Opcodes\Spike\Cart instance where you can find the purchased items/products, if you need that to build the final redirect URL.

use Opcodes\Spike\Cart;

Spike::redirectAfterProductPurchaseTo(function (Cart $cart) {
    if ($cart->billable->subscribed()) {
        return "/special-subscriber-thank-you";

    return null;    // `null` value will not redirect anywhere.
}, 5);


If you have any questions, feedback, or need any help setting up Spike within your project, feel free to reach out to me.