简体   繁体   中英

How to cancel the Paypal Billing Agreement using REST API with PHP code

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.

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) {                  
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM