Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adiciona método de pagamento Bolepix #170

Merged
merged 86 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
347c913
feat: creating PIX gateway class
devaguia Feb 2, 2024
29abfd9
feat: processando pagamentos com o método de pagamento PIX
devaguia Feb 6, 2024
8762e7b
feat: adicionando script para copiar código pix
devaguia Feb 6, 2024
91c159c
fix: add cursor pointer no botão de copiar pix code
devaguia Feb 6, 2024
f5a306c
feat: criando renovação de cobrança PIX
devaguia Feb 22, 2024
305b309
fix: passando variavel order_id para a página de assinatura para pode…
devaguia Feb 26, 2024
566b0e4
feat: invertendo verificação na visualização de Qr Code para restring…
devaguia Feb 26, 2024
88008a4
fix: merge conflicts build/add_pix_gateway <- master
devaguia Mar 7, 2024
9b244e8
feat: melhorando compatibilidade com HPOS
devaguia Mar 7, 2024
a39b56e
fix: codeclimate issues
devaguia Mar 7, 2024
95f3d98
fix: codeclimate issues
devaguia Mar 7, 2024
f38899a
fix: codeclimate issues
devaguia Mar 7, 2024
3cb7543
fix: codeclimate issues
devaguia Mar 7, 2024
c9630fd
fix: codeclimate issues
devaguia Mar 7, 2024
e722cdf
fix: codeclimate issues
devaguia Mar 7, 2024
a2712f3
fix: codeclimate issues
devaguia Mar 7, 2024
55360ec
fix: codeclimate issues
devaguia Mar 7, 2024
f85c0bc
fix: codeclimate issues
devaguia Mar 7, 2024
dccb5b6
fix: codeclimate issues
devaguia Mar 7, 2024
2c7a100
fix: codeclimate issues
devaguia Mar 7, 2024
3498daf
fix: codeclimate issues
devaguia Mar 7, 2024
919b3c4
fix: codeclimate issues
devaguia Mar 7, 2024
13d1ff4
fix: codeclimate issues
devaguia Mar 7, 2024
161f35d
fix: codeclimate issues
devaguia Mar 7, 2024
687c0ff
fix: codeclimate issues
devaguia Mar 7, 2024
dfedef3
fix: codeclimate issues
devaguia Mar 7, 2024
f65ed76
fix: codeclimate issues
devaguia Mar 7, 2024
f8b0f0f
fix: codeclimate issues
devaguia Mar 7, 2024
304f0ee
fix: codeclimate issues
devaguia Mar 7, 2024
32617fd
fix: codeclimate issues
devaguia Mar 7, 2024
1657a3d
fix: codeclimate issues
devaguia Mar 7, 2024
2d123a0
fix: codeclimate issues
devaguia Mar 7, 2024
1281463
fix: codeclimate issues
devaguia Mar 7, 2024
75fe00e
fix: codeclimate issues
devaguia Mar 7, 2024
1fb73fa
fix: codeclimate issues
devaguia Mar 7, 2024
cb233de
fix: codeclimate issues
devaguia Mar 7, 2024
8eed16c
fix: codeclimate issues
devaguia Mar 7, 2024
63bbfc6
fix: codeclimate issues
devaguia Mar 8, 2024
aaea680
fix: codeclimate issues
devaguia Mar 8, 2024
e204017
fix: codeclimate issues
devaguia Mar 8, 2024
8acb880
fix: codeclimate issues
devaguia Mar 8, 2024
7f8fadd
fix: codeclimate issues
devaguia Mar 8, 2024
1fe1c3d
fix: codeclimate issues
devaguia Mar 8, 2024
7c58948
fix: codeclimate issues
devaguia Mar 8, 2024
bb8e3fe
fix: codeclimate issues
devaguia Mar 8, 2024
0993b77
fix: codeclimate issues
devaguia Mar 8, 2024
4719681
fix: codeclimate issues
devaguia Mar 8, 2024
54a3bb3
fix: codeclimate issues
devaguia Mar 8, 2024
0515a1a
fix: codeclimate issues
devaguia Mar 8, 2024
a7b83af
fix: codeclimate issues
devaguia Mar 8, 2024
48aa5d5
fix: codeclimate issues
devaguia Mar 8, 2024
821f472
fix: codeclimate issues
devaguia Mar 8, 2024
c37ef34
fix: codeclimate issues
devaguia Mar 8, 2024
7446f26
fix: codeclimate issues
devaguia Mar 8, 2024
2cee083
fix: codeclimate issues
devaguia Mar 8, 2024
b9bc884
fix: codeclimate issues
devaguia Mar 8, 2024
886f766
fix: codeclimate issues
devaguia Mar 8, 2024
3ac3a73
fix: codeclimate issues
devaguia Mar 8, 2024
46977a0
fix: trocando texto do método de pagamento pix
devaguia Mar 12, 2024
83f7b02
fix: verificação de tipo de transação para webhook
devaguia Mar 12, 2024
2f88c81
fix: removendo propriedade de pattern
devaguia Mar 13, 2024
afbbdfc
fix: codeclimate issues
devaguia Mar 13, 2024
25dea56
docs: update documentation files
devaguia Mar 14, 2024
9f8e3b2
feat: iniciando a criação do novo método de pagamento Bolepix
devaguia Mar 19, 2024
f0a61d5
feat: adicionando suporte para bolepix no processo de pagamento
devaguia Mar 22, 2024
3ac6857
feat: criando visualização na thankyou page e processando pagamento
devaguia Mar 25, 2024
0afcf41
fix: codeclimate issues
devaguia Mar 25, 2024
6676cd3
fix: codeclimate issues
devaguia Mar 25, 2024
ed23251
fix: codeclimate issues
devaguia Mar 25, 2024
10bea26
fix: codeclimate issues
devaguia Mar 25, 2024
3e50505
run ci
devaguia Mar 25, 2024
69d112e
run ci
devaguia Mar 25, 2024
895d46d
fix: codeclimate issues
devaguia Mar 25, 2024
e4a1e07
fix: complexidade da função payment_method_code
devaguia Mar 26, 2024
387be02
fix: complexidade da função create_bill_meta_for_order
devaguia Mar 26, 2024
099407b
fix: automatic merge conflicts
devaguia Apr 5, 2024
f1b580d
fix: adicionando timezone para verificação de vencimento do QRcode
devaguia Apr 5, 2024
4469c2d
fix: Line exceeds 120 characters; contains 146 characters
devaguia Apr 5, 2024
f92cbbb
docs: atualiza número de versão do plugin
devaguia Apr 5, 2024
1bccff3
fix: corrigindo palavra expiration no template de visualização de PIX
devaguia Apr 10, 2024
76d4f53
fix: corrigindo textos nas classes de PIX e Bolepix
devaguia Apr 10, 2024
ff87032
fix: corrigindo identação no arquivo VindiWooCommerce.php
devaguia Apr 10, 2024
3e47d6b
fix: bug ao salvar produtos do tipo assinatura
devaguia Apr 11, 2024
59f23bf
fix: Line indented incorrectly; expected at least 12 spaces, found 10
devaguia Apr 11, 2024
d6389ea
docs: update readme.txt
devaguia Apr 11, 2024
471f296
fix: atualiza identação do arquivo VindiWooCommerce.php
devaguia Apr 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ engines:
duplication:
enabled: false
csslint:
enabled: true
enabled: false
phpmd:
enabled: true
checks:
Expand Down
7 changes: 6 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Tested up to: 6.4
WC requires at least: 3.0.0
WC tested up to: 8.6.1
Requires PHP: 5.6
Stable Tag: 1.2.7
Stable Tag: 1.2.8
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -40,6 +40,11 @@ Para dúvidas e suporte técnico, entre em contato com a equipe Vindi através d

