From 347c913778a659d891af55bd25e3d6f28404d7d6 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Fri, 2 Feb 2024 11:23:02 -0300 Subject: [PATCH 01/84] feat: creating PIX gateway class --- src/VindiWoocommerce.php | 2 + src/includes/gateways/PixPayment.php | 156 +++++++++++++++++++++++++++ 2 files changed, 158 insertions(+) create mode 100644 src/includes/gateways/PixPayment.php diff --git a/src/VindiWoocommerce.php b/src/VindiWoocommerce.php index 95c9cc51..90b25f7b 100644 --- a/src/VindiWoocommerce.php +++ b/src/VindiWoocommerce.php @@ -139,6 +139,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'; @@ -183,6 +184,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); return $methods; } diff --git a/src/includes/gateways/PixPayment.php b/src/includes/gateways/PixPayment.php new file mode 100644 index 00000000..9c306577 --- /dev/null +++ b/src/includes/gateways/PixPayment.php @@ -0,0 +1,156 @@ +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->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(); + + // Load the settings. + $this->init_settings(); + + add_action('woocommerce_view_order', array(&$this, 'show_pix_download'), -10, 1); + add_action('woocommerce_thankyou_' . $this->id, array(&$this, 'thank_you_page')); + + parent::__construct($vindi_settings, $controllers); + $this->title = $this->get_option('title'); + $this->description = $this->get_option('description'); + $this->enabled = $this->get_option('enabled'); + + } + + /** + * Should return payment type for payment processing. + * @return string + */ + public function type() + { + return 'pix'; + } + + public function init_form_fields() + { + + $this->form_fields = array( + 'enabled' => array( + 'title' => __('Habilitar/Desabilitar', VINDI), + 'label' => __('Habilitar pagamento por PIX 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' => __('PIX', 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 pix_quantity_to_render($order) + { + if (is_null($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(); + + if ($is_trial = $this->vindi_settings->get_is_active_sandbox()) + $is_trial = $this->routes->isMerchantStatusTrialOrSandbox(); + + $this->vindi_settings->get_template('pix-checkout.html.php', compact('is_trial', 'is_single_order')); + } + + public function thank_you_page($order_id) + { + $order = wc_get_order($order_id); + if ($order->get_payment_method() == 'vindi-pix') { + $vindi_order = get_post_meta($order_id, 'vindi_order', true); + $order_to_iterate = $this->pix_quantity_to_render($vindi_order); + $this->vindi_settings->get_template( + 'pix-download.html.php', + compact('vindi_order', 'order_to_iterate') + ); + } + } + + public function show_pix_download($order_id) + { + $order = wc_get_order($order_id); + if ($order->get_payment_method() == 'vindi-pix') { + $vindi_order = get_post_meta($order_id, 'vindi_order', true); + $order_to_iterate = $this->pix_quantity_to_render($vindi_order); + if (!$order->is_paid() && !$order->has_status('cancelled')) { + $this->vindi_settings->get_template( + 'pix-download.html.php', + compact('vindi_order', 'order_to_iterate') + ); + } + } + } +} From 29abfd90cc44bf9f22110625ac9a549f220dbd8f Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Tue, 6 Feb 2024 10:57:28 -0300 Subject: [PATCH 02/84] =?UTF-8?q?feat:=20processando=20pagamentos=20com=20?= =?UTF-8?q?o=20m=C3=A9todo=20de=20pagamento=20PIX?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/css/frontend.css | 36 ++++++++++------ src/assets/sass/frontend.sass | 2 +- src/includes/gateways/PixPayment.php | 2 +- src/templates/bankslip-download.html.php | 8 ++-- src/templates/pix-checkout.html.php | 25 +++++++++++ src/templates/pix-download.html.php | 53 ++++++++++++++++++++++++ src/utils/PaymentProcessor.php | 30 ++++++++++++-- 7 files changed, 133 insertions(+), 23 deletions(-) create mode 100644 src/templates/pix-checkout.html.php create mode 100644 src/templates/pix-download.html.php diff --git a/src/assets/css/frontend.css b/src/assets/css/frontend.css index b35ffc41..fd6e6eac 100644 --- a/src/assets/css/frontend.css +++ b/src/assets/css/frontend.css @@ -280,7 +280,7 @@ transform: rotateY(180deg); } -.vindi_bankslip_listing { +.vindi_payment_listing { background: #FFFFFF; border-radius: 2px; box-shadow: inset 5px 0px 0px #37D559; @@ -290,39 +290,39 @@ font-style: normal; margin-bottom: 1.41575em; } -.vindi_bankslip_listing .info_message { +.vindi_payment_listing .info_message { padding: 20px 30px; display: flex; } -.vindi_bankslip_listing .info_message .icon { +.vindi_payment_listing .info_message .icon { width: 30px; height: 30px; margin-right: 22px; background-image: url("../images/icon-bankslip.svg"); } -.vindi_bankslip_listing .info_message .message { +.vindi_payment_listing .info_message .message { display: flex; flex-direction: column; max-width: 90%; } -.vindi_bankslip_listing .info_message .message .message_title { +.vindi_payment_listing .info_message .message .message_title { margin: 0; line-height: 17px; font-weight: bold; font-size: 14px; } -.vindi_bankslip_listing .info_message .message .message_description { +.vindi_payment_listing .info_message .message .message_description { margin: 3px 0 0; line-height: 18px; font-weight: 300; font-size: 13px; } -.vindi_bankslip_listing .bankslips { +.vindi_payment_listing .charges { display: flex; flex-direction: column; align-items: flex-end; } -.vindi_bankslip_listing .bankslips .bankslip { +.vindi_payment_listing .charges .charge { width: calc(100% - 5px); display: flex; justify-content: space-between; @@ -330,13 +330,14 @@ border-top: 1px solid #E6E6E6; padding: 15px 17px 15px 25px; } -.vindi_bankslip_listing .bankslips .bankslip .product_title { +.vindi_payment_listing .charges .charge .product_title { + text-transform: capitalize; font-weight: bold; font-size: 14px; line-height: 17px; } -.vindi_bankslip_listing .bankslips .bankslip .download_button { - padding: 12px 30px; +.vindi_payment_listing .charges .charge .download_button { + padding: 12px 20px; background: #FFFFFF; border: 1px solid #006DFF; border-radius: 3px; @@ -347,11 +348,20 @@ text-align: center; text-decoration: none !important; transition: opacity 0.2s ease; + display: flex; + align-items: center; + justify-content: center; } -.vindi_bankslip_listing .bankslips .bankslip .download_button:hover { + +.vindi_payment_listing .charges .charge .download_button svg { + padding: 0 5px; + width: 24px; +} + +.vindi_payment_listing .charges .charge .download_button:hover { opacity: 0.5; } -.vindi_bankslip_listing .bankslips .bankslip .download_button:focus { +.vindi_payment_listing .charges .charge .download_button:focus { outline-color: #006DFF; } diff --git a/src/assets/sass/frontend.sass b/src/assets/sass/frontend.sass index 8188f089..7e391b3e 100644 --- a/src/assets/sass/frontend.sass +++ b/src/assets/sass/frontend.sass @@ -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 diff --git a/src/includes/gateways/PixPayment.php b/src/includes/gateways/PixPayment.php index 9c306577..6ec73377 100644 --- a/src/includes/gateways/PixPayment.php +++ b/src/includes/gateways/PixPayment.php @@ -102,7 +102,7 @@ public function init_form_fields() # Issue: https://github.com/vindi/vindi-woocommerce/issues/75 public function pix_quantity_to_render($order) { - if (is_null($order[0])) { + if (!isset($order[0])) { return $order; } diff --git a/src/templates/bankslip-download.html.php b/src/templates/bankslip-download.html.php index 0b69c9c0..bc004c3e 100644 --- a/src/templates/bankslip-download.html.php +++ b/src/templates/bankslip-download.html.php @@ -1,6 +1,6 @@ -
+
@@ -12,10 +12,10 @@

-
+
-
+
@@ -26,7 +26,7 @@ -
+
diff --git a/src/templates/pix-checkout.html.php b/src/templates/pix-checkout.html.php new file mode 100644 index 00000000..e1cf7563 --- /dev/null +++ b/src/templates/pix-checkout.html.php @@ -0,0 +1,25 @@ + + + +
+

+

+ Modo Trial. Este modo é proposto para a realização de testes e, portanto, nenhum pedido será efetivamente cobrado.', VINDI); ?> +

+
+ +
+ + + +
+ +
+
+ + + +
+
diff --git a/src/templates/pix-download.html.php b/src/templates/pix-download.html.php new file mode 100644 index 00000000..5f394d8a --- /dev/null +++ b/src/templates/pix-download.html.php @@ -0,0 +1,53 @@ + + +
+
+
+
+

+ +

+

+ +

