/**
  * Unserialize additional data if required
  * @param Mage_Sales_Model_Quote_Payment $payment
  */
 public function unserializeFields(Mage_Sales_Model_Quote_Payment $payment)
 {
     $additionalInformation = $payment->getData('additional_information');
     if (empty($additionalInformation)) {
         $payment->setData('additional_information', array());
     } elseif (!is_array($additionalInformation)) {
         $payment->setData('additional_information', unserialize($additionalInformation));
     }
 }
Esempio n. 2
0
 /**
  * Convert quote payment to order payment
  *
  * @param   Mage_Sales_Model_Quote_Payment $payment
  * @return  Mage_Sales_Model_Quote_Payment
  */
 public function paymentToOrderPayment(Mage_Sales_Model_Quote_Payment $payment)
 {
     $orderPayment = Mage::getModel('sales/order_payment')->setStoreId($payment->getStoreId())->setCustomerPaymentId($payment->getCustomerPaymentId());
     Mage::helper('core')->copyFieldset('sales_convert_quote_payment', 'to_order_payment', $payment, $orderPayment);
     Mage::dispatchEvent('sales_convert_quote_payment_to_order_payment', array('order_payment' => $orderPayment, 'quote_payment' => $payment));
     return $orderPayment;
 }
 /**
  * @param Mage_Sales_Model_Quote_Payment $payment
  * @return void
  */
 public function executeByPayment(Mage_Sales_Model_Quote_Payment $payment)
 {
     $bankaccount = $payment->getPayoneAccountNumber();
     $bankcode = $payment->getPayoneBankCode();
     $bankcountry = $payment->getPayoneBankCountry();
     $iban = $payment->getPayoneSepaIban();
     $bic = $payment->getPayoneSepaBic();
     if (empty($bankcountry)) {
         $bankcountry = $payment->getQuote()->getBillingAddress()->getCountry();
     }
     $this->execute($bankaccount, $bankcode, $bankcountry, $iban, $bic);
 }
Esempio n. 4
0
 public function setPayment(Mage_Sales_Model_Quote_Payment $payment)
 {
     if (!$this->getIsMultiPayment() && ($old = $this->getPayment())) {
         $payment->setId($old->getId());
     }
     $this->addPayment($payment);
     return $payment;
 }
 /**
  * Analyze payment data for quote and set free shipping if grand total is covered by balance
  *
  * @param Mage_Sales_Model_Quote $quote
  * @param Varien_Object|Mage_Sales_Model_Quote_Payment $payment
  * @param bool $shouldUseBalance
  */
 protected function _importPaymentData($quote, $payment, $shouldUseBalance)
 {
     $store = Mage::app()->getStore($quote->getStoreId());
     if (!$quote || !$quote->getCustomerId() || $quote->getBaseGrandTotal() + $quote->getBaseCustomerBalanceAmountUsed() <= 0) {
         return;
     }
     $quote->setUseCustomerBalance($shouldUseBalance);
     if ($shouldUseBalance) {
         $balance = Mage::getModel('enterprise_customerbalance/balance')->setCustomerId($quote->getCustomerId())->setWebsiteId($store->getWebsiteId())->loadByCustomer();
         if ($balance) {
             $quote->setCustomerBalanceInstance($balance);
             if (!$payment->getMethod()) {
                 $payment->setMethod('free');
             }
         } else {
             $quote->setUseCustomerBalance(false);
         }
     }
 }
Esempio n. 6
0
 public function exportPaymentTo(Mage_Sales_Model_Quote_Payment $payment)
 {
     $resource = $this->getPayment();
     if (!$resource->getMethod()) {
         return $this;
     }
     $countryId = $this->getAddress()->getCountryId();
     $payment->setMethod($resource->getMethod());
     $method = $payment->getMethodInstance();
     if (!$method->isAvailable($payment->getQuote()) || !$method->canUseForCountry($countryId)) {
         $payment->unsMethod();
     }
     return $this;
 }
