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

吃可爱长大的小学妹 提交于 2021-01-27 06:52:42

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/42155987/how-to-cancel-the-paypal-billing-agreement-using-rest-api-with-php-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!