public function updateQuotePayment(Adyen_Subscription_Model_Subscription $subscription, Mage_Sales_Model_Quote $quote) { Mage::dispatchEvent('adyen_subscription_service_updatequotepayment_before', array('subscription' => $subscription, 'quote' => $quote)); // Set payment method $methodInstance = $subscription->getBillingAgreement()->getPaymentMethodInstance(); if (!method_exists($methodInstance, 'initBillingAgreementPaymentInfo')) { Mage::helper('adyen_subscription')->logQuoteCron(sprintf('Payment method %s does not support Adyen_Subscription', $methodInstance->getCode())); Adyen_Subscription_Exception::throwException(Mage::helper('adyen_subscription')->__('Payment method %s does not support Adyen_Subscription', $methodInstance->getCode())); } // Set billing agreement data /* @noinspection PhpUndefinedMethodInspection */ try { /* @noinspection PhpUndefinedMethodInspection */ $methodInstance->initBillingAgreementPaymentInfo($subscription->getBillingAgreement(), $quote->getPayment()); // importan $quote->save() will not update payment object so use this: $quote->getPayment()->save(); Mage::dispatchEvent('adyen_subscription_service_updatequotepayment_after', array('subscription' => $subscription, 'quote' => $quote)); } catch (Mage_Core_Exception $e) { Mage::helper('adyen_subscription')->logQuoteCron(sprintf('Failed to set billing agreement data %s', $e->getMessage())); $subscription->setErrorMessage($e->getMessage()); $subscription->setStatus($subscription::STATUS_QUOTE_ERROR); Mage::getModel('core/resource_transaction')->addObject($quote)->addObject($subscription)->save(); Mage::dispatchEvent('adyen_subscription_service_updatequotepayment_fail', array('subscription' => $subscription, 'status' => $subscription::STATUS_QUOTE_ERROR, 'error' => $e->getMessage())); } }