You are browsing documentation for an outdated version of Spike.

Use the version selector on the left (navigation), or visit latest docs here.

Using Coupons in Spike

This feature is available since Spike v1.3. Make sure to update Spike first.

Spike allows the use of Stripe's Promotion Codes both for Subscriptions and Products. The coupons are created directly in Stripe and customer-usable promotional codes can be used by your customers to apply discounts for one-off product purchases or even subscriptions.

Enable coupons in Spike

To enable coupons in Spike, first enable it in config/spike.php:

    /*
    |--------------------------------------------------------------------------
    | Allow users to enter discount codes
    |--------------------------------------------------------------------------
    |
    | Configure whether users should be able to enter discount codes.
    | Discount codes can be configured in the Stripe dashboard.
    |
    */

    'allow_discount_codes' => true,
    

Generating coupons

Coupons must be created directly in Stripe, under "Products" -> "Coupons".

When creating coupons, make sure to also enable "Use customer-facing coupon codes", which will allow your customers to enter the promotional code during their checkout flow.

For example, if you create a promotional code "20OFF" like so: Stripe coupon setup example

The customer will be able to enter "20OFF" in the discount input field and apply it to their shopping cart or subscription flow: Stripe coupon usage example

Known limitations

Stripe has a lot of options available when creating coupons and their promotional codes. There are a few known limitations you should know about when creating these coupons in Stripe.

  • Customers can only enter the customer-facing coupon codes. It will not accept the Stripe IDs of coupons or promotions. See above for an example.
  • Customer can only use one coupon at the time. They will have to remove the current coupon before they can use a different one.
  • Fixed amount discount must use the same currency as your products.
  • Some coupon limitations in Stripe (e.g. first order only, minimum order value, etc.) cannot be used when applying coupons via API, which is how Spike works.
  • Coupons recurring for X number of months will still apply to the full year when a yearly subscription is selected. Monthly subscriptions work as expected.

Behaviour when switching subscription plans

There are two ways Spike can behave when the user has previously used a coupon and is now switching to a different subscription plan. It can either reuse the same coupon, which will show up to the user when they're switching to a different plan, or it can ignore the previously-set coupon.

You can set this in config/spike.php like so:

    /*
    |--------------------------------------------------------------------------
    | Persist applied discounts when switching plans
    |--------------------------------------------------------------------------
    |
    | When enabled, the previously applied discount code will carry over
    | to the new plan when switching plans. When disabled, the discount
    | will be removed when switching plans.
    |
    */

    'persist_discounts_when_switching_plans' => true,
    

Support

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