Skip to content

Instantly share code, notes, and snippets.

@JudeRosario
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JudeRosario/87fba19cb797537b1054 to your computer and use it in GitHub Desktop.
Save JudeRosario/87fba19cb797537b1054 to your computer and use it in GitHub Desktop.
Authorize.Net ARB : Membership

Better Processing Logic for Authorize.Net ARB (Membership)

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; 
@JudeRosario
Copy link
Author

Replace code in the classes/Membership/Gateway/Authorize.php file after taking a backup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment