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 Pix #166

Merged
merged 74 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 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
a4ff2a7
fix: adicionando uma linha ao final do arquivo .codeclimate.yml
devaguia Mar 26, 2024
d60ae22
fix: removendo ponto final indesejado da propriedade "Tested up to" n…
devaguia Mar 26, 2024
38b8dd2
fix: quebra de linha para com mais de 120 caracteres
devaguia Mar 26, 2024
ad5238d
fix: corrigindo texto na descrição do método de pagamento pix
devaguia Mar 26, 2024
f543a43
fix: adicionando dois espaços na linha para melhorar a identação
devaguia Mar 26, 2024
eac8b68
fix: adicionando espaço depois da vírgula
devaguia Mar 26, 2024
aa6d9c3
fix: adicionando timezone ao buscar a data atual durante verificação …
devaguia Mar 26, 2024
b05ff2d
fix: codeclimate issues - identação
devaguia Mar 26, 2024
05659ab
fix: codeclimate issues - identação
devaguia Mar 26, 2024
fe6315c
fix: codeclimate issues - identação
devaguia Mar 26, 2024
4875aee
fix: codeclimate issues - identação
devaguia Mar 26, 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: 2 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
engines:
duplication:
enabled: false
csslint:
enabled: true
phpmd:
Expand Down
4 changes: 2 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Tags: vindi, subscriptions, pagamento-recorrente, cobranca-recorrente, cobrança
Author URI: https://vindi.com.br/ | https://mentores.com.br
Author: Vindi | Mentores Digital
Requires at least: 4.4
Tested up to: 6.3
Tested up to: 6.4
WC requires at least: 3.0.0
WC tested up to: 7.6.0
WC tested up to: 8.6.1
Requires PHP: 5.6
Stable Tag: 1.2.6
License: GPLv3
Expand Down
37 changes: 37 additions & 0 deletions src/VindiWoocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ public function __construct()
));

add_filter('woocommerce_cart_needs_payment', [$this, 'filter_woocommerce_cart_needs_payment'], 10, 2);
add_action('wp_ajax_renew_pix_charge', [$this, 'renew_pix_charge']);
add_action('wp_ajax_nopriv_renew_pix_charge', [$this, 'renew_pix_charge']);
}

