application/libraries/Stripe.php
//If you want to cancel the subscription at the end of the current billing period (i.e., for the duration of time the customer has already paid for), provide an at_period_end value of true
If you want to cancel the subscription at the end of the current billing period , provide an at_period_end value of true
If you want to cancel the subscription at the end of the current billing period provide an at_period_end value of true
function cancel_subscription($subscription_id, $at_period_end = false){
        try{
            $sub = \Stripe\Subscription::retrieve($subscription_id);
            $subscription = $sub->cancel(['at_period_end' => $at_period_end]);
            if(empty($subscription)){
                return array('status'=>false,'message'=>'Something went wrong');
            }
            return array('status'=>true,'message'=>'Retrieved successfully', 'data'=>$subscription); 
        }catch (Exception $e) {
            $message = $e->getMessage();
            return array('status'=>false,'message'=>$message);
        }
    }
function cancel_subscription ( $ subscription_id , $ at_period_end = false ) { try { $ sub = \ Stripe \ Subscription :: retrieve ( $ subscription_id ) ; $ subscription = $ sub -> cancel ( [ 'at_period_end' => $ at_period_end ] ) ; if ( empty ( $ subscription ) ) { return array ( 'status' => false , 'message' => 'Something went wrong' ) ; } return array ( 'status' => true , 'message' => 'Retrieved successfully' , 'data' => $ subscription ) ; } catch ( Exception $ e ) { $ message = $ e -> getMessage ( ) ; return array ( 'status' => false , 'message' => $ message ) ; } }
If you want to cancel the subscription at the end of the current billing period (i.e., for the duration of time the customer has already paid for), provide an at_period_end value of true
If you want to cancel the subscription at the end of the current billing period ( i . e . for the duration of time the customer has already paid for ) provide an at_period_end value of true
//success