== Changelog ==

= 1.2.8 - 05/04/2024 =
-Lançamento da versão de patch.
- **Melhoria:** Adiciona o método de pagamento BolePix
- **Correção:** Bug ao atualizar produtos do tipo assinatura

= 1.2.7 - 04/04/2024 =
-Lançamento da versão de patch.
- **Melhoria:** Adiciona o método de pagamento Pix
Expand Down
2 changes: 2 additions & 0 deletions src/VindiWoocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public function init()
require_once plugin_dir_path(__FILE__) . '/includes/gateways/CreditPayment.php';
require_once plugin_dir_path(__FILE__) . '/includes/gateways/BankSlipPayment.php';
require_once plugin_dir_path(__FILE__) . '/includes/gateways/PixPayment.php';
require_once plugin_dir_path(__FILE__) . '/includes/gateways/BolepixPayment.php';
require_once plugin_dir_path(__FILE__) . '/utils/SubscriptionStatusHandler.php';
require_once plugin_dir_path(__FILE__) . '/utils/InterestPriceHandler.php';

Expand Down Expand Up @@ -187,6 +188,7 @@ public function add_gateway($methods)
$methods[] = new VindiCreditGateway($this->settings, $this->controllers);
$methods[] = new VindiBankSlipGateway($this->settings, $this->controllers);
$methods[] = new VindiPixGateway($this->settings, $this->controllers);
$methods[] = new VindiBolepixGateway($this->settings, $this->controllers);
thais-kusuki-vindi marked this conversation as resolved.
Show resolved Hide resolved

