protected function swapAcrossFrequencies($plan)
{
$currentPlan = BraintreeService::findPlan($this->braintree_plan);
$discount = $this->switchingToMonthlyPlan($currentPlan, $plan) ? $this->getDiscountForSwitchToMonthly($currentPlan, $plan) : $this->getDiscountForSwitchToYearly();
$options = [];
if ($discount->amount > 0 && $discount->numberOfBillingCycles > 0) {
$options = ['discounts' => ['add' => [['inheritedFromId' => 'plan-credit', 'amount' => (double) $discount->amount, 'numberOfBillingCycles' => $discount->numberOfBillingCycles]]]];
}
$this->cancelNow();
return $this->user->newSubscription($this->name, $plan->id)->skipTrial()->create(null, [], $options);
}