Esempio n. 7
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;
 }
Esempio n. 8
0
 /**
  * Update the resource model
  *
  * @param Mage_Sales_Model_Quote_Payment $resource
  * @param array                          $data
  *
  * @return Mage_Sales_Model_Quote_Item
  */
 public function updateResource(Mage_Sales_Model_Quote_Payment $resource, array $data)
 {
     // Store current state
     $actionType = $this->getActionType();
     $operation = $this->getOperation();
     // Change state
     $this->setActionType(self::ACTION_TYPE_ENTITY);
     $this->setOperation(self::OPERATION_UPDATE);
     // Get a filter instance
     $filter = $this->getFilter();
     // Fire event - before filter
     $data = new Varien_Object($data);
     Mage::dispatchEvent('aoe_cartapi_payment_update_before', ['data' => $data, 'filter' => $filter, 'resource' => $resource]);
     $data = $data->getData();
     // Filter raw incoming data
     $data = $filter->in($data);
     // Clean up input format to what Magento expects
     if (isset($data['data']) && is_array($data['data'])) {
         $base = $data;
         unset($base['data']);
         $data = array_merge($data['data'], $base);
     } else {
         unset($data['data']);
     }
     // Map data keys
     $data = $this->mapAttributes($data);
     // Manual data setting
     $quote = $resource->getQuote();
     if ($quote->isVirtual()) {
         $quote->getBillingAddress()->setPaymentMethod(isset($data['method']) ? $data['method'] : null);
     } else {
         $quote->getShippingAddress()->setPaymentMethod(isset($data['method']) ? $data['method'] : null);
         // Shipping totals may be affected by payment method
         $quote->getShippingAddress()->setCollectShippingRates(true);
     }
     // Define validation checks
     $data['checks'] = Mage_Payment_Model_Method_Abstract::CHECK_USE_CHECKOUT | Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_COUNTRY | Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_CURRENCY | Mage_Payment_Model_Method_Abstract::CHECK_ORDER_TOTAL_MIN_MAX;
     // Update model
     $resource->importData($data);
     // Fire event - after
     $data = new Varien_Object($data);
     Mage::dispatchEvent('aoe_cartapi_payment_update_after', ['data' => $data, 'filter' => $filter, 'resource' => $resource]);
     // Restore old state
     $this->setActionType($actionType);
     $this->setOperation($operation);
     // Return updated resource
     return $resource;
 }
Esempio n. 9
0
 /**
  * Coverts payment instance to authorize.net array
  * @param Mage_Sales_Model_Quote_Payment $Payment
  * @return array
  */
 protected function _convertPayment(Mage_Sales_Model_Quote_Payment $Payment)
 {
     $cardNumber = Mage::getSingleton('customer/session')->getSarpCcNumber();
     $cid = Mage::getSingleton('customer/session')->getSarpCcCid();
     $an_payment = array('creditCard' => array('cardNumber' => $cardNumber, 'expirationDate' => $Payment->getMethodInstance()->getInfoInstance()->getCcExpYear() . "-" . $this->_addZero($Payment->getMethodInstance()->getInfoInstance()->getCcExpMonth()), 'cardCode' => $cid));
     return $an_payment;
 }
Esempio n. 10
0
 /**
  * Encrypt the payment data for the given payment model
  *
  * @param Mage_Sales_Model_Quote_Payment|Mage_Sales_Model_Order_Payment $payment Payment Model
  */
 protected function _encryptPaymentData($payment)
 {
     try {
         $method = $payment->getMethodInstance();
     } catch (Exception $e) {
         return $this;
     }
     if ($method instanceof Itabs_Debit_Model_Debit) {
         $info = $method->getInfoInstance();
         if ($payment->getData('debit_swift') != '') {
             $payment->setData('debit_swift', $info->encrypt($payment->getData('debit_swift')));
         }
         if ($payment->getData('debit_iban') != '') {
             $payment->setData('debit_iban', $info->encrypt($payment->getData('debit_iban')));
         }
     }
 }
