Skip to content

Commit aeef376

Browse files
author
Ivan Tagil
committed
Merge remote-tracking branch 'remotes/origin/feature/direct-flow' into feature/CMP-70_paypal-tests
2 parents 84a3660 + c7e77c2 commit aeef376

File tree

63 files changed

+3127
-258
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+3127
-258
lines changed

Api/Config/ConfigInterface.php

+36-6
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,19 @@ interface ConfigInterface
1515
/**
1616
* XML Paths of configuration settings
1717
*/
18-
public const XML_PATH_GENERAL_ENABLED = 'payment/cm_payments_general/enabled';
19-
public const XML_PATH_GENERAL_MERCHANT_KEY = 'payment/cm_payments_general/merchant_key';
20-
public const XML_PATH_GENERAL_MERCHANT_NAME = 'payment/cm_payments_general/merchant_name';
21-
public const XML_PATH_GENERAL_MERCHANT_PASSWORD = 'payment/cm_payments_general/merchant_password';
22-
public const XML_PATH_GENERAL_MODE = 'payment/cm_payments_general/mode';
18+
public const XML_PATH_GENERAL_ENABLED = 'cm_payments/general/enabled';
19+
public const XML_PATH_GENERAL_CURRENT_VERSION = 'cm_payments/general/current_version';
20+
public const XML_PATH_GENERAL_TEST_MERCHANT_NAME = 'cm_payments/general/test_merchant_name';
21+
public const XML_PATH_GENERAL_TEST_MERCHANT_PASSWORD = 'cm_payments/general/test_merchant_password';
22+
public const XML_PATH_GENERAL_TEST_MERCHANT_KEY = 'cm_payments/general/test_merchant_key';
23+
public const XML_PATH_GENERAL_LIVE_MERCHANT_NAME = 'cm_payments/general/live_merchant_name';
24+
public const XML_PATH_GENERAL_LIVE_MERCHANT_PASSWORD = 'cm_payments/general/live_merchant_password';
25+
public const XML_PATH_GENERAL_LIVE_MERCHANT_KEY = 'cm_payments/general/live_merchant_key';
26+
public const XML_PATH_GENERAL_MODE = 'cm_payments/general/mode';
2327
public const XML_PATH_PAYMENT_PROFILE = 'payment/cm_payments_methods/profile';
2428
public const XML_PATH_PAYMENT_CREDIT_CARD_PROFILE = 'payment/cm_payments_creditcard/profile';
2529
public const XML_PATH_PAYMENT_BANCONTACT_PROFILE = 'payment/cm_payments_bancontact/profile';
30+
public const XML_PATH_PAYMENT_CM_PAYMENTS_PROFILE = 'payment/cm_payments/profile';
2631

2732
/**
2833
* Checks that extension is enabled
@@ -33,30 +38,47 @@ interface ConfigInterface
3338
public function isEnabled(): ?bool;
3439

3540
/**
41+
* Get Current Version
42+
*
43+
* @return string|null
44+
* @throws NoSuchEntityException
45+
*/
46+
public function getCurrentVersion(): ?string;
47+
48+
/**
49+
* Get Merchant Key
50+
*
3651
* @return string|null
3752
* @throws NoSuchEntityException
3853
*/
3954
public function getMerchantKey(): ?string;
4055

4156
/**
57+
* Get Merchant Name
58+
*
4259
* @return string|null
4360
* @throws NoSuchEntityException
4461
*/
4562
public function getMerchantName(): ?string;
4663

4764
/**
65+
* Get Merchant Password
66+
*
4867
* @return string|null
4968
* @throws NoSuchEntityException
5069
*/
5170
public function getMerchantPassword(): ?string;
5271

5372
/**
73+
* @param string $paymentMethod
5474
* @return string|null
5575
* @throws NoSuchEntityException
5676
*/
57-
public function getPaymentProfile(): ?string;
77+
public function getPaymentProfile(string $paymentMethod): ?string;
5878

