getnet-adquirencia /
split-example-magento
| 1 | <?php |
||||
| 2 | /** |
||||
| 3 | * Copyright © O2TI. All rights reserved. |
||||
| 4 | * |
||||
| 5 | * @author Bruno Elisei <[email protected]> |
||||
| 6 | * See COPYING.txt for license details. |
||||
| 7 | */ |
||||
| 8 | |||||
| 9 | namespace Getnet\SplitExampleMagento\Plugin\Getnet\PaymentMagento\Gateway\Request; |
||||
| 10 | |||||
| 11 | use Getnet\PaymentMagento\Gateway\Config\Config; |
||||
| 12 | use Getnet\PaymentMagento\Gateway\Data\Order\OrderAdapterFactory; |
||||
|
0 ignored issues
–
show
|
|||||
| 13 | use Getnet\PaymentMagento\Gateway\Request\RefundRequest; |
||||
| 14 | use Getnet\PaymentMagento\Gateway\SubjectReader; |
||||
| 15 | use Getnet\SplitExampleMagento\Helper\Data as SplitHelper; |
||||
| 16 | use Magento\Framework\App\Config\ScopeConfigInterface; |
||||
| 17 | use Magento\Framework\Serialize\Serializer\Json; |
||||
| 18 | use Magento\Sales\Api\Data\TransactionSearchResultInterfaceFactory as TransactionSearch; |
||||
|
0 ignored issues
–
show
The type
Magento\Sales\Api\Data\T...hResultInterfaceFactory was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||
| 19 | |||||
| 20 | /** |
||||
| 21 | * Class Addtional Data for Refund - add marketplace data in Transaction. |
||||
| 22 | */ |
||||
| 23 | class AddtionalDataRefundRequest |
||||
| 24 | { |
||||
| 25 | public const MARKETPLACE_SUBSELLER_PAYMENTS = 'marketplace_subseller_payments'; |
||||
| 26 | |||||
| 27 | /** |
||||
| 28 | * @var SubjectReader |
||||
| 29 | */ |
||||
| 30 | protected $subjectReader; |
||||
| 31 | |||||
| 32 | /** |
||||
| 33 | * @var OrderAdapterFactory |
||||
| 34 | */ |
||||
| 35 | protected $orderAdapterFactory; |
||||
| 36 | |||||
| 37 | /** |
||||
| 38 | * @var Config |
||||
| 39 | */ |
||||
| 40 | protected $config; |
||||
| 41 | |||||
| 42 | /** |
||||
| 43 | * @var SplitHelper; |
||||
| 44 | */ |
||||
| 45 | protected $splitHelper; |
||||
| 46 | |||||
| 47 | /** |
||||
| 48 | * @var TransactionSearch |
||||
| 49 | */ |
||||
| 50 | protected $transactionSearch; |
||||
| 51 | |||||
| 52 | /** |
||||
| 53 | * @var Json |
||||
| 54 | */ |
||||
| 55 | protected $json; |
||||
| 56 | |||||
| 57 | /** |
||||
| 58 | * @var ScopeConfigInterface |
||||
| 59 | */ |
||||
| 60 | protected $scopeConfig; |
||||
| 61 | |||||
| 62 | /** |
||||
| 63 | * @param SubjectReader $subjectReader |
||||
| 64 | * @param OrderAdapterFactory $orderAdapterFactory |
||||
| 65 | * @param Config $config |
||||
| 66 | * @param SplitHelper $splitHelper |
||||
| 67 | * @param TransactionSearch $transactionSearch |
||||
| 68 | * @param Json $json |
||||
| 69 | * @param ScopeConfigInterface $scopeConfig |
||||
| 70 | */ |
||||
| 71 | public function __construct( |
||||
| 72 | SubjectReader $subjectReader, |
||||
| 73 | OrderAdapterFactory $orderAdapterFactory, |
||||
| 74 | Config $config, |
||||
| 75 | SplitHelper $splitHelper, |
||||
| 76 | TransactionSearch $transactionSearch, |
||||
| 77 | Json $json, |
||||
| 78 | ScopeConfigInterface $scopeConfig |
||||
| 79 | ) { |
||||
| 80 | $this->subjectReader = $subjectReader; |
||||
| 81 | $this->orderAdapterFactory = $orderAdapterFactory; |
||||
| 82 | $this->config = $config; |
||||
| 83 | $this->splitHelper = $splitHelper; |
||||
| 84 | $this->transactionSearch = $transactionSearch; |
||||
| 85 | $this->json = $json; |
||||
| 86 | $this->scopeConfig = $scopeConfig; |
||||
| 87 | } |
||||
| 88 | |||||
| 89 | /** |
||||
| 90 | * Around method Build. |
||||
| 91 | * |
||||
| 92 | * @param RefundRequest $subject |
||||
| 93 | * @param \Closure $proceed |
||||
| 94 | * @param array $buildSubject |
||||
| 95 | * |
||||
| 96 | * @return mixin |
||||
|
0 ignored issues
–
show
The type
Getnet\SplitExampleMagen...o\Gateway\Request\mixin was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||
| 97 | * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
||||
| 98 | */ |
||||
| 99 | public function aroundBuild( |
||||
| 100 | RefundRequest $subject, |
||||
|
0 ignored issues
–
show
The parameter
$subject is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||
| 101 | \Closure $proceed, |
||||
| 102 | $buildSubject |
||||
| 103 | ) { |
||||
| 104 | $result = $proceed($buildSubject); |
||||
| 105 | |||||
| 106 | $paymentDO = $this->subjectReader->readPayment($buildSubject); |
||||
| 107 | |||||
| 108 | $order = $paymentDO->getOrder(); |
||||
| 109 | |||||
| 110 | $orderId = $order->getId(); |
||||
| 111 | |||||
| 112 | $transaction = $this->transactionSearch->create()->addOrderIdFilter($orderId)->getFirstItem(); |
||||
| 113 | |||||
| 114 | $sellersItems = $transaction->getOrder()->getPayment()->getAdditionalInformation('marketplace'); |
||||
| 115 | |||||
| 116 | $sellersItems = $this->json->unserialize($sellersItems); |
||||
| 117 | |||||
| 118 | if (is_array($sellersItems)) { |
||||
| 119 | foreach ($sellersItems as $sellerId => $items) { |
||||
| 120 | $sellers = ['subseller_id' => $sellerId]; |
||||
| 121 | |||||
| 122 | $sellerItems = ['order_items' => $items]; |
||||
| 123 | |||||
| 124 | $amountSub = array_sum(array_column($sellersItems[$sellerId], 'amount')); |
||||
| 125 | |||||
| 126 | $subAmount = ['subseller_sales_amount' => $amountSub]; |
||||
| 127 | } |
||||
| 128 | $formart = array_merge_recursive($sellers, $subAmount, $sellerItems); |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Comprehensibility
Best Practice
introduced
by
Comprehensibility
Best Practice
introduced
by
|
|||||
| 129 | $result = array_merge($result, [self::MARKETPLACE_SUBSELLER_PAYMENTS => $formart]); |
||||
| 130 | } |
||||
| 131 | |||||
| 132 | return $result; |
||||
| 133 | } |
||||
| 134 | } |
||||
| 135 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths