billing_cycle_anchor cannot be later than next natural billing date
The billing_cycle_anchor cannot be farther in the future than the term of the subscription, so a monthly subscription with a four month free trial, for example, will fail with above message.
From CRM_Core_Payment_Stripe::doRecurPayment()...
// This is the parameter that specifies the start date for the subscription.
// If omitted the subscription will start immediately.
$billingCycleAnchor = $this->getRecurBillingCycleDay($params);
if ($billingCycleAnchor) {
if ($billingCycleAnchor < strtotime("+{$params['recurFrequencyInterval']} {$params['recurFrequencyUnit']}")) {
$subscriptionParams['billing_cycle_anchor'] = $billingCycleAnchor;
} else {
$subscriptionParams['trial_end'] = $billingCycleAnchor;
}
}
I've updated the bit above to treat such a situation as free trial period and it seems to work, client is testing. Does that seem like the best solution?