|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright © Getnet. All rights reserved. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Bruno Elisei <[email protected]> |
|
6
|
|
|
* See LICENSE for license details. |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Getnet\PaymentMagento\Model\Ui; |
|
10
|
|
|
|
|
11
|
|
|
use Getnet\PaymentMagento\Gateway\Config\ConfigWallet; |
|
12
|
|
|
use Magento\Checkout\Model\ConfigProviderInterface; |
|
13
|
|
|
use Magento\Framework\Escaper; |
|
14
|
|
|
use Magento\Framework\View\Asset\Source; |
|
15
|
|
|
use Magento\Payment\Model\CcConfig; |
|
16
|
|
|
use Magento\Quote\Api\Data\CartInterface; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Class ConfigProviderWallet - Defines properties of the payment form.. |
|
20
|
|
|
*/ |
|
21
|
|
|
class ConfigProviderWallet implements ConfigProviderInterface |
|
22
|
|
|
{ |
|
23
|
|
|
/* |
|
24
|
|
|
* @const string |
|
25
|
|
|
*/ |
|
26
|
|
|
public const CODE = 'getnet_paymentmagento_wallet'; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var ConfigWallet |
|
30
|
|
|
*/ |
|
31
|
|
|
private $config; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @var CartInterface |
|
35
|
|
|
*/ |
|
36
|
|
|
private $cart; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @var CcConfig |
|
40
|
|
|
*/ |
|
41
|
|
|
protected $ccConfig; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @var Escaper |
|
45
|
|
|
*/ |
|
46
|
|
|
protected $escaper; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @var Source |
|
50
|
|
|
*/ |
|
51
|
|
|
protected $assetSource; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @param ConfigWallet $config |
|
55
|
|
|
* @param CartInterface $cart |
|
56
|
|
|
* @param CcConfig $ccConfig |
|
57
|
|
|
* @param Escaper $escaper |
|
58
|
|
|
* @param Source $assetSource |
|
59
|
|
|
*/ |
|
60
|
|
|
public function __construct( |
|
61
|
|
|
ConfigWallet $config, |
|
62
|
|
|
CartInterface $cart, |
|
63
|
|
|
CcConfig $ccConfig, |
|
64
|
|
|
Escaper $escaper, |
|
65
|
|
|
Source $assetSource |
|
66
|
|
|
) { |
|
67
|
|
|
$this->config = $config; |
|
68
|
|
|
$this->cart = $cart; |
|
69
|
|
|
$this->escaper = $escaper; |
|
70
|
|
|
$this->ccConfig = $ccConfig; |
|
71
|
|
|
$this->assetSource = $assetSource; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Retrieve assoc array of checkout configuration. |
|
76
|
|
|
* |
|
77
|
|
|
* @return array |
|
78
|
|
|
*/ |
|
79
|
|
|
public function getConfig() |
|
80
|
|
|
{ |
|
81
|
|
|
$storeId = $this->cart->getStoreId(); |
|
82
|
|
|
|
|
83
|
|
|
return [ |
|
84
|
|
|
'payment' => [ |
|
85
|
|
|
self::CODE => [ |
|
86
|
|
|
'isActive' => $this->config->isActive($storeId), |
|
87
|
|
|
'title' => $this->config->getTitle($storeId), |
|
88
|
|
|
'instruction_checkout' => nl2br( |
|
89
|
|
|
$this->escaper->escapeHtml( |
|
|
|
|
|
|
90
|
|
|
$this->config->getInstructionCheckout($storeId) |
|
91
|
|
|
) |
|
92
|
|
|
), |
|
93
|
|
|
'logo' => $this->getLogo(), |
|
94
|
|
|
], |
|
95
|
|
|
], |
|
96
|
|
|
]; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Get icons for available payment methods. |
|
101
|
|
|
* |
|
102
|
|
|
* @return array |
|
103
|
|
|
*/ |
|
104
|
|
|
public function getLogo() |
|
105
|
|
|
{ |
|
106
|
|
|
$logo = []; |
|
107
|
|
|
$asset = $this->ccConfig->createAsset('Getnet_PaymentMagento::images/wallet/logo.svg'); |
|
108
|
|
|
$placeholder = $this->assetSource->findSource($asset); |
|
109
|
|
|
if ($placeholder) { |
|
110
|
|
|
list($width, $height) = getimagesizefromstring($asset->getSourceFile()); |
|
111
|
|
|
$logo = [ |
|
112
|
|
|
'url' => $asset->getUrl(), |
|
113
|
|
|
'width' => $width, |
|
114
|
|
|
'height' => $height, |
|
115
|
|
|
'title' => __('Getnet'), |
|
116
|
|
|
]; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
return $logo; |
|
120
|
|
|
} |
|
121
|
|
|
} |
|
122
|
|
|
|