title: Laravel How to make Paypal cancel a user-signed plan
body: <p>I'm doing a subscription system, and I would like that when the user upgrades or downgrades the plan, cancel the previous subscription on paypal and create a new one. It is already creating a new one, but it does not cancel the previous one. Current code:</p>
  <pre><code>            $old_agreement = new \PayPal\Api\Agreement();
  
              $old_agreement-&gt;setId(&quot;I-G0JJ5A9KMR--&quot;);
              $agreementStateDescriptor = new \PayPal\Api\AgreementStateDescriptor();
              $agreementStateDescriptor-&gt;setNote(&quot;Cancel the agreement&quot;);
              try {
                  $old_agreement-&gt;cancel($agreementStateDescriptor, $this-&gt;_apiContext);
                  $cancelAgreementDetails = Agreement::get($old_agreement-&gt;getId(), $this-&gt;_apiContext);
              } catch (Exception $ex) {
                  Log::error($ex);
              }
  </code></pre>