Skip to content

Commit b13123d

Browse files
committed
v. 4.47.0
* Adicionado suporte a divisão de pagamentos (split) nativa. * Adicionado [suporte a Dokan Marketplace](https://ajuda.pbintegracoes.com/hc/pt-br/articles/40558023581965-Dokan-Split-Divis%C3%A3o-de-Pagamentos-para-Marketplace) para divisão de pagamentos entre múltiplos vendedores (split, multivendor). * Adicionado opção para habilitar/desabilitar opção de salvar cartão de crédito para compras futuras. Desativado por padrão. Merge branch 'release/4.47.0' :
2 parents 55e3252 + 3d9c8bc commit b13123d

38 files changed

+3990
-43
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
},
103103
"extends": "eslint:recommended",
104104
"parserOptions": {
105-
"sourceType": "module"
105+
"sourceType": "module",
106+
"ecmaVersion": 2018
106107
}
107108
}
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
<?php
2+
if (!defined('ABSPATH')) {
3+
exit;
4+
}
5+
6+
/**
7+
* Integrations settings page
8+
*
9+
* @package RM_PagBank/Admin/Settings
10+
*/
11+
12+
// Enqueue integrations CSS
13+
wp_enqueue_style(
14+
'pagbank-connect-integrations',
15+
plugins_url('public/css/integrations.css', WC_PAGSEGURO_CONNECT_PLUGIN_FILE),
16+
[],
17+
WC_PAGSEGURO_CONNECT_VERSION
18+
);
19+
20+
// Load integrations settings fields
21+
$integrations_fields = include WC_PAGSEGURO_CONNECT_BASE_DIR.'/admin/views/settings/dokan-split-fields.php';
22+
23+
// Get saved options
24+
$integrations_options = get_option('woocommerce_rm-pagbank-integrations_settings', []);
25+
26+
// Check if Dokan is active
27+
$dokan_is_active = function_exists('dokan');
28+
29+
// Display the settings form
30+
?>
31+
<input type="hidden" name="section" value="rm-pagbank-integrations" />
32+
<?php if (!$dokan_is_active): ?>
33+
<div class="notice notice-warning inline" style="margin: 20px 0;">
34+
<p>
35+
<strong><?php esc_html_e('Atenção:', 'pagbank-connect'); ?></strong>
36+
<?php esc_html_e('O plugin Dokan não está instalado ou não está ativo. As configurações de Split Dokan serão ignoradas até que o Dokan seja instalado e ativado.', 'pagbank-connect'); ?>
37+
</p>
38+
</div>
39+
<?php endif; ?>
40+
<table class="form-table">
41+
<?php
42+
foreach ($integrations_fields as $key => $field) {
43+
// Use field ID if available, otherwise use key
44+
if (!isset($field['id'])) {
45+
$field['id'] = $key;
46+
}
47+
$field_id = $field['id']; // Use the field ID for HTML attributes
48+
$field_value = isset($integrations_options[$key]) ? $integrations_options[$key] : (isset($field['default']) ? $field['default'] : '');
49+
50+
switch ($field['type']) {
51+
case 'title':
52+
?>
53+
<tr>
54+
<td colspan="2">
55+
<h2><?php echo esc_html($field['title']); ?></h2>
56+
<?php if (!empty($field['desc'])): ?>
57+
<p><?php echo wp_kses_post($field['desc']); ?></p>
58+
<?php endif; ?>
59+
</td>
60+
</tr>
61+
<?php
62+
break;
63+
64+
case 'checkbox':
65+
?>
66+
<tr valign="top" <?php echo !$dokan_is_active ? 'style="opacity: 0.6;"' : ''; ?>>
67+
<th scope="row" class="titledesc">
68+
<label for="<?php echo esc_attr($field_id); ?>"><?php echo esc_html($field['title']); ?></label>
69+
</th>
70+
<td class="forminp forminp-<?php echo esc_attr($field['type']); ?>">
71+
<fieldset>
72+
<legend class="screen-reader-text"><span><?php echo esc_html($field['title']); ?></span></legend>
73+
<label for="<?php echo esc_attr($field_id); ?>">
74+
<input
75+
type="checkbox"
76+
class="<?php echo esc_attr(isset($field['class']) ? $field['class'] : ''); ?>"
77+
name="<?php echo esc_attr($key); ?>"
78+
id="<?php echo esc_attr($field_id); ?>"
79+
value="1"
80+
<?php checked($field_value, 'yes'); ?>
81+
<?php disabled(!$dokan_is_active); ?>
82+
/>
83+
<?php echo wp_kses_post(isset($field['description']) ? $field['description'] : ''); ?>
84+
<?php if (!$dokan_is_active && $key === 'dokan_split_enabled'): ?>
85+
<p class="description" style="color: #d63638; margin-top: 5px;">
86+
<strong><?php esc_html_e('', 'pagbank-connect'); ?></strong>
87+
<?php esc_html_e('Esta configuração será ignorada porque o Dokan não está ativo ou instalado.', 'pagbank-connect'); ?>
88+
</p>
89+
<?php endif; ?>
90+
</label>
91+
</fieldset>
92+
</td>
93+
</tr>
94+
<?php
95+
break;
96+
97+
case 'text':
98+
case 'number':
99+
?>
100+
<tr valign="top" <?php echo !$dokan_is_active ? 'style="opacity: 0.6;"' : ''; ?>>
101+
<th scope="row" class="titledesc">
102+
<label for="<?php echo esc_attr($field_id); ?>"><?php echo esc_html($field['title']); ?></label>
103+
</th>
104+
<td class="forminp forminp-<?php echo esc_attr($field['type']); ?>">
105+
<input
106+
type="<?php echo esc_attr($field['type']); ?>"
107+
name="<?php echo esc_attr($key); ?>"
108+
id="<?php echo esc_attr($field_id); ?>"
109+
value="<?php echo esc_attr($field_value); ?>"
110+
class="<?php echo esc_attr(isset($field['class']) ? $field['class'] : ''); ?>"
111+
<?php disabled(!$dokan_is_active); ?>
112+
<?php if (isset($field['custom_attributes']) && is_array($field['custom_attributes'])) {
113+
foreach ($field['custom_attributes'] as $attr => $attr_value) {
114+
echo esc_attr($attr) . '="' . esc_attr($attr_value) . '" ';
115+
}
116+
} ?>
117+
/>
118+
<?php if (!empty($field['description'])): ?>
119+
<p class="description"><?php echo wp_kses_post($field['description']); ?></p>
120+
<?php endif; ?>
121+
</td>
122+
</tr>
123+
<?php
124+
break;
125+
126+
case 'select':
127+
?>
128+
<tr valign="top" <?php echo !$dokan_is_active ? 'style="opacity: 0.6;"' : ''; ?>>
129+
<th scope="row" class="titledesc">
130+
<label for="<?php echo esc_attr($field_id); ?>"><?php echo esc_html($field['title']); ?></label>
131+
</th>
132+
<td class="forminp forminp-<?php echo esc_attr($field['type']); ?>">
133+
<select
134+
name="<?php echo esc_attr($key); ?>"
135+
id="<?php echo esc_attr($field_id); ?>"
136+
class="<?php echo esc_attr(isset($field['class']) ? $field['class'] : ''); ?>"
137+
<?php disabled(!$dokan_is_active); ?>
138+
>
139+
<?php foreach ($field['options'] as $option_key => $option_value): ?>
140+
<option value="<?php echo esc_attr($option_key); ?>" <?php selected($field_value, $option_key); ?>>
141+
<?php echo esc_html($option_value); ?>
142+
</option>
143+
<?php endforeach; ?>
144+
</select>
145+
<?php if (!empty($field['description'])): ?>
146+
<p class="description"><?php echo wp_kses_post($field['description']); ?></p>
147+
<?php endif; ?>
148+
</td>
149+
</tr>
150+
<?php
151+
break;
152+
}
153+
}
154+
?>
155+
</table>

