Skip to content

Commit be3dfc1

Browse files
authored
Feat/add remove integration button ecpj 22 #574
2 parents 87670da + 65ddd98 commit be3dfc1

13 files changed

Lines changed: 238 additions & 117 deletions

File tree

assets/images/pagarme-avatar.svg

Lines changed: 2 additions & 2 deletions
Loading

assets/stylesheets/admin/style.css

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,33 @@
3030
margin-right: 0;
3131
}
3232

33-
.hub_button_integration-field > a.button.pagarme-hub-integration-btn {
33+
.hub_button_integration-field > a.button.pagarme-hub-integration-btn,
34+
.hub_button_integration-field > a.button#pagarme-hub-desintegration-link,
35+
.access_dash_button-field > a.button.pagarme-access-dash-btn {
3436
position: relative;
3537
padding-right: 38px;
3638
}
3739

38-
.hub_button_integration-field > a.button.pagarme-hub-integration-btn > img {
40+
.hub_button_integration-field > a.button.pagarme-hub-integration-btn > img,
41+
.hub_button_integration-field > a.button#pagarme-hub-desintegration-link > span.dashicons,
42+
.access_dash_button-field > a.button.pagarme-access-dash-btn > img {
3943
position: absolute;
4044
top: 50%;
4145
right: 11px;
4246
max-height: 1.4em;
47+
}
48+
49+
.hub_button_integration-field > a.button.pagarme-hub-integration-btn > img,
50+
.access_dash_button-field > a.button.pagarme-access-dash-btn > img {
4351
margin-top: -0.7em;
4452
}
4553

54+
.hub_button_integration-field > a.button#pagarme-hub-desintegration-link > span.dashicons {
55+
margin-top: -0.5em;
56+
}
57+
4658
.pagarme-message-warning {
47-
margin: 1em 0 0;
59+
margin: 1em 0 0 1em;
4860
padding: 1em;
4961
background: #fae5e5;
5062
color: #e02b27;

assets/stylesheets/front/style.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
flex-direction: row;
104104
}
105105

106-
.pagarme_creditcard_divider p:after,
106+
.pagarme_creditcard_divider p:after,
107107
.pagarme_creditcard_divider p:before {
108108
content: "";
109109
flex: 1 1;
@@ -118,6 +118,10 @@
118118
margin-right: 0.5em;
119119
}
120120

121+
body.woocommerce-checkout.woocommerce-order-received #page #content #main .woocommerce .woocommerce-order .woocommerce-message:has(.pagarme-response) {
122+
display: block !important;
123+
}
124+
121125
.woocommerce-order .woocommerce-message .pagarme-response p:last-child {
122126
margin-bottom: 0;
123127
}
-191 Bytes
Binary file not shown.

languages/woo-pagarme-payments-pt_BR.po

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ msgstr ""
55
"Project-Id-Version: WooCommerce Pagar.me Payments 1.0\n"
66
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/woo-pagarme-payments\n"
77
"POT-Creation-Date: 2018-06-22 13:58-0300\n"
8-
"PO-Revision-Date: 2024-10-24 16:33-0300\n"
8+
"PO-Revision-Date: 2025-10-17 12:54-0300\n"
99
"Last-Translator: Pagar.me\n"
1010
"Language-Team: \n"
1111
"Language: pt_BR\n"
1212
"MIME-Version: 1.0\n"
1313
"Content-Type: text/plain; charset=UTF-8\n"
1414
"Content-Transfer-Encoding: 8bit\n"
1515
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
16-
"X-Generator: Poedit 3.5\n"
16+
"X-Generator: Poedit 3.8\n"
1717
"X-Poedit-SourceCharset: UTF-8\n"
18-
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c;_nc:1,2;_x:1,2c;_ex:1,2c;"
19-
"_nx:4c,1,2;_nx_noop:4c,1,2\n"
18+
"X-Poedit-KeywordsList: "
19+
"__;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c;_nc:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
2020
"X-Poedit-Basepath: ..\n"
2121
"X-Textdomain-Support: yes\n"
2222
"X-Poedit-SearchPath-0: .\n"
@@ -1051,13 +1051,9 @@ msgstr "Integrar com Pagar.me"
10511051
msgid "View Integration"
10521052
msgstr "Visualizar integração"
10531053