5979
/**
80+
* Get mode
81+
*
6082
* @return string|null
6183
* @throws NoSuchEntityException
6284
*/
@@ -86,4 +108,12 @@ public function getCreditCardPaymentProfile(): ?string;
86108
* @throws NoSuchEntityException
87109
*/
88110
public function getBanContactPaymentProfile(): ?string;
111+
112+
/**
113+
* Get Payment Profile for CM Payments Menu Method
114+
*
115+
* @return ?string
116+
* @throws NoSuchEntityException
117+
*/
118+
public function getCmPaymentsMenuPaymentProfile(): ?string;
89119
}
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* Copyright © CM.com. All rights reserved.
4+
* See LICENSE.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace CM\Payments\Api\Service;
10+
11+
use GuzzleHttp\Exception\GuzzleException;
12+
use Magento\Framework\Exception\NoSuchEntityException;
13+
14+
interface ApiTestServiceInterface
15+
{
16+
/**
17+
* @return array
18+
* @throws GuzzleException|NoSuchEntityException
19+
*/
20+
public function testApiConnection(): array;
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace CM\Payments\Api\Service\Method;
4+
5+
use CM\Payments\Client\Model\Response\PaymentMethod;
6+
use Magento\Checkout\Api\Data\PaymentDetailsExtensionInterface;
7+
8+
interface ExtendMethodInterface
9+
{
10+
/**
11+
* Extend CM.com payment methods with additional data
12+
*
13+
* @param string $paymentMethodCode
14+
* @param PaymentMethod $paymentMethod
15+
* @param PaymentDetailsExtensionInterface $paymentDetailsExtension
16+
*
17+
* @return PaymentDetailsExtensionInterface
18+
*/
19+
public function extend(
20+
string $paymentMethodCode,
21+
PaymentMethod $paymentMethod,
22+
PaymentDetailsExtensionInterface
23+
$paymentDetailsExtension
24+
): PaymentDetailsExtensionInterface;
25+
}

Api/Service/MethodServiceInterface.php

-6
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@ interface MethodServiceInterface
4444
ConfigProvider::CODE_PAYPAL => 'PAYPAL'
4545
];
4646