admin/views/html-recurring-settings-page.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@
2727
<a href="<?php echo admin_url( 'admin.php?page=wc-settings&tab=checkout&section=rm-pagbank-boleto' ) ?>#tab-boleto" class="nav-tab"><?php esc_html_e('Boleto', 'pagbank-connect') ?></a>
2828
<a href="<?php echo admin_url( 'admin.php?page=wc-settings&tab=checkout&section=rm-pagbank-redirect' ) ?>#tab-redirect" class="nav-tab"><?php esc_html_e('Checkout PagBank', 'pagbank-connect') ?></a>
2929
<a href="<?php echo admin_url( 'admin.php?page=wc-settings&tab=checkout&section=rm-pagbank-recurring-settings' ) ?>#tab-recurring" class="nav-tab nav-tab-active"><?php esc_html_e('Recorrência', 'pagbank-connect') ?></a>
30+
<a href="<?php echo admin_url( 'admin.php?page=wc-settings&tab=checkout&section=rm-pagbank-integrations' ) ?>#tab-integrations" class="nav-tab"><?php esc_html_e('Integrações', 'pagbank-connect') ?></a>
3031
</nav>
3132
</fieldset>

admin/views/html-settings-page.php

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,43 @@
4949
<?php echo '<h4>' . esc_html( $this->get_method_description() ) . '</h4>'; ?>
5050
</div>
5151
<!-- navigation tabs-->
52+
<?php
53+
$current_section = isset($_GET['section']) ? sanitize_text_field($_GET['section']) : 'rm-pagbank';
54+
$show_integrations = isset($_GET['show_integrations']) && $_GET['show_integrations'] === '1';
55+
?>
5256
<nav class="nav-tab-wrapper ">
53-
<a href="<?php echo admin_url( 'admin.php?page=wc-settings&tab=checkout&section=rm-pagbank' ) ?>#tab-general" class="nav-tab <?php echo $this->id === 'rm-pagbank' ? 'nav-tab-active' : '' ?>"><?php esc_html_e('Geral', 'pagbank-connect') ?></a>
54-
<a href="<?php echo admin_url( 'admin.php?page=wc-settings&tab=checkout&section=rm-pagbank-cc' ) ?>#tab-credit-card" class="nav-tab <?php echo $this->id === 'rm-pagbank-cc' ? 'nav-tab-active' : '' ?>"><?php esc_html_e('Cartão de Crédito', 'pagbank-connect') ?></a>
55-
<a href="<?php echo admin_url( 'admin.php?page=wc-settings&tab=checkout&section=rm-pagbank-pix' ) ?>#tab-pix" class="nav-tab <?php echo $this->id === 'rm-pagbank-pix' ? 'nav-tab-active' : '' ?>"><?php esc_html_e('PIX', 'pagbank-connect') ?></a>
56-
<a href="<?php echo admin_url( 'admin.php?page=wc-settings&tab=checkout&section=rm-pagbank-boleto' ) ?>#tab-boleto" class="nav-tab <?php echo $this->id === 'rm-pagbank-boleto' ? 'nav-tab-active' : '' ?>"><?php esc_html_e('Boleto', 'pagbank-connect') ?></a>
57-
<a href="<?php echo admin_url( 'admin.php?page=wc-settings&tab=checkout&section=rm-pagbank-redirect' ) ?>#tab-redirect" class="nav-tab <?php echo $this->id === 'rm-pagbank-redirect' ? 'nav-tab-active' : '' ?>"><?php esc_html_e('Checkout PagBank', 'pagbank-connect') ?></a>
58-
<a href="<?php echo admin_url( 'admin.php?page=wc-settings&tab=checkout&section=rm-pagbank-recurring-settings' ) ?>#tab-recurring" class="nav-tab <?php echo $this->id === 'rm-pagbank-recurring' ? 'nav-tab-active' : '' ?>"><?php esc_html_e('Recorrência', 'pagbank-connect') ?></a>
57+
<a href="<?php echo admin_url( 'admin.php?page=wc-settings&tab=checkout&section=rm-pagbank' ) ?>#tab-general" class="nav-tab <?php echo ($current_section === 'rm-pagbank' && !$show_integrations) ? 'nav-tab-active' : '' ?>"><?php esc_html_e('Geral', 'pagbank-connect') ?></a>
58+
<a href="<?php echo admin_url( 'admin.php?page=wc-settings&tab=checkout&section=rm-pagbank-cc' ) ?>#tab-credit-card" class="nav-tab <?php echo $current_section === 'rm-pagbank-cc' ? 'nav-tab-active' : '' ?>"><?php esc_html_e('Cartão de Crédito', 'pagbank-connect') ?></a>
59+
<a href="<?php echo admin_url( 'admin.php?page=wc-settings&tab=checkout&section=rm-pagbank-pix' ) ?>#tab-pix" class="nav-tab <?php echo $current_section === 'rm-pagbank-pix' ? 'nav-tab-active' : '' ?>"><?php esc_html_e('PIX', 'pagbank-connect') ?></a>
60+
<a href="<?php echo admin_url( 'admin.php?page=wc-settings&tab=checkout&section=rm-pagbank-boleto' ) ?>#tab-boleto" class="nav-tab <?php echo $current_section === 'rm-pagbank-boleto' ? 'nav-tab-active' : '' ?>"><?php esc_html_e('Boleto', 'pagbank-connect') ?></a>
61+
<a href="<?php echo admin_url( 'admin.php?page=wc-settings&tab=checkout&section=rm-pagbank-redirect' ) ?>#tab-redirect" class="nav-tab <?php echo $current_section === 'rm-pagbank-redirect' ? 'nav-tab-active' : '' ?>"><?php esc_html_e('Checkout PagBank', 'pagbank-connect') ?></a>
62+
<a href="<?php echo admin_url( 'admin.php?page=wc-settings&tab=checkout&section=rm-pagbank-recurring-settings' ) ?>#tab-recurring" class="nav-tab <?php echo $current_section === 'rm-pagbank-recurring' ? 'nav-tab-active' : '' ?>"><?php esc_html_e('Recorrência', 'pagbank-connect') ?></a>
63+
<a href="<?php echo admin_url( 'admin.php?page=wc-settings&tab=checkout&section=rm-pagbank-integrations' ) ?>#tab-integrations" class="nav-tab <?php echo $show_integrations ? 'nav-tab-active' : '' ?>"><?php esc_html_e('Integrações', 'pagbank-connect') ?></a>
5964
</nav>
60-
<?php if ($this->id === 'rm-pagbank'): ?>
65+
<?php if (!$show_integrations && $this->id === 'rm-pagbank'): ?>
6166
<h3><?php esc_html_e('Credenciais', 'pagbank-connect') ?></h3>
6267
<p><?php esc_html_e('Para utilizar o PagBank Connect, você precisa autorizar nossa aplicação e obter suas credenciais connect.', 'pagbank-connect') ?></p>
6368
<a href="https://pbintegracoes.com/connect/autorizar/?utm_source=wordpressadmin" onclick="window.open(this.href, '_blank'); return false;" class="button button-secondary"><?php esc_html_e('Obter Connect Key', 'pagbank-connect') ?></a>
6469
<a href="https://pbintegracoes.com/connect/sandbox/?utm_source=wordpressadmin" onclick="window.open(this.href, '_blank'); return false;" class="button button-secondary"><?php esc_html_e('Obter Connect Key para Testes', 'pagbank-connect') ?></a>
6570
<a href="https://ajuda.pbintegracoes.com/hc/pt-br/?utm_source=wordpressadmin" target="_blank" class="button button-secondary" title="<?php esc_html_e('Ir para central de ajuda. Lá você pode encontrar resposta para a maioria dos problemas e perguntas, ou entrar em contato conosco.', 'pagbank-connect');?>"><?php esc_html_e('Obter ajuda', 'pagbank-connect') ?></a>
6671
<a href="<?php echo admin_url( 'admin.php?page=wc-settings&tab=shipping&section=rm_enviofacil' ) ?>" class="button button-secondary" title="<?php esc_html_e('Economize no Frete com Envio Fácil', 'pagbank-connect');?>"><?php esc_html_e('📦 Envio Fácil', 'pagbank-connect') ?></a>
6772
<?php endif; ?>
68-
<?php echo '<table class="form-table">' . $this->generate_settings_html( $this->get_form_fields(), false ) . '</table>'; // WPCS: XSS ok. ?>
73+
74+
<?php if ($show_integrations): ?>
75+
<!-- Integrations Settings -->
76+
<?php include WC_PAGSEGURO_CONNECT_BASE_DIR.'/admin/views/html-integrations-settings.php'; ?>
77+
78+
<script type="text/javascript">
79+
jQuery(document).ready(function($) {
80+
// Load integrations.js for field visibility control
81+
<?php if (file_exists(WC_PAGSEGURO_CONNECT_BASE_DIR . '/public/js/admin/integrations.js')): ?>
82+
$.getScript('<?php echo plugins_url('public/js/admin/integrations.js', WC_PAGSEGURO_CONNECT_PLUGIN_FILE); ?>');
83+
<?php endif; ?>
84+
});
85+
</script>
86+
<?php else: ?>
87+
<?php echo '<table class="form-table">' . $this->generate_settings_html( $this->get_form_fields(), false ) . '</table>'; // WPCS: XSS ok. ?>
88+
<?php endif; ?>
6989
</fieldset>
7090

7191
<?php

admin/views/settings/cc-fields.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,12 @@
162162
.'Esta opção só será exibida se o motivo da recusa do pagamento pelo PagBank permitir uma nova tentativa. <br/>',
163163
'default' => 'yes',
164164
],
165+
'cc_allow_save_card' => [
166+
'title' => __('Permitir salvar cartão', 'pagbank-connect'),
167+
'label' => __('Habilitar opção de salvar cartão no checkout', 'pagbank-connect'),
168+
'type' => 'checkbox',
169+
'description' => __('Quando habilitado, os clientes poderão salvar o cartão de crédito para compras futuras. <br/>'
170+
.'Para pedidos recorrentes (assinaturas), o cartão sempre será salvo automaticamente, independente desta configuração.', 'pagbank-connect'),
171+
'default' => 'no',
172+
],
165173
);

0 commit comments

Comments
 (0)