当前位置: 首页>>代码示例>>PHP>>正文


PHP Quote::getPayment方法代码示例

本文整理汇总了PHP中Magento\Quote\Model\Quote::getPayment方法的典型用法代码示例。如果您正苦于以下问题:PHP Quote::getPayment方法的具体用法?PHP Quote::getPayment怎么用?PHP Quote::getPayment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Quote\Model\Quote的用法示例。


在下文中一共展示了Quote::getPayment方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _beforeToHtml

 /**
  * Retrieve payment method and assign additional template values
  *
  * @return $this
  * @SuppressWarnings(PHPMD.UnusedLocalVariable)
  */
 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;
                     }
                 }
             }
         }
         $canEditShippingAddress = $this->_quote->getMayEditShippingAddress() && $this->_quote->getPayment()->getAdditionalInformation(\Magento\Paypal\Model\Express\Checkout::PAYMENT_INFO_BUTTON) == 1;
         // misc shipping parameters
         $this->setShippingMethodSubmitUrl($this->getUrl("{$this->_controllerPath}/saveShippingMethod"))->setCanEditShippingAddress($canEditShippingAddress)->setCanEditShippingMethod($this->_quote->getMayEditShippingMethod());
     }
     $this->setEditUrl($this->getUrl("{$this->_controllerPath}/edit"))->setPlaceOrderUrl($this->getUrl("{$this->_controllerPath}/placeOrder"));
     return parent::_beforeToHtml();
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:36,代码来源:Review.php

