/** * Update billing agreement status * * @param Mage_Payment_Model_Billing_AgreementAbstract $agreement * @throws Exception|Mage_Core_Exception * @return Mage_Paypal_Model_Method_Agreement */ public function updateBillingAgreementStatus(Mage_Payment_Model_Billing_AgreementAbstract $agreement) { $targetStatus = $agreement->getStatus(); if (Mage_Sales_Model_Billing_Agreement::STATUS_CANCELED == $targetStatus) { $targetStatus = self::STATUS_CANCELED; } $api = $this->_pro->getApi()->setBillingAgreementId($agreement->getReferenceId())->setBillingAgreementStatus($targetStatus); try { $api->callUpdateBillingAgreement(); } catch (Mage_Core_Exception $e) { // when BA was already canceled, just pretend that the operation succeeded if (!(self::STATUS_CANCELED == $targetStatus && $api->getIsBillingAgreementAlreadyCancelled())) { throw $e; } } return $this; }
/** * Retrieve billing agreement customer details by token * * @param Adyen_Payment_Model_Billing_Agreement|Mage_Payment_Model_Billing_AgreementAbstract $agreement * @return array */ public function getBillingAgreementTokenInfo(Mage_Payment_Model_Billing_AgreementAbstract $agreement) { $recurringContractDetail = $this->_api()->getRecurringContractDetail($agreement->getCustomerReference(), $agreement->getReferenceId()); if (!$recurringContractDetail) { Adyen_Payment_Exception::throwException(Mage::helper('adyen')->__('The recurring contract (%s) could not be retrieved', $agreement->getReferenceId())); } $agreement->parseRecurringContractData($recurringContractDetail); return $recurringContractDetail; }