. */ namespace Storefront\BTCPay\Model; use Storefront\BTCPay\Api\Data\TransactionInterface; use Storefront\BTCPay\Api\Data\TransactionInterfaceFactory; use Magento\Framework\Api\DataObjectHelper; class Transaction extends \Magento\Framework\Model\AbstractModel { const STATUS_PAID = 'paid'; const STATUS_CONFIRMED = 'confirmed'; const STATUS_COMPLETE = 'complete'; const STATUS_INVALID = 'invalid'; const STATUS_EXPIRED = 'expired'; protected $transactionDataFactory; protected $dataObjectHelper; protected $_eventPrefix = 'storefront_btcpay_transaction'; /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param TransactionInterfaceFactory $transactionDataFactory * @param DataObjectHelper $dataObjectHelper * @param \Storefront\BTCPay\Model\ResourceModel\Transaction $resource * @param \Storefront\BTCPay\Model\ResourceModel\Transaction\Collection $resourceCollection * @param array $data */ public function __construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, TransactionInterfaceFactory $transactionDataFactory, DataObjectHelper $dataObjectHelper, \Storefront\BTCPay\Model\ResourceModel\Transaction $resource, \Storefront\BTCPay\Model\ResourceModel\Transaction\Collection $resourceCollection, array $data = []) { $this->transactionDataFactory = $transactionDataFactory; $this->dataObjectHelper = $dataObjectHelper; parent::__construct($context, $registry, $resource, $resourceCollection, $data); } /** * Retrieve transaction model with transaction data * @return TransactionInterface */ public function getDataModel() { $transactionData = $this->getData(); $transactionDataObject = $this->transactionDataFactory->create(); $this->dataObjectHelper->populateWithArray($transactionDataObject, $transactionData, TransactionInterface::class); return $transactionDataObject; } }