I have an an app in which I use Stripe and Laravel Cashier for billing. Creating new customers is easy and works perfectly. However, my app also makes it possible for users to cancel a subscription and restart it on a later date. I looked into the Stripe API on how to do this, but I can't seem to make it work in Cashier. The request is sent and as far as I can see the the subscription is restarted successfully, but for some reason the Stripe API throws an exception (invalid HTTP code) .
here is the code I'm using:
if( $this->isBillable() ) {
if( !is_null($token) ) {
// Create new subscription if a token is provided
$this->subscription( $plan )->create( $token );
} else {
// Renew the previous subscription if we already know the customer
$newPlan = null;
if( $plan != $this->stripe_plan ) {
$newPlan = $plan;
}
$stripeCustomer = $this->subscription()->getStripeCustomer( $this->stripe_id );
$this->subscription()->create( $newPlan, array(), $stripeCustomer );
}
}
Is there anyone that has experience with this? What am I missing here?