Example #1
0
 /**
  * Import payment data to billing agreement
  *
  * $payment->getBillingAgreementData() contains array with following structure :
  *  [billing_agreement_id]  => string
  *  [method_code]           => string
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @return Mage_Sales_Model_Billing_Agreement
  */
 public function importOrderPayment(Mage_Sales_Model_Order_Payment $payment)
 {
     $baData = $payment->getBillingAgreementData();
     $this->_paymentMethodInstance = isset($baData['method_code']) ? Mage::helper('payment')->getMethodInstance($baData['method_code']) : $payment->getMethodInstance();
     if ($this->_paymentMethodInstance) {
         $this->_paymentMethodInstance->setStore($payment->getMethodInstance()->getStore());
         $this->setCustomerId($payment->getOrder()->getCustomerId())->setMethodCode($this->_paymentMethodInstance->getCode())->setReferenceId($baData['billing_agreement_id'])->setStatus(self::STATUS_ACTIVE);
     }
     return $this;
 }