4

We have implemented "Billing Plan & Agreements" in our website as explained on http://paypal.github.io/PayPal-PHP-SDK/sample/.

We have implemented weekly recurring payment and just want to cancel the billing agreement through the API.

Ravee Sunshine
  • 386
  • 1
  • 5
  • 15
  • It's on that link under the Billing Plan and Agreements, the "Suspend Agreement" option. [Details here.](http://paypal.github.io/PayPal-PHP-SDK/sample/doc/billing/SuspendBillingAgreement.html) – samiles Feb 10 '17 at 09:43

1 Answers1

8

You need to create a object of Agreement & AgreementStateDescriptor and using object of Agreement call the cancel() method. Below is the code example using PHP.

        $agreementId = "I-ABACAGAH";                  
        $agreement = new Agreement();            

        $agreement->setId($agreementId);
        $agreementStateDescriptor = new AgreementStateDescriptor();
        $agreementStateDescriptor->setNote("Cancel the agreement");

        try {
            $agreement->cancel($agreementStateDescriptor, $this->_apiContext);
            $cancelAgreementDetails = Agreement::get($agreement->getId(), $this->_apiContext);                
        } catch (Exception $ex) {                  
        }
Mohd Bashir
  • 949
  • 1
  • 8
  • 17