for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Copyright © Getnet. All rights reserved.
*
* @author Bruno Elisei <[email protected]>
* See LICENSE for license details.
*/
namespace Getnet\PaymentMagento\Gateway\Request;
use Getnet\PaymentMagento\Gateway\Config\Config;
use Getnet\PaymentMagento\Gateway\SubjectReader;
use InvalidArgumentException;
use Magento\Payment\Gateway\Data\PaymentDataObjectInterface;
use Magento\Payment\Gateway\Request\BuilderInterface;
* Class Store Id Data Request - Store Id structure.
class StoreIdDataRequest implements BuilderInterface
{
* Store Id block name.
public const STORE_ID = 'store_id';
* @var SubjectReader
protected $subjectReader;
* @var Config
protected $config;
* @param SubjectReader $subjectReader
* @param Config $config
public function __construct(
SubjectReader $subjectReader,
Config $config
) {
$this->subjectReader = $subjectReader;
$this->config = $config;
}
* Build.
* @param array $buildSubject
public function build(array $buildSubject): array
if (!isset($buildSubject['payment'])
|| !$buildSubject['payment'] instanceof PaymentDataObjectInterface
throw new InvalidArgumentException('Payment data object should be provided');
$paymentDO = $buildSubject['payment'];
$order = $paymentDO->getOrder();
$storeId = $order->getStoreId();
return [
self::STORE_ID => $storeId ?: 0,
];