Skip to content

Commit e809ed4

Browse files
first commit
0 parents  commit e809ed4

File tree

125 files changed

+14849
-0
lines changed

Some content is hidden

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

125 files changed

+14849
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
/**
3+
* Novalnet payment extension
4+
*
5+
* NOTICE OF LICENSE
6+
*
7+
* This source file is subject to the Novalnet End User License Agreement
8+
* that is bundled with this package in the file LICENSE.txt
9+
*
10+
* DISCLAIMER
11+
*
12+
* If you wish to customize Novalnet payment extension for your needs,
13+
* please contact [email protected] for more information.
14+
*
15+
* @category Novalnet
16+
* @package Novalnet_Payment
17+
* @copyright Copyright (c) Novalnet AG
18+
* @license https://www.novalnet.de/payment-plugins/kostenlos/lizenz
19+
*/
20+
namespace Novalnet\Payment\Api;
21+
22+
interface CallbackRepositoryInterface
23+
{
24+
/**
25+
* Novalnet payment callback
26+
*
27+
* @api
28+
* @return string
29+
*/
30+
public function callback();
31+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
/**
3+
* Novalnet payment extension
4+
*
5+
* NOTICE OF LICENSE
6+
*
7+
* This source file is subject to the Novalnet End User License Agreement
8+
* that is bundled with this package in the file LICENSE.txt
9+
*
10+
* DISCLAIMER
11+
*
12+
* If you wish to customize Novalnet payment extension for your needs,
13+
* please contact [email protected] for more information.
14+
*
15+
* @category Novalnet
16+
* @package Novalnet_Payment
17+
* @copyright Copyright (c) Novalnet AG
18+
* @license https://www.novalnet.de/payment-plugins/kostenlos/lizenz
19+
*/
20+
namespace Novalnet\Payment\Api;
21+
22+
interface NovalnetRepositoryInterface
23+
{
24+
/**
25+
* Novalnet product activation key auto config
26+
*
27+
* @api
28+
* @param string $signature
29+
* @param string $payment_access_key
30+
* @return string
31+
*/
32+
public function activateProductKey($signature, $payment_access_key);
33+
34+
/**
35+
* Novalnet Webhook URL configuration
36+
*
37+
* @api
38+
* @param string $signature
39+
* @param string $payment_access_key
40+
* @return string
41+
*/
42+
public function configWebhookUrl($signature, $payment_access_key);
43+
44+
/**
45+
* Returns URL to redirect after place order
46+
*
47+
* @api
48+
* @param string[] $data
49+
* @return string
50+
*/
51+
public function getRedirectURL($data);
52+
53+
/**
54+
* Place Order
55+
*
56+
* @api
57+
* @param string[] $data
58+
* @param bool $paymentPage
59+
* @return string
60+
*/
61+
public function placeOrder($data, $paymentPage = false);
62+
63+
/**
64+
* To get v3 payment form link
65+
*
66+
* @api
67+
* @param string[] $data
68+
* @return string
69+
*/
70+
public function getPayByLink($data);
71+
}

Block/Adminhtml/Button/Control.php

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
<?php
2+
/**
3+
* Novalnet payment extension
4+
*
5+
* NOTICE OF LICENSE
6+
*
7+
* This source file is subject to the Novalnet End User License Agreement
8+
* that is bundled with this package in the file LICENSE.txt
9+
*
10+
* DISCLAIMER
11+
*
12+
* If you wish to customize Novalnet payment extension for your needs,
13+
* please contact [email protected] for more information.
14+
*
15+
* @category Novalnet
16+
* @package Novalnet_Payment
17+
* @copyright Copyright (c) Novalnet AG
18+
* @license https://www.novalnet.de/payment-plugins/kostenlos/lizenz
19+
*/
20+
namespace Novalnet\Payment\Block\Adminhtml\Button;
21+
22+
use Magento\Backend\Block\Widget\Button\Toolbar as ToolbarContext;
23+
use Magento\Framework\View\Element\AbstractBlock;
24+
use Magento\Backend\Block\Widget\Button\ButtonList;
25+
26+
class Control extends \Magento\Sales\Block\Adminhtml\Order\View
27+
{
28+
/**
29+
* @var \Magento\Framework\Registry
30+
*/
31+
protected $coreRegistry = null;
32+
33+
/**
34+
* @var \Novalnet\Payment\Model\NNConfig
35+
*/
36+
protected $novalnetConfig;
37+
38+
/**
39+
* @var \Novalnet\Payment\Helper\Data
40+
*/
41+
protected $novalnetHelper;
42+
43+
/**
44+
* @param \Magento\Framework\Registry $registry
45+
* @param \Novalnet\Payment\Model\NNConfig $novalnetConfig
46+
* @param \Novalnet\Payment\Helper\Data $novalnetHelper
47+
*/
48+
public function __construct(
49+
\Magento\Framework\Registry $registry,
50+
\Novalnet\Payment\Model\NNConfig $novalnetConfig,
51+
\Novalnet\Payment\Helper\Data $novalnetHelper
52+
) {
53+
$this->coreRegistry = $registry;
54+
$this->novalnetConfig = $novalnetConfig;
55+
$this->novalnetHelper = $novalnetHelper;
56+
}
57+
58+
/**
59+
* Before push buttons
60+
*
61+
* @param ToolbarContext $toolbar
62+
* @param AbstractBlock $context
63+
* @param ButtonList $buttonList
64+
* @return mixed
65+
*/
66+
public function beforePushButtons(
67+
ToolbarContext $toolbar,
68+
\Magento\Framework\View\Element\AbstractBlock $context,
69+
\Magento\Backend\Block\Widget\Button\ButtonList $buttonList
70+
) {
71+
if (!$context instanceof \Magento\Sales\Block\Adminhtml\Order\View) {
72+
return [$context, $buttonList];
73+
}
74+
75+
$order = $this->getOrder();
76+
$payment = $order->getPayment();
77+
$paymentMethodCode = $payment->getMethodInstance()->getCode();
78+
$additionalData = $this->novalnetHelper->getPaymentAdditionalData($payment->getAdditionalData());
79+
$paymentType = !empty($additionalData['NnPaymentType']) ? $additionalData['NnPaymentType'] : '';
80+
81+
if (!empty($paymentMethodCode) && preg_match('/novalnet/i', $paymentMethodCode)) {
82+
if ($context instanceof \Magento\Sales\Block\Adminhtml\Order\Invoice\View) {
83+
if ($paymentType == "INVOICE") {
84+
$buttonList->remove('capture');
85+
}
86+
return [$context, $buttonList];
87+
}
88+
89+
$transactionStatus = !empty($additionalData['NnStatus'])
90+
? $this->novalnetHelper->getStatus($additionalData['NnStatus'], $order, $paymentType) : '';
91+
92+
if ($transactionStatus) {
93+
// remove Capture button
94+
$buttonList->update('order_invoice', 'label', __('Capture'));
95+
96+
if (in_array($transactionStatus, ['PENDING', 'DEACTIVATED']) || !empty($additionalData['NnZeroAmountBooking'])) {
97+
$buttonList->remove('order_invoice');
98+
}
99+
100+
if ($order->canInvoice() && $transactionStatus == 'ON_HOLD' &&
101+
$paymentType == "INVOICE"
102+
) {
103+
$buttonList->remove('order_invoice');
104+
$message = __('Are you sure you want to capture the payment?');
105+
$capturePaymentUrl = $context->getUrl(
106+
'novalnetpayment/sales/ordercapture',
107+
['order_id' => $order->getId()]
108+
);
109+
110+
$buttonList->add(
111+
'novalnet_confirm',
112+
[
113+
'label' => __('Novalnet Capture'),
114+
'onclick' => "confirmSetLocation('{$message}', '{$capturePaymentUrl}')"
115+
]
116+
);
117+
}
118+
119+
if ($transactionStatus == 'ON_HOLD') {
120+
$buttonList->remove('void_payment');
121+
$message = __('Are you sure you want to cancel the payment?');
122+
$voidPaymentUrl = $context->getUrl(
123+
'sales/*/voidPayment',
124+
['order_id' => $order->getId()]
125+
);
126+
$buttonList->add(
127+
'void_payment',
128+
[
129+
'label' => __('Void'),
130+
'onclick' => "confirmSetLocation('{$message}', '{$voidPaymentUrl}')"
131+
]
132+
);
133+
}
134+
135+
$processMode = !empty($additionalData['NnPaymentProcessMode']) ? $additionalData['NnPaymentProcessMode'] : '';
136+
137+
if ($transactionStatus == 'PENDING' && ($processMode == 'redirect' && !in_array($paymentType, ['GOOGLEPAY', 'APPLEPAY', 'CREDITCARD'])) ||
138+
in_array(
139+
$paymentType,
140+
[
141+
'PREPAYMENT',
142+
'CASHPAYMENT',
143+
'MULTIBANCO'
144+
]
145+
)
146+
) {
147+
$buttonList->remove('order_cancel'); // remove Cancel button
148+
$buttonList->remove('void_payment'); // remove Void button
149+
}
150+
}
151+
}
152+
153+
return [$context, $buttonList];
154+
}
155+
156+
/**
157+
* Retrieve order model object
158+
*
159+
* @return \Magento\Sales\Model\Order
160+
*/
161+
public function getOrder()
162+
{
163+
return $this->coreRegistry->registry('sales_order');
164+
}
165+
}

0 commit comments

Comments
 (0)