Skip to content

Commit 8c7adb0

Browse files
committed
v.4.44.0
* Dashboard de relatórios da recorrência: agora você pode ver alguns indicadores importantes de suas assinaturas, como o total de assinaturas ativas, o total de assinaturas canceladas e o total de assinaturas suspensas, Receita Recorrente Mensal, e muito mais. * Agora é possível salvar o cartão de crédito para uso posterior no checkout em blocos (nativo do WooCommerce). * Possível correção onde em alguns cenários dois campos de parcelamento eram exibidos na página de checkout. * Alteração no URL de nossa API e de alguns links de ajuda. Merge branch 'release/4.44.0'
2 parents 79ddf19 + d653b22 commit 8c7adb0

File tree

16 files changed

+882
-38
lines changed

16 files changed

+882
-38
lines changed

admin/views/settings/cc-fields.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
'title' => __('Opções de Parcelamento', 'pagbank-connect'),
2525
'type' => 'select',
2626
'description' => __(
27-
'<a href="https://pagsegurotransparente.zendesk.com/hc/pt-br/articles/19945359660173-'
27+
'<a href="https://ajuda.pbintegracoes.com/hc/pt-br/articles/19945359660173-'
2828
.'Op%C3%A7%C3%B5es-de-Parcelamento" target="_blank">Saiba mais</a>',
2929
'pagbank-connect'
3030
),
@@ -66,7 +66,7 @@
6666
'title' => __('Limitar parcelas?', 'pagbank-connect'),
6767
'type' => 'select',
6868
'description' => __(
69-
'<a href="https://pagsegurotransparente.zendesk.com/hc/pt-br/articles/19945359660173'
69+
'<a href="https://ajuda.pbintegracoes.com/hc/pt-br/articles/19945359660173'
7070
.'-Op%C3%A7%C3%B5es-de-Parcelamento#limitar-parcelas" target="_blank">Saiba mais</a>',
7171
'pagbank-connect'
7272
),
@@ -89,7 +89,7 @@
8989
'title' => __('Informações de Parcelamento', 'pagbank-connect'),
9090
'label' => __('Exibir informações de parcelamento na tela do produto?', 'pagbank-connect'),
9191
'type' => 'checkbox',
92-
'description' => 'Veja <a href="https://pagsegurotransparente.zendesk.com/hc/pt-br'
92+
'description' => 'Veja <a href="https://ajuda.pbintegracoes.com/hc/pt-br'
9393
.'/articles/26223028355597-Exibir-informa%C3%A7%C3%B5es-de-parcelamento-na-p%C3%A1gina-de-produt'
9494
.'o" target="_blank">como funciona</a>.',
9595
'default' => 'no',
@@ -98,7 +98,7 @@
9898
'title' => __('Shortcode de parcelamento', 'pagbank-connect'),
9999
'label' => __('Habilitar', 'pagbank-connect'),
100100
'type' => 'checkbox',
101-
'description' => 'Veja <a href="https://pagsegurotransparente.zendesk.com/hc/pt-br'
101+
'description' => 'Veja <a href="https://ajuda.pbintegracoes.com/hc/pt-br'
102102
.'/articles/26223028355597-Exibir-informa%C3%A7%C3%B5es-de-parcelamento-na-p%C3%A1gina-de-produt'
103103
.'o#shortcode" target="_blank">como usar</a>.',
104104
'default' => 'no',
@@ -107,7 +107,7 @@
107107
'title' => __('Formato das informações de parcelamento', 'pagbank-connect'),
108108
'type' => 'select',
109109
'description' => __(
110-
'<a href="https://pagsegurotransparente.zendesk.com/hc/pt-br/articles/26223028355597'
110+
'<a href="https://ajuda.pbintegracoes.com/hc/pt-br/articles/26223028355597'
111111
.'-Exibir-informa%C3%A7%C3%B5es-de-parcelamento-na-p%C3%A1gina-de-produto" target="_blank"'
112112
.'>Saiba mais </a>',
113113
'pagbank-connect'
@@ -124,7 +124,7 @@
124124
'default' => 'CompraViaPagBank',
125125
'description' => __(
126126
'Nome que será exibido na fatura do Cliente. <a href="https://'
127-
.'pagsegurotransparente.zendesk.com/hc/pt-br/articles/19945038495629-Identificador-na-fatura" '
127+
.'ajuda.pbintegracoes.com/hc/pt-br/articles/19945038495629-Identificador-na-fatura" '
128128
.'target="_blank">Veja algumas dicas</a>.',
129129
'pagbank-connect'
130130
),
@@ -137,7 +137,7 @@
137137
'title' => __('Autenticação 3D', 'pagbank-connect'),
138138
'label' => __('Habilitar', 'pagbank-connect'),
139139
'type' => 'checkbox',
140-
'description' => 'Habilita a autenticação <a href="https://pagsegurotransparente.zendesk.com/hc/pt-br/a'
140+
'description' => 'Habilita a autenticação <a href="https://ajuda.pbintegracoes.com/hc/pt-br/a'
141141
.'rticles/22375922278157-Autentica%C3%A7%C3%A3o-3DS-Sua-prote%C3%A7%C3%A3o-contra-Chargeback" '
142142
.'target="_blank">3D Secure</a> para compras com cartão de crédito. <br/>'
143143
.'A autenticação 3D Secure é um protocolo de segurança que adiciona uma camada extra de proteção '

assets/screenshot-2.jpg

-67.7 KB
Loading

assets/screenshot-8.jpg

-49.6 KB
Loading

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "ricardomartins/pagbank-woocommerce",
33
"description": "Integração PagBank (PagSeguro) WooCommerce com desconto nas taxas oficiais",
44
"type": "wordpress-plugin",
5-
"version": "4.43.0",
5+
"version": "4.44.0",
66
"license": "GPL-3.0",
77
"autoload": {
88
"psr-4": {

public/js/blocks/checkout-blocks-cc.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import CreditCardForm from "./components/CreditCardForm";
99
import CustomerDocumentField from './components/CustomerDocumentField';
1010
import RecurringInfo from './components/RecurringInfo';
1111
import RetryInput from './components/RetryInput';
12+
import SavedCardInstallments from './components/SavedCardInstallments';
13+
import SavedCreditCardToken from './components/SavedCreditCardToken';
1214
const { useSelect } = window.wp.data;
1315
const { checkoutStore } = window.wc.wcBlocksData;
1416
const settings = getSetting('rm-pagbank-cc_data', {});
@@ -424,6 +426,7 @@ const Content = ( props ) => {
424426
const ccNumber = document.getElementById('rm-pagbank-card-number').value;
425427
const ccHolderName = document.getElementById('rm-pagbank-card-holder-name').value;
426428
const card3dRetry = document.getElementById('rm-pagbank-card-retry-with-3ds');
429+
const newPaymentMethod = document.getElementById('rm-pagbank-cc-new-payment-method-in-block');
427430

428431
return {
429432
type: emitResponse.responseTypes.SUCCESS,
@@ -436,7 +439,8 @@ const Content = ( props ) => {
436439
'rm-pagbank-card-number': ccNumber.replace(/\D/g, ''),
437440
'rm-pagbank-card-holder-name': ccHolderName,
438441
'rm-pagbank-card-3d': card3d,
439-
'rm-pagbank-card-retry-with-3ds': card3dRetry?.checked
442+
'rm-pagbank-card-retry-with-3ds': card3dRetry?.checked,
443+
'rm-pagbank-cc-new-payment-method-in-block': newPaymentMethod?.checked,
440444
},
441445
},
442446
};
@@ -458,6 +462,7 @@ const Content = ( props ) => {
458462
<div className="rm-pagbank-cc">
459463
{showRetryInput ? <RetryInput /> : null}
460464
<CreditCardForm />
465+
<SavedCreditCardToken />
461466
<CustomerDocumentField />
462467
{settings.isCartRecurring ? <RecurringInfo /> : null}
463468
</div>
@@ -474,6 +479,7 @@ const Rm_Pagbank_Cc_Block_Gateway = {
474479
supports: {
475480
features: settings?.supports ?? [],
476481
},
482+
savedTokenComponent: <SavedCardInstallments />,
477483
};
478484

479485
registerPaymentMethod( Rm_Pagbank_Cc_Block_Gateway );
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import React, { useState, useEffect } from 'react';
2+
import { __ } from '@wordpress/i18n';
3+
import InstallmentsOptions from './InstallmentsOptions';
4+
5+
const SavedCardInstallments = (props) => {
6+
const { token, emitResponse, eventRegistration, billing } = props;
7+
const { onPaymentSetup, onCheckoutValidation: onCheckoutValidation, onCheckoutSuccess, onCheckoutFail } = eventRegistration;
8+
// Example: fetch installments by saved card BIN
9+
const [installments, setInstallments] = useState([]);
10+
const [selectedInstallment, setSelectedInstallment] = useState('1'); // default to 1 installment
11+
12+
// Function to fetch installments based on BIN and total amount
13+
const fetchInstallments = (bin, total) => {
14+
if (!bin || bin.length < 6) return;
15+
jQuery.ajax({
16+
url: window.wc.wcSettings.getSetting('rm-pagbank-cc_data', {}).ajax_url,
17+
method: 'POST',
18+
data: {
19+
cc_bin: bin,
20+
amount: total,
21+
nonce: window.wc.wcSettings.getSetting('rm-pagbank-cc_data', {}).rm_pagbank_nonce,
22+
action: 'ps_get_installments',
23+
},
24+
success: (response) => {
25+
setInstallments(response);
26+
},
27+
error: () => {
28+
alert('Erro ao calcular parcelas. Verifique os dados do cartão e tente novamente.');
29+
}
30+
});
31+
};
32+
33+
// Function to get the CC BIN for a specific token
34+
const getTokenBin = (tokenId) => {
35+
const savedTokens = window.wc.wcSettings.getSetting('rm-pagbank-cc_data', {}).savedTokens || [];
36+
const tokenData = savedTokens.find(t => t.id == tokenId);
37+
return tokenData ? tokenData.cc_bin : '555566'; // fallback to default BIN
38+
};
39+
40+
// Function to get the customer document for a specific token
41+
const getTokenCustomerDocument = (tokenId) => {
42+
const savedTokens = window.wc.wcSettings.getSetting('rm-pagbank-cc_data', {}).savedTokens || [];
43+
const tokenData = savedTokens.find(t => t.id == tokenId);
44+
return tokenData ? tokenData.customer_document : '';
45+
};
46+
47+
useEffect(() => {
48+
// When selecting the token, fetch installments using the token's BIN and total checkout amount
49+
const total = billing?.cartTotal?.value || 0;
50+
const tokenBin = getTokenBin(token);
51+
fetchInstallments(tokenBin, total);
52+
}, [token, billing?.cartTotal?.value]);
53+
54+
// Integrate with checkout blocks to send the selected installment
55+
useEffect(() => {
56+
if (!eventRegistration || !emitResponse) return;
57+
58+
const unsubscribe = onPaymentSetup(() => {
59+
const customerDocument = getTokenCustomerDocument(token);
60+
61+
const paymentMethodData = {
62+
'rm-pagbank-card-installments-token': selectedInstallment,
63+
'token': token,
64+
'payment_method': token,
65+
'payment_method': 'rm-pagbank-cc',
66+
'wc-rm-pagbank-cc-payment-token': token,
67+
'isSavedToken': true,
68+
};
69+
70+
// Add customer document if available
71+
if (customerDocument) {
72+
paymentMethodData['rm-pagbank-customer-document'] = customerDocument;
73+
}
74+
75+
return {
76+
type: emitResponse.responseTypes.SUCCESS,
77+
meta: {
78+
paymentMethodData: paymentMethodData,
79+
},
80+
};
81+
} );
82+
83+
return () => {
84+
unsubscribe();
85+
}
86+
87+
}, [selectedInstallment, token, onPaymentSetup]);
88+
89+
return (
90+
<div style={{ marginTop: '1em' }}>
91+
<InstallmentsOptions
92+
installments={installments}
93+
onChange={e => setSelectedInstallment(e.target.value)}
94+
/>
95+
</div>
96+
);
97+
};
98+
99+
export default SavedCardInstallments;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React, { useState } from "react";
2+
import { __ } from "@wordpress/i18n";
3+
4+
const SavedCreditCardToken = () => {
5+
const [isChecked, setIsChecked] = useState(false);
6+
const handleCheckboxChange = () => {
7+
setIsChecked(!isChecked);
8+
};
9+
10+
return (
11+
<div className="form-row form-row-wide woocommerce-SavedPaymentMethods-saveNew" style={{ marginTop: '1em' }}>
12+
<label htmlFor="rm-pagbank-cc-new-payment-method-in-block" className="woocommerce-form__label woocommerce-form__label-for-checkbox checkbox">
13+
<input
14+
type="checkbox"
15+
id="rm-pagbank-cc-new-payment-method-in-block"
16+
name="rm-pagbank-cc-new-payment-method-in-block"
17+
className="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox"
18+
checked={isChecked}
19+
onChange={handleCheckboxChange}
20+
/>
21+
<span className="woocommerce-form__label-text">
22+
{__("Salvar cartão para futuras compras", "pagbank-connect")}
23+
</span>
24+
</label>
25+
</div>
26+
);
27+
};
28+
29+
export default SavedCreditCardToken;

readme.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Donate link: https://github.com/sponsors/r-martins
55
Requires at least: 4.0
66
Tested up to: 6.8
77
Requires PHP: 7.4
8-
Stable tag: 4.43.0
8+
Stable tag: 4.44.0
99
License: GPLv3
1010
License URI: https://www.gnu.org/licenses/gpl-3.0.html
1111
PagBank com PIX, Cartão de Crédito, Boleto, Recorrência + Envio Fácil e com Menos Taxas no PagSeguro.
@@ -204,6 +204,12 @@ Você deve fazer isso através de Pull Requests ao [repositório oficial no gith
204204

205205
== Changelog ==
206206

207+
= 4.44.0 =
208+
* Dashboard de relatórios da recorrência: agora você pode ver alguns indicadores importantes de suas assinaturas, como o total de assinaturas ativas, o total de assinaturas canceladas e o total de assinaturas suspensas, Receita Recorrente Mensal, e muito mais.
209+
* Agora é possível salvar o cartão de crédito para uso posterior no checkout em blocos (nativo do WooCommerce).
210+
* Possível correção onde em alguns cenários dois campos de parcelamento eram exibidos na página de checkout.
211+
* Alteração no URL de nossa API e de alguns links de ajuda.
212+
207213
= 4.43.0 =
208214
* Agora é possível salvar o cartão para uso posterior
209215
* Correção: no checkout em blocos as parcelas nem sempre eram atualizadas quando o pedido tinha seu total alterado (ex: alteração de frete)
@@ -460,13 +466,13 @@ Ao atualizar versões majoritárias (ex: 3.5 para 4.0), certifique-se de testar
460466

461467
== Screenshots ==
462468
1. Cartão de Crédito na visão do cliente
463-
2. PIX - Tela de Sucesso
469+
2. PIX - Tela de Sucesso com confirmação instantânea
464470
3. Configurações de cartão de crédito
465471
4. PIX e Boleto - Configurações
466472
5. Admin - Tela do Pedido
467473
6. Envio Fácil
468474
7. Autenticação 3D Secure
469-
8. Pedidos Recorrentes (assinaturas)
475+
8. Pedidos Recorrentes (assinaturas) com relatórios
470476
9. Parcelamento na Página de Produto
471477
10. Suporte a Checkout em Blocos do WooCommerce
472478
11. Conteúdo para assinantes

rm-pagbank.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* @wordpress-plugin
1111
* Plugin Name: PagBank Connect
1212
* Description: Integra seu WooCommerce com as APIs PagSeguro v4 através da aplicação de Ricardo Martins (com descontos nas taxas oficiais), com suporte a PIX transparente e muito mais.
13-
* Version: 4.43.0
13+
* Version: 4.44.0
1414
* Requires at least: 5.2
1515
* Tested up to: 6.8
1616
* Requires PHP: 7.4
@@ -32,7 +32,7 @@
3232
defined( 'ABSPATH' ) || die( 'No direct script access allowed!' );
3333

3434
// Plugin constants.
35-
define( 'WC_PAGSEGURO_CONNECT_VERSION', '4.43.0' );
35+
define( 'WC_PAGSEGURO_CONNECT_VERSION', '4.44.0' );
3636
define( 'WC_PAGSEGURO_CONNECT_PLUGIN_FILE', __FILE__ );
3737
define( 'WC_PAGSEGURO_CONNECT_BASE_DIR', __DIR__ );
3838
define( 'WC_PAGSEGURO_CONNECT_TEMPLATES_DIR', WC_PAGSEGURO_CONNECT_BASE_DIR . '/src/templates/' );

src/Connect.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ public static function init()
114114
}
115115

116116
add_action('wp_ajax_pagbank_dismiss_pix_order_keys_notice', [StandalonePix::class, 'dismissPixOrderKeysNotice']);
117+
add_filter('woocommerce_admin_reports', [\RM_PagBank\Connect\Recurring\Admin\Reports\RecurringsReport::class, 'reportsFilter']);
117118
}
118119

119120
public static function gatewayBlockSupport() {

0 commit comments

Comments
 (0)