diff --git a/CHANGELOG.md b/CHANGELOG.md index 205f0f42..2e8108b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 1.3.0 +* Fix: Compatibilidade com PHP 8 +* Fix: Adequação de funções depreciadas + # 1.2.1 * Add: Ajuste do header da requisição * Fix: Compatibilidade com Brazilian Market on Woocommerce @@ -143,4 +147,4 @@ # v0.1.0 -* Versão Beta \ No newline at end of file +* Versão Beta diff --git a/auto/woo-gerencianet-official.zip b/auto/woo-gerencianet-official.zip index 5927a9fe..5c427efc 100755 Binary files a/auto/woo-gerencianet-official.zip and b/auto/woo-gerencianet-official.zip differ diff --git a/manual/woo-gerencianet-official/includes/class-wc-gerencianet-oficial-gateway.php b/manual/woo-gerencianet-official/includes/class-wc-gerencianet-oficial-gateway.php old mode 100644 new mode 100755 index 86437d67..a8004709 --- a/manual/woo-gerencianet-official/includes/class-wc-gerencianet-oficial-gateway.php +++ b/manual/woo-gerencianet-official/includes/class-wc-gerencianet-oficial-gateway.php @@ -150,8 +150,8 @@ public function process_refund( $order_id, $amount = null, $reason = '' ) { return false; } - $e2eid = get_post_meta($order->id, 'endToEndId', true); - $apiID = get_post_meta($order->id, 'charge_id', true); + $e2eid = get_post_meta($order->get_id(), 'endToEndId', true); + $apiID = get_post_meta($order->get_id(), 'charge_id', true); if(isset($e2eid) && $e2eid != ""){ @@ -1139,7 +1139,7 @@ public function gerencianet_pay_billet($checkout_type, $order_id, $charge_id) add_post_meta(intval($post_order_id), 'billet_discount_value', $discountBilletTotal, true); } $order->update_status('on-hold', __('Waiting')); - $order->reduce_order_stock(); + wc_reduce_stock_levels($order_id); WC()->cart->empty_cart(); } else { if ('yes' == $this->debug) { @@ -1506,20 +1506,20 @@ protected function generate_payment_page_options($order_id) } } - if ($validate->_corporate($order->billing_company)) { + if ($validate->_corporate($order->get_billing_company())) { $gn_billing_name_corporate_validate = true; - $gn_order_name_corporate = $order->billing_company; + $gn_order_name_corporate = $order->get_billing_company(); } } - if (isset($order->billing_email)) { - if ($validate->_email($order->billing_email)) { + if ($order->get_billing_email() !== NULL) { + if ($validate->_email($order->get_billing_email())) { $gn_billing_email_validate = true; } } - if (isset($order->billing_phone)) { - if ($validate->_phone_number($order->billing_phone)) { + if ($order->get_billing_phone() !== NULL) { + if ($validate->_phone_number($order->get_billing_phone())) { $gn_billing_phone_number_validate = true; } } @@ -1530,13 +1530,13 @@ protected function generate_payment_page_options($order_id) } } - if (isset($order->billing_address_1)) { - if ($validate->_street($order->billing_address_1)) { + if ($order->get_billing_address_1() !== NULL) { + if ($validate->_street($order->get_billing_address_1())) { $gn_billing_street_validate = true; } } - if (isset($order->billing_number)) { + if ($order->billing_number !== NULL) { if ($validate->_number($order->billing_number)) { $gn_billing_number_validate = true; } @@ -1548,26 +1548,20 @@ protected function generate_payment_page_options($order_id) } } - if (isset($order->billing_city)) { - if ($validate->_city($order->billing_city)) { + if ($order->get_billing_city() !== NULL) { + if ($validate->_city($order->get_billing_city())) { $gn_billing_city_validate = true; } } - if (isset($order->billing_city)) { - if ($validate->_city($order->billing_city)) { - $gn_billing_city_validate = true; - } - } - - if (isset($order->billing_postcode)) { - if ($validate->_zipcode($order->billing_postcode)) { + if ($order->get_billing_postcode() !== NULL) { + if ($validate->_zipcode($order->get_billing_postcode())) { $gn_billing_zipcode_validate = true; } } - if (isset($order->billing_state)) { - if ($validate->_state($order->billing_state)) { + if ($order->get_billing_state() !== NULL) { + if ($validate->_state($order->get_billing_state())) { $gn_billing_state_validate = true; } } @@ -1826,7 +1820,7 @@ private function process_payment_method($method_payment, $order_id, $charge_id, $pay_charge = ($method_payment !== 'pix') ? $this->{$functionCall}('OSC', $order_id, $charge_id) - : Pix::gerencianet_pay_pix('OSC', $order_id, $charge_id, $cpf_cnpj); + : Pix::woocommerce_gerencianet_pay_pix('OSC', $order_id, $charge_id, $cpf_cnpj); $resultCheckPay = array(); $resultCheckPay = json_decode($pay_charge, true); @@ -1888,7 +1882,7 @@ protected function generate_gn_thankyou_page($order_id) { $this->styles(); $order = wc_get_order($order_id); - $email = $order->billing_email; + $email = $order->get_billing_email(); $billet_url = get_post_meta($order_id, 'billet', true); $qrcode = get_post_meta($order_id, 'pix_qr', true); @@ -2089,7 +2083,7 @@ public function currency_not_supported_message() function gn_order_view_billet_link($order) { - $billet = get_post_meta($order->id, 'billet', true); + $billet = get_post_meta($order->get_id(), 'billet', true); if (!empty($billet)) { if ($order->get_status() == "on-hold" || $order->get_status() == "pending") { echo " @@ -2107,7 +2101,7 @@ function gn_order_view_billet_link($order) function gn_email_billet_link($order) { - $billet = get_post_meta($order->id, 'billet', true); + $billet = get_post_meta($order->get_id(), 'billet', true); if (!empty($billet)) { echo "
diff --git a/manual/woo-gerencianet-official/includes/lib/GerencianetValidation.php b/manual/woo-gerencianet-official/includes/lib/GerencianetValidation.php index 3d84f12c..93f8e0b5 100644 --- a/manual/woo-gerencianet-official/includes/lib/GerencianetValidation.php +++ b/manual/woo-gerencianet-official/includes/lib/GerencianetValidation.php @@ -126,10 +126,10 @@ public function _cpf( $data ) { for ( $t = 9; $t < 11; $t ++ ) { for ( $d = 0, $c = 0; $c < $t; $c ++ ) { - $d += $cpf{$c} * ( ( $t + 1 ) - $c ); + $d += $cpf[$c] * (($t + 1) - $c); } $d = ( ( 10 * $d ) % 11 ) % 10; - if ( $cpf{$c} != $d ) { + if ($cpf[$c] != $d) { return false; } } @@ -158,21 +158,21 @@ public function _cnpj( $cnpj ) { } for ( $i = 0, $j = 5, $soma = 0; $i < 12; $i ++ ) { - $soma += $cnpj{$i} * $j; + $soma += $cnpj[$i] * $j; $j = ( $j == 2 ) ? 9 : $j - 1; } $resto = $soma % 11; - if ( $cnpj{12} != ( $resto < 2 ? 0 : 11 - $resto ) ) { + if ( $cnpj[12] != ( $resto < 2 ? 0 : 11 - $resto ) ) { return false; } for ( $i = 0, $j = 6, $soma = 0; $i < 13; $i ++ ) { - $soma += $cnpj{$i} * $j; + $soma += $cnpj[$i] * $j; $j = ( $j == 2 ) ? 9 : $j - 1; } $resto = $soma % 11; - return $cnpj{13} == ( $resto < 2 ? 0 : 11 - $resto ); + return $cnpj[13] == ( $resto < 2 ? 0 : 11 - $resto ); } /** diff --git a/manual/woo-gerencianet-official/includes/lib/gerencianet/gerencianet/gerencianet-sdk-php/src/Gerencianet/Request.php b/manual/woo-gerencianet-official/includes/lib/gerencianet/gerencianet/gerencianet-sdk-php/src/Gerencianet/Request.php index fc2ebbae..c12ebaa4 100644 --- a/manual/woo-gerencianet-official/includes/lib/gerencianet/gerencianet/gerencianet-sdk-php/src/Gerencianet/Request.php +++ b/manual/woo-gerencianet-official/includes/lib/gerencianet/gerencianet/gerencianet-sdk-php/src/Gerencianet/Request.php @@ -27,7 +27,7 @@ public function __construct(array $options = null) 'headers' => [ 'Content-Type' => 'application/json', 'api-sdk' => 'php-' . $composerData['version'], - 'wordpress-plugin' => 'v1.2.1', // ATUALIZAR VERSÃO A CADA ATUALIZAÇÃO + 'wordpress-plugin' => 'v1.3.0', // ATUALIZAR VERSÃO A CADA ATUALIZAÇÃO 'partner-token' => $partner_token ] ]; diff --git a/manual/woo-gerencianet-official/includes/lib/payments/Pix.php b/manual/woo-gerencianet-official/includes/lib/payments/Pix.php old mode 100644 new mode 100755 index 39bcfac4..17443f77 --- a/manual/woo-gerencianet-official/includes/lib/payments/Pix.php +++ b/manual/woo-gerencianet-official/includes/lib/payments/Pix.php @@ -11,8 +11,9 @@ class Pix { * * @return string */ - public static function woocommerce_gerencianet_pay_pix() { - echo Pix::gerencianet_pay_pix('checkout_page', null, null); + public static function woocommerce_gerencianet_pay_pix($typecheck, $order_id, $charge_id, $cpf_cnpj) { + $pix = new Pix(); + return $pix->gerencianet_pay_pix($typecheck, $order_id, $charge_id, $cpf_cnpj); die(); } @@ -57,8 +58,7 @@ public function gerencianet_pay_pix($checkout_type, $order_id, $charge_id, $cpf_ $gateway = new WC_Gerencianet_Oficial_Gateway(); //get order data - $post_order_id = isset($arrayDadosPost['order_id']) ? $arrayDadosPost['order_id'] : $order_id; - $order = wc_get_order($post_order_id); + $order = wc_get_order($order_id); $full_name = $order->get_formatted_billing_full_name(); $totalOrder = strval($gateway->calculatePixDiscount()); @@ -81,30 +81,31 @@ public function gerencianet_pay_pix($checkout_type, $order_id, $charge_id, $cpf_ ], [ "nome" => "Número do Pedido", - "valor" => "#".$post_order_id + "valor" => "#".$order_id ] ] ]; $credential = Pix::get_gn_api_credentials($gateway->gnIntegration->get_gn_api_credentials()); - $gnApiResult = GerencianetIntegration::pay_pix($credential, $body); + $gnApiResult = $gateway->gnIntegration->pay_pix($credential, $body); $resultCheck = json_decode($gnApiResult, true); if (isset($resultCheck['txid']) && isset($resultCheck['loc']['id'])) { - $gnApiQrCode = GerencianetIntegration::generate_qrcode($credential, $resultCheck['loc']['id']); + $gnApiQrCode = $gateway->gnIntegration->generate_qrcode($credential, $resultCheck['loc']['id']); $resultQrCode = json_decode($gnApiQrCode, true); - $resultCheck['charge_id'] = $post_order_id; - + $resultCheck['charge_id'] = $order_id; if(isset($resultQrCode['imagemQrcode'])) { $resultCheck['imagemQrcode'] = $resultQrCode['imagemQrcode']; global $wpdb; - if ($order->get_status() != 'failed' && !isset($meta_discount_value_array[0])) { + $order_data = $order->get_data(); + + if ($order_data['status'] != 'failed' && !isset($meta_discount_value_array[0])) { $wpdb->insert($wpdb->prefix . 'woocommerce_order_items', array( 'order_item_name' => __('Discount of ', WCGerencianetOficial::getTextDomain()) . str_replace(".", ",", $gateway->discountPix) . __('% Pix', WCGerencianetOficial::getTextDomain()), 'order_item_type' => 'fee', - 'order_id' => intval($post_order_id) + 'order_id' => intval($order_id) )); $lastid = $wpdb->insert_id; @@ -132,15 +133,15 @@ public function gerencianet_pay_pix($checkout_type, $order_id, $charge_id, $cpf_ 'meta_value' => '0' )); - update_post_meta(intval($post_order_id), '_order_total', number_format(intval(ceil($gateway->gn_price_format($totalOrder))) / 100, 2, '.', '')); - update_post_meta(intval($post_order_id), '_payment_method_title', sanitize_text_field(__('Pix - Gerencianet', WCGerencianetOficial::getTextDomain()))); - add_post_meta(intval($post_order_id), 'pix_qr', $resultQrCode['imagemQrcode'], true); - add_post_meta(intval($post_order_id), 'pix_qr_copy', $resultQrCode['qrcode'], true); - add_post_meta(intval($post_order_id), 'txid', $resultCheck['txid'], true); + update_post_meta(intval($order_id), '_order_total', number_format(intval(ceil($gateway->gn_price_format($totalOrder))) / 100, 2, '.', '')); + update_post_meta(intval($order_id), '_payment_method_title', sanitize_text_field(__('Pix - Gerencianet', WCGerencianetOficial::getTextDomain()))); + add_post_meta(intval($order_id), 'pix_qr', $resultQrCode['imagemQrcode'], true); + add_post_meta(intval($order_id), 'pix_qr_copy', $resultQrCode['qrcode'], true); + add_post_meta(intval($order_id), 'txid', $resultCheck['txid'], true); } $order->update_status('on-hold', __('Waiting')); - $order->reduce_order_stock(); - WC()->cart->empty_cart(); + wc_reduce_stock_levels($order_id); + WC()->cart->empty_cart(); } else { if ($gateway->gnIntegration->debug == 'yes') { @@ -202,7 +203,7 @@ public static function updateWebhook($gateway) { $pix_key = $gateway->pix_key; $skip_mtls = ($gateway->pix_mtls == 'yes') ? 'false' : 'true'; // Precisa ser string - $gnApi = GerencianetIntegration::update_webhook($credential, $pix_key, $skip_mtls, $url); + $gnApi = $gateway->gnIntegration->update_webhook($credential, $pix_key, $skip_mtls, $url); $result = json_decode($gnApi, true); if($gateway->debug == 'yes' && $result['webhookUrl']) { @@ -259,7 +260,7 @@ public static function successful_webhook($posted) { // Atualiza status foreach($orders as &$order) { - add_post_meta(intval($order->id), 'endToEndId', $order_notify->endToEndId, true); + add_post_meta(intval($order->get_id()), 'endToEndId', $order_notify->endToEndId, true); $order->update_status('processing', __('Paid')); $order->payment_complete(); } diff --git a/manual/woo-gerencianet-official/readme.txt b/manual/woo-gerencianet-official/readme.txt old mode 100644 new mode 100755 index 853bf5e0..8245f452 --- a/manual/woo-gerencianet-official/readme.txt +++ b/manual/woo-gerencianet-official/readme.txt @@ -2,8 +2,8 @@ Contributors: Gerencianet Tags: woocommerce, gerencianet, payment, transparent checkout, pix, bank slip, card, brazil, payments brazil Requires at least: 5.x -Tested up to: 5.6.2 -Stable tag: 1.2.1 +Tested up to: 5.7 +Stable tag: 1.3.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -56,6 +56,11 @@ Caso você tenha alguma dúvida ou sugestão, entre em contato conosco pelo site 10. Recomendamos que antes de disponibilizar pagamentos pela Gerencianet, o lojista realize testes de cobrança com o sandbox(ambiente de testes) ativado para verificar se o procedimento de pagamento está acontecendo conforme esperado. = Changelog = + += 1.3.0 = +* Fix: Compatibilidade com PHP 8 +* Fix: Adequação de funções depreciadas + = 1.2.1 = * Add: Ajuste do header da requisição * Fix: Compatibilidade com Brazilian Market on Woocommerce diff --git a/manual/woo-gerencianet-official/templates/order-received.php b/manual/woo-gerencianet-official/templates/order-received.php index 64183d55..e4c572a2 100755 --- a/manual/woo-gerencianet-official/templates/order-received.php +++ b/manual/woo-gerencianet-official/templates/order-received.php @@ -53,7 +53,7 @@
- +