-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGetCreditCardCVVWidgetConfig.php
90 lines (78 loc) · 2.3 KB
/
GetCreditCardCVVWidgetConfig.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
namespace PayU\PaymentGateway\Model;
use PayU\PaymentGateway\Api\GetAvailableLocaleInterface;
use PayU\PaymentGateway\Api\PayUConfigInterface;
use PayU\PaymentGateway\Api\PayUGetCreditCardCVVWidgetConfigInterface;
use Magento\Checkout\Model\Session as CheckoutSession;
use PayU\PaymentGateway\Model\Ui\CardConfigProvider;
/**
* Class GetCreditCardCVVWidgetConfig
* @package PayU\PaymentGateway\Model
*/
class GetCreditCardCVVWidgetConfig implements PayUGetCreditCardCVVWidgetConfigInterface
{
/**
* @var GetAvailableLocaleInterface
*/
private $availableLocale;
/**
* @var \OpenPayU_Configuration
*/
private $openPayUConfig;
/**
* @var PayUConfigInterface
*/
private $payUConfig;
/**
* @var CheckoutSession
*/
private $checkoutSession;
/**
* GetCreditCardCVVWidgetConfig constructor.
*
* @param \OpenPayU_Configuration $openPayUConfig
* @param GetAvailableLocaleInterface $availableLocale
* @param PayUConfigInterface $payUConfig
* @param CheckoutSession $checkoutSession
*/
public function __construct(
\OpenPayU_Configuration $openPayUConfig,
GetAvailableLocaleInterface $availableLocale,
PayUConfigInterface $payUConfig,
CheckoutSession $checkoutSession
) {
$this->availableLocale = $availableLocale;
$this->openPayUConfig = $openPayUConfig;
$this->payUConfig = $payUConfig;
$this->checkoutSession = $checkoutSession;
}
/**
* {@inheritdoc}
*/
public function execute($cvvUrl)
{
$this->payUConfig->setDefaultConfig(CardConfigProvider::CODE);
$config = $this->openPayUConfig;
return [
static::CONFIG_ENV => $config::getEnvironment(),
static::CONFIG_POS_ID => $config::getMerchantPosId(),
static::CONFIG_CVV_URL => $this->getCvvUrl($cvvUrl),
static::CONFIG_LANGUAGE => $this->availableLocale->execute()
];
}
/**
* Get refId part from ccv url for widget config
*
* @param string $cvvUrl
*
* @return string
*/
private function getCvvUrl($cvvUrl)
{
$urlParams = explode('?', $cvvUrl);
if (isset($urlParams[1])) {
return $urlParams[1];
}
return '';
}
}