/**
Expand Down Expand Up @@ -139,6 +141,7 @@ public function init()
require_once plugin_dir_path(__FILE__) . '/includes/admin/Settings.php';
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__) . '/utils/SubscriptionStatusHandler.php';
require_once plugin_dir_path(__FILE__) . '/utils/InterestPriceHandler.php';

Expand Down Expand Up @@ -183,6 +186,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);
rai-gondim-vindi marked this conversation as resolved.
Show resolved Hide resolved

return $methods;
}
Expand Down Expand Up @@ -212,6 +216,39 @@ private function cart_has_trial($cart)

return false;
}

public function renew_pix_charge()
{
$order_id = filter_input(INPUT_POST, 'order_id', FILTER_SANITIZE_NUMBER_INT);
$charge_id = filter_input(INPUT_POST, 'charge_id', FILTER_SANITIZE_NUMBER_INT);
$subscription_id = filter_input(INPUT_POST, 'subscription_id', FILTER_SANITIZE_NUMBER_INT);

$order = wc_get_order($order_id);
$vindi_order = $order->get_meta('vindi_order', true);

if ($charge_id && $subscription_id) {
$routes = new VindiRoutes($this->settings);
$charge = $routes->renewCharge($charge_id);

if (isset($charge['status']) && isset($charge['last_transaction']['gateway_response_fields'])) {
$last_transaction = $charge['last_transaction']['gateway_response_fields'];

$subscription = $vindi_order[$subscription_id];
$bill = [
'id' => $subscription['bill']['id'],
'status' => $subscription['bill']['status'],
'charge_id' => $charge['id'],
'pix_expiration' => $last_transaction['max_days_to_keep_waiting_payment'],
'pix_code' => $last_transaction['qrcode_original_path'],
'pix_qr' => $last_transaction['qrcode_path'],
];

$vindi_order[$subscription_id]['bill'] = $bill;
$order->update_meta_data('vindi_order', $vindi_order);
$order->save();
}
}
}
}

add_action('plugins_loaded', array(WcVindiPayment::class, 'get_instance'));
36 changes: 23 additions & 13 deletions src/assets/css/frontend.css

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

12 changes: 6 additions & 6 deletions src/assets/js/frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ class FrontEnd {
jQuery(".vindi-change-card").bind('click', function () {
jQuery('.vindi-old-cc-data').hide();
jQuery('.vindi-old-cc-data').find('input').prop('disabled', true);

jQuery('.vindi-new-cc-data').find('input, select').prop('disabled', false);
jQuery('.vindi-new-cc-data').show();

return false;
});
}
Expand Down Expand Up @@ -54,9 +54,9 @@ class FrontEnd {

setCardNumber(element, id, number) {
const svg = document.getElementById(id);

if (svg) {
svg.innerHTML = element.value === '' ? number : element.value
svg.innerHTML = element.value === '' ? number : element.value
}
}

Expand Down Expand Up @@ -141,6 +141,6 @@ class FrontEnd {

new FrontEnd;

jQuery('body').on('updated_checkout', () => {
new FrontEnd
jQuery('body').on('updated_checkout', () => {
new FrontEnd
});
54 changes: 54 additions & 0 deletions src/assets/js/thankyou.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
class Thankyou {
constructor() {
if (!document.querySelector(".vindi_payment_listing")) return;

this.copyPixLine();
this.renewPixCharge();
}

renewPixCharge() {
const btn = document.querySelector('#generate_new_qr_code');

if (btn) {
btn.addEventListener('click', () => {
const order = btn.getAttribute('data-order');
const charge = btn.getAttribute('data-charge');
const subscription = btn.getAttribute('data-subscription');

jQuery.ajax({
url: ajax_object.ajax_url,
type: 'post',
data: {
action: 'renew_pix_charge',
charge_id: charge,
order_id: order,
subscription_id: subscription
},
success: function(response) {
window.location.reload();
}
});
devaguia marked this conversation as resolved.
Show resolved Hide resolved
});
}
}

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

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

new Thankyou;

jQuery('body').on('updated_checkout', () => {
new Thankyou;
})

2 changes: 1 addition & 1 deletion src/assets/sass/frontend.sass
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@
//****************************\\
// BANK SLIPS' LIST STYLING \\
//****************************\\
.vindi_bankslip_listing
.vindi_payment_listing
background: #FFFFFF
border-radius: 2px
box-shadow: inset 5px 0px 0px #37D559
Expand Down
4 changes: 2 additions & 2 deletions src/includes/gateways/BankSlipPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function thank_you_page($order_id)
{
$order = wc_get_order($order_id);
if ($order->get_payment_method() == 'vindi-bank-slip') {
$vindi_order = get_post_meta($order_id, 'vindi_order', true);
$vindi_order = $order->get_meta('vindi_order', true);
$order_to_iterate = $this->bank_slip_quantity_to_render($vindi_order);
$this->vindi_settings->get_template(
'bankslip-download.html.php',
Expand All @@ -148,7 +148,7 @@ public function show_bank_slip_download($order_id)
{
$order = wc_get_order($order_id);
if ($order->get_payment_method() == 'vindi-bank-slip') {
$vindi_order = get_post_meta($order_id, 'vindi_order', true);
$vindi_order = $order->get_meta('vindi_order', true);
$order_to_iterate = $this->bank_slip_quantity_to_render($vindi_order);
if (!$order->is_paid() && !$order->has_status('cancelled')) {
$this->vindi_settings->get_template(
Expand Down
Loading