|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file has been created by developers from BitBag. |
|
5
|
|
|
* Feel free to contact us once you face any issues or want to start |
|
6
|
|
|
* another great project. |
|
7
|
|
|
* You can find more information about us on https://bitbag.shop and write us |
|
8
|
|
|
* an email on [email protected]. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
declare(strict_types=1); |
|
12
|
|
|
|
|
13
|
|
|
namespace BitBag\SyliusMolliePlugin\Helper; |
|
14
|
|
|
|
|
15
|
|
|
use BitBag\SyliusMolliePlugin\Entity\MollieGatewayConfigInterface; |
|
16
|
|
|
use BitBag\SyliusMolliePlugin\Payments\PaymentTerms\Options; |
|
17
|
|
|
use Sylius\Bundle\PayumBundle\Provider\PaymentDescriptionProviderInterface; |
|
18
|
|
|
use Sylius\Component\Core\Model\OrderInterface; |
|
19
|
|
|
use Sylius\Component\Core\Model\PaymentInterface; |
|
20
|
|
|
|
|
21
|
|
|
final class PaymentDescription implements PaymentDescriptionInterface |
|
22
|
|
|
{ |
|
23
|
|
|
/** @var PaymentDescriptionProviderInterface */ |
|
24
|
|
|
private $paymentDescriptionProvider; |
|
25
|
|
|
|
|
26
|
|
|
public function __construct(PaymentDescriptionProviderInterface $paymentDescriptionProvider) |
|
27
|
|
|
{ |
|
28
|
|
|
$this->paymentDescriptionProvider = $paymentDescriptionProvider; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function getPaymentDescription( |
|
32
|
|
|
PaymentInterface $payment, |
|
33
|
|
|
MollieGatewayConfigInterface $methodConfig, |
|
34
|
|
|
OrderInterface $order |
|
35
|
|
|
): string { |
|
36
|
|
|
$paymentMethodType = array_search($methodConfig->getPaymentType(), Options::getAvailablePaymentType()); |
|
37
|
|
|
$description = $methodConfig->getPaymentDescription(); |
|
38
|
|
|
|
|
39
|
|
|
if ($paymentMethodType === Options::PAYMENT_API && !empty($description)) { |
|
40
|
|
|
$replacements = [ |
|
41
|
|
|
'{ordernumber}' => $order->getNumber(), |
|
42
|
|
|
'{storename}' => $order->getChannel()->getName() |
|
43
|
|
|
]; |
|
44
|
|
|
|
|
45
|
|
|
return str_replace( |
|
46
|
|
|
array_keys($replacements), |
|
47
|
|
|
array_values($replacements), |
|
48
|
|
|
$methodConfig->getPaymentDescription() |
|
49
|
|
|
); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
return $this->paymentDescriptionProvider->getPaymentDescription($payment); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|