1054-
#: templates/adminhtml/system/config/form/field/hub/integration.phtml:23
1055-
msgid ""
1056-
"Have you removed your integration on Pagar.me Hub, but it shows active? Click <a id='pagarme-hub-desintegration-"
1057-
"link'>here</a> to remove your keys."
1058-
msgstr ""
1059-
"Removeu sua integração no Hub Pagar.me, mas ainda aparece ativa? Clique <a id='pagarme-hub-desintegration-link'>aqui</"
1060-
"a> para finalizar removendo suas chaves."
1054+
#: templates/adminhtml/system/config/form/field/hub/integration.phtml:32
1055+
msgid "Delete integration"
1056+
msgstr "Excluir integração"
10611057

10621058
#: templates/adminhtml/system/config/form/field/hub/integration.phtml:28
10631059
msgid "Disintegrate?"
@@ -1086,6 +1082,9 @@ msgstr "Erro na Desintegração"
10861082
msgid "Integration keys not removed."
10871083
msgstr "Chaves de integração não removidas."
10881084

1085+
msgid "Pagar.me order panel"
1086+
msgstr "Painel de pedidos Pagar.me"
1087+
10891088
msgid "2 credit cards"
10901089
msgstr "2 cartões de crédito"
10911090

@@ -1102,11 +1101,11 @@ msgid "Important! This store is in the testing phase. Orders placed in this envi
11021101
msgstr "Importante! Esta loja está em fase de testes. Os pedidos realizados neste ambiente não serão efetivados."
11031102

11041103
msgid ""
1105-
"Important! This store is linked to the Pagar.me test environment. This environment is intended for integration "
1104+
"<b>Important!</b> This store is linked to the Pagar.me test environment. This environment is intended for integration "
11061105
"validation and does not generate real financial transactions."
11071106
msgstr ""
1108-
"Importante! Esta loja está vinculada ao ambiente de testes da Pagar.me. Este ambiente é destinado a validação de "
1109-
"integração e não gera operações financeiras reais."
1107+
"<b>Importante!</b> Esta loja está vinculada ao ambiente de testes da Pagar.me. Este ambiente é destinado a validação "
1108+
"de integração e não gera operações financeiras reais."
11101109

11111110
msgid "Yes"
11121111
msgstr "Sim"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/**
3+
* @author Open Source Team
4+
* @copyright 2025 Pagar.me (https://pagar.me)
5+
* @license https://pagar.me Copyright
6+
*
7+
* @link https://pagar.me
8+
*/
9+
10+
declare( strict_types=1 );
11+
12+
namespace Woocommerce\Pagarme\Block\Adminhtml\System\Config\Form\Field\Hub;
13+
14+
use Woocommerce\Pagarme\Block\Adminhtml\System\Config\Form\AbstractField;
15+
16+
defined( 'ABSPATH' ) || exit;
17+
18+
/**
19+
* Class Dash
20+
* @package Woocommerce\Pagarme\Block\Adminthml\System\Config\Form\Field
21+
*/
22+
class Dash extends AbstractField
23+
{
24+
/** @var string */
25+
protected $template = 'hub/dash.phtml';
26+
27+
/**
28+
* @return void
29+
*/
30+
public function elementCallBack()
31+
{
32+
$this->setCurrent($this->getDefault());
33+
if ($value = $this->config->getData($this->getId())) {
34+
$this->setCurrent($value);
35+
}
36+
parent::includeTemplate();
37+
}
38+
}

src/Block/Adminhtml/System/Config/Form/Field/Hub/Integration.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Woocommerce\Pagarme\Block\Adminhtml\System\Config\Form\Field\Hub;
1313

1414
use Woocommerce\Pagarme\Block\Adminhtml\System\Config\Form\AbstractField;
15+
use Woocommerce\Pagarme\Helper\Utils;
1516

1617
defined( 'ABSPATH' ) || exit;
1718

