|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* MIT License |
|
5
|
|
|
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace SprykerEco\Yves\Computop\Mapper\Init\PostPlace; |
|
9
|
|
|
|
|
10
|
|
|
use ArrayObject; |
|
11
|
|
|
use Generated\Shared\Transfer\ComputopPayuCeeSinglePaymentTransfer; |
|
|
|
|
|
|
12
|
|
|
use Generated\Shared\Transfer\QuoteTransfer; |
|
|
|
|
|
|
13
|
|
|
use Spryker\Shared\Shipment\ShipmentConfig; |
|
14
|
|
|
use Spryker\Yves\Router\Router\Router; |
|
15
|
|
|
use SprykerEco\Shared\Computop\ComputopConfig as ComputopSharedConfig; |
|
16
|
|
|
use SprykerEco\Yves\Computop\Mapper\Init\AbstractMapper; |
|
17
|
|
|
use SprykerEco\Yves\Computop\Plugin\Router\ComputopRouteProviderPlugin; |
|
18
|
|
|
|
|
19
|
|
|
class PayuCeeSingleMapper extends AbstractMapper |
|
20
|
|
|
{ |
|
21
|
|
|
protected const SHIPMENT_ARTICLE_NAME = 'Shipment'; |
|
22
|
|
|
protected const ONE_ITEM_AMOUNT = 1; |
|
23
|
|
|
protected const ARTICLE_LIST_DELIMITER = ','; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer |
|
27
|
|
|
* |
|
28
|
|
|
* @return \Generated\Shared\Transfer\ComputopPayuCeeSinglePaymentTransfer |
|
29
|
|
|
*/ |
|
30
|
|
|
public function createComputopPaymentTransfer(QuoteTransfer $quoteTransfer): ComputopPayuCeeSinglePaymentTransfer |
|
31
|
|
|
{ |
|
32
|
|
|
/** @var \Generated\Shared\Transfer\ComputopPayuCeeSinglePaymentTransfer $computopPayuCeeSinglePaymentTransfer */ |
|
33
|
|
|
$computopPayuCeeSinglePaymentTransfer = parent::createComputopPaymentTransfer($quoteTransfer); |
|
34
|
|
|
|
|
35
|
|
|
$encryptedMac = $this->computopApiService->generateEncryptedMac( |
|
36
|
|
|
$this->createRequestTransfer($computopPayuCeeSinglePaymentTransfer) |
|
37
|
|
|
); |
|
38
|
|
|
|
|
39
|
|
|
$computopPayuCeeSinglePaymentTransfer |
|
40
|
|
|
->setMac($encryptedMac) |
|
41
|
|
|
->setOrderDesc($this->computopApiService->getDescriptionValue($quoteTransfer->getItems()->getArrayCopy())) |
|
42
|
|
|
->setCapture($this->getCaptureType(ComputopSharedConfig::PAYMENT_METHOD_PAYU_CEE_SINGLE)) |
|
43
|
|
|
->setLanguage(mb_strtoupper($this->store->getCurrentLanguage())); |
|
44
|
|
|
|
|
45
|
|
|
if ($quoteTransfer->getItems()->count()) { |
|
46
|
|
|
$computopPayuCeeSinglePaymentTransfer->setArticleList( |
|
47
|
|
|
$this->getArticleList($quoteTransfer->getItems(), $quoteTransfer->getExpenses()) |
|
48
|
|
|
); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
if ($quoteTransfer->getCustomer()) { |
|
52
|
|
|
$computopPayuCeeSinglePaymentTransfer->fromArray($quoteTransfer->getCustomer()->toArray(), true); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
return $computopPayuCeeSinglePaymentTransfer; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer |
|
60
|
|
|
* |
|
61
|
|
|
* @return \Generated\Shared\Transfer\ComputopPayuCeeSinglePaymentTransfer |
|
62
|
|
|
*/ |
|
63
|
|
|
protected function createTransferWithUnencryptedValues(QuoteTransfer $quoteTransfer): ComputopPayuCeeSinglePaymentTransfer |
|
64
|
|
|
{ |
|
65
|
|
|
$urlSuccess = $this->router->generate(ComputopRouteProviderPlugin::PAYU_CEE_SINGLE_SUCCESS, [], Router::ABSOLUTE_URL); |
|
66
|
|
|
|
|
67
|
|
|
return (new ComputopPayuCeeSinglePaymentTransfer()) |
|
68
|
|
|
->setTransId($this->generateTransId($quoteTransfer)) |
|
69
|
|
|
->setUrlSuccess($urlSuccess); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @param \Generated\Shared\Transfer\ItemTransfer[]|\ArrayObject $itemTransfers |
|
74
|
|
|
* @param \Generated\Shared\Transfer\ExpenseTransfer[]|\ArrayObject $expenseTransfers |
|
75
|
|
|
* |
|
76
|
|
|
* @return string |
|
77
|
|
|
*/ |
|
78
|
|
|
protected function getArticleList(ArrayObject $itemTransfers, ArrayObject $expenseTransfers): string |
|
79
|
|
|
{ |
|
80
|
|
|
$articlesList = []; |
|
81
|
|
|
|
|
82
|
|
|
foreach ($itemTransfers as $item) { |
|
83
|
|
|
$articlesList[] = implode(static::ARTICLE_LIST_DELIMITER, [ |
|
84
|
|
|
$item->getName() ? $this->replaceForbiddenCharacters($item->getName()) : '', |
|
85
|
|
|
$item->getSumSubtotalAggregation(), |
|
86
|
|
|
$item->getQuantity(), |
|
87
|
|
|
]); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
$articlesList[] = implode(static::ARTICLE_LIST_DELIMITER, [ |
|
91
|
|
|
static::SHIPMENT_ARTICLE_NAME, |
|
92
|
|
|
$this->getDeliveryCosts($expenseTransfers), |
|
93
|
|
|
static::ONE_ITEM_AMOUNT, |
|
94
|
|
|
]); |
|
95
|
|
|
|
|
96
|
|
|
return implode('+', $articlesList); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @param \Generated\Shared\Transfer\ExpenseTransfer[]|\ArrayObject $expenseTransfers |
|
101
|
|
|
* |
|
102
|
|
|
* @return int |
|
103
|
|
|
*/ |
|
104
|
|
|
protected function getDeliveryCosts(ArrayObject $expenseTransfers): int |
|
105
|
|
|
{ |
|
106
|
|
|
$deliveryCosts = 0; |
|
107
|
|
|
foreach ($expenseTransfers as $expenseTransfer) { |
|
108
|
|
|
if ($expenseTransfer->getType() === ShipmentConfig::SHIPMENT_EXPENSE_TYPE) { |
|
109
|
|
|
$deliveryCosts += $expenseTransfer->getSumGrossPrice(); |
|
110
|
|
|
} |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
return $deliveryCosts; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* @param string $name |
|
118
|
|
|
* |
|
119
|
|
|
* @return string |
|
120
|
|
|
*/ |
|
121
|
|
|
protected function replaceForbiddenCharacters(string $name): string |
|
122
|
|
|
{ |
|
123
|
|
|
return str_replace([',', '+', '-'], ' ', $name); |
|
124
|
|
|
} |
|
125
|
|
|
} |
|
126
|
|
|
|
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