Example #1
0
 /**
  * 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;
 }
Example #2
0
 /**
  * Validate data
  *
  * @return bool
  */
 public function isValid()
 {
     $result = parent::isValid();
     if (!$this->getCustomerId()) {
         $this->_errors[] = Mage::helper('payment')->__('Customer ID is not set.');
     }
     if (!$this->getStatus()) {
         $this->_errors[] = Mage::helper('payment')->__('Billing Agreement status is not set.');
     }
     return $result && empty($this->_errors);
 }
Example #3
0
 /**
  * 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;
 }
Example #4
0
 /**
  * Create billing agreement
  *
  * @param Mage_Payment_Model_Billing_AgreementAbstract $agreement
  * @return $this
  */
 public function placeBillingAgreement(Mage_Payment_Model_Billing_AgreementAbstract $agreement)
 {
     $agreement->setBillingAgreementId('SEPA12345');
     return $this;
 }