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