<?php
namespace App\Apollo\StructureParser; class Processor extends \App\Galileo\StructureParser\Processor { protected function buildTransactionObj(?\App\Utils\BaseParser\Structure\StructureParser\Processor $processor = null, $transactionType = null, $transactionIndexes = null, $classType = 'Transaction') { if ('Transaction' == $classType) { return new \App\Apollo\StructureParser\Structures\Transaction($processor, $transactionType, $transactionIndexes); } throw new \Exception('Unknown class type used'); } protected function triggerPlugins(array $transactions) { foreach ($transactions as $tr) { if ($tr->price) { $paxPrice = $tr->price; $paxPrice->originalPriceArr['supplier'] = $paxPrice->supplier; $paxPrice->originalPriceArr['supplierCurrency'] = $paxPrice->supplierCurrency; $paxPrice->originalPriceArr['tax'] = $paxPrice->tax->getAmount(); $paxPrice->originalPriceArr['taxCurrency'] = $paxPrice->tax->getCurrency(); $paxPrice->originalPriceArr['commission'] = $paxPrice->commission + $paxPrice->commissionVAT; $paxPrice->originalPriceArr['commissionCurrency'] = $paxPrice->commissionCurrency; $paxPrice->originalPriceArr['commissionComponents'] = array_map(function($c) { return [ 'IOSource' => 'raw', 'category' => $c->category, 'source' => $c->source, 'amount' => $c->amount, 'VAT' => $c->VAT, 'currency' => $c->currency, 'code' => $c->code, ]; }, $paxPrice->components->getComponentsByCategory('commission')); } } \Engine\Plugins\Manager::getInstance()->executeEvent('Apollo-getTransactions', ['this'=>$this, 'transactions'=>$transactions]); } protected function getTransactionFromRefundRaw(array $transactions, $transactionIndexes) { $transaction = $this->buildTransactionObj($this, "refund", []); $transaction->setMessagesCollector(new \App\MessagesCollector()); $structureHandled = true; $transactions[] = $transaction->getData(); return [$structureHandled, $transactions, ]; } } 