+
+
+
+ + +
+ + + +
+
+ +
+ +
+
+ + + +
+ + + + + + +
+ + + + +
+
+ diff --git a/src/utils/PaymentProcessor.php b/src/utils/PaymentProcessor.php index 8364aab1..269ed781 100644 --- a/src/utils/PaymentProcessor.php +++ b/src/utils/PaymentProcessor.php @@ -177,7 +177,6 @@ public function get_bank_slip_payment_type($customer_id) return array( 'customer_id' => $customer_id, 'payment_method_code' => $this->payment_method_code(), - ); } @@ -209,7 +208,22 @@ public function is_bank_slip() */ public function payment_method_code() { - return $this->is_cc() ? 'credit_card' : 'bank_slip'; + switch ($this->gateway->type()) { + case 'bank_slip': + $code = 'bank_slip'; + break; + case 'cc': + $code = 'credit_card'; + break; + case 'pix': + $code = 'pix'; + break; + default: + $code = ''; + break; + + } + return $code; } /** @@ -1100,11 +1114,19 @@ protected function create_bill($customer_id, $order_items) */ protected function create_bill_meta_for_order($bill) { - $bill_meta['id'] = $bill['id']; $bill_meta['status'] = $bill['status']; + if (isset($bill['charges']) && count($bill['charges'])) { - $bill_meta['bank_slip_url'] = $bill['charges'][0]['print_url']; + $charges = end($bill['charges']); + if ($this->payment_method_code() === 'pix' && isset($charges['last_transaction']['gateway_response_fields'])) { + $transaction = $charges['last_transaction']['gateway_response_fields']; + + $bill_meta['pix_code'] = $transaction['qrcode_original_path']; + $bill_meta['pix_qr'] = $transaction['qrcode_path']; + } else { + $bill_meta['bank_slip_url'] = $charges['print_url']; + } } return $bill_meta; } From 8762e7bbae2bb772042367856c8aae0150089524 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Tue, 6 Feb 2024 14:51:42 -0300 Subject: [PATCH 03/84] =?UTF-8?q?feat:=20adicionando=20script=20para=20cop?= =?UTF-8?q?iar=20c=C3=B3digo=20pix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/js/frontend.js | 12 ++++++------ src/assets/js/thankyou.js | 27 +++++++++++++++++++++++++++ src/templates/pix-download.html.php | 1 + src/utils/FrontendFilesLoader.php | 9 +++++++++ 4 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 src/assets/js/thankyou.js diff --git a/src/assets/js/frontend.js b/src/assets/js/frontend.js index 4c3f364f..6053fe3b 100644 --- a/src/assets/js/frontend.js +++ b/src/assets/js/frontend.js @@ -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; }); } @@ -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 } } @@ -141,6 +141,6 @@ class FrontEnd { new FrontEnd; -jQuery('body').on('updated_checkout', () => { - new FrontEnd +jQuery('body').on('updated_checkout', () => { + new FrontEnd }); diff --git a/src/assets/js/thankyou.js b/src/assets/js/thankyou.js new file mode 100644 index 00000000..c1717b2f --- /dev/null +++ b/src/assets/js/thankyou.js @@ -0,0 +1,27 @@ +class Thankyou { + constructor() { + if (!document.querySelector(".vindi_payment_listing")) return; + + this.copyPixLine(); + } + + 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; +}) + diff --git a/src/templates/pix-download.html.php b/src/templates/pix-download.html.php index 5f394d8a..5fc3eb3e 100644 --- a/src/templates/pix-download.html.php +++ b/src/templates/pix-download.html.php @@ -25,6 +25,7 @@
diff --git a/src/utils/FrontendFilesLoader.php b/src/utils/FrontendFilesLoader.php index f77c77cc..7800d92c 100644 --- a/src/utils/FrontendFilesLoader.php +++ b/src/utils/FrontendFilesLoader.php @@ -48,6 +48,15 @@ public static function frontendFiles() ); wp_enqueue_script('vindi_woocommerce_brands_js'); + wp_register_script( + 'vindi_woocommerce_thankyou_js', + plugins_url('/assets/js/thankyou.js', plugin_dir_path(__FILE__)), + array(), + VINDI_VERSION, + true + ); + wp_enqueue_script('vindi_woocommerce_thankyou_js'); + wp_register_style('vindi_woocommerce_style', plugins_url('/assets/css/frontend.css', plugin_dir_path(__FILE__)), array(), VINDI_VERSION); wp_enqueue_style('vindi_woocommerce_style'); } From 91c159c25e6512fef50c7cd94e44272a8151e18d Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Tue, 6 Feb 2024 14:56:03 -0300 Subject: [PATCH 04/84] =?UTF-8?q?fix:=20add=20cursor=20pointer=20no=20bot?= =?UTF-8?q?=C3=A3o=20de=20copiar=20pix=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/css/frontend.css | 1 + src/templates/pix-download.html.php | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/assets/css/frontend.css b/src/assets/css/frontend.css index fd6e6eac..628e72f6 100644 --- a/src/assets/css/frontend.css +++ b/src/assets/css/frontend.css @@ -360,6 +360,7 @@ .vindi_payment_listing .charges .charge .download_button:hover { opacity: 0.5; + cursor: pointer; } .vindi_payment_listing .charges .charge .download_button:focus { outline-color: #006DFF; diff --git a/src/templates/pix-download.html.php b/src/templates/pix-download.html.php index 5fc3eb3e..20d0298c 100644 --- a/src/templates/pix-download.html.php +++ b/src/templates/pix-download.html.php @@ -24,8 +24,7 @@
- From f5a306c0767d48a858b7abbfcc0b5a714689c168 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 22 Feb 2024 16:35:37 -0300 Subject: [PATCH 05/84] =?UTF-8?q?feat:=20criando=20renova=C3=A7=C3=A3o=20d?= =?UTF-8?q?e=20cobran=C3=A7a=20PIX?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/VindiWoocommerce.php | 34 +++++++++++++++++++++ src/assets/js/thankyou.js | 27 +++++++++++++++++ src/includes/gateways/PixPayment.php | 2 +- src/routes/RoutesApi.php | 17 +++++++++++ src/templates/pix-download.html.php | 40 +++++++++++++++++-------- src/utils/FrontendFilesLoader.php | 1 + src/utils/PaymentProcessor.php | 4 ++- src/utils/SubscriptionStatusHandler.php | 16 +++++----- 8 files changed, 119 insertions(+), 22 deletions(-) diff --git a/src/VindiWoocommerce.php b/src/VindiWoocommerce.php index 90b25f7b..cda32599 100644 --- a/src/VindiWoocommerce.php +++ b/src/VindiWoocommerce.php @@ -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']); } /** @@ -214,6 +216,38 @@ 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); + } + } + } } add_action('plugins_loaded', array(WcVindiPayment::class, 'get_instance')); diff --git a/src/assets/js/thankyou.js b/src/assets/js/thankyou.js index c1717b2f..86749476 100644 --- a/src/assets/js/thankyou.js +++ b/src/assets/js/thankyou.js @@ -3,6 +3,33 @@ class Thankyou { 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(); + } + }); + }); + } } copyPixLine() { diff --git a/src/includes/gateways/PixPayment.php b/src/includes/gateways/PixPayment.php index 6ec73377..c7fd43ad 100644 --- a/src/includes/gateways/PixPayment.php +++ b/src/includes/gateways/PixPayment.php @@ -134,7 +134,7 @@ public function thank_you_page($order_id) $order_to_iterate = $this->pix_quantity_to_render($vindi_order); $this->vindi_settings->get_template( 'pix-download.html.php', - compact('vindi_order', 'order_to_iterate') + compact('vindi_order', 'order_to_iterate', 'order_id') ); } } diff --git a/src/routes/RoutesApi.php b/src/routes/RoutesApi.php index 6d90e013..313c277c 100644 --- a/src/routes/RoutesApi.php +++ b/src/routes/RoutesApi.php @@ -57,6 +57,23 @@ public function createPlan($data) return $response['plan']; } + /** + * Update method for updating plan in the Vindi + * + * @since 1.0.0 + * @version 1.0.0 + * @return array + */ + public function renewCharge($charge_id) + { + $response = $this->api->request(sprintf( + 'charges/%s/charge', + filter_var($charge_id, FILTER_SANITIZE_NUMBER_INT) + ), 'POST', []); + + return $response['charge']; + } + /** * Update method for updating plan in the Vindi * diff --git a/src/templates/pix-download.html.php b/src/templates/pix-download.html.php index 20d0298c..31ae0708 100644 --- a/src/templates/pix-download.html.php +++ b/src/templates/pix-download.html.php @@ -13,24 +13,40 @@
- + $subscription) : ?>
-
- -
-
+ new DateTime()) :?> +
+ +
+ + +
+
+ Seu Qr Code Expirou! +
+ + + + +
+
diff --git a/src/utils/FrontendFilesLoader.php b/src/utils/FrontendFilesLoader.php index 7800d92c..e248e093 100644 --- a/src/utils/FrontendFilesLoader.php +++ b/src/utils/FrontendFilesLoader.php @@ -56,6 +56,7 @@ public static function frontendFiles() true ); wp_enqueue_script('vindi_woocommerce_thankyou_js'); + wp_localize_script('vindi_woocommerce_thankyou_js', 'ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ))); wp_register_style('vindi_woocommerce_style', plugins_url('/assets/css/frontend.css', plugin_dir_path(__FILE__)), array(), VINDI_VERSION); wp_enqueue_style('vindi_woocommerce_style'); diff --git a/src/utils/PaymentProcessor.php b/src/utils/PaymentProcessor.php index 269ed781..ea2427d2 100644 --- a/src/utils/PaymentProcessor.php +++ b/src/utils/PaymentProcessor.php @@ -1116,12 +1116,14 @@ protected function create_bill_meta_for_order($bill) { $bill_meta['id'] = $bill['id']; $bill_meta['status'] = $bill['status']; - + if (isset($bill['charges']) && count($bill['charges'])) { $charges = end($bill['charges']); if ($this->payment_method_code() === 'pix' && isset($charges['last_transaction']['gateway_response_fields'])) { $transaction = $charges['last_transaction']['gateway_response_fields']; + $bill_meta['charge_id'] = $charges['id']; + $bill_meta['pix_expiration'] = $transaction['max_days_to_keep_waiting_payment']; $bill_meta['pix_code'] = $transaction['qrcode_original_path']; $bill_meta['pix_qr'] = $transaction['qrcode_path']; } else { diff --git a/src/utils/SubscriptionStatusHandler.php b/src/utils/SubscriptionStatusHandler.php index b1a1777e..c44d90fc 100644 --- a/src/utils/SubscriptionStatusHandler.php +++ b/src/utils/SubscriptionStatusHandler.php @@ -156,15 +156,15 @@ public function order_canceled($order) } $single_payment_bill_id = 0; - foreach ($vindi_order as $key => $item) { - if ($key == 'single_payment' && - $vindi_order[$key]['bill']['status'] != 'canceled') { - $single_payment_bill_id = $vindi_order[$key]['bill']['id']; - } +foreach ($vindi_order as $key => $item) { + if ($key == 'single_payment' && + $vindi_order[$key]['bill']['status'] != 'canceled') { + $single_payment_bill_id = $vindi_order[$key]['bill']['id']; + } + + $vindi_order[$key]['bill']['status'] = 'canceled'; +} - $vindi_order[$key]['bill']['status'] = 'canceled'; - } - update_post_meta($order->id, 'vindi_order', $vindi_order); if ($single_payment_bill_id) { From 305b309cc8854726fa7b1ac50cfdf754782d8b15 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Mon, 26 Feb 2024 09:20:20 -0300 Subject: [PATCH 06/84] =?UTF-8?q?fix:=20passando=20variavel=20order=5Fid?= =?UTF-8?q?=20para=20a=20p=C3=A1gina=20de=20assinatura=20para=20poder=20se?= =?UTF-8?q?r=20poss=C3=ADvel=20utilizar=20o=20bot=C3=A3o=20de=20gerar=20no?= =?UTF-8?q?vo=20Qr=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/VindiWoocommerce.php | 5 +++-- src/includes/gateways/PixPayment.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/VindiWoocommerce.php b/src/VindiWoocommerce.php index cda32599..f54d8d7c 100644 --- a/src/VindiWoocommerce.php +++ b/src/VindiWoocommerce.php @@ -197,7 +197,7 @@ public function add_gateway($methods) */ public function filter_woocommerce_cart_needs_payment($needs_payment, $cart) { - if (floatval($cart->total) == 0 && $this->cart_has_trial($cart)) { + if (floatval($cart->total) == 0 || $this->cart_has_trial($cart)) { return true; } @@ -222,7 +222,7 @@ 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); @@ -245,6 +245,7 @@ public function renew_pix_charge() $vindi_order[$subscription_id]['bill'] = $bill; $order->update_meta_data('vindi_order', $vindi_order); + $order->save(); } } } diff --git a/src/includes/gateways/PixPayment.php b/src/includes/gateways/PixPayment.php index c7fd43ad..ae9b7a44 100644 --- a/src/includes/gateways/PixPayment.php +++ b/src/includes/gateways/PixPayment.php @@ -148,7 +148,7 @@ public function show_pix_download($order_id) if (!$order->is_paid() && !$order->has_status('cancelled')) { $this->vindi_settings->get_template( 'pix-download.html.php', - compact('vindi_order', 'order_to_iterate') + compact('vindi_order', 'order_to_iterate', 'order_id') ); } } From 566b0e4458677a9eb9e02b703743d4549c03afa7 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Mon, 26 Feb 2024 09:28:33 -0300 Subject: [PATCH 07/84] =?UTF-8?q?feat:=20invertendo=20verifica=C3=A7=C3=A3?= =?UTF-8?q?o=20na=20visualiza=C3=A7=C3=A3o=20de=20Qr=20Code=20para=20restr?= =?UTF-8?q?ingir=20a=20op=C3=A7=C3=A3o=20de=20renova=C3=A7=C3=A3o=20soment?= =?UTF-8?q?e=20para=20pagamentos=20recorrentes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/templates/pix-download.html.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/templates/pix-download.html.php b/src/templates/pix-download.html.php index 31ae0708..411eaae7 100644 --- a/src/templates/pix-download.html.php +++ b/src/templates/pix-download.html.php @@ -20,19 +20,7 @@
- new DateTime()) :?> -
- -
- - +
Seu Qr Code Expirou! @@ -46,6 +34,18 @@ class="download_button">
+ +
+ +
+
From 9b244e8c209331a6f19363a8f91c34833874866b Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 07:52:06 -0300 Subject: [PATCH 08/84] feat: melhorando compatibilidade com HPOS --- src/includes/gateways/BankSlipPayment.php | 4 ++-- src/includes/gateways/PixPayment.php | 4 ++-- src/services/Webhooks.php | 10 +++++----- src/utils/PaymentGateway.php | 2 +- src/utils/PaymentProcessor.php | 6 +++--- src/utils/SubscriptionStatusHandler.php | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/includes/gateways/BankSlipPayment.php b/src/includes/gateways/BankSlipPayment.php index b85028f3..0b81714f 100644 --- a/src/includes/gateways/BankSlipPayment.php +++ b/src/includes/gateways/BankSlipPayment.php @@ -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', @@ -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( diff --git a/src/includes/gateways/PixPayment.php b/src/includes/gateways/PixPayment.php index ae9b7a44..bf13dab9 100644 --- a/src/includes/gateways/PixPayment.php +++ b/src/includes/gateways/PixPayment.php @@ -130,7 +130,7 @@ public function thank_you_page($order_id) { $order = wc_get_order($order_id); if ($order->get_payment_method() == 'vindi-pix') { - $vindi_order = get_post_meta($order_id, 'vindi_order', true); + $vindi_order = $order->get_meta('vindi_order', true); $order_to_iterate = $this->pix_quantity_to_render($vindi_order); $this->vindi_settings->get_template( 'pix-download.html.php', @@ -143,7 +143,7 @@ public function show_pix_download($order_id) { $order = wc_get_order($order_id); if ($order->get_payment_method() == 'vindi-pix') { - $vindi_order = get_post_meta($order_id, 'vindi_order', true); + $vindi_order = $order->get_meta('vindi_order', true); $order_to_iterate = $this->pix_quantity_to_render($vindi_order); if (!$order->is_paid() && !$order->has_status('cancelled')) { $this->vindi_settings->get_template( diff --git a/src/services/Webhooks.php b/src/services/Webhooks.php index 83176f0e..b6496fe4 100644 --- a/src/services/Webhooks.php +++ b/src/services/Webhooks.php @@ -114,7 +114,7 @@ private function subscription_renew($renew_infos) $order_id = $subscription->get_last_order(); $order = $this->find_order_by_id($order_id); $subscription_id = $renew_infos['vindi_subscription_id']; - $order_post_meta = array(get_post_meta($order->id, 'vindi_order', true)); + $order_post_meta = array($order->get_meta('vindi_order', true)); $order_post_meta[$subscription_id]['cycle'] = $renew_infos['cycle']; $order_post_meta[$subscription_id]['product'] = $renew_infos['plan_name']; $order_post_meta[$subscription_id]['bill'] = array( @@ -122,7 +122,7 @@ private function subscription_renew($renew_infos) 'status' => $renew_infos['bill_status'], 'bank_slip_url' => $renew_infos['bill_print_url'], ); - update_post_meta($order->id, 'vindi_order', $order_post_meta); + $order->update_meta_data('vindi_order', $order_post_meta); $this->vindi_settings->logger->log('Novo Período criado: Pedido #'.$order->id); // We've already processed the renewal @@ -167,7 +167,7 @@ private function bill_paid($data) if(empty($data->bill->subscription)) { $order = $this->find_order_by_id($data->bill->code); - $vindi_order = get_post_meta($order->id, 'vindi_order', true); + $vindi_order = $order->get_meta('vindi_order', true); if(is_array($vindi_order)) { $vindi_order['single_payment']['bill']['status'] = $data->bill->status; } else { @@ -178,14 +178,14 @@ private function bill_paid($data) $cycle = $data->bill->period->cycle; $order = $this->find_order_by_subscription_and_cycle($vindi_subscription_id, $cycle); - $vindi_order = get_post_meta($order->id, 'vindi_order', true); + $vindi_order = $order->get_meta('vindi_order', true); if(is_array($vindi_order)) { $vindi_order[$vindi_subscription_id]['bill']['status'] = $data->bill->status; } else { return; } } - update_post_meta($order->id, 'vindi_order', $vindi_order); + $order->update_meta_data('vindi_order', $vindi_order); // Order informations always be updated in last array element $vindi_order_info = end($vindi_order); diff --git a/src/utils/PaymentGateway.php b/src/utils/PaymentGateway.php index 4fbaa5d8..fe1cef2e 100644 --- a/src/utils/PaymentGateway.php +++ b/src/utils/PaymentGateway.php @@ -248,7 +248,7 @@ public function process_refund($order_id, $amount = null, $reason = '') { } $results = []; - $order_meta = get_post_meta($order->id, 'vindi_order', true); + $order_meta = $order->get_meta('vindi_order', true); foreach ($order_meta as $key => $order_item) { $bill_id = $order_item['bill']['id']; diff --git a/src/utils/PaymentProcessor.php b/src/utils/PaymentProcessor.php index 941fcba1..f1f82a07 100644 --- a/src/utils/PaymentProcessor.php +++ b/src/utils/PaymentProcessor.php @@ -368,7 +368,7 @@ public function process_order() } } - update_post_meta($this->order->get_id(), 'vindi_order', $order_post_meta); + $this->order->update_meta_data('vindi_order', $order_post_meta); WC()->session->__unset('current_payment_profile'); WC()->session->__unset('current_customer'); remove_action('woocommerce_scheduled_subscription_payment', 'WC_Subscriptions_Manager::prepare_renewal'); @@ -1034,7 +1034,7 @@ protected function create_subscription($customer_id, $order_item) } $subscription['wc_id'] = $wc_subscription_id; if (isset($subscription['bill']['id'])) { - update_post_meta($this->order->get_id(), 'vindi_bill_id', $subscription['bill']['id']); + $this->order->update_meta_data('vindi_bill_id', $subscription['bill']['id']); } return $subscription; } @@ -1102,7 +1102,7 @@ protected function create_bill($customer_id, $order_items) if ($bill['id']) { $this->logger->log(sprintf('Update Bill: %s', json_encode($bill))); - update_post_meta($this->order->id, 'vindi_bill_id', $bill['id']); + $this->order->update_meta_data('vindi_bill_id', $bill['id']); } return $bill; } diff --git a/src/utils/SubscriptionStatusHandler.php b/src/utils/SubscriptionStatusHandler.php index ff0cf18e..434cb027 100644 --- a/src/utils/SubscriptionStatusHandler.php +++ b/src/utils/SubscriptionStatusHandler.php @@ -154,7 +154,7 @@ public function order_canceled($order) $order = wc_get_order($order); } - $vindi_order = get_post_meta($order->id, 'vindi_order', true); + $vindi_order = $order->get_meta('vindi_order', true); if (!is_array($vindi_order)) { return; @@ -168,7 +168,7 @@ public function order_canceled($order) } } - update_post_meta($order->id, 'vindi_order', $vindi_order); + $order->update_meta_data('vindi_order', $vindi_order); if ($single_payment_bill_id) { $this->routes->deleteBill($single_payment_bill_id); From a39b56e335c6d02bc463c14c475f8e8d2683d364 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 08:05:34 -0300 Subject: [PATCH 09/84] fix: codeclimate issues --- src/includes/gateways/PixPayment.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/includes/gateways/PixPayment.php b/src/includes/gateways/PixPayment.php index bf13dab9..7138a18f 100644 --- a/src/includes/gateways/PixPayment.php +++ b/src/includes/gateways/PixPayment.php @@ -55,8 +55,6 @@ public function __construct(VindiSettings $vindi_settings, VindiControllers $con ); $this->init_form_fields(); - - // Load the settings. $this->init_settings(); add_action('woocommerce_view_order', array(&$this, 'show_pix_download'), -10, 1); From 95f3d98c82dfeb9c6aca0277c179c026d8caee37 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 08:13:01 -0300 Subject: [PATCH 10/84] fix: codeclimate issues --- src/utils/FrontendFilesLoader.php | 33 +++++++++++++------------------ 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/src/utils/FrontendFilesLoader.php b/src/utils/FrontendFilesLoader.php index e248e093..c36b1bf8 100644 --- a/src/utils/FrontendFilesLoader.php +++ b/src/utils/FrontendFilesLoader.php @@ -25,11 +25,9 @@ public static function adminFiles() } public static function frontendFiles() { - wp_register_script('imask', plugins_url('/assets/js/imask.min.js', plugin_dir_path(__FILE__)), array(), VINDI_VERSION, true); - - wp_register_script('vindi_woocommerce_frontend_js', plugins_url('/assets/js/frontend.js', plugin_dir_path(__FILE__)), array('jquery', 'imask'), VINDI_VERSION, true); - wp_enqueue_script('vindi_woocommerce_frontend_js'); - + wp_register_script('imask', plugins_url('/assets/js/imask.min.js', plugin_dir_path(__FILE__)), array(), VINDI_VERSION, true); + wp_register_script('vindi_woocommerce_frontend_js', plugins_url('/assets/js/frontend.js', plugin_dir_path(__FILE__)), array('jquery', 'imask'), VINDI_VERSION, true); + wp_enqueue_script('vindi_woocommerce_frontend_js'); wp_register_script( 'vindi_woocommerce_masks_js', plugins_url('/assets/js/masks.js', plugin_dir_path(__FILE__)), @@ -38,7 +36,6 @@ public static function frontendFiles() true ); wp_enqueue_script('vindi_woocommerce_masks_js'); - wp_register_script( 'vindi_woocommerce_brands_js', plugins_url('/assets/js/brands.js', plugin_dir_path(__FILE__)), @@ -47,18 +44,16 @@ public static function frontendFiles() true ); wp_enqueue_script('vindi_woocommerce_brands_js'); - - wp_register_script( - 'vindi_woocommerce_thankyou_js', - plugins_url('/assets/js/thankyou.js', plugin_dir_path(__FILE__)), - array(), - VINDI_VERSION, - true - ); - wp_enqueue_script('vindi_woocommerce_thankyou_js'); - wp_localize_script('vindi_woocommerce_thankyou_js', 'ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ))); - - wp_register_style('vindi_woocommerce_style', plugins_url('/assets/css/frontend.css', plugin_dir_path(__FILE__)), array(), VINDI_VERSION); - wp_enqueue_style('vindi_woocommerce_style'); + wp_register_script( + 'vindi_woocommerce_thankyou_js', + plugins_url('/assets/js/thankyou.js', plugin_dir_path(__FILE__)), + array(), + VINDI_VERSION, + true + ); + wp_enqueue_script('vindi_woocommerce_thankyou_js'); + wp_localize_script('vindi_woocommerce_thankyou_js', 'ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ))); + wp_register_style('vindi_woocommerce_style', plugins_url('/assets/css/frontend.css', plugin_dir_path(__FILE__)), array(), VINDI_VERSION); + wp_enqueue_style('vindi_woocommerce_style'); } } From f38899a6e7c0bf6a9426488d8558b777e7a9f0ed Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 08:24:38 -0300 Subject: [PATCH 11/84] fix: codeclimate issues --- src/includes/gateways/PixPayment.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/includes/gateways/PixPayment.php b/src/includes/gateways/PixPayment.php index 7138a18f..58dcab21 100644 --- a/src/includes/gateways/PixPayment.php +++ b/src/includes/gateways/PixPayment.php @@ -20,7 +20,7 @@ class VindiPixGateway extends VindiPaymentGateway /** * @var VindiSettings */ - public $vindi_settings; + public $vindiSettings; /** * @var VindiControllers @@ -31,7 +31,7 @@ class VindiPixGateway extends VindiPaymentGateway * Constructor for the gateway. */ - public function __construct(VindiSettings $vindi_settings, VindiControllers $controllers) + public function __construct(VindiSettings $vindiSettings, VindiControllers $controllers) { $this->id = 'vindi-pix'; $this->icon = apply_filters('vindi_woocommerce_pix_icon', ''); @@ -60,7 +60,7 @@ public function __construct(VindiSettings $vindi_settings, VindiControllers $con add_action('woocommerce_view_order', array(&$this, 'show_pix_download'), -10, 1); add_action('woocommerce_thankyou_' . $this->id, array(&$this, 'thank_you_page')); - parent::__construct($vindi_settings, $controllers); + parent::__construct($vindiSettings, $controllers); $this->title = $this->get_option('title'); $this->description = $this->get_option('description'); $this->enabled = $this->get_option('enabled'); From 3cb7543d07e3c99256976063568b6b7cb5d7836b Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 08:26:54 -0300 Subject: [PATCH 12/84] fix: codeclimate issues --- src/includes/gateways/PixPayment.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/includes/gateways/PixPayment.php b/src/includes/gateways/PixPayment.php index 58dcab21..c54a49e7 100644 --- a/src/includes/gateways/PixPayment.php +++ b/src/includes/gateways/PixPayment.php @@ -117,9 +117,10 @@ public function payment_fields() } $is_single_order = $this->is_single_order(); - - if ($is_trial = $this->vindi_settings->get_is_active_sandbox()) + $is_trial = $this->vindi_settings->get_is_active_sandbox(); + if ($is_trial) { $is_trial = $this->routes->isMerchantStatusTrialOrSandbox(); + } $this->vindi_settings->get_template('pix-checkout.html.php', compact('is_trial', 'is_single_order')); } From c9630fd600de434aefd08ff09e20d0d687e5bdcc Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 08:29:05 -0300 Subject: [PATCH 13/84] fix: codeclimate issues --- src/includes/gateways/PixPayment.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/includes/gateways/PixPayment.php b/src/includes/gateways/PixPayment.php index c54a49e7..c00d0ce7 100644 --- a/src/includes/gateways/PixPayment.php +++ b/src/includes/gateways/PixPayment.php @@ -14,7 +14,6 @@ * @class VindiPixGateway * @extends VindiPaymentGateway */ - class VindiPixGateway extends VindiPaymentGateway { /** @@ -64,7 +63,6 @@ public function __construct(VindiSettings $vindiSettings, VindiControllers $cont $this->title = $this->get_option('title'); $this->description = $this->get_option('description'); $this->enabled = $this->get_option('enabled'); - } /** From e722cdf154248f10cab4cd69aab4d567d8e89eee Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 08:41:05 -0300 Subject: [PATCH 14/84] fix: codeclimate issues --- src/includes/gateways/PixPayment.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/includes/gateways/PixPayment.php b/src/includes/gateways/PixPayment.php index c00d0ce7..411c0c22 100644 --- a/src/includes/gateways/PixPayment.php +++ b/src/includes/gateways/PixPayment.php @@ -29,7 +29,6 @@ class VindiPixGateway extends VindiPaymentGateway /** * Constructor for the gateway. */ - public function __construct(VindiSettings $vindiSettings, VindiControllers $controllers) { $this->id = 'vindi-pix'; @@ -37,7 +36,6 @@ public function __construct(VindiSettings $vindiSettings, VindiControllers $cont $this->method_title = __('Vindi - PIX', VINDI); $this->method_description = __('Aceitar pagamentos via boleto bancário utilizando a Vindi.', VINDI); $this->has_fields = true; - $this->supports = array( 'subscriptions', 'products', @@ -52,17 +50,11 @@ public function __construct(VindiSettings $vindiSettings, VindiControllers $cont 'multiple_subscriptions', 'pre-orders' ); - $this->init_form_fields(); $this->init_settings(); - add_action('woocommerce_view_order', array(&$this, 'show_pix_download'), -10, 1); add_action('woocommerce_thankyou_' . $this->id, array(&$this, 'thank_you_page')); - parent::__construct($vindiSettings, $controllers); - $this->title = $this->get_option('title'); - $this->description = $this->get_option('description'); - $this->enabled = $this->get_option('enabled'); } /** From a2712f3ea46fda8b9dbc64d3d16a5e7dc2154158 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 08:55:53 -0300 Subject: [PATCH 15/84] fix: codeclimate issues --- src/includes/gateways/PixPayment.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/includes/gateways/PixPayment.php b/src/includes/gateways/PixPayment.php index 411c0c22..c55d96a8 100644 --- a/src/includes/gateways/PixPayment.php +++ b/src/includes/gateways/PixPayment.php @@ -118,6 +118,9 @@ public function payment_fields() 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-pix') { $vindi_order = $order->get_meta('vindi_order', true); $order_to_iterate = $this->pix_quantity_to_render($vindi_order); @@ -131,6 +134,9 @@ public function thank_you_page($order_id) public function show_pix_download($order_id) { $order = wc_get_order($order_id); + $vindi_order = []; + $order_to_iterate = 0; + if ($order->get_payment_method() == 'vindi-pix') { $vindi_order = $order->get_meta('vindi_order', true); $order_to_iterate = $this->pix_quantity_to_render($vindi_order); From 55360ecf32cfd04d606593bde445b41fe054ecdc Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 09:02:33 -0300 Subject: [PATCH 16/84] fix: codeclimate issues --- src/utils/FrontendFilesLoader.php | 52 ++++++++++++++++++------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/src/utils/FrontendFilesLoader.php b/src/utils/FrontendFilesLoader.php index c36b1bf8..7d85ee26 100644 --- a/src/utils/FrontendFilesLoader.php +++ b/src/utils/FrontendFilesLoader.php @@ -23,27 +23,13 @@ public static function adminFiles() wp_enqueue_style('vindi_woocommerce_admin_style'); wp_enqueue_script("vindi_products", plugins_url('/assets/js/product.js', plugin_dir_path(__FILE__))); } - public static function frontendFiles() - { - wp_register_script('imask', plugins_url('/assets/js/imask.min.js', plugin_dir_path(__FILE__)), array(), VINDI_VERSION, true); - wp_register_script('vindi_woocommerce_frontend_js', plugins_url('/assets/js/frontend.js', plugin_dir_path(__FILE__)), array('jquery', 'imask'), VINDI_VERSION, true); + public static function frontendFiles() + { + wp_register_script('vindi_woocommerce_frontend_js', plugins_url('/assets/js/frontend.js', plugin_dir_path(__FILE__)), array('jquery'), VINDI_VERSION, true); wp_enqueue_script('vindi_woocommerce_frontend_js'); - wp_register_script( - 'vindi_woocommerce_masks_js', - plugins_url('/assets/js/masks.js', plugin_dir_path(__FILE__)), - array('imask'), - VINDI_VERSION, - true - ); - wp_enqueue_script('vindi_woocommerce_masks_js'); - wp_register_script( - 'vindi_woocommerce_brands_js', - plugins_url('/assets/js/brands.js', plugin_dir_path(__FILE__)), - array(), - VINDI_VERSION, - true - ); - wp_enqueue_script('vindi_woocommerce_brands_js'); + + self::enqueueCreditCardScripts(); + wp_register_script( 'vindi_woocommerce_thankyou_js', plugins_url('/assets/js/thankyou.js', plugin_dir_path(__FILE__)), @@ -55,5 +41,29 @@ public static function frontendFiles() wp_localize_script('vindi_woocommerce_thankyou_js', 'ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ))); wp_register_style('vindi_woocommerce_style', plugins_url('/assets/css/frontend.css', plugin_dir_path(__FILE__)), array(), VINDI_VERSION); wp_enqueue_style('vindi_woocommerce_style'); - } + } + + public static function enqueueCreditCardScripts() + { + wp_register_script('imask', plugins_url('/assets/js/imask.min.js', plugin_dir_path(__FILE__)), array(), VINDI_VERSION, true); + + wp_register_script( + 'vindi_woocommerce_masks_js', + plugins_url('/assets/js/masks.js', plugin_dir_path(__FILE__)), + array('imask'), + VINDI_VERSION, + true + ); + wp_enqueue_script('vindi_woocommerce_masks_js'); + + wp_register_script( + 'vindi_woocommerce_brands_js', + plugins_url('/assets/js/brands.js', plugin_dir_path(__FILE__)), + array(), + VINDI_VERSION, + true + ); + wp_enqueue_script('vindi_woocommerce_brands_js'); + } + } From f85c0bc732826e1b3853d5bb747dde4797f99b2b Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 09:07:49 -0300 Subject: [PATCH 17/84] fix: codeclimate issues --- src/utils/FrontendFilesLoader.php | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/utils/FrontendFilesLoader.php b/src/utils/FrontendFilesLoader.php index 7d85ee26..fd5ff6b7 100644 --- a/src/utils/FrontendFilesLoader.php +++ b/src/utils/FrontendFilesLoader.php @@ -25,11 +25,31 @@ public static function adminFiles() } public static function frontendFiles() { - wp_register_script('vindi_woocommerce_frontend_js', plugins_url('/assets/js/frontend.js', plugin_dir_path(__FILE__)), array('jquery'), VINDI_VERSION, true); + wp_register_script( + 'vindi_woocommerce_frontend_js', + plugins_url('/assets/js/frontend.js', + plugin_dir_path(__FILE__)), + array('jquery'), + VINDI_VERSION, + true + ); wp_enqueue_script('vindi_woocommerce_frontend_js'); self::enqueueCreditCardScripts(); + self::enqueueThankyouPageScript(); + wp_register_style( + 'vindi_woocommerce_style', + plugins_url('/assets/css/frontend.css', + plugin_dir_path(__FILE__)), + array(), + VINDI_VERSION + ); + wp_enqueue_style('vindi_woocommerce_style'); + } + + public static function enqueueThankyouPageScript() + { wp_register_script( 'vindi_woocommerce_thankyou_js', plugins_url('/assets/js/thankyou.js', plugin_dir_path(__FILE__)), @@ -38,9 +58,11 @@ public static function frontendFiles() true ); wp_enqueue_script('vindi_woocommerce_thankyou_js'); - wp_localize_script('vindi_woocommerce_thankyou_js', 'ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ))); - wp_register_style('vindi_woocommerce_style', plugins_url('/assets/css/frontend.css', plugin_dir_path(__FILE__)), array(), VINDI_VERSION); - wp_enqueue_style('vindi_woocommerce_style'); + wp_localize_script( + 'vindi_woocommerce_thankyou_js', + 'ajax_object', + array( 'ajax_url' => admin_url( 'admin-ajax.php' )) + ); } public static function enqueueCreditCardScripts() From dccb5b6c89de935dbde3d148666edd3a2fe1e3e8 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 09:12:30 -0300 Subject: [PATCH 18/84] fix: codeclimate issues --- src/utils/FrontendFilesLoader.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/utils/FrontendFilesLoader.php b/src/utils/FrontendFilesLoader.php index fd5ff6b7..4a320e71 100644 --- a/src/utils/FrontendFilesLoader.php +++ b/src/utils/FrontendFilesLoader.php @@ -27,8 +27,7 @@ public static function frontendFiles() { wp_register_script( 'vindi_woocommerce_frontend_js', - plugins_url('/assets/js/frontend.js', - plugin_dir_path(__FILE__)), + plugins_url('/assets/js/frontend.js', plugin_dir_path(__FILE__)), array('jquery'), VINDI_VERSION, true @@ -40,8 +39,7 @@ public static function frontendFiles() wp_register_style( 'vindi_woocommerce_style', - plugins_url('/assets/css/frontend.css', - plugin_dir_path(__FILE__)), + plugins_url('/assets/css/frontend.css', plugin_dir_path(__FILE__)), array(), VINDI_VERSION ); From 2c7a10078670707cd82bc12e8edea456e1550385 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 09:14:32 -0300 Subject: [PATCH 19/84] fix: codeclimate issues --- src/utils/FrontendFilesLoader.php | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/utils/FrontendFilesLoader.php b/src/utils/FrontendFilesLoader.php index 4a320e71..9915a5d3 100644 --- a/src/utils/FrontendFilesLoader.php +++ b/src/utils/FrontendFilesLoader.php @@ -49,13 +49,14 @@ public static function frontendFiles() public static function enqueueThankyouPageScript() { wp_register_script( - 'vindi_woocommerce_thankyou_js', - plugins_url('/assets/js/thankyou.js', plugin_dir_path(__FILE__)), - array(), - VINDI_VERSION, - true + 'vindi_woocommerce_thankyou_js', + plugins_url('/assets/js/thankyou.js', plugin_dir_path(__FILE__)), + array(), + VINDI_VERSION, + true ); wp_enqueue_script('vindi_woocommerce_thankyou_js'); + wp_localize_script( 'vindi_woocommerce_thankyou_js', 'ajax_object', @@ -68,20 +69,20 @@ public static function enqueueCreditCardScripts() wp_register_script('imask', plugins_url('/assets/js/imask.min.js', plugin_dir_path(__FILE__)), array(), VINDI_VERSION, true); wp_register_script( - 'vindi_woocommerce_masks_js', - plugins_url('/assets/js/masks.js', plugin_dir_path(__FILE__)), - array('imask'), - VINDI_VERSION, - true + 'vindi_woocommerce_masks_js', + plugins_url('/assets/js/masks.js', plugin_dir_path(__FILE__)), + array('imask'), + VINDI_VERSION, + true ); wp_enqueue_script('vindi_woocommerce_masks_js'); wp_register_script( - 'vindi_woocommerce_brands_js', - plugins_url('/assets/js/brands.js', plugin_dir_path(__FILE__)), - array(), - VINDI_VERSION, - true + 'vindi_woocommerce_brands_js', + plugins_url('/assets/js/brands.js', plugin_dir_path(__FILE__)), + array(), + VINDI_VERSION, + true ); wp_enqueue_script('vindi_woocommerce_brands_js'); } From 3498dafc7fafab8a82eaa1f17fbde1ba479f290e Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 09:18:14 -0300 Subject: [PATCH 20/84] fix: codeclimate issues --- src/utils/FrontendFilesLoader.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/utils/FrontendFilesLoader.php b/src/utils/FrontendFilesLoader.php index 9915a5d3..ea6a9a1c 100644 --- a/src/utils/FrontendFilesLoader.php +++ b/src/utils/FrontendFilesLoader.php @@ -56,11 +56,11 @@ public static function enqueueThankyouPageScript() true ); wp_enqueue_script('vindi_woocommerce_thankyou_js'); - + wp_localize_script( 'vindi_woocommerce_thankyou_js', 'ajax_object', - array( 'ajax_url' => admin_url( 'admin-ajax.php' )) + array('ajax_url' => admin_url( 'admin-ajax.php' )) ); } @@ -86,5 +86,4 @@ public static function enqueueCreditCardScripts() ); wp_enqueue_script('vindi_woocommerce_brands_js'); } - -} +} \ No newline at end of file From 919b3c4a47a87499a7a401b5d9dbe0b6e21d8063 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 09:25:14 -0300 Subject: [PATCH 21/84] fix: codeclimate issues --- src/utils/FrontendFilesLoader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/FrontendFilesLoader.php b/src/utils/FrontendFilesLoader.php index ea6a9a1c..c11d4f71 100644 --- a/src/utils/FrontendFilesLoader.php +++ b/src/utils/FrontendFilesLoader.php @@ -60,7 +60,7 @@ public static function enqueueThankyouPageScript() wp_localize_script( 'vindi_woocommerce_thankyou_js', 'ajax_object', - array('ajax_url' => admin_url( 'admin-ajax.php' )) + array('ajax_url' => admin_url('admin-ajax.php')) ); } From 13d1ff4c64102bb2c50dba02ab992a484baea2a2 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 09:26:24 -0300 Subject: [PATCH 22/84] fix: codeclimate issues --- src/utils/FrontendFilesLoader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/FrontendFilesLoader.php b/src/utils/FrontendFilesLoader.php index c11d4f71..e7bfd95b 100644 --- a/src/utils/FrontendFilesLoader.php +++ b/src/utils/FrontendFilesLoader.php @@ -86,4 +86,4 @@ public static function enqueueCreditCardScripts() ); wp_enqueue_script('vindi_woocommerce_brands_js'); } -} \ No newline at end of file +} From 161f35d8deb759057e21c6a2da01d50e98a1c7b2 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 09:30:33 -0300 Subject: [PATCH 23/84] fix: codeclimate issues --- src/services/Webhooks.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/services/Webhooks.php b/src/services/Webhooks.php index b6496fe4..5388e3b9 100644 --- a/src/services/Webhooks.php +++ b/src/services/Webhooks.php @@ -114,7 +114,7 @@ private function subscription_renew($renew_infos) $order_id = $subscription->get_last_order(); $order = $this->find_order_by_id($order_id); $subscription_id = $renew_infos['vindi_subscription_id']; - $order_post_meta = array($order->get_meta('vindi_order', true)); + $order_post_meta = array($order->get_meta('vindi_order', true)); $order_post_meta[$subscription_id]['cycle'] = $renew_infos['cycle']; $order_post_meta[$subscription_id]['product'] = $renew_infos['plan_name']; $order_post_meta[$subscription_id]['bill'] = array( @@ -122,7 +122,7 @@ private function subscription_renew($renew_infos) 'status' => $renew_infos['bill_status'], 'bank_slip_url' => $renew_infos['bill_print_url'], ); - $order->update_meta_data('vindi_order', $order_post_meta); + $order->update_meta_data('vindi_order', $order_post_meta); $this->vindi_settings->logger->log('Novo Período criado: Pedido #'.$order->id); // We've already processed the renewal @@ -167,7 +167,7 @@ private function bill_paid($data) if(empty($data->bill->subscription)) { $order = $this->find_order_by_id($data->bill->code); - $vindi_order = $order->get_meta('vindi_order', true); + $vindi_order = $order->get_meta('vindi_order', true); if(is_array($vindi_order)) { $vindi_order['single_payment']['bill']['status'] = $data->bill->status; } else { @@ -178,14 +178,14 @@ private function bill_paid($data) $cycle = $data->bill->period->cycle; $order = $this->find_order_by_subscription_and_cycle($vindi_subscription_id, $cycle); - $vindi_order = $order->get_meta('vindi_order', true); + $vindi_order = $order->get_meta('vindi_order', true); if(is_array($vindi_order)) { $vindi_order[$vindi_subscription_id]['bill']['status'] = $data->bill->status; } else { return; } } - $order->update_meta_data('vindi_order', $vindi_order); + $order->update_meta_data('vindi_order', $vindi_order); // Order informations always be updated in last array element $vindi_order_info = end($vindi_order); From 687c0ff67574e0545b27612d8f7dedef0735e582 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 09:32:45 -0300 Subject: [PATCH 24/84] fix: codeclimate issues --- src/utils/PaymentProcessor.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/PaymentProcessor.php b/src/utils/PaymentProcessor.php index f1f82a07..0ceadc9c 100644 --- a/src/utils/PaymentProcessor.php +++ b/src/utils/PaymentProcessor.php @@ -1116,6 +1116,7 @@ protected function create_bill($customer_id, $order_items) */ protected function create_bill_meta_for_order($bill) { + $bill_meta = []; $bill_meta['id'] = $bill['id']; $bill_meta['status'] = $bill['status']; From dfedef338d307e9f897f9e09227621bd074532a9 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 09:46:01 -0300 Subject: [PATCH 25/84] fix: codeclimate issues --- src/utils/PaymentProcessor.php | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/utils/PaymentProcessor.php b/src/utils/PaymentProcessor.php index 0ceadc9c..81f3a7a3 100644 --- a/src/utils/PaymentProcessor.php +++ b/src/utils/PaymentProcessor.php @@ -210,21 +210,20 @@ public function is_bank_slip() */ public function payment_method_code() { - switch ($this->gateway->type()) { - case 'bank_slip': - $code = 'bank_slip'; - break; - case 'cc': - $code = 'credit_card'; - break; - case 'pix': - $code = 'pix'; - break; - default: - $code = ''; - break; - - } + switch ($this->gateway->type()) { + case 'bank_slip': + $code = 'bank_slip'; + break; + case 'cc': + $code = 'credit_card'; + break; + case 'pix': + $code = 'pix'; + break; + default: + $code = ''; + break; + } return $code; } From f65ed762da50d37791299a40bbdc50cfdb5b2145 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 09:51:56 -0300 Subject: [PATCH 26/84] fix: codeclimate issues --- src/utils/PaymentProcessor.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utils/PaymentProcessor.php b/src/utils/PaymentProcessor.php index 81f3a7a3..eb8478e7 100644 --- a/src/utils/PaymentProcessor.php +++ b/src/utils/PaymentProcessor.php @@ -213,16 +213,16 @@ public function payment_method_code() switch ($this->gateway->type()) { case 'bank_slip': $code = 'bank_slip'; - break; + break; case 'cc': $code = 'credit_card'; - break; + break; case 'pix': $code = 'pix'; - break; + break; default: - $code = ''; - break; + $code = ''; + break; } return $code; } From f8b0f0fd75deabb631bd100aada8b7dfa216fd0d Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 09:53:47 -0300 Subject: [PATCH 27/84] fix: codeclimate issues --- src/utils/PaymentProcessor.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/utils/PaymentProcessor.php b/src/utils/PaymentProcessor.php index eb8478e7..b326c2a8 100644 --- a/src/utils/PaymentProcessor.php +++ b/src/utils/PaymentProcessor.php @@ -1120,17 +1120,17 @@ protected function create_bill_meta_for_order($bill) $bill_meta['status'] = $bill['status']; if (isset($bill['charges']) && count($bill['charges'])) { - $charges = end($bill['charges']); - if ($this->payment_method_code() === 'pix' && isset($charges['last_transaction']['gateway_response_fields'])) { - $transaction = $charges['last_transaction']['gateway_response_fields']; - - $bill_meta['charge_id'] = $charges['id']; - $bill_meta['pix_expiration'] = $transaction['max_days_to_keep_waiting_payment']; - $bill_meta['pix_code'] = $transaction['qrcode_original_path']; - $bill_meta['pix_qr'] = $transaction['qrcode_path']; - } else { - $bill_meta['bank_slip_url'] = $charges['print_url']; - } + $charges = end($bill['charges']); + if ($this->payment_method_code() === 'pix' && isset($charges['last_transaction']['gateway_response_fields'])) { + $transaction = $charges['last_transaction']['gateway_response_fields']; + + $bill_meta['charge_id'] = $charges['id']; + $bill_meta['pix_expiration'] = $transaction['max_days_to_keep_waiting_payment']; + $bill_meta['pix_code'] = $transaction['qrcode_original_path']; + $bill_meta['pix_qr'] = $transaction['qrcode_path']; + } else { + $bill_meta['bank_slip_url'] = $charges['print_url']; + } } return $bill_meta; } From 304f0ee70da5c30ca1adf4effb454ce938d24109 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 09:56:46 -0300 Subject: [PATCH 28/84] fix: codeclimate issues --- src/utils/PaymentProcessor.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/PaymentProcessor.php b/src/utils/PaymentProcessor.php index b326c2a8..143c7ca8 100644 --- a/src/utils/PaymentProcessor.php +++ b/src/utils/PaymentProcessor.php @@ -1121,6 +1121,8 @@ protected function create_bill_meta_for_order($bill) if (isset($bill['charges']) && count($bill['charges'])) { $charges = end($bill['charges']); + + $bill_meta['bank_slip_url'] = $charges['print_url'] ?? ''; if ($this->payment_method_code() === 'pix' && isset($charges['last_transaction']['gateway_response_fields'])) { $transaction = $charges['last_transaction']['gateway_response_fields']; @@ -1128,8 +1130,7 @@ protected function create_bill_meta_for_order($bill) $bill_meta['pix_expiration'] = $transaction['max_days_to_keep_waiting_payment']; $bill_meta['pix_code'] = $transaction['qrcode_original_path']; $bill_meta['pix_qr'] = $transaction['qrcode_path']; - } else { - $bill_meta['bank_slip_url'] = $charges['print_url']; + unset($bill_meta['bank_slip_url']); } } return $bill_meta; From 32617fd9f886846859ecdafcb7fd605fa96cbfa3 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 10:00:04 -0300 Subject: [PATCH 29/84] fix: codeclimate issues --- src/utils/PaymentProcessor.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/PaymentProcessor.php b/src/utils/PaymentProcessor.php index 143c7ca8..bc9e9206 100644 --- a/src/utils/PaymentProcessor.php +++ b/src/utils/PaymentProcessor.php @@ -1123,7 +1123,8 @@ protected function create_bill_meta_for_order($bill) $charges = end($bill['charges']); $bill_meta['bank_slip_url'] = $charges['print_url'] ?? ''; - if ($this->payment_method_code() === 'pix' && isset($charges['last_transaction']['gateway_response_fields'])) { + if ($this->payment_method_code() === 'pix' + && isset($charges['last_transaction']['gateway_response_fields'])) { $transaction = $charges['last_transaction']['gateway_response_fields']; $bill_meta['charge_id'] = $charges['id']; From 1657a3d75c7c0512e78f248f602c2bb27f211a23 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 10:02:21 -0300 Subject: [PATCH 30/84] fix: codeclimate issues --- src/utils/PaymentProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/PaymentProcessor.php b/src/utils/PaymentProcessor.php index bc9e9206..749a74c2 100644 --- a/src/utils/PaymentProcessor.php +++ b/src/utils/PaymentProcessor.php @@ -219,7 +219,7 @@ public function payment_method_code() break; case 'pix': $code = 'pix'; - break; + break; default: $code = ''; break; From 2d123a077f16439b9c3c9c8d33a15a86c83bac10 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 10:03:06 -0300 Subject: [PATCH 31/84] fix: codeclimate issues --- src/utils/PaymentGateway.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/PaymentGateway.php b/src/utils/PaymentGateway.php index fe1cef2e..ad8072df 100644 --- a/src/utils/PaymentGateway.php +++ b/src/utils/PaymentGateway.php @@ -248,7 +248,7 @@ public function process_refund($order_id, $amount = null, $reason = '') { } $results = []; - $order_meta = $order->get_meta('vindi_order', true); + $order_meta = $order->get_meta('vindi_order', true); foreach ($order_meta as $key => $order_item) { $bill_id = $order_item['bill']['id']; From 1281463c858d0ef487a48ee21c773d7f43e7b572 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 10:23:30 -0300 Subject: [PATCH 32/84] fix: codeclimate issues --- src/VindiWoocommerce.php | 56 ++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/VindiWoocommerce.php b/src/VindiWoocommerce.php index f54d8d7c..75454929 100644 --- a/src/VindiWoocommerce.php +++ b/src/VindiWoocommerce.php @@ -186,7 +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); + $methods[] = new VindiPixGateway($this->settings, $this->controllers); return $methods; } @@ -219,35 +219,35 @@ private function cart_has_trial($cart) 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_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(); + $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(); + } } - } } } From 75fe00e169a1dd4a7a578df174fc975b7b8fb964 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 10:25:18 -0300 Subject: [PATCH 33/84] fix: codeclimate issues --- src/VindiWoocommerce.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VindiWoocommerce.php b/src/VindiWoocommerce.php index 75454929..abad2fc2 100644 --- a/src/VindiWoocommerce.php +++ b/src/VindiWoocommerce.php @@ -186,7 +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); + $methods[] = new VindiPixGateway($this->settings, $this->controllers); return $methods; } From 1fb73faa6155518a3a2acf4f689d9400ee8b022f Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 10:35:24 -0300 Subject: [PATCH 34/84] fix: codeclimate issues --- src/routes/RoutesApi.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/routes/RoutesApi.php b/src/routes/RoutesApi.php index c775ab19..2458e89a 100644 --- a/src/routes/RoutesApi.php +++ b/src/routes/RoutesApi.php @@ -58,22 +58,22 @@ public function createPlan($data) return $response['plan']; } - /** - * Update method for updating plan in the Vindi - * - * @since 1.0.0 - * @version 1.0.0 - * @return array - */ - public function renewCharge($charge_id) - { - $response = $this->api->request(sprintf( - 'charges/%s/charge', - filter_var($charge_id, FILTER_SANITIZE_NUMBER_INT) - ), 'POST', []); - - return $response['charge']; - } + /** + * Update method for updating plan in the Vindi + * + * @since 1.0.0 + * @version 1.0.0 + * @return array + */ + public function renewCharge($charge_id) + { + $response = $this->api->request(sprintf( + 'charges/%s/charge', + filter_var($charge_id, FILTER_SANITIZE_NUMBER_INT) + ), 'POST', []); + + return $response['charge']; + } /** * Update method for updating plan in the Vindi From cb233de9a98bd3e5dc2eda2d814ac52e1e92bb6b Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 10:39:00 -0300 Subject: [PATCH 35/84] fix: codeclimate issues --- src/routes/RoutesApi.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/RoutesApi.php b/src/routes/RoutesApi.php index 2458e89a..d6f6277a 100644 --- a/src/routes/RoutesApi.php +++ b/src/routes/RoutesApi.php @@ -68,9 +68,9 @@ public function createPlan($data) public function renewCharge($charge_id) { $response = $this->api->request(sprintf( - 'charges/%s/charge', - filter_var($charge_id, FILTER_SANITIZE_NUMBER_INT) - ), 'POST', []); + 'charges/%s/charge', + filter_var($charge_id, FILTER_SANITIZE_NUMBER_INT) + ), 'POST', []); return $response['charge']; } From 8eed16cd54bc621c54964848f7d6d4730211d621 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 7 Mar 2024 10:41:07 -0300 Subject: [PATCH 36/84] fix: codeclimate issues --- src/routes/RoutesApi.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/RoutesApi.php b/src/routes/RoutesApi.php index d6f6277a..72833b31 100644 --- a/src/routes/RoutesApi.php +++ b/src/routes/RoutesApi.php @@ -70,7 +70,7 @@ public function renewCharge($charge_id) $response = $this->api->request(sprintf( 'charges/%s/charge', filter_var($charge_id, FILTER_SANITIZE_NUMBER_INT) - ), 'POST', []); + ), 'POST', []); return $response['charge']; } From 63bbfc684fdb53ff25987d89a00812a463032d87 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Fri, 8 Mar 2024 10:25:32 -0300 Subject: [PATCH 37/84] fix: codeclimate issues --- src/routes/RoutesApi.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/routes/RoutesApi.php b/src/routes/RoutesApi.php index 72833b31..d0f687ee 100644 --- a/src/routes/RoutesApi.php +++ b/src/routes/RoutesApi.php @@ -70,7 +70,10 @@ public function renewCharge($charge_id) $response = $this->api->request(sprintf( 'charges/%s/charge', filter_var($charge_id, FILTER_SANITIZE_NUMBER_INT) - ), 'POST', []); + ), + 'POST', + [] + ); return $response['charge']; } From aaea6802f162d5979a449ccf438c63ed8f03a2b3 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Fri, 8 Mar 2024 10:29:28 -0300 Subject: [PATCH 38/84] fix: codeclimate issues --- src/routes/RoutesApi.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/routes/RoutesApi.php b/src/routes/RoutesApi.php index d0f687ee..982748be 100644 --- a/src/routes/RoutesApi.php +++ b/src/routes/RoutesApi.php @@ -67,12 +67,13 @@ public function createPlan($data) */ public function renewCharge($charge_id) { - $response = $this->api->request(sprintf( - 'charges/%s/charge', - filter_var($charge_id, FILTER_SANITIZE_NUMBER_INT) - ), - 'POST', - [] + $response = $this->api->request( + sprintf( + 'charges/%s/charge', + filter_var($charge_id, FILTER_SANITIZE_NUMBER_INT) + ), + 'POST', + [] ); return $response['charge']; From e20401798fbedd4400e41c591478bc70909a7bc5 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Fri, 8 Mar 2024 10:39:00 -0300 Subject: [PATCH 39/84] fix: codeclimate issues --- src/routes/RoutesApi.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/RoutesApi.php b/src/routes/RoutesApi.php index 982748be..7e9a6278 100644 --- a/src/routes/RoutesApi.php +++ b/src/routes/RoutesApi.php @@ -69,8 +69,8 @@ public function renewCharge($charge_id) { $response = $this->api->request( sprintf( - 'charges/%s/charge', - filter_var($charge_id, FILTER_SANITIZE_NUMBER_INT) + 'charges/%s/charge', + filter_var($charge_id, FILTER_SANITIZE_NUMBER_INT) ), 'POST', [] From 8acb880c7f6031b5a0edaa5dfae1706fa276caf8 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Fri, 8 Mar 2024 10:53:39 -0300 Subject: [PATCH 40/84] fix: codeclimate issues --- src/templates/pix-download.html.php | 128 ++++++++++++++-------------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/src/templates/pix-download.html.php b/src/templates/pix-download.html.php index 411eaae7..2a789724 100644 --- a/src/templates/pix-download.html.php +++ b/src/templates/pix-download.html.php @@ -1,69 +1,69 @@ -
-
-
-
-

