I'm using Stripe in my project to bill users for my services. I would like to integrate coupons in this app to give some customers a "discount" of x months for free. This can easily be done using Stripe Coupons, but as far as I can see, coupons can only be applied when creating the subscription. I would like to be able to do this at any point in time, e.g. when a user (with an existing subscription) refers another user to my website. Does anyone know if this is possible? And if so, where can I find an example or some documentation on this?
Found a solution for my problem in the Stripe documentation:
// Set your secret key: remember to change this to your live secret key in production
// See your keys here https://dashboard.stripe.com/account/apikeys
\Stripe\Stripe::setApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
$cu = \Stripe\Customer::retrieve("cus_3R1W8PG2DmsmM9");
$cu->coupon = "coupon_ID";
$cu->save();
And also in Laravel Cashier: $this->subscription()->applyCoupon('coupon_ID');