本文整理汇总了PHP中Mage_Sales_Model_Quote::getPayment方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Quote::getPayment方法的具体用法?PHP Mage_Sales_Model_Quote::getPayment怎么用?PHP Mage_Sales_Model_Quote::getPayment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Quote
的用法示例。
在下文中一共展示了Mage_Sales_Model_Quote::getPayment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createNewOrder
/**
* @param Mage_Sales_Model_Quote $quote
* @return Mage_Sales_Model_Order
* @throws Exception
*/
public function createNewOrder($quote)
{
$convert = Mage::getModel('sales/convert_quote');
if ($quote->isVirtual()) {
$this->setOrder($convert->addressToOrder($quote->getBillingAddress()));
} else {
$this->setOrder($convert->addressToOrder($quote->getShippingAddress()));
}
$this->getOrder()->setBillingAddress($convert->addressToOrderAddress($quote->getBillingAddress()));
if ($quote->getBillingAddress()->getCustomerAddress()) {
$this->getOrder()->getBillingAddress()->setCustomerAddress($quote->getBillingAddress()->getCustomerAddress());
}
if (!$quote->isVirtual()) {
$this->getOrder()->setShippingAddress($convert->addressToOrderAddress($quote->getShippingAddress()));
if ($quote->getShippingAddress()->getCustomerAddress()) {
$this->getOrder()->getShippingAddress()->setCustomerAddress($quote->getShippingAddress()->getCustomerAddress());
}
}
$this->getOrder()->setPayment($convert->paymentToOrderPayment($quote->getPayment()));
$this->getOrder()->getPayment()->setTransactionId($quote->getPayment()->getTransactionId());
foreach ($quote->getAllItems() as $item) {
/** @var Mage_Sales_Model_Order_Item $item */
$orderItem = $convert->itemToOrderItem($item);
if ($item->getParentItem()) {
$orderItem->setParentItem($this->getOrder()->getItemByQuoteItemId($item->getParentItem()->getId()));
}
$this->getOrder()->addItem($orderItem);
}
$this->getOrder()->setQuote($quote);
$this->getOrder()->setExtOrderId($quote->getPayment()->getTransactionId());
$this->getOrder()->setCanSendNewEmailFlag(false);
$this->_initTransaction($quote);
return $this->getOrder();
}
示例2: _beforeToHtml
/**
* Retrieve payment method and assign additional template values
*
* @return EbayEnterprise_Paypal_Block_Express_Review
*/
protected function _beforeToHtml()
{
$methodInstance = $this->_quote->getPayment()->getMethodInstance();
$this->setPaymentMethodTitle($methodInstance->getTitle());
$this->setShippingRateRequired(true);
if ($this->_quote->getIsVirtual()) {
$this->setShippingRateRequired(false);
} else {
// prepare shipping rates
$this->_address = $this->_quote->getShippingAddress();
$groups = $this->_address->getGroupedAllShippingRates();
if ($groups && $this->_address) {
$this->setShippingRateGroups($groups);
// determine current selected code & name
foreach ($groups as $rates) {
foreach ($rates as $rate) {
if ($this->_address->getShippingMethod() == $rate->getCode()) {
$this->_currentShippingRate = $rate;
break 2;
}
}
}
}
$canEditShippingAddress = $this->_quote->getMayEditShippingAddress() && $this->_quote->getPayment()->getAdditionalInformation(EbayEnterprise_PayPal_Model_Express_Checkout::PAYMENT_INFO_BUTTON) == 1;
// misc shipping parameters
$this->setShippingMethodSubmitUrl($this->getUrl("{$this->_paypalActionPrefix}/checkout/saveShippingMethod"))->setCanEditShippingAddress($canEditShippingAddress)->setCanEditShippingMethod($this->_quote->getMayEditShippingMethod());
}
$this->setEditUrl($this->getUrl("{$this->_paypalActionPrefix}/checkout/edit"))->setPlaceOrderUrl($this->getUrl("{$this->_paypalActionPrefix}/checkout/placeOrder"));
return parent::_beforeToHtml();
}
示例3: _beforeToHtml
/**
* Retrieve payment method and assign additional template values
*
* @return Mage_Paypal_Block_Express_Review
*/
protected function _beforeToHtml()
{
$methodInstance = $this->_quote->getPayment()->getMethodInstance();
$this->setPaymentMethodTitle($methodInstance->getTitle());
$this->setShippingRateRequired(true);
if ($this->_quote->getIsVirtual()) {
$this->setShippingRateRequired(false);
} else {
// prepare shipping rates
$this->_address = $this->_quote->getShippingAddress();
$groups = $this->_address->getGroupedAllShippingRates();
if ($groups && $this->_address) {
$this->setShippingRateGroups($groups);
// determine current selected code & name
foreach ($groups as $code => $rates) {
foreach ($rates as $rate) {
if ($this->_address->getShippingMethod() == $rate->getCode()) {
$this->_currentShippingRate = $rate;
break 2;
}
}
}
}
}
return parent::_beforeToHtml();
}
示例4: _beforeToHtml
/**
* Retrieve payment method and assign additional template values
*
* @return Mage_Paypal_Block_Express_Review
*/
protected function _beforeToHtml()
{
$methodInstance = $this->_quote->getPayment()->getMethodInstance();
$this->setPaymentMethodTitle($methodInstance->getTitle());
$this->setUpdateOrderSubmitUrl($this->getUrl("{$this->_paypalActionPrefix}/express/updateOrder"));
$this->setUpdateShippingMethodsUrl($this->getUrl("{$this->_paypalActionPrefix}/express/updateShippingMethods"));
$this->setShippingRateRequired(true);
if ($this->_quote->getIsVirtual()) {
$this->setShippingRateRequired(false);
} else {
// prepare shipping rates
$this->_address = $this->_quote->getShippingAddress();
$groups = $this->_address->getGroupedAllShippingRates();
if ($groups && $this->_address) {
$this->setShippingRateGroups($groups);
// determine current selected code & name
foreach ($groups as $code => $rates) {
foreach ($rates as $rate) {
if ($this->_address->getShippingMethod() == $rate->getCode()) {
$this->_currentShippingRate = $rate;
break 2;
}
}
}
}
// misc shipping parameters
$this->setShippingMethodSubmitUrl($this->getUrl("{$this->_paypalActionPrefix}/express/saveShippingMethod"))->setCanEditShippingAddress($this->_quote->getMayEditShippingAddress())->setCanEditShippingMethod($this->_quote->getMayEditShippingMethod());
}
$this->setEditUrl($this->getUrl("{$this->_paypalActionPrefix}/express/edit"))->setPlaceOrderUrl($this->getUrl("{$this->_paypalActionPrefix}/express/placeOrder"));
return parent::_beforeToHtml();
}
示例5: _placeOrder
protected function _placeOrder($checkoutMessage, $orderStatus = 'pending', $notifyCreateOrder = false)
{
$this->_quote->collectTotals();
$this->_quote->reserveOrderId();
error_reporting(E_ERROR);
$service = Mage::getModel('sales/service_quote', $this->_quote);
// If file not exist may catch warring
error_reporting(E_ALL);
if ($service != false && method_exists($service, 'submitAll')) {
// Magento version 1.4.1.x
// $service = Mage::getModel('sales/service_quote', $quote);
$service->submitAll();
$orderObj = $service->getOrder();
} else {
// Magento version 1.4.0.x , 1.3.x
$convertQuoteObj = Mage::getSingleton('sales/convert_quote');
$orderObj = $convertQuoteObj->addressToOrder($this->_quote->getShippingAddress());
$orderObj->setBillingAddress($convertQuoteObj->addressToOrderAddress($this->_quote->getBillingAddress()));
$orderObj->setShippingAddress($convertQuoteObj->addressToOrderAddress($this->_quote->getShippingAddress()));
$orderObj->setPayment($convertQuoteObj->paymentToOrderPayment($this->_quote->getPayment()));
$items = $this->_quote->getShippingAddress()->getAllItems();
foreach ($items as $item) {
//@var $item Mage_Sales_Model_Quote_Item
$orderItem = $convertQuoteObj->itemToOrderItem($item);
if ($item->getParentItem()) {
$orderItem->setParentItem($orderObj->getItemByQuoteItemId($item->getParentItem()->getId()));
}
$orderObj->addItem($orderItem);
}
$orderObj->setCanShipPartiallyItem(false);
$orderObj->place();
}
$orderMessages = '';
$notifyMessages = $this->_processNotifyMessage();
if ($checkoutMessage || $notifyMessages) {
$orderMessages .= '<br /><b><u>' . Mage::helper('M2ePro')->__('M2E Pro Notes') . ':</u></b><br /><br />';
if ($checkoutMessage) {
$orderMessages .= '<b>' . Mage::helper('M2ePro')->__('Checkout Message From Buyer') . ':</b>';
$orderMessages .= $checkoutMessage . '<br />';
}
if ($notifyMessages) {
$orderMessages .= $notifyMessages;
}
}
// Adding notification to order
$orderObj->addStatusToHistory($orderStatus, $orderMessages, false);
$orderObj->save();
// --------------------
Mage::helper('M2ePro/Module')->getConfig()->setGroupValue('/synchronization/orders/', 'current_magento_order_id', $orderObj->getId());
$this->setFatalErrorHandler();
// --------------------
// Send Notification to customer after create order
if ($notifyCreateOrder) {
// Send new order E-mail only if select such mode
$orderObj->sendNewOrderEmail();
}
return $orderObj;
}
示例6: prepareOrderReview
/**
* Check whether order review has enough data to initialize
*
* @param $token
* @throws Mage_Core_Exception
*/
public function prepareOrderReview()
{
$payment = $this->_quote->getPayment();
if (!$payment || !$this->_quote->getCustomerEmail()) {
Mage::throwException(Mage::helper('sagepaysuite')->__('Payer is not identified.'));
}
$this->_ignoreAddressValidation();
$this->_quote->collectTotals()->save();
}
示例7: _isNewToken
/**
* check is new token when checkout
*
* @return bool
*/
protected function _isNewToken()
{
$info = $this->_quote->getPayment();
Mage::helper('ewayrapid')->unserializeInfoInstace($info);
if ($token = Mage::getSingleton('core/session')->getData('newToken')) {
Mage::getSingleton('core/session')->unsetData('newToken');
return true;
}
return false;
}
示例8: prepareOrderReview
/**
* Preparing order review
*/
public function prepareOrderReview()
{
$payment = $this->_quote->getPayment();
if (!$payment || !$payment->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_PAYER_ID)) {
Mage::throwException(Mage::helper('paypal')->__('Payer is not identified.'));
}
$this->_quote->setMayEditShippingAddress(1 != $this->_quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_SHIPPING_OVERRIDEN));
$this->_quote->setMayEditShippingMethod('' == $this->_quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_SHIPPING_METHOD));
$this->_ignoreAddressValidation();
$this->_quote->collectTotals()->save();
}
示例9: getPaymentFeeAmount
/**
* Get the payment fee amount of the payment method that is selected
*
* @param Mage_Sales_Model_Quote
* @return float
*/
public function getPaymentFeeAmount(Mage_Sales_Model_Quote $quote, $store = null)
{
$paymentMethod = $quote->getPayment()->getMethod();
if ($paymentMethod == 'adyen_openinvoice') {
return Mage::getStoreConfig('payment/adyen_openinvoice/fee');
} elseif ($paymentMethod == 'adyen_ideal') {
return Mage::getStoreConfig('payment/adyen_ideal/fee');
} elseif (substr($paymentMethod, 0, 10) == 'adyen_hpp_') {
return $this->getHppPaymentMethodFee($paymentMethod);
}
return 0;
}
示例10: testOverviewAction
/**
* Covers app/code/core/Mage/Checkout/Block/Multishipping/Payment/Info.php
* and app/code/core/Mage/Checkout/Block/Multishipping/Overview.php
*
* @magentoDataFixture Mage/Sales/_files/quote.php
* @magentoDataFixture Mage/Customer/_files/customer.php
*/
public function testOverviewAction()
{
$quote = new Mage_Sales_Model_Quote();
$quote->load('test01', 'reserved_order_id');
Mage::getSingleton('Mage_Checkout_Model_Session')->setQuoteId($quote->getId());
$session = new Mage_Customer_Model_Session();
$session->login('customer@example.com', 'password');
$this->getRequest()->setPost('payment', array('method' => 'checkmo'));
$this->dispatch('checkout/multishipping/overview');
$html = $this->getResponse()->getBody();
$this->assertContains('<p>' . $quote->getPayment()->getMethodInstance()->getTitle() . '</p>', $html);
$this->assertContains('<span class="price">$10.00</span>', $html);
}
示例11: place
/**
* Place the order and recurring payment profiles when customer returned from paypal
* Until this moment all quote data must be valid
*
* @param string $token
* @param string $shippingMethodCode
*/
public function place($token, $shippingMethodCode = null)
{
$this->updateShippingMethod($shippingMethodCode);
$isNewCustomer = $this->_prepareQuote();
$this->_ignoreAddressValidation();
$this->_quote->collectTotals();
$this->_getApi();
$payerId = $this->_quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_PAYER_ID);
$doExpressReply = $this->_api->doExpressCheckout($this->_quote, $token, $payerId);
$doAuthorizationReply = $this->_api->doAuthorization($this->_quote);
$this->_quote->getPayment()->importData(array_merge($doExpressReply, $doAuthorizationReply));
$service = Mage::getModel('sales/service_quote', $this->_quote);
try {
$service->submitAll();
// Any exceptions thrown from submitAll indicate an order that failed
// to be created. In any such cases, the payment auth needs to be voided.
} catch (Exception $e) {
$this->_api->doVoidQuote($this->_quote);
// Throw an exception for the controller to handle. Needs to indicate
// the failure to complete the PayPal payment as the PayPal process
// needs to be restarted once the auth was performed.
throw Mage::exception('EbayEnterprise_PayPal', $this->_helper->__(EbayEnterprise_Paypal_Model_Express_Api::EBAYENTERPRISE_PAYPAL_API_FAILED));
}
$this->_quote->save();
if ($isNewCustomer) {
try {
$this->_involveNewCustomer();
} catch (Exception $e) {
$this->_logger->logException($e, $this->_context->getMetaData(__CLASS__, [], $e));
}
}
$order = $service->getOrder();
if (!$order) {
return;
}
switch ($order->getState()) {
// Even after placement, paypal can disallow authorize/capture
case Mage_Sales_Model_Order::STATE_PENDING_PAYMENT:
break;
// regular placement, when everything is ok
// regular placement, when everything is ok
case Mage_Sales_Model_Order::STATE_PROCESSING:
case Mage_Sales_Model_Order::STATE_COMPLETE:
case Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW:
$order->sendNewOrderEmail();
break;
}
$this->_order = $order;
Mage::dispatchEvent('checkout_submit_all_after', array('order' => $order, 'quote' => $this->_quote));
}
示例12: _setBillingAgreementRequest
/**
* Set create billing agreement flag to api call
*
* @return Mage_Paypal_Model_Express_Checkout
*/
protected function _setBillingAgreementRequest()
{
if (!$this->_customerId || $this->_quote->hasNominalItems()) {
return $this;
}
$isRequested = $this->_isBARequested || $this->_quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT);
if (!($this->_config->allow_ba_signup == Mage_Paypal_Model_Config::EC_BA_SIGNUP_AUTO || $isRequested && $this->_config->shouldAskToCreateBillingAgreement())) {
return $this;
}
if (!Mage::getModel('sales/billing_agreement')->needToCreateForCustomer($this->_customerId)) {
return $this;
}
$this->_api->setBillingType($this->_api->getBillingAgreementType());
return $this;
}
示例13: restoreCart
/**
* Restore
*
* @param $quote Mage_Sales_Model_Quote
* @param $status string
* @return bool
*/
public function restoreCart(Mage_Sales_Model_Quote $quote, $status)
{
$storeId = $quote->getStoreId();
$gatewayMethod = $quote->getPayment()->getMethod();
$needRestore = false;
$statuses = array('canceled', 'expired', 'declined', 'void');
if (Mage::getStoreConfig('payment/msp/keep_cart', $storeId) || Mage::getStoreConfig('msp/settings/keep_cart', $storeId) || $gatewayMethod == 'msp_payafter') {
$needRestore = true;
}
if ($needRestore && in_array($status, $statuses)) {
$quote->setIsActive(true)->setReservedOrderId(null)->save();
return true;
}
return false;
}
示例14: getPaymentSpecificParams
protected function getPaymentSpecificParams(Mage_Sales_Model_Quote $quote)
{
$alias = $quote->getPayment()->getAdditionalInformation('alias');
if (is_null($alias) && $this->getDataHelper()->isAdminSession()) {
$alias = $this->getAliasHelper()->getAlias($quote);
}
$params = array('ALIAS' => $alias);
if (is_numeric($quote->getPayment()->getAdditionalInformation('cvc'))) {
$params['CVC'] = $quote->getPayment()->getAdditionalInformation('cvc');
}
$requestParams3ds = array();
if ($this->getConfig()->get3dSecureIsActive() && false == $this->getDataHelper()->isAdminSession()) {
$requestParams3ds = array('FLAG3D' => 'Y', 'WIN3DS' => Netresearch_OPS_Model_Payment_Abstract::OPS_DIRECTLINK_WIN3DS, 'LANGUAGE' => Mage::app()->getLocale()->getLocaleCode(), 'HTTP_ACCEPT' => '*/*', 'HTTP_USER_AGENT' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)', 'ACCEPTURL' => $this->getConfig()->getAcceptUrl(), 'DECLINEURL' => $this->getConfig()->getDeclineUrl(), 'EXCEPTIONURL' => $this->getConfig()->getExceptionUrl());
}
$params = array_merge($params, $requestParams3ds);
return $params;
}
示例15: savePayment
/**
* Specify quote payment method
*
* @param array $data
* @return array
*/
public function savePayment($data)
{
if ($this->_quote->isVirtual()) {
$this->_quote->getBillingAddress()->setPaymentMethod($this->_methodType);
} else {
$this->_quote->getShippingAddress()->setPaymentMethod($this->_methodType);
}
$payment = $this->_quote->getPayment();
$data['method'] = $this->_methodType;
$payment->importData($data);
$email = isset($data['payer']) ? $data['payer'] : null;
$payment->setAdditionalInformation(self::PAYMENT_INFO_PAYER_EMAIL, $email);
$payment->setAdditionalInformation(self::PAYMENT_INFO_TRANSACTION_ID, isset($data['transaction_id']) ? $data['transaction_id'] : null);
$this->_quote->setCustomerEmail($email);
$this->_quote->collectTotals()->save();
return array();
}