- -

-

- -

-
-
-
+
+
+
+
+

+ +

+

+ +

+
+
+
$subscription) : ?> - -
- - - -
- -
-
- Seu Qr Code Expirou! -
- - - - -
- -
- -
- - -
-
- - - -
- - - - - - -
- - - + +
+ + + +
+ +
+
+ Seu Qr Code Expirou! +
+ + + + +
+ +
+ +
+ + +
+
+ + + +
+ + + + + + +
+ + + -
-
+
+
From 7f8fadde31ed59a406cdb66cccdbe1109dd79113 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Fri, 8 Mar 2024 10:59:38 -0300 Subject: [PATCH 41/84] fix: codeclimate issues --- src/templates/bankslip-download.html.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/templates/bankslip-download.html.php b/src/templates/bankslip-download.html.php index bc004c3e..9be26ea3 100644 --- a/src/templates/bankslip-download.html.php +++ b/src/templates/bankslip-download.html.php @@ -1,6 +1,6 @@ -
+
@@ -12,10 +12,10 @@

-
+
-
+
@@ -26,7 +26,7 @@ -
+
From 1fe1c3d6b99fab7191b4761d91221a83b5cb91ce Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Fri, 8 Mar 2024 11:03:57 -0300 Subject: [PATCH 42/84] fix: codeclimate issues --- src/templates/pix-checkout.html.php | 31 ++++++++++++++--------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/templates/pix-checkout.html.php b/src/templates/pix-checkout.html.php index e1cf7563..852314f5 100644 --- a/src/templates/pix-checkout.html.php +++ b/src/templates/pix-checkout.html.php @@ -1,25 +1,24 @@ -
-

