Gateway/Request/ReferenceIdRequest.php
<?php
/**
* PagBank Payment Magento Module.
*
* Copyright © 2023 PagBank. All rights reserved.
*
* @author Bruno Elisei <brunoelisei@o2ti.com>
* @license See LICENSE for license details.
*/
namespace PagBank\PaymentMagento\Gateway\Request;
use Magento\Payment\Gateway\Data\PaymentDataObject;
use Magento\Payment\Gateway\Helper\SubjectReader;
use Magento\Payment\Gateway\Request\BuilderInterface;
/**
* Class Reference Id Request - Structure for order reference information in orders.
*/
class ReferenceIdRequest implements BuilderInterface
{
/**
* Reference id block name.
*/
public const REFERENCE_ID = 'reference_id';
/**
* @var SubjectReader
*/
protected $subjectReader;
/**
* @param SubjectReader $subjectReader
*/
public function __construct(
SubjectReader $subjectReader
) {
$this->subjectReader = $subjectReader;
}
/**
* Build.
*
* @param array $buildSubject
*
* @SuppressWarnings(PHPMD.StaticAccess)
*/
public function build(array $buildSubject)
{
$result = [];
/** @var PaymentDataObject $paymentDO * */
$paymentDO = SubjectReader::readPayment($buildSubject);
/** @var \Magento\Sales\Model\Order $order */
$order = $paymentDO->getOrder();
$result = [
self::REFERENCE_ID => $order->getOrderIncrementId(),
];
return $result;
}
}