@@ -37,10 +38,20 @@ public function elementCallBack()
3738
}
3839

3940
/**
40-
* @return string|null
41+
* @return string
4142
*/
42-
public function getButtonLabel()
43+
public function getIntegrationButtonLabel()
4344
{
4445
return ($this->config->getHubInstallId()) ? __('View Integration', 'woo-pagarme-payments') : __('Integrate With Pagar.me', 'woo-pagarme-payments');
4546
}
47+
48+
/**
49+
* Check if current user has permission to desintegrate with Pagar.me Hub
50+
*
51+
* @return bool `true` if is an admin and if the account and merchant are saved, `false` otherwise
52+
*/
53+
public function userCanDesintegrate()
54+
{
55+
return Utils::isCurrentUserAdmin() && $this->config->isAccAndMerchSaved();
56+
}
4657
}

src/Controller/HubCommand.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
}
88

99
use Pagarme\Core\Hub\Services\HubIntegrationService;
10-
use Woocommerce\Pagarme\Concrete\WoocommerceCoreSetup as CoreSetup;
1110
use Woocommerce\Pagarme\Core;
1211
use Woocommerce\Pagarme\Model\Config;
1312
use Woocommerce\Pagarme\Helper\Utils;
@@ -27,6 +26,13 @@ public function __construct()
2726