-

- Modo Trial. Este modo é proposto para a realização de testes e, portanto, nenhum pedido será efetivamente cobrado.', VINDI); ?> -

-
+
+

+

+ Modo Trial. Este modo é proposto para a realização de testes e, portanto, nenhum pedido será efetivamente cobrado.', VINDI); ?> +

+
+ - +
+ +
+
-
- -
-
+ - - -
+
From 7c58948a41563127c60e7c267e638d35c8b92b03 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Fri, 8 Mar 2024 11:08:49 -0300 Subject: [PATCH 43/84] fix: codeclimate issues --- src/templates/pix-checkout.html.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/templates/pix-checkout.html.php b/src/templates/pix-checkout.html.php index 852314f5..5dba7d73 100644 --- a/src/templates/pix-checkout.html.php +++ b/src/templates/pix-checkout.html.php @@ -1,10 +1,17 @@ - + - +

- Modo Trial. Este modo é proposto para a realização de testes e, portanto, nenhum pedido será efetivamente cobrado.', VINDI); ?> + Modo Trial. Este modo é proposto para a realização de testes e, portanto, nenhum pedido será efetivamente cobrado.', + VINDI + ); ?>

From bb8e3fe28341efff80dbd8faed54f4f1854e41ce Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Fri, 8 Mar 2024 11:11:28 -0300 Subject: [PATCH 44/84] fix: codeclimate issues --- src/templates/pix-checkout.html.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/templates/pix-checkout.html.php b/src/templates/pix-checkout.html.php index 5dba7d73..f9e40fa2 100644 --- a/src/templates/pix-checkout.html.php +++ b/src/templates/pix-checkout.html.php @@ -1,7 +1,7 @@ @@ -9,7 +9,8 @@