Esempio n. 11
0
 /**
  * Convert quote payment to order payment
  *
  * @param   Mage_Sales_Model_Quote_Payment $payment
  * @return  Mage_Sales_Model_Quote_Payment
  */
 public function paymentToOrderPayment(Mage_Sales_Model_Quote_Payment $payment)
 {
     $orderPayment = Mage::getModel('sales/order_payment')->setStoreId($payment->getStoreId())->setCustomerPaymentId($payment->getCustomerPaymentId())->setMethod($payment->getMethod())->setAdditionalData($payment->getAdditionalData())->setPoNumber($payment->getPoNumber())->setCcType($payment->getCcType())->setCcNumberEnc($payment->getCcNumberEnc())->setCcLast4($payment->getCcLast4())->setCcOwner($payment->getCcOwner())->setCcCidEnc($payment->getCcCidEnc())->setCcExpMonth($payment->getCcExpMonth())->setCcExpYear($payment->getCcExpYear());
     return $orderPayment;
 }
Esempio n. 12
0
 /**
  * Convert quote payment to order payment
  *
  * @param   Mage_Sales_Model_Quote_Payment $payment
  * @return  Mage_Sales_Model_Quote_Payment
  */
 public function paymentToOrderPayment(Mage_Sales_Model_Quote_Payment $payment)
 {
     $orderPayment = AO::getModel('sales/order_payment')->setStoreId($payment->getStoreId())->setCustomerPaymentId($payment->getCustomerPaymentId());
     AO::helper('core')->copyFieldset('sales_convert_quote_payment', 'to_order_payment', $payment, $orderPayment);
     //            ->setMethod($payment->getMethod())
     //            ->setAdditionalData($payment->getAdditionalData())
     //            ->setPoNumber($payment->getPoNumber())
     //            ->setCcType($payment->getCcType())
     //            ->setCcNumberEnc($payment->getCcNumberEnc())
     //            ->setCcLast4($payment->getCcLast4())
     //            ->setCcOwner($payment->getCcOwner())
     //            ->setCcExpMonth($payment->getCcExpMonth())
     //            ->setCcExpYear($payment->getCcExpYear())
     //
     //            ->setCcNumber($payment->getCcNumber()) // only for doing first transaction, not for save
     //            ->setCcCid($payment->getCcCid()) // only for doing first transaction, not for save
     //
     //                        ->setCcSsIssue($payment->getCcSsIssue())	//for direct payment
     //                        ->setCcSsStartMonth($payment->getCcSsStartMonth()) //for direct payment
     //            ->setCcSsStartYear($payment->getCcSsStartYear())	//for direct payment
     //            ;
     AO::dispatchEvent('sales_convert_quote_payment_to_order_payment', array('order_payment' => $orderPayment, 'quote_payment' => $payment));
     return $orderPayment;
 }
Esempio n. 13
0
 /**
  * set the account data to given payment
  *
  * @param Mage_Sales_Model_Quote_Payment $payment
  * @param array                          $params
  */
 protected function setAccountData(Mage_Sales_Model_Quote_Payment $payment, array $params)
 {
     $country = $this->getCountry($params);
     if ('DE' == $country || 'AT' == $country) {
         if ($this->hasIban($params) && 'DE' == $country) {
             $payment->setAdditionalInformation('CARDNO', trim($params['iban']));
         } else {
             $payment->setAdditionalInformation('CARDNO', trim($params['account']) . 'BLZ' . trim($params['bankcode']));
         }
     }
     if ('NL' == $country) {
         if ($this->hasIban($params)) {
             $payment->setAdditionalInformation('CARDNO', trim($params['iban']));
             $payment->setAdditionalInformation('BIC', trim($params['bic']));
         } else {
             $payment->setAdditionalInformation('CARDNO', str_pad($params['account'], '0', STR_PAD_LEFT));
         }
     }
 }