예제 #1
0
 /**
  * @param Adyen_Payment_Model_Billing_Agreement $billingAgreement
  * @param Mage_Sales_Model_Quote_Payment        $paymentInfo
  *
  * @return $this
  */
 public function initBillingAgreementPaymentInfo(Adyen_Payment_Model_Billing_Agreement $billingAgreement, Mage_Sales_Model_Quote_Payment $paymentInfo)
 {
     try {
         $recurringDetailReference = $billingAgreement->getReferenceId();
         $paymentInfo->setMethod('adyen_oneclick_' . $recurringDetailReference);
         $paymentInfo->setAdditionalInformation('recurring_detail_reference', $recurringDetailReference);
         // set the ccType needed for Sepa, Sofort and Ideal
         $agreementData = $billingAgreement->getAgreementData();
         if (isset($agreementData['variant'])) {
             $paymentInfo->setCcType($agreementData['variant']);
         }
     } catch (Exception $e) {
         Adyen_Payment_Exception::logException($e);
     }
     return $this;
 }
 /**
  * The additional info and cc type of a quote payment are not updated when
  * selecting another payment method while editing a subscription or subscription quote,
  * but they have to be updated for the payment method to be valid
  *
  * @param Mage_Sales_Model_Quote $quote
  * @param Adyen_Payment_Model_Billing_Agreement $billingAgreement
  * @return Mage_Sales_Model_Quote
  * @throws Exception
  */
 public function updateQuotePayment(Mage_Sales_Model_Quote $quote, Adyen_Payment_Model_Billing_Agreement $billingAgreement)
 {
     Mage::dispatchEvent('adyen_subscription_quote_updatequotepayment_before', array('billingAgreement' => $billingAgreement, 'quote' => $quote));
     $subscriptionDetailReference = str_replace('adyen_oneclick_', '', $quote->getPayment()->getData('method'));
     $quote->getPayment()->setAdditionalInformation('recurring_detail_reference', $subscriptionDetailReference);
     $agreementData = $billingAgreement->getAgreementData();
     if (isset($agreementData['variant'])) {
         $quote->getPayment()->setCcType($agreementData['variant']);
     } else {
         $quote->getPayment()->setCcType(null);
     }
     $quote->getPayment()->save();
     Mage::dispatchEvent('adyen_subscription_quote_updatequotepayment_after', array('billingAgreement' => $billingAgreement, 'quote' => $quote));
     return $quote;
 }