Modo Trial. Este modo é proposto para a realização de testes e, portanto, nenhum pedido será efetivamente cobrado.', + 'Sua conta na Vindi está em Modo Trial. + Este modo é proposto para a realização de testes e, portanto, nenhum pedido será efetivamente cobrado.', VINDI ); ?>

From 0993b7799b58a4cd5f069546fd318dff32099c95 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Fri, 8 Mar 2024 11:13:29 -0300 Subject: [PATCH 45/84] fix: codeclimate issues --- src/templates/pix-checkout.html.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/templates/pix-checkout.html.php b/src/templates/pix-checkout.html.php index f9e40fa2..f55b71da 100644 --- a/src/templates/pix-checkout.html.php +++ b/src/templates/pix-checkout.html.php @@ -10,7 +10,8 @@

Modo Trial. - Este modo é proposto para a realização de testes e, portanto, nenhum pedido será efetivamente cobrado.', + Este modo é proposto para a realização de testes e, portanto, + nenhum pedido será efetivamente cobrado.', VINDI ); ?>

From 471968100bbf48ff1256aaf2ef806247d42da25d Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Fri, 8 Mar 2024 11:26:23 -0300 Subject: [PATCH 46/84] fix: codeclimate issues --- src/templates/pix-download.html.php | 55 +++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 10 deletions(-) diff --git a/src/templates/pix-download.html.php b/src/templates/pix-download.html.php index 2a789724..5b3c236c 100644 --- a/src/templates/pix-download.html.php +++ b/src/templates/pix-download.html.php @@ -1,5 +1,9 @@ - - + +
@@ -8,20 +12,32 @@

