The subscriptions array of objects has previous_recurrings_used to keep track of recurring that have occurred. So the following condition might work.
[var3_0_previous_recurrings_used] Greater Than 1
There could be issues with this though if there are multiple subscriptions in a basket.
You could act on the user state change instead though using the onCPayUserStateChange trigger and the below conditions to catch auto renewals. This would work with multiple subscriptions in a basket.
[var2] Equal To A
[var6] Equal To PaidSubscription
[var7] Equal To R
[var10] Equal To 1
See the below phpdoc for onCPayUserStateChange to help with conditions.
Code:
/**
* Called at each change of user subscription state due to a plan activation or deactivation
*
* @param UserTable $user The user owning the $subscription with that $planId
* @param string $status New status: 'A'=Active, 'X'=Expired, 'C'=Cancelled
* @param int $planId Plan Id which is changing status
* @param int $replacedPlanId Replaced Plan Id in case of an upgrade
* @param ParamsInterface $integrationParams Integration parameters for that plan $planId
* @param string $cause 'PaidSubscription' (first activation only), 'SubscriptionActivated' (renewals, cancellation reversals), 'SubscriptionDeactivated', 'Denied'
* @param string $reason 'N' new subscription, 'R' renewal, 'U'=update )
* @param int $now Unix time
* @param cbpaidSomething $subscription Subscription/Donation/Merchandise record
* @param int $autorenewed 0: not auto-renewing (manually renewed), 1: automatically renewed (if $reason == 'R')
* @return void
*/
public function onCPayUserStateChange( $user, $status, $planId, $replacedPlanId, $integrationParams, $cause, $reason, $now, $subscription, $autorenewed )
Below is a set of IF conditions checking for various payment events (taken from CBSubs Emails).
Code:
if ( ( $status == 'A' ) && ( $cause == 'PaidSubscription' ) && ( $reason != 'R' ) ) {
$event = 'activation';
} elseif ( ( $status == 'A' ) && ( $cause == 'PaidSubscription' ) && ( $reason == 'R' ) && ( $autorenewed == 0 ) ) {
$event = 'renewal';
} elseif ( ( $status == 'A' ) && ( $cause == 'PaidSubscription' ) && ( $reason == 'R' ) && ( $autorenewed == 1 ) ) {
$event = 'autorenewal';
} elseif ( ( $status == 'X' ) && ( $cause != 'Pending' ) ) {
$event = 'expired';
} elseif ( ( $status == 'C' ) && ( $cause != 'Pending' ) ) {
$event = 'deactivation';
} elseif ( ( $cause == 'Pending' ) && ( $reason != 'R' ) && ( $autorenewed == 0 ) ) {
$event = 'pendingfirst';
} elseif ( ( $cause == 'Pending' ) && ( $reason == 'R' ) && ( $autorenewed == 0 ) ) {
$event = 'pendingrenewal';
}