wirecardBrasil /
magento2
| 1 | <?php |
||||
| 2 | /** |
||||
| 3 | * Copyright © Wirecard Brasil. All rights reserved. |
||||
| 4 | * |
||||
| 5 | * @author Bruno Elisei <[email protected]> |
||||
| 6 | * See COPYING.txt for license details. |
||||
| 7 | */ |
||||
| 8 | |||||
| 9 | namespace Moip\Magento2\Gateway\Request; |
||||
| 10 | |||||
| 11 | use Magento\Framework\Pricing\Helper\Data as PriceHelper; |
||||
|
0 ignored issues
–
show
|
|||||
| 12 | use Magento\Payment\Gateway\Request\BuilderInterface; |
||||
|
0 ignored issues
–
show
The type
Magento\Payment\Gateway\Request\BuilderInterface 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...
|
|||||
| 13 | use Moip\Magento2\Gateway\Config\Config; |
||||
| 14 | use Moip\Magento2\Gateway\Config\ConfigCc; |
||||
| 15 | use Moip\Magento2\Gateway\Data\Order\OrderAdapterFactory; |
||||
|
0 ignored issues
–
show
The type
Moip\Magento2\Gateway\Da...der\OrderAdapterFactory 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...
|
|||||
| 16 | use Moip\Magento2\Gateway\SubjectReader; |
||||
| 17 | |||||
| 18 | /** |
||||
| 19 | * Class SellerDataRequest - Order seller amount structure. |
||||
| 20 | */ |
||||
| 21 | class SellerDataRequest implements BuilderInterface |
||||
| 22 | { |
||||
| 23 | /** |
||||
| 24 | * Receivers block name. |
||||
| 25 | */ |
||||
| 26 | const RECEIVERS = 'receivers'; |
||||
| 27 | |||||
| 28 | /** |
||||
| 29 | * Moip Account block name. |
||||
| 30 | */ |
||||
| 31 | const RECEIVERS_MOIP_ACCOUNT = 'moipAccount'; |
||||
| 32 | |||||
| 33 | /** |
||||
| 34 | * Moip Account Id block name. |
||||
| 35 | */ |
||||
| 36 | const RECEIVERS_MOIP_ACCOUNT_ID = 'id'; |
||||
| 37 | |||||
| 38 | /** |
||||
| 39 | * Type Receiver block name. |
||||
| 40 | */ |
||||
| 41 | const RECEIVERS_TYPE = 'type'; |
||||
| 42 | |||||
| 43 | /** |
||||
| 44 | * Secondary Type Receiver. |
||||
| 45 | * required. |
||||
| 46 | */ |
||||
| 47 | const RECEIVERS_TYPE_SECONDARY = 'SECONDARY'; |
||||
| 48 | |||||
| 49 | /** |
||||
| 50 | * Amount Receiver block name. |
||||
| 51 | */ |
||||
| 52 | const RECEIVERS_AMOUNT = 'amount'; |
||||
| 53 | |||||
| 54 | /** |
||||
| 55 | * Fixed Receiver Type block name. |
||||
| 56 | */ |
||||
| 57 | const RECEIVERS_TYPE_FIXED = 'fixed'; |
||||
| 58 | |||||
| 59 | /** |
||||
| 60 | * Percent Receiver Type block name. |
||||
| 61 | */ |
||||
| 62 | const RECEIVERS_TYPE_PERCENT = 'percent'; |
||||
| 63 | |||||
| 64 | /** |
||||
| 65 | * @var SubjectReader |
||||
| 66 | */ |
||||
| 67 | private $subjectReader; |
||||
| 68 | |||||
| 69 | /** |
||||
| 70 | * @var OrderAdapterFactory |
||||
| 71 | */ |
||||
| 72 | private $orderAdapterFactory; |
||||
| 73 | |||||
| 74 | /** |
||||
| 75 | * @var Config |
||||
| 76 | */ |
||||
| 77 | private $config; |
||||
| 78 | |||||
| 79 | /** |
||||
| 80 | * @var configCc |
||||
| 81 | */ |
||||
| 82 | private $configCc; |
||||
| 83 | |||||
| 84 | /** |
||||
| 85 | * @var priceHelper |
||||
| 86 | */ |
||||
| 87 | private $priceHelper; |
||||
| 88 | |||||
| 89 | /** |
||||
| 90 | * @param SubjectReader $subjectReader |
||||
| 91 | * @param OrderAdapterFactory $orderAdapterFactory |
||||
| 92 | * @param Config $Config |
||||
| 93 | * @param ConfigCc $ConfigCc |
||||
| 94 | * @param CheckoutHelper $checkoutHelper |
||||
|
0 ignored issues
–
show
The type
Moip\Magento2\Gateway\Request\CheckoutHelper 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...
|
|||||
| 95 | */ |
||||
| 96 | public function __construct( |
||||
| 97 | SubjectReader $subjectReader, |
||||
| 98 | OrderAdapterFactory $orderAdapterFactory, |
||||
| 99 | Config $config, |
||||
| 100 | ConfigCc $configCc, |
||||
| 101 | PriceHelper $checkoutHelper |
||||
| 102 | ) { |
||||
| 103 | $this->subjectReader = $subjectReader; |
||||
| 104 | $this->orderAdapterFactory = $orderAdapterFactory; |
||||
| 105 | $this->config = $config; |
||||
| 106 | $this->configCc = $configCc; |
||||
| 107 | $this->priceHelper = $checkoutHelper; |
||||
| 108 | } |
||||
| 109 | |||||
| 110 | /** |
||||
| 111 | * {@inheritdoc} |
||||
| 112 | */ |
||||
| 113 | public function build(array $buildSubject) |
||||
| 114 | { |
||||
| 115 | $paymentDO = $this->subjectReader->readPayment($buildSubject); |
||||
| 116 | $payment = $paymentDO->getPayment(); |
||||
| 117 | |||||
| 118 | $result = []; |
||||
| 119 | |||||
| 120 | $orderAdapter = $this->orderAdapterFactory->create( |
||||
| 121 | ['order' => $payment->getOrder()] |
||||
| 122 | ); |
||||
| 123 | |||||
| 124 | $order = $paymentDO->getOrder(); |
||||
| 125 | |||||
| 126 | $storeId = $order->getStoreId(); |
||||
| 127 | $useSplit = $this->config->getSplitValue('use_split', $storeId); |
||||
| 128 | if (!$useSplit) { |
||||
| 129 | return $result; |
||||
| 130 | } |
||||
| 131 | |||||
| 132 | $addition = $orderAdapter->getTaxAmount(); |
||||
|
0 ignored issues
–
show
|
|||||
| 133 | $interest = $orderAdapter->getBaseMoipInterestAmount(); |
||||
| 134 | $grandTotal = $order->getGrandTotalAmount(); |
||||
| 135 | $total = $grandTotal; |
||||
| 136 | |||||
| 137 | $secondaryMPA = $this->config->getSplitValue('secondary_mpa', $storeId); |
||||
| 138 | $secondaryPercent = $this->config->getSplitValue('secondary_percent', $storeId); |
||||
| 139 | $commiUseShipping = $this->config->getSplitValue('secondary_percent_include_shipping', $storeId); |
||||
| 140 | $commiUseInterest = $this->config->getSplitValue('secondary_percent_include_interest', $storeId); |
||||
| 141 | |||||
| 142 | if (!$commiUseInterest) { |
||||
| 143 | if ($interest > 0) { |
||||
| 144 | $total = $grandTotal - $interest; |
||||
| 145 | } elseif ($interest < 0) { |
||||
| 146 | $total = $grandTotal + $interest; |
||||
| 147 | } |
||||
| 148 | } |
||||
| 149 | |||||
| 150 | if (!$commiUseShipping) { |
||||
| 151 | $total = $total - $orderAdapter->getShippingAmount(); |
||||
| 152 | } |
||||
| 153 | |||||
| 154 | $commission = $total * ($secondaryPercent / 100); |
||||
| 155 | |||||
| 156 | $result[self::RECEIVERS][] = [ |
||||
| 157 | self::RECEIVERS_MOIP_ACCOUNT => [ |
||||
| 158 | self::RECEIVERS_MOIP_ACCOUNT_ID => $secondaryMPA, |
||||
| 159 | ], |
||||
| 160 | self::RECEIVERS_TYPE => self::RECEIVERS_TYPE_SECONDARY, |
||||
| 161 | self::RECEIVERS_AMOUNT => [ |
||||
| 162 | self::RECEIVERS_TYPE_FIXED => $this->config->formatPrice(round($commission, 2)), |
||||
|
0 ignored issues
–
show
round($commission, 2) of type double is incompatible with the type integer expected by parameter $amount of Moip\Magento2\Gateway\Config\Config::formatPrice().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 163 | ], |
||||
| 164 | ]; |
||||
| 165 | |||||
| 166 | return $result; |
||||
| 167 | } |
||||
| 168 | } |
||||
| 169 |
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