2827
public function handle_requests()
2928
{
29+
if (!Utils::isCurrentUserAdmin()) {
30+
return $this->sendResponse(
31+
'You do not have permission to access this resource.',
32+
self::HTTP_BAD_REQUEST
33+
);
34+
}
35+
3036
$params = Utils::get_json_post_data();
3137

3238
if (empty($params)) {

src/Controller/Settings.php

Lines changed: 77 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
}
1717

1818
use WC_Subscriptions_Core_Plugin;
19+
use Woocommerce\Pagarme\Block\Adminhtml\System\Config\Form\Field\Hub\Dash;
1920
use Woocommerce\Pagarme\Block\Adminhtml\System\Config\Form\Field\Hub\Environment;
2021
use Woocommerce\Pagarme\Block\Adminhtml\System\Config\Form\Field\Hub\Integration;
2122
use Woocommerce\Pagarme\Block\Adminhtml\System\Config\Form\Field\Select;
@@ -125,74 +126,77 @@ private function setSectionsFields(array $value = null)
125126
$this->sectionsFields = $value;
126127
return;
127128
}
128-
$this->sectionsFields = [
129-
'section' => [
130-
[
131-
'id' => 'options_section',
132-
'title' => 'General',
133-
'fields' => [
134-
[
135-
'fieldObject' => Integration::class,
136-
'id' => 'hub_button_integration',
137-
'title' => 'Pagar.me integration',
138-
],
139-
[
140-
'fieldObject' => Environment::class,
141-
'id' => 'hub_environment',
142-
'title' => 'Integration environment',
143-
'default' => '',
144-
],
145-
[
146-
'fieldObject' => Select::class,
147-
'id' => 'multicustomers',
148-
'title' => 'Multi-buyers',
149-
'options' => $this->yesNoOptions->toLabelsArray(),
150-
'default' => strtolower(Yesno::NO),
151-
],
152-
[
153-
'fieldObject' => Select::class,
154-
'id' => 'modify_address',
155-
'title' => 'Modify address fields',
156-
'options' => $this->yesNoOptions->toLabelsArray(),
157-
'default' => strtolower(Yesno::YES),
158-
'description' => [
159-
'format' => "Corrects the 'label' and 'placeholder' attributes of the 'Address' and "
160-
. "'Complement' fields to instruct users on how to fill them in correctly.",
161-
'values' => []
162-
],
163-
],
164-
[
165-
'fieldObject' => Select::class,
166-
'id' => 'allow_no_address',
167-
'title' => 'Allow order without address',
168-
'options' => $this->yesNoOptions->toLabelsArray(),
169-
'default' => strtolower(Yesno::NO),
170-
'description' => [
171-
'format' => 'For PSP customers with Pagar.me Antifraud active, it is mandatory to fill'
172-
. ' in all address fields. %sRead documentation »%s',
173-
'values' => [
174-
'<a href="'
175-
. self::PAGARME_DOCS_ANTIFRAUD_URL
176-
. '" target="_blank" rel="noopener">',
177-
'</a>'
178-
]
179-
],
180-
],
181-
[
182-
'fieldObject' => Select::class,
183-
'id' => 'enable_logs',
184-
'title' => 'Logs',
185-
'options' => $this->yesNoOptions->toLabelsArray(),
186-
'default' => strtolower(Yesno::NO),
187-
'description' => 'Log Pagar.me events, you can check this log in WooCommerce>Status>Logs.'
188-
]
189-
],
129+
130+
$fields = [
131+
[
132+
'fieldObject' => Integration::class,
133+
'id' => 'hub_button_integration',
134+
'title' => 'Pagar.me integration',
135+
]
136+
];
137+
138+
if ($this->config->isAccAndMerchSaved()){
139+
$fields[] = [
140+
'fieldObject' => Environment::class,
141+
'id' => 'hub_environment',
142+
'title' => 'Integration environment',
143+
'default' => '',
144+
];
145+
$fields[] = [
146+
'fieldObject' => Dash::class,
147+
'id' => 'access_dash_button',
148+
'title' => 'Pagar.me order panel',
149+
'default' => '',
150+
];
151+
}
152+
153+
$fields[] = [
154+
'fieldObject' => Select::class,
155+
'id' => 'multicustomers',
156+
'title' => 'Multi-buyers',
157+
'options' => $this->yesNoOptions->toLabelsArray(),
158+
'default' => strtolower(Yesno::NO),
159+
];
160+
$fields[] = [
161+
'fieldObject' => Select::class,
162+
'id' => 'modify_address',
163+
'title' => 'Modify address fields',
164+
'options' => $this->yesNoOptions->toLabelsArray(),
165+
'default' => strtolower(Yesno::YES),
166+
'description' => [
167+
'format' => "Corrects the 'label' and 'placeholder' attributes of the 'Address' and "
168+
. "'Complement' fields to instruct users on how to fill them in correctly.",
169+
'values' => []
170+
]
171+
];
172+
$fields[] = [
173+
'fieldObject' => Select::class,
174+
'id' => 'allow_no_address',
175+
'title' => 'Allow order without address',
176+
'options' => $this->yesNoOptions->toLabelsArray(),
177+
'default' => strtolower(Yesno::NO),
178+
'description' => [
179+
'format' => 'For PSP customers with Pagar.me Antifraud active, it is mandatory to fill'
180+
. ' in all address fields. %sRead documentation »%s',
181+
'values' => [
182+
'<a href="'
183+
. self::PAGARME_DOCS_ANTIFRAUD_URL
184+
. '" target="_blank" rel="noopener">',
185+
'</a>'
190186
]
191187
]
192188
];
189+
$fields[] = [
190+
'fieldObject' => Select::class,
191+
'id' => 'enable_logs',
192+
'title' => 'Logs',
193+
'options' => $this->yesNoOptions->toLabelsArray(),
194+
'default' => strtolower(Yesno::NO),
195+
'description' => 'Log Pagar.me events, you can check this log in WooCommerce>Status>Logs.'
196+
];
193197

194198
if (empty($this->config->getAccountId()) && $this->config->getHubInstallId()) {
195-
$this->sectionsFields['section'][0]['fields'][] =
199+
$fields[] =
196200
[
197201
'fieldObject' => Select::class,
198202
'id' => 'is_gateway_integration_type',
@@ -202,6 +206,16 @@ private function setSectionsFields(array $value = null)
202206
'description' => 'Configurations that only works for Gateway customers, who have a direct contract with an acquirer.'
203207
];
204208
}
209+
210+
$this->sectionsFields = [
211+
'section' => [
212+
[
213+
'id' => 'options_section',
214+
'title' => 'General',
215+
'fields' => $fields
216+
]
217+
]
218+
];
205219
}
206220

207221
/**

0 commit comments

Comments
 (0)