* EDIT 2018/04/04: This is applicable to both Spark 6 and 5
* EDIT 2018/02/19: This posts was made for Spark 5, but most likely it still perfectly applies to Spark 6. I've read the changelog and upgrade instructions, and those do not mention any changes regarding coupons. I'll update this post once we upgrade to Spark 6.
A couple of days ago it was Black Friday and at publica.la we decided to put out a beefy discount for new customers. Thankfully we use Laravel Spark to handle all the SaaS boilerplate needed to bill our clients, but while it does offer full support for discount coupons… IMO the docs are a bit lacking. I even tweeted asking for help but, ironically, all I got was a response from a guy that though I was looking for a discount to actually buy Spark.
* I'm going to make the assumption that you're using Stripe as the gateway, but Braintree should be pretty similar (tell us in the comments if you know about it).
Spark offers two different ways to go about coupons:
1. Individually with every purchase, like you would expect from any kind of system. This is the one that's missing in the docs. Basically, you need to setup your coupons 100% on Stripe side and then use it as a query string on your Spark powered site. So, for example:
With that in place, Spark will then automatically validate it against Stripe and show an input box in case the user wants to change the code.
2. And the other is called site-wide promotions , which is exactly what we needed ! The way it works is by globally forcing a coupon code in the query string section of the URL (don't worry, it won't mess with any existing values), but still letting the users change it case they want to. Yep, perfect for a Black Friday kind of deal.
All you need to do is use this code:
/* * This will probably go in your SparkServiceProvider.php */ Spark::promotion('coupon_code_here');