return $methods;
}
Expand Down
3 changes: 3 additions & 0 deletions src/assets/css/frontend.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/assets/js/thankyou.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ class Thankyou {
}

copyPixLine() {
const btn = document.querySelector('#copy_vindi_pix_code');
const buttons = document.querySelectorAll('.copy_vindi_line');

if(btn) {
buttons.forEach((btn) => {
btn.addEventListener('click', () => {
const text = btn.getAttribute('data-code');
if (navigator?.clipboard?.writeText) {
navigator.clipboard.writeText(text);
}
});
}
})
}
}

Expand Down
6 changes: 2 additions & 4 deletions src/controllers/PlansController.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ function create($post_id, $post, $update, $recreated = false)
$post_status = get_post_status($post_id);
$vindi_plan_id = get_post_meta($post_id, 'vindi_plan_id', true);

if (!$recreated && $post_status != 'publish') {
if (!empty($vindi_plan_id)) {
return $this->update($post_id);
}
if (!$recreated && $post_status != 'publish' || !empty($vindi_plan_id)) {
return $this->update($post_id);
}

$product = wc_get_product($post_id);
Expand Down
147 changes: 147 additions & 0 deletions src/includes/gateways/BolepixPayment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
<?php

namespace VindiPaymentGateways;

/**
* Vindi Payment Bolepix Gateway class.
*
* Extended by individual payment gateways to handle payments.
*
* @class VindiBolepixGateway
* @extends VindiPaymentGateway
*/
class VindiBolepixGateway extends VindiPaymentGateway
{
/**
* @var VindiSettings
*/
public $vindiSettings;

/**
* @var VindiControllers
*/
public $controllers;

/**
* Constructor for the gateway.
*/
public function __construct(VindiSettings $vindiSettings, VindiControllers $controllers)
{
$this->id = 'vindi-bolepix';
$this->icon = apply_filters('vindi_woocommerce_bolepix_icon', '');
$this->method_title = __('Vindi - Bolepix', VINDI);
$this->method_description = __('Aceitar pagamentos via Bolepix utilizando a Vindi.', VINDI);
$this->has_fields = true;
$this->supports = array(
'subscriptions',
'products',
'subscription_cancellation',
'subscription_reactivation',
'subscription_suspension',
'subscription_amount_changes',
'subscription_payment_method_change',
'subscription_payment_method_change_customer',
'subscription_payment_method_change_admin',
'subscription_date_changes',
'multiple_subscriptions',
'pre-orders'
);
$this->init_form_fields();
$this->init_settings();
add_action('woocommerce_view_order', array(&$this, 'show_bolepix_download'), -10, 1);
add_action('woocommerce_thankyou_' . $this->id, array(&$this, 'thank_you_page'));
parent::__construct($vindiSettings, $controllers);
}

/**
* Should return payment type for payment processing.
* @return string
*/
public function type()
{
return 'bolepix';
}

public function init_form_fields()
{

$this->form_fields = array(
'enabled' => array(
'title' => __('Habilitar/Desabilitar', VINDI),
'label' => __('Habilitar pagamento por Bolepix com Vindi', VINDI),
'type' => 'checkbox',
'default' => 'no',
),
'title' => array(
'title' => __('Título', VINDI),
'type' => 'text',
'description' => __('Título que o cliente verá durante o processo de pagamento.', VINDI),
'default' => __('Bolepix', VINDI),
)
);
}

# Essa função é responsável por verificar a compra que está sendo feita
# No caso de uma assinatura única, o $order[0] não existirá e retornará ela mesmo
# Issue: https://github.com/vindi/vindi-woocommerce/issues/75
public function bolepix_quantity_to_render($order)
{
if (!isset($order[0])) {
return $order;
}

return $order[0];
}

public function payment_fields()
{
$user_country = $this->get_country_code();

if (empty($user_country)) {
_e('Selecione o País para visualizar as formas de pagamento.', VINDI);
return;
}

$is_single_order = $this->is_single_order();
$is_trial = $this->vindi_settings->get_is_active_sandbox();
if ($is_trial) {
$is_trial = $this->routes->isMerchantStatusTrialOrSandbox();
}

$this->vindi_settings->get_template('bolepix-checkout.html.php', compact('is_trial', 'is_single_order'));
}

public function thank_you_page($order_id)
{
$order = wc_get_order($order_id);
$vindi_order = [];
$order_to_iterate = 0;

if ($order->get_payment_method() == 'vindi-bolepix') {
$vindi_order = $order->get_meta('vindi_order', true);
$order_to_iterate = $this->bolepix_quantity_to_render($vindi_order);
$this->vindi_settings->get_template(
'bolepix-download.html.php',
compact('vindi_order', 'order_to_iterate', 'order_id')
);
}
}

public function show_bolepix_download($order_id)
{
$order = wc_get_order($order_id);
$vindi_order = [];
$order_to_iterate = 0;

if ($order->get_payment_method() == 'vindi-bolepix') {
$vindi_order = $order->get_meta('vindi_order', true);
$order_to_iterate = $this->bolepix_quantity_to_render($vindi_order);
if (!$order->is_paid() && !$order->has_status('cancelled')) {
$this->vindi_settings->get_template(
'bolepix-download.html.php',
compact('vindi_order', 'order_to_iterate', 'order_id')
);
}
}
}
}
4 changes: 2 additions & 2 deletions src/includes/gateways/PixPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace VindiPaymentGateways;

/**
* Vindi Payment PIX Card Gateway class.
* Vindi Payment PIX Gateway class.
*
* Extended by individual payment gateways to handle payments.
*
Expand All @@ -30,7 +30,7 @@ public function __construct(VindiSettings $vindiSettings, VindiControllers $cont
$this->id = 'vindi-pix';
$this->icon = apply_filters('vindi_woocommerce_pix_icon', '');
$this->method_title = __('Vindi - PIX', VINDI);
$this->method_description = __('Aceitar pagamentos via boleto bancário utilizando a Vindi.', VINDI);
$this->method_description = __('Aceitar pagamentos via PIX utilizando a Vindi.', VINDI);
$this->has_fields = true;
$this->supports = array(
'subscriptions',
Expand Down
33 changes: 33 additions & 0 deletions src/templates/bolepix-checkout.html.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
if (!defined('ABSPATH')) {
exit;
}
?>

<?php if ($is_trial) : ?>
<div style="padding: 10px;border: 1px solid #f00; background-color: #fdd; color: #f00; margin: 10px 2px">
<h3 style="color: #f00"><?php _e('MODO DE TESTES', VINDI); ?></h3>
<p>
<?php _e(
'Sua conta na Vindi está em <strong>Modo Trial</strong>.
Este modo é proposto para a realização de testes e, portanto,
nenhum pedido será efetivamente cobrado.',
VINDI
); ?>
</p>
</div>
<?php endif; ?>
<fieldset>
<?php do_action('vindi_bolepix_form_start'); ?>

<div class="vindi-invoice-description" style="padding: 20px 0; font-weight: bold;">
<?php
_e('Após confirmar o pedido, use PIX ou Boleto Bancário para efetuar o pagamento.', VINDI);
?>
</div>
<div class="clear"></div>

<?php do_action('vindi_bolepix_form_end'); ?>

<div class="clear"></div>
</fieldset>
77 changes: 77 additions & 0 deletions src/templates/bolepix-download.html.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
if (!defined('ABSPATH')) {
exit;
}
?>
<?php if (isset($vindi_order)) : ?>
<div class="vindi_payment_listing">
<div class="info_message">
<div class="icon"></div>
<div class="message">
<p class="message_title">
<?php _e('Aqui estão as sua cobranças com Bolepix.', VINDI); ?>
</p>
<p class="message_description">
<?php
_e(
'Você pode pagar utilizando PIX ou Boleto Bancário.
Após recebermos a confirmação do pagamento, seu pedido será processado.',
VINDI
);
?>
</p>
</div>
</div>
<div class="charges">
<?php foreach ($order_to_iterate as $key => $subscription) : ?>
thais-kusuki-vindi marked this conversation as resolved.
Show resolved Hide resolved
<?php if (is_array($subscription) && array_key_exists('product', $subscription)
&& !in_array($subscription['bill']['status'], array('paid', 'canceled'))) : ?>
<div class="bolepix_charge charge">
<span class="bolepix_product_title product_title">
<?php echo $subscription['product']; ?>
</span>
<div>
<div class="qr_code_viwer">
<object type="image/svg+xml"
alt="QR Code image"
data="<?php echo esc_url($subscription['bill']['pix_qr']); ?>">
</object>
</div>
<div style="display: flex;
flex-direction: column;
align-items: end;
justify-content: end;
position: relative;
right: 75px;">
<a id="copy_vindi_bolepix_code"
class="download_button copy_vindi_line"
data-code="<?php echo esc_attr($subscription['bill']['pix_code']); ?>">
<?php _e('Copiar código PIX', VINDI); ?>
</a>
<a class="download_button"
href="<?php echo esc_url($subscription['bill']['bank_slip_url']); ?>"
target="_blank">
<?php _e('Baixar boleto', VINDI); ?>
<svg color="#006DFF"
style="padding: 0 5px;"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 512 512">
<path d="M288 32c0-17.7-14.3-32-32-32s-32
14.3-32 32V274.7l-73.4-73.4c-12.5-12.5-32.8-12.5-45.3
0s-12.5 32.8 0 45.3l128 128c12.5 12.5 32.8 12.5
45.3 0l128-128c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3
0L288 274.7V32zM64 352c-35.3 0-64 28.7-64 64v32c0 35.3
28.7 64 64 64H448c35.3 0 64-28.7
64-64V416c0-35.3-28.7-64-64-64H346.5l-45.3
45.3c-25 25-65.5 25-90.5 0L165.5 352H64zm368
56a24 24 0 1 1 0 48 24 24 0 1 1 0-48z"/>
</svg>
</a>
</div>
</div>
</div>
<?php endif; ?>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
Loading
Loading