コード例 #1
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;
 }
コード例 #2
0
 /**
  * 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);
         }
     }
 }
コード例 #3
0
ファイル: Oneclick.php プロジェクト: asarturas/magento
 /**
  * @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;
 }