Add this logic to the _process_serial_purchase
function. Replace this line (~ Line number 900)
$subscription->totalOccurrences = $total_occurencies;
With whats given below
$card_exp = explode("-",$subscription->creditCardExpirationDate);
$sub_end = explode("-",date('Y-m',strtotime('+1 year')));
if ( ($sub_end[0] == $card_exp[0] && $sub_end[1] >= $card_exp[1])
|| ($sub_end[0] > $card_exp[0] && $sub_end[1] < $card_exp[1]) )
{
$subscription->totalOccurrences = $card_exp[1] - $sub_end[1] > 0 ?
$card_exp[1] - $sub_end[1] - 1:
$card_exp[1] - $sub_end[1] + 11 ;
}
else {
$subscription->totalOccurrences = $total_occurencies;
}
$subscription->intervalLength = 1;
Replace code in the
classes/Membership/Gateway/Authorize.php
file after taking a backup.