123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Payment\Gateway\Data\Quote;
- use Magento\Framework\Exception\LocalizedException;
- use Magento\Payment\Gateway\Data\OrderAdapterInterface;
- use Magento\Quote\Api\Data\CartInterface;
- use Magento\Payment\Gateway\Data\AddressAdapterInterface;
- /**
- * Class QuoteAdapter
- */
- class QuoteAdapter implements OrderAdapterInterface
- {
- /**
- * @var CartInterface
- */
- private $quote;
- /**
- * @var AddressAdapter
- */
- private $addressAdapterFactory;
- /**
- * @param CartInterface $quote
- * @param AddressAdapterFactory $addressAdapterFactory
- */
- public function __construct(
- CartInterface $quote,
- AddressAdapterFactory $addressAdapterFactory
- ) {
- $this->quote = $quote;
- $this->addressAdapterFactory = $addressAdapterFactory;
- }
- /**
- * Returns currency code
- *
- * @return string
- */
- public function getCurrencyCode()
- {
- return $this->quote->getCurrency()->getBaseCurrencyCode();
- }
- /**
- * Returns order increment id
- *
- * @return string
- */
- public function getOrderIncrementId()
- {
- return $this->quote->getReservedOrderId();
- }
- /**
- * Returns customer ID
- *
- * @return int|null
- */
- public function getCustomerId()
- {
- return $this->quote->getCustomer()->getId();
- }
- /**
- * Returns billing address
- *
- * @return AddressAdapterInterface|null
- */
- public function getBillingAddress()
- {
- if ($this->quote->getBillingAddress()) {
- return $this->addressAdapterFactory->create(
- ['address' => $this->quote->getBillingAddress()]
- );
- }
- return null;
- }
- /**
- * Returns shipping address
- *
- * @return AddressAdapterInterface|null
- */
- public function getShippingAddress()
- {
- if ($this->quote->getShippingAddress()) {
- return $this->addressAdapterFactory->create(
- ['address' => $this->quote->getShippingAddress()]
- );
- }
- return null;
- }
- /**
- * Returns order store id
- *
- * @return int
- */
- public function getStoreId()
- {
- return $this->quote->getStoreId();
- }
- /**
- * Returns order id
- *
- * @return int
- */
- public function getId()
- {
- return $this->quote->getId();
- }
- /**
- * Returns order grand total amount
- *
- * @return null
- */
- public function getGrandTotalAmount()
- {
- return null;
- }
- /**
- * Returns list of line items in the cart
- *
- * @return \Magento\Quote\Api\Data\CartItemInterface[]|null
- */
- public function getItems()
- {
- return $this->quote->getItems();
- }
- /**
- * Gets the remote IP address for the order.
- *
- * @return string|null Remote IP address.
- */
- public function getRemoteIp()
- {
- return null;
- }
- }
|