- +

- $subscription) : ?> - + $subscription) : ?> +
-
+
Seu Qr Code Expirou!
@@ -31,10 +47,20 @@ data-subscription="" class="download_button"> - + + +
- +
@@ -43,14 +69,23 @@ class="download_button"> class="download_button" data-code=""> - + + +
- +
From 54a3bb3865f5f5e8ab17d9fac3c1795fb76e1cdc Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Fri, 8 Mar 2024 11:33:42 -0300 Subject: [PATCH 47/84] fix: codeclimate issues --- src/templates/pix-download.html.php | 50 ++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/src/templates/pix-download.html.php b/src/templates/pix-download.html.php index 5b3c236c..48135a2f 100644 --- a/src/templates/pix-download.html.php +++ b/src/templates/pix-download.html.php @@ -12,8 +12,9 @@

-

- +
viewBox="0 0 512 512" >
- + +
- - + - + From a7b83af1d3afec7e0063cc9f875c852b48f9a88a Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Fri, 8 Mar 2024 11:44:50 -0300 Subject: [PATCH 49/84] fix: codeclimate issues --- src/assets/css/frontend.css | 1 - src/templates/pix-download.html.php | 7 ++++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/assets/css/frontend.css b/src/assets/css/frontend.css index 628e72f6..652dd518 100644 --- a/src/assets/css/frontend.css +++ b/src/assets/css/frontend.css @@ -354,7 +354,6 @@ } .vindi_payment_listing .charges .charge .download_button svg { - padding: 0 5px; width: 24px; } diff --git a/src/templates/pix-download.html.php b/src/templates/pix-download.html.php index e11582c2..b24ae14b 100644 --- a/src/templates/pix-download.html.php +++ b/src/templates/pix-download.html.php @@ -26,8 +26,8 @@ $subscription) : ?> -
- +
+
@@ -83,7 +83,8 @@ class="download_button"> class="download_button" data-code=""> - Date: Fri, 8 Mar 2024 14:03:31 -0300 Subject: [PATCH 51/84] fix: codeclimate issues --- .codeclimate.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.codeclimate.yml b/.codeclimate.yml index c9b54523..aade2ce7 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -2,7 +2,7 @@ engines: csslint: enabled: true phpmd: - enabled: false + enabled: true checks: StaticAccess: enabled: false @@ -17,7 +17,7 @@ engines: Naming/LongVariable: enabled: false phpcodesniffer: - enabled: false + enabled: true config: standard: "PSR1,PSR2" checks: From c37ef34e3f22df8b5c8bd1d62de4728ef8e736cb Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Fri, 8 Mar 2024 14:06:30 -0300 Subject: [PATCH 52/84] fix: codeclimate issues --- .codeclimate.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.codeclimate.yml b/.codeclimate.yml index aade2ce7..ef39930d 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -23,3 +23,6 @@ engines: checks: PSR1 Methods CamelCapsMethodName NotCamelCaps: enabled: false +plugins: + duplication: + enabled: false \ No newline at end of file From 7446f26c55971d69d29ba5f707bb010ae5f24bb0 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Fri, 8 Mar 2024 14:13:30 -0300 Subject: [PATCH 53/84] fix: codeclimate issues --- .codeclimate.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.codeclimate.yml b/.codeclimate.yml index ef39930d..c94fc218 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -22,7 +22,4 @@ engines: standard: "PSR1,PSR2" checks: PSR1 Methods CamelCapsMethodName NotCamelCaps: - enabled: false -plugins: - duplication: - enabled: false \ No newline at end of file + enabled: false \ No newline at end of file From 2cee0830bd4d523d12e37cf59c71fb240ceefa72 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Fri, 8 Mar 2024 14:16:17 -0300 Subject: [PATCH 54/84] fix: codeclimate issues --- .codeclimate.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.codeclimate.yml b/.codeclimate.yml index c94fc218..bdcbb125 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -1,4 +1,6 @@ engines: + duplication: + enabled: false csslint: enabled: true phpmd: From b9bc8840801ac67af0fe23a0a6cff17dcc1835e3 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Fri, 8 Mar 2024 14:19:36 -0300 Subject: [PATCH 55/84] fix: codeclimate issues --- src/includes/gateways/PixPayment.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/includes/gateways/PixPayment.php b/src/includes/gateways/PixPayment.php index c55d96a8..92251deb 100644 --- a/src/includes/gateways/PixPayment.php +++ b/src/includes/gateways/PixPayment.php @@ -2,10 +2,6 @@ namespace VindiPaymentGateways; -if (!defined('ABSPATH')) { - exit; -} - /** * Vindi Payment PIX Card Gateway class. * From 886f76697567bfefc55b001640424a4a440557f4 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Fri, 8 Mar 2024 14:37:13 -0300 Subject: [PATCH 56/84] fix: codeclimate issues --- src/services/Webhooks.php | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/services/Webhooks.php b/src/services/Webhooks.php index 5388e3b9..48926a08 100644 --- a/src/services/Webhooks.php +++ b/src/services/Webhooks.php @@ -164,27 +164,28 @@ private function bill_created($data) */ private function bill_paid($data) { - if(empty($data->bill->subscription)) { - $order = $this->find_order_by_id($data->bill->code); + if(empty($data->bill->subscription)) { + $order = $this->find_order_by_id($data->bill->code); $vindi_order = $order->get_meta('vindi_order', true); - if(is_array($vindi_order)) { - $vindi_order['single_payment']['bill']['status'] = $data->bill->status; - } else { - return; - } - } else { - $vindi_subscription_id = $data->bill->subscription->id; - $cycle = $data->bill->period->cycle; - $order = $this->find_order_by_subscription_and_cycle($vindi_subscription_id, $cycle); + if(!is_array($vindi_order)) { + return; + } + $vindi_order['single_payment']['bill']['status'] = $data->bill->status; + } + + if(empty($data->bill->subscription)) { + $vindi_subscription_id = $data->bill->subscription->id; + $cycle = $data->bill->period->cycle; + $order = $this->find_order_by_subscription_and_cycle($vindi_subscription_id, $cycle); $vindi_order = $order->get_meta('vindi_order', true); - if(is_array($vindi_order)) { - $vindi_order[$vindi_subscription_id]['bill']['status'] = $data->bill->status; - } else { - return; - } - } + if(!is_array($vindi_order)) { + return; + } + + $vindi_order[$vindi_subscription_id]['bill']['status'] = $data->bill->status; + } $order->update_meta_data('vindi_order', $vindi_order); // Order informations always be updated in last array element From 3ac3a732a766c9a83628671f4e199644a7160572 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Fri, 8 Mar 2024 14:40:28 -0300 Subject: [PATCH 57/84] fix: codeclimate issues --- src/services/Webhooks.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/services/Webhooks.php b/src/services/Webhooks.php index 48926a08..99f51cfd 100644 --- a/src/services/Webhooks.php +++ b/src/services/Webhooks.php @@ -164,28 +164,29 @@ private function bill_created($data) */ private function bill_paid($data) { - if(empty($data->bill->subscription)) { + if (empty($data->bill->subscription)) { $order = $this->find_order_by_id($data->bill->code); $vindi_order = $order->get_meta('vindi_order', true); - if(!is_array($vindi_order)) { + if (!is_array($vindi_order)) { return; } $vindi_order['single_payment']['bill']['status'] = $data->bill->status; } - if(empty($data->bill->subscription)) { + if (empty($data->bill->subscription)) { $vindi_subscription_id = $data->bill->subscription->id; $cycle = $data->bill->period->cycle; $order = $this->find_order_by_subscription_and_cycle($vindi_subscription_id, $cycle); $vindi_order = $order->get_meta('vindi_order', true); - if(!is_array($vindi_order)) { + if (!is_array($vindi_order)) { return; } $vindi_order[$vindi_subscription_id]['bill']['status'] = $data->bill->status; } + $order->update_meta_data('vindi_order', $vindi_order); // Order informations always be updated in last array element From 46977a09cae332d09795f80a3f6ee2a3e7c29ab1 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Tue, 12 Mar 2024 09:11:21 -0300 Subject: [PATCH 58/84] =?UTF-8?q?fix:=20trocando=20texto=20do=20m=C3=A9tod?= =?UTF-8?q?o=20de=20pagamento=20pix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/templates/pix-checkout.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/templates/pix-checkout.html.php b/src/templates/pix-checkout.html.php index f55b71da..9b69f73d 100644 --- a/src/templates/pix-checkout.html.php +++ b/src/templates/pix-checkout.html.php @@ -22,7 +22,7 @@
From 83f7b023996bd508b7be70788cd14114fa90edf8 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Tue, 12 Mar 2024 09:16:59 -0300 Subject: [PATCH 59/84] =?UTF-8?q?fix:=20verifica=C3=A7=C3=A3o=20de=20tipo?= =?UTF-8?q?=20de=20transa=C3=A7=C3=A3o=20para=20webhook?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/Webhooks.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/services/Webhooks.php b/src/services/Webhooks.php index 99f51cfd..546c6846 100644 --- a/src/services/Webhooks.php +++ b/src/services/Webhooks.php @@ -164,6 +164,7 @@ private function bill_created($data) */ private function bill_paid($data) { + $order = false; if (empty($data->bill->subscription)) { $order = $this->find_order_by_id($data->bill->code); @@ -174,7 +175,7 @@ private function bill_paid($data) $vindi_order['single_payment']['bill']['status'] = $data->bill->status; } - if (empty($data->bill->subscription)) { + if (!empty($data->bill->subscription)) { $vindi_subscription_id = $data->bill->subscription->id; $cycle = $data->bill->period->cycle; $order = $this->find_order_by_subscription_and_cycle($vindi_subscription_id, $cycle); @@ -186,6 +187,10 @@ private function bill_paid($data) $vindi_order[$vindi_subscription_id]['bill']['status'] = $data->bill->status; } + + if (!$order) { + return; + } $order->update_meta_data('vindi_order', $vindi_order); From 2f88c8116aab4537b96e30bd7e3550187d7205d9 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Wed, 13 Mar 2024 14:35:57 -0300 Subject: [PATCH 60/84] fix: removendo propriedade de pattern --- src/templates/creditcard-checkout.html.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/templates/creditcard-checkout.html.php b/src/templates/creditcard-checkout.html.php index 7a8fcccb..b5e3ddfb 100644 --- a/src/templates/creditcard-checkout.html.php +++ b/src/templates/creditcard-checkout.html.php @@ -157,7 +157,7 @@ * - + * - +
- +
From afbbdfcd01dd2d8ed5f074641a14e27c985b8f7d Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Wed, 13 Mar 2024 14:39:05 -0300 Subject: [PATCH 61/84] fix: codeclimate issues --- src/templates/creditcard-checkout.html.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/templates/creditcard-checkout.html.php b/src/templates/creditcard-checkout.html.php index b5e3ddfb..18fd165d 100644 --- a/src/templates/creditcard-checkout.html.php +++ b/src/templates/creditcard-checkout.html.php @@ -157,7 +157,13 @@ * - + * - +
From 25dea56712069c4c74e6c23b9bdfb0a9746bd687 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 14 Mar 2024 14:11:55 -0300 Subject: [PATCH 62/84] docs: update documentation files --- readme.txt | 4 ++-- vindi.php | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/readme.txt b/readme.txt index 5de012ee..ba4da12f 100644 --- a/readme.txt +++ b/readme.txt @@ -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 diff --git a/vindi.php b/vindi.php index ec3ccd46..eb4b4e6a 100644 --- a/vindi.php +++ b/vindi.php @@ -8,9 +8,7 @@ * Author URI: https://www.vindi.com.br * Version: 1.2.6 * Requires at least: 4.4 - * Tested up to: 6.3 - * WC requires at least: 3.0.0 - * WC tested up to: 7.6.0 + * Tested up to: 6.4 * Text Domain: vindi-payment-gateway * * Domain Path: ./src/languages/ From 9f8e3b21e4636ee1db79c4a53b7283e975b28490 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Tue, 19 Mar 2024 13:39:40 -0300 Subject: [PATCH 63/84] =?UTF-8?q?feat:=20iniciando=20a=20cria=C3=A7=C3=A3o?= =?UTF-8?q?=20do=20novo=20m=C3=A9todo=20de=20pagamento=20Bolepix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/VindiWoocommerce.php | 2 + src/includes/gateways/BolepixPayment.php | 147 +++++++++++++++++++++++ src/includes/gateways/PixPayment.php | 2 +- src/templates/bolepix-checkout.html.php | 33 +++++ src/templates/bolepix-download.html.php | 114 ++++++++++++++++++ src/templates/pix-download.html.php | 17 --- 6 files changed, 297 insertions(+), 18 deletions(-) create mode 100644 src/includes/gateways/BolepixPayment.php create mode 100644 src/templates/bolepix-checkout.html.php create mode 100644 src/templates/bolepix-download.html.php diff --git a/src/VindiWoocommerce.php b/src/VindiWoocommerce.php index abad2fc2..5cc3f28d 100644 --- a/src/VindiWoocommerce.php +++ b/src/VindiWoocommerce.php @@ -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'; @@ -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); return $methods; } diff --git a/src/includes/gateways/BolepixPayment.php b/src/includes/gateways/BolepixPayment.php new file mode 100644 index 00000000..80a13cae --- /dev/null +++ b/src/includes/gateways/BolepixPayment.php @@ -0,0 +1,147 @@ +id = 'vindi-bolepix'; + $this->icon = apply_filters('vindi_woocommerce_bolepix_icon', ''); + $this->method_title = __('Vindi - Bolepix', VINDI); + $this->method_description = __('Aceitar pagamentos via Bolepix bancário 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') + ); + } + } + } +} diff --git a/src/includes/gateways/PixPayment.php b/src/includes/gateways/PixPayment.php index 92251deb..72d4fb79 100644 --- a/src/includes/gateways/PixPayment.php +++ b/src/includes/gateways/PixPayment.php @@ -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', diff --git a/src/templates/bolepix-checkout.html.php b/src/templates/bolepix-checkout.html.php new file mode 100644 index 00000000..9066c2b1 --- /dev/null +++ b/src/templates/bolepix-checkout.html.php @@ -0,0 +1,33 @@ + + + +
+

+

+ Modo Trial. + Este modo é proposto para a realização de testes e, portanto, + nenhum pedido será efetivamente cobrado.', + VINDI + ); ?> +

+
+ +
+ + +
+ +
+
+ + + +
+
diff --git a/src/templates/bolepix-download.html.php b/src/templates/bolepix-download.html.php new file mode 100644 index 00000000..d9841bb8 --- /dev/null +++ b/src/templates/bolepix-download.html.php @@ -0,0 +1,114 @@ + + +
+
+
+
+

+ +

+

+ +

+
+
+
+ $subscription) : ?> + +
+ + + +
+ +
+
+ Seu Qr Code Expirou! +
+ + + + + + +
+ +
+ + +
+ + +
+
+ + +
+
+ diff --git a/src/templates/pix-download.html.php b/src/templates/pix-download.html.php index b24ae14b..03f65c2b 100644 --- a/src/templates/pix-download.html.php +++ b/src/templates/pix-download.html.php @@ -107,23 +107,6 @@ class="download_button"
- - - -
- - - - - - -
- -
From f0a61d5516fdba3058b2899ecd0dc6a5e1c40eba Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Fri, 22 Mar 2024 08:55:22 -0300 Subject: [PATCH 64/84] feat: adicionando suporte para bolepix no processo de pagamento --- src/utils/PaymentProcessor.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/utils/PaymentProcessor.php b/src/utils/PaymentProcessor.php index 749a74c2..f119dc3a 100644 --- a/src/utils/PaymentProcessor.php +++ b/src/utils/PaymentProcessor.php @@ -220,6 +220,9 @@ public function payment_method_code() case 'pix': $code = 'pix'; break; + case 'bolepix': + $code = 'pix_bank_slip'; + break; default: $code = ''; break; @@ -1118,20 +1121,19 @@ protected function create_bill_meta_for_order($bill) $bill_meta = []; $bill_meta['id'] = $bill['id']; $bill_meta['status'] = $bill['status']; - if (isset($bill['charges']) && count($bill['charges'])) { $charges = end($bill['charges']); - $bill_meta['bank_slip_url'] = $charges['print_url'] ?? ''; - if ($this->payment_method_code() === 'pix' - && isset($charges['last_transaction']['gateway_response_fields'])) { - $transaction = $charges['last_transaction']['gateway_response_fields']; - - $bill_meta['charge_id'] = $charges['id']; - $bill_meta['pix_expiration'] = $transaction['max_days_to_keep_waiting_payment']; - $bill_meta['pix_code'] = $transaction['qrcode_original_path']; - $bill_meta['pix_qr'] = $transaction['qrcode_path']; - unset($bill_meta['bank_slip_url']); + + if ($this->payment_method_code() === 'pix' || $this->payment_method_code() ==='pix_bank_slip') { + if (isset($charges['last_transaction']['gateway_response_fields'])) { + $transaction = $charges['last_transaction']['gateway_response_fields']; + + $bill_meta['charge_id'] = $charges['id']; + $bill_meta['pix_expiration'] = $transaction['max_days_to_keep_waiting_payment'] ?? ''; + $bill_meta['pix_code'] = $transaction['qrcode_original_path']; + $bill_meta['pix_qr'] = $transaction['qrcode_path']; + } } } return $bill_meta; From 3ac6857ba7e3d518c7df73dc45f8f68c56157f51 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Mon, 25 Mar 2024 09:53:50 -0300 Subject: [PATCH 65/84] =?UTF-8?q?feat:=20criando=20visualiza=C3=A7=C3=A3o?= =?UTF-8?q?=20na=20thankyou=20page=20e=20processando=20pagamento?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/css/frontend.css | 4 +- src/assets/js/thankyou.js | 6 +- src/templates/bolepix-download.html.php | 109 ++++++++---------------- src/templates/pix-download.html.php | 2 +- 4 files changed, 42 insertions(+), 79 deletions(-) diff --git a/src/assets/css/frontend.css b/src/assets/css/frontend.css index 652dd518..f79eff13 100644 --- a/src/assets/css/frontend.css +++ b/src/assets/css/frontend.css @@ -337,7 +337,9 @@ line-height: 17px; } .vindi_payment_listing .charges .charge .download_button { - padding: 12px 20px; + width: 150px; + height: 40px; + margin: 5px 0; background: #FFFFFF; border: 1px solid #006DFF; border-radius: 3px; diff --git a/src/assets/js/thankyou.js b/src/assets/js/thankyou.js index 86749476..104b2e35 100644 --- a/src/assets/js/thankyou.js +++ b/src/assets/js/thankyou.js @@ -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); } }); - } + }) } } diff --git a/src/templates/bolepix-download.html.php b/src/templates/bolepix-download.html.php index d9841bb8..aaa9097e 100644 --- a/src/templates/bolepix-download.html.php +++ b/src/templates/bolepix-download.html.php @@ -31,80 +31,41 @@
- -
-
- Seu Qr Code Expirou! -
- - - - - - -
- -
- - -
- - +
+ + +
+
diff --git a/src/templates/pix-download.html.php b/src/templates/pix-download.html.php index 03f65c2b..ef14b505 100644 --- a/src/templates/pix-download.html.php +++ b/src/templates/pix-download.html.php @@ -80,7 +80,7 @@ class="download_button"> position: relative; right: 75px;"> Date: Mon, 25 Mar 2024 11:16:10 -0300 Subject: [PATCH 66/84] fix: codeclimate issues --- src/templates/bolepix-download.html.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/templates/bolepix-download.html.php b/src/templates/bolepix-download.html.php index aaa9097e..28a17808 100644 --- a/src/templates/bolepix-download.html.php +++ b/src/templates/bolepix-download.html.php @@ -48,7 +48,9 @@ class="download_button copy_vindi_line" data-code=""> - + Date: Mon, 25 Mar 2024 11:16:30 -0300 Subject: [PATCH 67/84] fix: codeclimate issues --- src/templates/bolepix-download.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/templates/bolepix-download.html.php b/src/templates/bolepix-download.html.php index 28a17808..6d10fba8 100644 --- a/src/templates/bolepix-download.html.php +++ b/src/templates/bolepix-download.html.php @@ -51,7 +51,7 @@ class="download_button copy_vindi_line" - + Date: Mon, 25 Mar 2024 11:36:42 -0300 Subject: [PATCH 68/84] fix: codeclimate issues --- .codeclimate.yml | 6 +++--- src/utils/PaymentProcessor.php | 11 +++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.codeclimate.yml b/.codeclimate.yml index bdcbb125..2c500ca4 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -2,7 +2,7 @@ engines: duplication: enabled: false csslint: - enabled: true + enabled: false phpmd: enabled: true checks: @@ -23,5 +23,5 @@ engines: config: standard: "PSR1,PSR2" checks: - PSR1 Methods CamelCapsMethodName NotCamelCaps: - enabled: false \ No newline at end of file + PSR1 Methods CamelCapsMethodName NotCamelCaps CognitiveComplexity: + enabled: false diff --git a/src/utils/PaymentProcessor.php b/src/utils/PaymentProcessor.php index f119dc3a..5fef91f8 100644 --- a/src/utils/PaymentProcessor.php +++ b/src/utils/PaymentProcessor.php @@ -212,22 +212,21 @@ public function payment_method_code() { switch ($this->gateway->type()) { case 'bank_slip': - $code = 'bank_slip'; + return 'bank_slip'; break; case 'cc': - $code = 'credit_card'; + return 'credit_card'; break; case 'pix': - $code = 'pix'; + return 'pix'; break; case 'bolepix': - $code = 'pix_bank_slip'; + return 'pix_bank_slip'; break; default: - $code = ''; + return ''; break; } - return $code; } /** From 10bea26239d21eadbed8d58fb15a88c44ab809b6 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Mon, 25 Mar 2024 11:41:13 -0300 Subject: [PATCH 69/84] fix: codeclimate issues --- .codeclimate.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.codeclimate.yml b/.codeclimate.yml index 2c500ca4..63a0f39d 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -19,7 +19,7 @@ engines: Naming/LongVariable: enabled: false phpcodesniffer: - enabled: true + enabled: false config: standard: "PSR1,PSR2" checks: From 3e50505f09abcaab2582d8abca03ead61b69d80e Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Mon, 25 Mar 2024 14:31:45 -0300 Subject: [PATCH 70/84] run ci From 69d112ec2ab116c655cd507d90a63f0ba43120fd Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Mon, 25 Mar 2024 14:33:22 -0300 Subject: [PATCH 71/84] run ci From 895d46d3245ea9d1b6ea2c33af6648395d6df43e Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Mon, 25 Mar 2024 14:33:28 -0300 Subject: [PATCH 72/84] fix: codeclimate issues --- .codeclimate.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.codeclimate.yml b/.codeclimate.yml index 63a0f39d..bf870692 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -19,9 +19,9 @@ engines: Naming/LongVariable: enabled: false phpcodesniffer: - enabled: false + enabled: true config: standard: "PSR1,PSR2" checks: - PSR1 Methods CamelCapsMethodName NotCamelCaps CognitiveComplexity: + PSR1 Methods CamelCapsMethodName NotCamelCaps: enabled: false From e4a1e07c5023bc9bdb8a84497de928facc465bde Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Tue, 26 Mar 2024 09:27:21 -0300 Subject: [PATCH 73/84] =?UTF-8?q?fix:=20complexidade=20da=20fun=C3=A7?= =?UTF-8?q?=C3=A3o=20payment=5Fmethod=5Fcode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/PaymentProcessor.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/utils/PaymentProcessor.php b/src/utils/PaymentProcessor.php index 5fef91f8..988e4a6c 100644 --- a/src/utils/PaymentProcessor.php +++ b/src/utils/PaymentProcessor.php @@ -211,22 +211,18 @@ public function is_bank_slip() public function payment_method_code() { switch ($this->gateway->type()) { - case 'bank_slip': - return 'bank_slip'; - break; case 'cc': - return 'credit_card'; - break; - case 'pix': - return 'pix'; + $code = 'credit_card'; break; case 'bolepix': - return 'pix_bank_slip'; + $code = 'pix_bank_slip'; break; default: - return ''; + $code = $this->gateway->type(); break; } + + return $code; } /** From 387be026be2d6ac5ae1be5d48250136661c591dc Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Tue, 26 Mar 2024 09:35:48 -0300 Subject: [PATCH 74/84] =?UTF-8?q?fix:=20complexidade=20da=20fun=C3=A7?= =?UTF-8?q?=C3=A3o=20create=5Fbill=5Fmeta=5Ffor=5Forder?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/PaymentProcessor.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/utils/PaymentProcessor.php b/src/utils/PaymentProcessor.php index 988e4a6c..03f326a2 100644 --- a/src/utils/PaymentProcessor.php +++ b/src/utils/PaymentProcessor.php @@ -1120,15 +1120,13 @@ protected function create_bill_meta_for_order($bill) $charges = end($bill['charges']); $bill_meta['bank_slip_url'] = $charges['print_url'] ?? ''; - if ($this->payment_method_code() === 'pix' || $this->payment_method_code() ==='pix_bank_slip') { - if (isset($charges['last_transaction']['gateway_response_fields'])) { - $transaction = $charges['last_transaction']['gateway_response_fields']; - - $bill_meta['charge_id'] = $charges['id']; - $bill_meta['pix_expiration'] = $transaction['max_days_to_keep_waiting_payment'] ?? ''; - $bill_meta['pix_code'] = $transaction['qrcode_original_path']; - $bill_meta['pix_qr'] = $transaction['qrcode_path']; - } + if (array_intersect([$this->payment_method_code()], ['pix', 'pix_bank_slip']) + && isset($charges['last_transaction']['gateway_response_fields'])) { + $transaction = $charges['last_transaction']['gateway_response_fields']; + $bill_meta['charge_id'] = $charges['id']; + $bill_meta['pix_expiration'] = $transaction['max_days_to_keep_waiting_payment'] ?? ''; + $bill_meta['pix_code'] = $transaction['qrcode_original_path']; + $bill_meta['pix_qr'] = $transaction['qrcode_path']; } } return $bill_meta; From f1b580d213e9550f20151dbdce149d3ac9e5f36f Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Fri, 5 Apr 2024 09:55:15 -0300 Subject: [PATCH 75/84] =?UTF-8?q?fix:=20adicionando=20timezone=20para=20ve?= =?UTF-8?q?rifica=C3=A7=C3=A3o=20de=20vencimento=20do=20QRcode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/templates/pix-download.html.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/templates/pix-download.html.php b/src/templates/pix-download.html.php index e6d2c07d..c7ee809c 100644 --- a/src/templates/pix-download.html.php +++ b/src/templates/pix-download.html.php @@ -33,8 +33,7 @@
Date: Fri, 5 Apr 2024 10:40:52 -0300 Subject: [PATCH 77/84] =?UTF-8?q?docs:=20atualiza=20n=C3=BAmero=20de=20ver?= =?UTF-8?q?s=C3=A3o=20do=20plugin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readme.txt | 6 +++++- src/utils/DefinitionVariables.php | 2 +- vindi.php | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/readme.txt b/readme.txt index 90f6a789..1966e92a 100644 --- a/readme.txt +++ b/readme.txt @@ -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 @@ -40,6 +40,10 @@ 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 + = 1.2.7 - 04/04/2024 = -Lançamento da versão de patch. - **Melhoria:** Adiciona o método de pagamento Pix diff --git a/src/utils/DefinitionVariables.php b/src/utils/DefinitionVariables.php index 5158baca..9579ecb4 100644 --- a/src/utils/DefinitionVariables.php +++ b/src/utils/DefinitionVariables.php @@ -1,6 +1,6 @@ Date: Wed, 10 Apr 2024 09:17:46 -0300 Subject: [PATCH 78/84] =?UTF-8?q?fix:=20corrigindo=20palavra=20expiration?= =?UTF-8?q?=20no=20template=20de=20visualiza=C3=A7=C3=A3o=20de=20PIX?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/templates/pix-download.html.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/templates/pix-download.html.php b/src/templates/pix-download.html.php index 3f35e269..a1169fa3 100644 --- a/src/templates/pix-download.html.php +++ b/src/templates/pix-download.html.php @@ -33,11 +33,11 @@
+ if ($pix_expiration < $now && $key !== 'single_payment') :?>