示例2: execute

 /**
  * Execute operation
  *
  * @param string $nonce
  * @param array $details
  * @param Quote $quote
  * @return void
  * @throws \InvalidArgumentException
  * @throws LocalizedException
  */
 public function execute($nonce, array $details, Quote $quote)
 {
     if (empty($nonce) || empty($details)) {
         throw new \InvalidArgumentException('The "nonce" and "details" fields does not exists');
     }
     $payment = $quote->getPayment();
     $payment->setMethod(ConfigProvider::PAYPAL_CODE);
     $payment->setAdditionalInformation(DataAssignObserver::PAYMENT_METHOD_NONCE, $nonce);
     $this->updateQuote($quote, $details);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:20,代码来源:QuoteUpdater.php

示例3: testOverviewAction

 /**
  * Covers \Magento\Multishipping\Block\Checkout\Payment\Info and \Magento\Multishipping\Block\Checkout\Overview
  *
  * @magentoConfigFixture current_store multishipping/options/checkout_multiple 1
  */
 public function testOverviewAction()
 {
     /** @var \Magento\Framework\Data\Form\FormKey $formKey */
     $formKey = $this->_objectManager->get('Magento\\Framework\\Data\\Form\\FormKey');
     $logger = $this->getMock('Psr\\Log\\LoggerInterface', [], [], '', false);
     /** @var \Magento\Customer\Api\AccountManagementInterface $service */
     $service = $this->_objectManager->create('Magento\\Customer\\Api\\AccountManagementInterface');
     $customer = $service->authenticate('customer@example.com', 'password');
     /** @var \Magento\Customer\Model\Session $customerSession */
     $customerSession = $this->_objectManager->create('Magento\\Customer\\Model\\Session', [$logger]);
     $customerSession->setCustomerDataAsLoggedIn($customer);
     $this->checkoutSession->setCheckoutState(State::STEP_BILLING);
     $this->getRequest()->setPostValue('payment', ['method' => 'checkmo']);
     $this->dispatch('multishipping/checkout/overview');
     $html = $this->getResponse()->getBody();
     $this->assertContains('<div class="box box-billing-method">', $html);
     $this->assertContains('<div class="box box-shipping-method">', $html);
     $this->assertContains('<dt class="title">' . $this->quote->getPayment()->getMethodInstance()->getTitle() . '</dt>', $html);
     $this->assertContains('<span class="price">$10.00</span>', $html);
     $this->assertContains('<input name="form_key" type="hidden" value="' . $formKey->getFormKey(), $html);
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:26,代码来源:CheckoutTest.php

示例4: testGetPaymentIsDeleted

 public function testGetPaymentIsDeleted()
 {
     $this->quote->setId(1);
     $payment = $this->getMock('Magento\\Quote\\Model\\Quote\\Payment', ['setQuote', 'isDeleted', 'getId', '__wakeup'], [], '', false);
     $payment->expects($this->exactly(2))->method('setQuote');
     $payment->expects($this->once())->method('isDeleted')->willReturn(true);
     $payment->expects($this->once())->method('getId')->willReturn(1);
     $quotePaymentCollectionMock = $this->getMock('Magento\\Quote\\Model\\Resource\\Quote\\Payment\\Collection', ['setQuoteFilter', 'getFirstItem'], [], '', false);
     $quotePaymentCollectionMock->expects($this->once())->method('setQuoteFilter')->with(1)->will($this->returnSelf());
     $quotePaymentCollectionMock->expects($this->once())->method('getFirstItem')->willReturn($payment);
     $this->quotePaymentCollectionFactoryMock->expects($this->once())->method('create')->willReturn($quotePaymentCollectionMock);
     $this->paymentFactoryMock->expects($this->once())->method('create')->willReturn($payment);
     $this->assertInstanceOf('\\Magento\\Quote\\Model\\Quote\\Payment', $this->quote->getPayment());
 }
开发者ID:nja78,项目名称:magento2,代码行数:14,代码来源:QuoteTest.php

示例5: _setBillingAgreementRequest

 /**
  * Set create billing agreement flag to api call
  *
  * @return $this
  */
 protected function _setBillingAgreementRequest()
 {
     if (!$this->_customerId) {
         return $this;
     }
     $isRequested = $this->_isBARequested || $this->_quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT);
     if (!($this->_config->getValue('allow_ba_signup') == PaypalConfig::EC_BA_SIGNUP_AUTO || $isRequested && $this->_config->shouldAskToCreateBillingAgreement())) {
         return $this;
     }
     if (!$this->_agreementFactory->create()->needToCreateForCustomer($this->_customerId)) {
         return $this;
     }
     $this->_api->setBillingType($this->_api->getBillingAgreementType());
     return $this;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:20,代码来源:Checkout.php

示例6: validateBeforeSubmit

 /**
  * Validate quote before submit
  *
  * @param Quote $quote
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function validateBeforeSubmit(QuoteEntity $quote)
 {
     if (!$quote->isVirtual()) {
         if ($quote->getShippingAddress()->validate() !== true) {
             throw new \Magento\Framework\Exception\LocalizedException(__('Please check the shipping address information. %1', implode(' ', $quote->getShippingAddress()->validate())));
         }
         $method = $quote->getShippingAddress()->getShippingMethod();
         $rate = $quote->getShippingAddress()->getShippingRateByCode($method);
         if (!$quote->isVirtual() && (!$method || !$rate)) {
             throw new \Magento\Framework\Exception\LocalizedException(__('Please specify a shipping method.'));
         }
     }
     if ($quote->getBillingAddress()->validate() !== true) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Please check the billing address information. %1', implode(' ', $quote->getBillingAddress()->validate())));
     }
     if (!$quote->getPayment()->getMethod()) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Please select a valid payment method.'));
     }
     return $this;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:27,代码来源:QuoteValidator.php

示例7: sendPaymentFailedEmail

 /**
  * Send email id payment was failed
  *
  * @param \Magento\Quote\Model\Quote $checkout
  * @param string $message
  * @param string $checkoutType
  * @return $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function sendPaymentFailedEmail($checkout, $message, $checkoutType = 'onepage')
 {
     $this->inlineTranslation->suspend();
     $template = $this->scopeConfig->getValue('checkout/payment_failed/template', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $checkout->getStoreId());
     $copyTo = $this->_getEmails('checkout/payment_failed/copy_to', $checkout->getStoreId());
     $copyMethod = $this->scopeConfig->getValue('checkout/payment_failed/copy_method', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $checkout->getStoreId());
     $bcc = [];
     if ($copyTo && $copyMethod == 'bcc') {
         $bcc = $copyTo;
     }
     $_receiver = $this->scopeConfig->getValue('checkout/payment_failed/receiver', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $checkout->getStoreId());
     $sendTo = [['email' => $this->scopeConfig->getValue('trans_email/ident_' . $_receiver . '/email', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $checkout->getStoreId()), 'name' => $this->scopeConfig->getValue('trans_email/ident_' . $_receiver . '/name', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $checkout->getStoreId())]];
     if ($copyTo && $copyMethod == 'copy') {
         foreach ($copyTo as $email) {
             $sendTo[] = ['email' => $email, 'name' => null];
         }
     }
     $shippingMethod = '';
     if ($shippingInfo = $checkout->getShippingAddress()->getShippingMethod()) {
         $data = explode('_', $shippingInfo);
         $shippingMethod = $data[0];
     }
     $paymentMethod = '';
     if ($paymentInfo = $checkout->getPayment()) {
         $paymentMethod = $paymentInfo->getMethod();
     }
     $items = '';
     foreach ($checkout->getAllVisibleItems() as $_item) {
         /* @var $_item \Magento\Quote\Model\Quote\Item */
         $items .= $_item->getProduct()->getName() . '  x ' . $_item->getQty() . '  ' . $checkout->getStoreCurrencyCode() . ' ' . $_item->getProduct()->getFinalPrice($_item->getQty()) . "\n";
     }
     $total = $checkout->getStoreCurrencyCode() . ' ' . $checkout->getGrandTotal();
     foreach ($sendTo as $recipient) {
         $transport = $this->_transportBuilder->setTemplateIdentifier($template)->setTemplateOptions(['area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $checkout->getStoreId()])->setTemplateVars(['reason' => $message, 'checkoutType' => $checkoutType, 'dateAndTime' => $this->_localeDate->formatDateTime(new \DateTime(), \IntlDateFormatter::MEDIUM, \IntlDateFormatter::MEDIUM), 'customer' => $checkout->getCustomerFirstname() . ' ' . $checkout->getCustomerLastname(), 'customerEmail' => $checkout->getCustomerEmail(), 'billingAddress' => $checkout->getBillingAddress(), 'shippingAddress' => $checkout->getShippingAddress(), 'shippingMethod' => $this->scopeConfig->getValue('carriers/' . $shippingMethod . '/title', \Magento\Store\Model\ScopeInterface::SCOPE_STORE), 'paymentMethod' => $this->scopeConfig->getValue('payment/' . $paymentMethod . '/title', \Magento\Store\Model\ScopeInterface::SCOPE_STORE), 'items' => nl2br($items), 'total' => $total])->setFrom($this->scopeConfig->getValue('checkout/payment_failed/identity', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $checkout->getStoreId()))->addTo($recipient['email'], $recipient['name'])->addBcc($bcc)->getTransport();
         $transport->sendMessage();
     }
     $this->inlineTranslation->resume();
     return $this;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:49,代码来源:Data.php

示例8: initializePaymentMethodData

 private function initializePaymentMethodData()
 {
     $quotePayment = $this->quote->getPayment();
     $quotePayment->importData($this->proxyOrder->getPaymentData());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:5,代码来源:Quote.php

示例9: _populateQuotePaymentMethod

 public function _populateQuotePaymentMethod(\Magento\Quote\Model\Quote $quote)
 {
     $quote->setPaymentMethod(self::METHOD_PAYMENT);
     $quote->getPayment()->setMethod(self::METHOD_PAYMENT);
 }
开发者ID:praxigento,项目名称:mobi_app_generic_mage2,代码行数:5,代码来源:SaleOrder.php


注:本文中的Magento\Quote\Model\Quote::getPayment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。