Example #1
0
 public function assignData($data)
 {
     if (!$data instanceof Varien_Object) {
         $data = new Varien_Object($data);
     }
     $info = $this->getInfoInstance();
     // get storeId
     if (Mage::app()->getStore()->isAdmin()) {
         $store = Mage::getSingleton('adminhtml/session_quote')->getStore();
     } else {
         $store = Mage::app()->getStore();
     }
     $storeId = $store->getId();
     if ($data->getRecurringDetailReference()) {
         // this can be the case if you select the recurring card from the POS express checkout mechanisme
         $info->setAdditionalInformation('recurring_detail_reference', $data->getRecurringDetailReference());
     } else {
         // Get recurringDetailReference from config
         $recurringDetailReference = Mage::getStoreConfig("payment/" . $this->getCode() . "/recurringDetailReference", $storeId);
         $info->setAdditionalInformation('recurring_detail_reference', $recurringDetailReference);
     }
     $ccType = Mage::getStoreConfig("payment/" . $this->getCode() . "/variant", $storeId);
     $ccType = Mage::helper('adyen')->getMagentoCreditCartType($ccType);
     $info->setCcType($ccType);
     if ($this->isCseEnabled()) {
         $info->setAdditionalInformation('encrypted_data', $data->getEncryptedDataOneclick());
     } else {
         // check if expiry month and year is changed
         $expiryMonth = $data->getOneclickExpMonth();
         $expiryYear = $data->getOneclickExpYear();
         $cvcCode = $data->getOneclickCid();
         $cardHolderName = Mage::getStoreConfig("payment/" . $this->getCode() . "/card_holderName", $storeId);
         $last4Digits = Mage::getStoreConfig("payment/" . $this->getCode() . "/card_number", $storeId);
         $cardHolderName = Mage::getStoreConfig("payment/" . $this->getCode() . "/card_holderName", $storeId);
         // just set default data for info block only
         $info->setCcType($ccType)->setCcOwner($cardHolderName)->setCcLast4($last4Digits)->setCcExpMonth($expiryMonth)->setCcExpYear($expiryYear)->setCcCid($cvcCode);
     }
     if (Mage::helper('adyen/installments')->isInstallmentsEnabled()) {
         $info->setAdditionalInformation('number_of_installments', $data->getInstallment());
     } else {
         $info->setAdditionalInformation('number_of_installments', "");
     }
     if ($info->getAdditionalInformation('number_of_installments') != "") {
         // recalculate the totals so that extra fee is defined
         $quote = Mage::getModel('checkout/type_onepage') !== false ? Mage::getModel('checkout/type_onepage')->getQuote() : Mage::getModel('checkout/session')->getQuote();
         $quote->setTotalsCollectedFlag(false);
         $quote->collectTotals();
     }
     return $this;
 }