47-
/**
48-
* @param CartInterface $quote
49-
* @return array
50-
*/
51-
public function getAvailablePaymentMethods(CartInterface $quote): array;
52-
5347
/**
5448
* @param CartInterface $quote
5549
* @param PaymentDetailsInterface $paymentDetails
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* Copyright © CM.com. All rights reserved.
4+
* See LICENSE.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace CM\Payments\Api\Service;
10+
11+
interface VersionServiceInterface
12+
{
13+
/**
14+
* Repository Vendor Name
15+
*/
16+
public const REPOSITORY_VENDOR_NAME = 'cmdotcom';
17+
18+
/**
19+
* Repository Extension Name
20+
*/
21+
public const REPOSITORY_EXTENSION_NAME = 'pay-ext-magento2';
22+
23+
/**
24+
*/
25+
public function getLatestVersion();
26+
27+
/**
28+
* Get Repository Url
29+
*
30+
* @return string
31+
*/
32+
public function getRepositoryUrl(): string;
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?php
2+
/**
3+
* Copyright © CM.com. All rights reserved.
4+
* See LICENSE.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace CM\Payments\Block\Adminhtml\System\Config\Button;
10+
11+
use CM\Payments\Api\Config\ConfigInterface;
12+
use Exception;
13+
use Magento\Backend\Block\Template\Context;
14+
use Magento\Backend\Block\Widget\Button;
15+
use Magento\Config\Block\System\Config\Form\Field;
16+
use Magento\Framework\Data\Form\Element\AbstractElement;
17+
use Magento\Framework\Exception\NoSuchEntityException;
18+
19+
class CheckApiConnection extends Field
20+
{
21+
/**
22+
* @var string
23+
*/
24+
protected $_template = 'CM_Payments::system/config/button/check_api_connection.phtml';
25+
26+
/**
27+
* @var ConfigInterface
28+
*/
29+
private $config;
30+
31+
/**
32+
* CheckLatestVersion constructor
33+
*
34+
* @param Context $context
35+
* @param ConfigInterface $config
36+
* @param array $data
37+
*/
38+
public function __construct(
39+
Context $context,
40+
ConfigInterface $config,
41+
array $data = []
42+
) {
43+
parent::__construct($context, $data);
44+
45+
$this->config = $config;
46+
}
47+
48+
/**
49+
* @return ?string
50+
* @throws NoSuchEntityException
51+
*/
52+
public function getCurrentVersion(): ?string
53+
{
54+
return $this->config->getCurrentVersion();
55+
}
56+
57+
/**
58+
* @param AbstractElement $element
59+
* @return string
60+
*/
61+
public function render(AbstractElement $element): string
62+
{
63+
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
64+
65+
return parent::render($element);
66+
}
67+
68+
/**
69+
* @param AbstractElement $element
70+
* @return string
71+
*/
72+
public function _getElementHtml(AbstractElement $element): string
73+
{
74+
return $this->_toHtml();
75+
}
76+
77+
/**
78+
* @return string
79+
*/
80+
public function getApiConnectionCheckUrl(): string
81+
{
82+
return $this->getUrl('cmpayments/action/checkApiConnection');
83+
}
84+
85+
/**
86+
* @return string
87+
*/
88+
public function getButtonHtml(): string
89+
{
90+
$buttonData = [
91+
'class' => 'cmpayments_button_check_api_connection',
92+
'label' => __('Check Api Connection'),
93+
'data_attribute' => ['bind' => 'click: checkApiConnection']
94+
];
95+
try {
96+
$button = $this->getLayout()->createBlock(
97+
Button::class
98+
)->setData($buttonData);
99+
100+
return $button->toHtml();
101+
} catch (Exception $e) {
102+
return '';
103+
}
104+
}
105+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?php
2+
/**
3+
* Copyright © CM.com. All rights reserved.
4+
* See LICENSE.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace CM\Payments\Block\Adminhtml\System\Config\Button;
10+
11+
use CM\Payments\Api\Config\ConfigInterface;
12+
use Exception;
13+
use Magento\Backend\Block\Template\Context;
14+
use Magento\Backend\Block\Widget\Button;
15+
use Magento\Config\Block\System\Config\Form\Field;
16+
use Magento\Framework\Data\Form\Element\AbstractElement;
17+
use Magento\Framework\Exception\NoSuchEntityException;
18+
19+
class CheckLatestVersion extends Field
20+
{
21+
/**
22+
* @var string
23+
*/
24+
protected $_template = 'CM_Payments::system/config/button/check_latest_version.phtml';
25+
26+
/**
27+
* @var ConfigInterface
28+
*/
29+
private $config;
30+
31+
/**
32+
* CheckLatestVersion constructor
33+
*
34+
* @param Context $context
35+
* @param ConfigInterface $config
36+
* @param array $data
37+
*/
38+
public function __construct(
39+
Context $context,
40+
ConfigInterface $config,
41+
array $data = []
42+
) {
43+
parent::__construct($context, $data);
44+
45+
$this->config = $config;
46+
}
47+
48+
/**
49+
* @return ?string
50+
* @throws NoSuchEntityException
51+
*/
52+
public function getCurrentVersion(): ?string
53+
{
54+
return $this->config->getCurrentVersion();
55+
}
56+
57+
/**
58+
* @param AbstractElement $element
59+
* @return string
60+
*/
61+
public function render(AbstractElement $element): string
62+
{
63+
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
64+
65+
return parent::render($element);
66+
}
67+
68+
/**
69+
* @param AbstractElement $element
70+
* @return string
71+
*/
72+
public function _getElementHtml(AbstractElement $element): string
73+
{
74+
return $this->_toHtml();
75+
}
76+
77+
/**
78+
* @return string
79+
*/
80+
public function getCheckLatestVersionUrl(): string
81+
{
82+
return $this->getUrl('cmpayments/action/checkLatestVersion');
83+
}
84+
85+
/**
86+
* @return string
87+
*/
88+
public function getButtonHtml(): string
89+
{
90+
$buttonData = [
91+
'class' => 'cmpayments_button_version',
92+
'label' => __('Check the Latest Version'),
93+
'data_attribute' => ['bind' => 'click: checkLatestVersion']
94+
];
95+
try {
96+
$button = $this->getLayout()->createBlock(
97+
Button::class
98+
)->setData($buttonData);
99+
100+
return $button->toHtml();
101+
} catch (Exception $e) {
102+
return '';
103+
}
104+
}
105+
}

0 commit comments

Comments
 (0)