| Current Path : /var/www/clients/client3/web2/web/vendor/magento/module-payment/Gateway/Data/Order/ |
| Current File : /var/www/clients/client3/web2/web/vendor/magento/module-payment/Gateway/Data/Order/OrderAdapter.php |
<?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();
}
}