an0nbr
Forum Replies Created
-
Its not about emails text, its about order page myaccount orders page
Forum: Plugins
In reply to: [PayPal Brasil para WooCommerce] Layout do BCDC horrivelVoltei pro PPP também, espero que não descontinuem ele, porque do jeito que o BCDC tem uma usabilidade podre, vai destruir o faturamento e quebrar a empresa, vou até adiantando procurando um novo gateway, pq se depender do time de usabilidade do Paypal vai quebrar
Hello.
I understand that we have an option to hide when you click “Update” button.
But can we have an option to hide when you select(click) a shipping option as well?
Forum: Plugins
In reply to: [Nota Fiscal Eletrônica WooCommerce] Impressao em massa nao funcionaDescobri o problema, o erro é do PDFMerger que não é compativel com php 8.2+
Se puderem arrumar o problema 🙁
Forum: Plugins
In reply to: [PayPal Brasil para WooCommerce] Parou de funcionar na versão 1.5.1Façam reclamação no Reclameaqui do PayPal, eles devem estar achando que o suporte do plugin está uma maravilha, uma atualização a cada 3-4 meses e quando sai é com um bug novo, sem consertar os antigos
Forum: Plugins
In reply to: [WooCommerce] Admin List orders at cell phoneSame here, please fix it asap, very annoying not seeing the names,
Forum: Plugins
In reply to: [Loco Translate] Cant open translations pageThanks, it was PHP version, upgraded from 8.1.2 to 8.3.9
Parou de botar mensagem de reembolso em pedido aleatorio sim
Forum: Plugins
In reply to: [PayPal Brasil para WooCommerce] Pedidos aprovados sem o ID da transação.Verifique também se houve o pagamento, pode ser que teve retentativa e passou
Forum: Plugins
In reply to: [PayPal Brasil para WooCommerce] Pedidos aprovados sem o ID da transação.Mais um erro grave. Esse “Pedido recebido” é status customizado? Porque o padrão é “Aprovado”.
Edite o arquivo /wp-content/plugins/paypal-brasil-para-woocommerce/includes/handlers/class-paypal-brasil-webhooks-handler.php, apague todo o texto do arquivo e coloque o código abaixo
<?php // Exit if not in WordPress. if (!defined('ABSPATH')) { exit; } // Check if class already exists before create. if (!class_exists('PayPal_Brasil_Webhooks_Handler')) { /** * Class WC_PPP_Brasil_Webhooks_Handler. */ class PayPal_Brasil_Webhooks_Handler { private $gateway_id; /** * @var PayPal_Brasil_Gateway */ private $gateway; /** * WC_PPP_Brasil_Webhooks_Handler constructor. * * @param $gateway_id string * @param $gateway PayPal_Brasil_Gateway */ public function __construct($gateway_id, $gateway) { $this->gateway_id = $gateway_id; $this->gateway = $gateway; } private function log($data) { if ($this->gateway) { $this->gateway->log($data); } } /** * Handle the event. * * @param $event * * @throws Exception */ public function handle($event){ global $wpdb; $method_name = 'handle_process_' . str_replace('.', '_', strtolower($event['event_type'])); $method_name = str_replace('-', '_', strtolower($method_name)); $this->log('Handling process method: ' . $method_name); if (method_exists($this, $method_name)) { $this->log('Method name: ' . $method_name); $resource_id = isset($event['resource']['sale_id']) ? $event['resource']['sale_id'] : $event['resource']['id']; $this->log('Resource ID: ' . $resource_id); $order_id_query = $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key IN ('paypal_brasil_sale_id', 'wc_ppp_brasil_sale_id','wc_bcdc_brasil_sale_id') AND meta_value = %s", $resource_id ); $this->log('Order ID query: ' . $order_id_query); $order_id = $wpdb->get_var($order_id_query); // If found the order ID with this sale ID. if (!empty($order_id)) { $this->log('Order ID: ' . $order_id); $order = wc_get_order($order_id); $payment_method = !empty($order) ? $order->get_payment_method() : ""; $this->log('Payment method: ' . $payment_method); // If is this gateway, process the order. if ($payment_method === $this->gateway_id) { $this->log('Processing for payment method: ' . $payment_method); $this->{$method_name}($order, $event); } else { $this->log('Payment method not found: ' . $payment_method); } } } else { throw new Exception('Invalid method to handle.'); } } /** * When payment is marked as completed. * * @param $order WC_Order */ public function handle_process_payment_sale_completed($order, $event) { // Check if order exists. if (!$order) { $this->log('Processing completed was not initiated because there is no order.'); return; } $this->log('Processing completed initiated.'); // Check if the current status isn't processing or completed. if ( !in_array($order->get_status(), array( 'processing', 'completed', 'refunded', 'cancelled' ), true) ) { $order->add_order_note(__('PayPal: Paid transaction.', "paypal-brasil-para-woocommerce")); $order->payment_complete(); $this->log('Processing completed finished.'); } } /** * When payment is denied. * * @param $order WC_Order */ public function handle_process_payment_sale_denied($order, $event) { // Check if order exists. if (!$order) { $this->log('Processing denied was not initiated because there is no order.'); return; } $this->log('Processing denied initiated.'); // Check if the current status isn't failed. if (!in_array($order->get_status(), array('failed', 'completed', 'processing'), true)) { $order->update_status('failed', __('PayPal: The transaction was rejected by the card company or for fraud.', "paypal-brasil-para-woocommerce")); $this->log('Processing denied finished.'); } else { $this->log('Processing denied did not change anything.'); } } /** * When payment is refunded. * * @param $order WC_Order * * @throws Exception */ public function handle_process_payment_sale_refunded($order, $event) { // Check if order exists. if (!$order) { $this->log('Processing refunded was not initiated because there is no order.'); return; } $this->log('Processing refunded initiated.'); // Check if is partial refund. $partial_refund = paypal_brasil_money_format($order->get_total() - $order->get_total_refunded()) !== paypal_brasil_money_format($event['resource']['amount']['total']); // Check if the current status isn't refunded. if (!in_array($order->get_status(), array('refunded'), true)) { // Check if is total refund if ($partial_refund) { $order->add_order_note(__('PayPal: The transaction was partially refunded.', "paypal-brasil-para-woocommerce")); } else { $order->update_status('refunded', __('PayPal: The transaction has been refunded in full.', "paypal-brasil-para-woocommerce")); } // Create the refund. $refund = wc_create_refund( array( 'amount' => wc_format_decimal($event['resource']['amount']['total']), 'reason' => $partial_refund ? __('PayPal: The transaction was partially refunded.', "paypal-brasil-para-woocommerce") : __('PayPal: transaction refunded in full.', "paypal-brasil-para-woocommerce"), 'order_id' => $order->get_id(), 'refund_payment' => false, ) ); if (is_wp_error($refund)) { $this->log('There was some error refunding.'); throw new Exception(sprintf(__('There was an error trying to make a refund: %s', "paypal-brasil-para-woocommerce"), $refund->get_error_message())); } $this->log('Processing refunded finished.'); } else { $this->log('Processing refunded did not change anything.'); throw new Exception(__('This order has already been refunded.', "paypal-brasil-para-woocommerce")); } } /** * When payment is reversed. * * @param $order WC_Order * * @throws Exception */ public function handle_process_payment_sale_reversed($order, $event) { // Check if order exists. if (!$order) { $this->log('Processing reversed was not initiated because there is no order.'); return; } $this->log('Processing reversed initiated.'); // Check if the current status isn't refunded. if (!in_array($order->get_status(), array('refunded'), true)) { $order->update_status('refunded', __('PayPal: The transaction has been rolled back.', "paypal-brasil-para-woocommerce")); $refund = wc_create_refund( array( 'amount' => wc_format_decimal($order->get_total() - $order->get_total_refunded()), 'reason' => __('PayPal: reversed transaction.', "paypal-brasil-para-woocommerce"), 'order_id' => $order->get_id(), 'refund_payment' => false, ) ); if (is_wp_error($refund)) { $this->log('There was some error reversing.'); throw new Exception(sprintf(__('There was an error trying to make a refund: %s', "paypal-brasil-para-woocommerce"), $refund->get_error_message())); } $this->log('Processing reversed finished.'); } else { $this->log('Processing reversed did not change anything.'); throw new Exception(__('This order has already been refunded.', "paypal-brasil-para-woocommerce")); } } /** * When payment is marked as completed. * * @param $order WC_Order */ public function handle_process_checkout_order_approved($order, $event) { // Check if order exists. if (!$order) { $this->log('Processing completed was not initiated because there is no order.'); return; } $this->log('Processing completed initiated.'); // Check if the current status isn't processing or completed. if ( !in_array($order->get_status(), array( 'completed', 'refunded', 'cancelled' ), true) ) { $order->add_order_note(__('PayPal: Paid transaction.', "paypal-brasil-para-woocommerce")); $order->payment_complete(); $this->log('Processing completed finished.'); } } /** * When payment is reversed. * * @param $order WC_Order * * @throws Exception */ public function handle_process_checkout_payment_approval_reversed($order, $event) { // Check if order exists. if (!$order) { $this->log('Processing reversed was not initiated because there is no order.'); return; } $this->log('Processing reversed initiated.'); // Check if the current status isn't refunded. if (!in_array($order->get_status(), array('refunded'), true)) { $order->update_status('refunded', __('PayPal: The transaction has been rolled back.', "paypal-brasil-para-woocommerce")); $refund = wc_create_refund( array( 'amount' => wc_format_decimal($order->get_total() - $order->get_total_refunded()), 'reason' => __('PayPal: reversed transaction.', "paypal-brasil-para-woocommerce"), 'order_id' => $order->get_id(), 'refund_payment' => false, ) ); if (is_wp_error($refund)) { $this->log('There was some error reversing.'); throw new Exception(sprintf(__('There was an error trying to make a refund: %s', "paypal-brasil-para-woocommerce"), $refund->get_error_message())); } $this->log('Processing reversed finished.'); } else { $this->log('Processing reversed did not change anything.'); throw new Exception(__('This order has already been refunded.', "paypal-brasil-para-woocommerce")); } } /** * When payment is cancelled. * * @param $order WC_Order * * @throws Exception */ public function handle_process_payment_order_cancelled($order, $event) { // Check if order exists. if (!$order) { $this->log('Processing reversed was not initiated because there is no order.'); return; } $this->log('Processing reversed initiated.'); // Check if the current status isn't refunded. if (!in_array($order->get_status(), array('refunded'), true)) { $order->update_status('refunded', __('PayPal: The transaction has been rolled back.', "paypal-brasil-para-woocommerce")); $refund = wc_create_refund( array( 'amount' => wc_format_decimal($order->get_total() - $order->get_total_refunded()), 'reason' => __('PayPal: reversed transaction.', "paypal-brasil-para-woocommerce"), 'order_id' => $order->get_id(), 'refund_payment' => false, ) ); if (is_wp_error($refund)) { $this->log('There was some error reversing.'); throw new Exception(sprintf(__('There was an error trying to make a refund: %s', "paypal-brasil-para-woocommerce"), $refund->get_error_message())); } $this->log('Processing reversed finished.'); } else { $this->log('Processing reversed did not change anything.'); throw new Exception(__('This order has already been refunded.', "paypal-brasil-para-woocommerce")); } } /** * When payment is marked as completed. * * @param $order WC_Order */ public function handle_process_payment_capture_completed($order, $event) { // Check if order exists. if (!$order) { $this->log('Processing completed was not initiated because there is no order.'); return; } $this->log('Processing completed initiated.'); // Check if the current status isn't processing or completed. if ( !in_array($order->get_status(), array( 'completed', 'refunded', 'cancelled' ), true) ) { $order->add_order_note(__('PayPal: Paid transaction.', "paypal-brasil-para-woocommerce")); $order->payment_complete(); $this->log('Processing completed finished.'); } } } }
Ou se quiser testar também eu já te mando a versão corrigida, quer que manda aqui?
Tem gente voltando pra versão 1.49
- This reply was modified 9 months, 2 weeks ago by an0nbr.
Encontrei o erro, editei e agora vou testar, o estagiario fez uma baita cagada, se funcionar volto aqui com a solução
Esse código abaixo pegando varios ids ao mesmo tempo:
public function handle($event)
{
global $wpdb;
$method_name = ‘handle_process_’ . str_replace(‘.’, ‘‘, strtolower($event[‘event_type’])); $method_name = str_replace(‘-‘, ‘‘, strtolower($method_name));
$this->log(‘Handling process method: ‘ . $method_name);
if (method_exists($this, $method_name)) {
$this->log(‘Method name: ‘ . $method_name);
$resource_id = isset($event[‘resource’][‘id’]) ? $event[‘resource’][‘id’] : null;
$this->log(‘Resource ID: ‘ . $resource_id);
/$order_id_query = $wpdb->prepare(“SELECT post_id FROM $wpdb->postmeta WHERE meta_key IN (‘paypal_brasil_sale_id’, ‘wc_ppp_brasil_sale_id’,’wc_bcdc_brasil_sale_id’) AND meta_value = %s”, $resource_id); $this->log(‘Order ID query: ‘ . $order_id_query); $order_id = $wpdb->get_var($order_id_query);/
$order_ids = wc_get_orders(
array(
‘meta_query’ => array(
‘relation’ => ‘OR’,
array(
‘key’ => ‘paypal_brasil_sale_id’,
‘value’ => $resource_id,
‘compare’ => ‘=’
),
array(
‘key’ => ‘wc_ppp_brasil_sale_id’,
‘value’ => $resource_id,
‘compare’ => ‘=’
),
array(
‘key’ => ‘wc_bcdc_brasil_sale_id’,
‘value’ => $resource_id,
‘compare’ => ‘=’
)
),
‘return’ => ‘ids’, // Especifica que queremos apenas IDs de pedidos
‘post_type’ => ‘shop_order’, // O tipo de post para pedidos do WooCommerce
‘posts_per_page’ => -1 // Recupera todos os pedidos que correspondem aos critérios
)
);// If found the order ID with this sale ID. if (!empty($order_ids)) { $order_id = $order_ids[0]; $this->log('Order ID: ' . $order_id); $order = wc_get_order($order_id); $payment_method = !empty($order) ? $order->get_payment_method() : ""; $this->log('Payment method: ' . $payment_method); // If is this gateway, process the order. if ($payment_method === $this->gateway_id) { $this->log('Processing for payment method: ' . $payment_method); $this->{$method_name}($order, $event); } else { $this->log('Payment method not found: ' . $payment_method); } } } else { throw new Exception('Invalid method to handle.'); } }
É isso mesmo,no arquivo paypal-brasil-para-woocommerce\includes\handlers\class-paypal-brasil-webhooks-handler.php, ele está pegando o id do PayPal nessa linha
$resource_id = isset( $event[‘resource’][‘sale_id’] ) ? $event[‘resource’][‘sale_id’] : $event[‘resource’][‘id’];
E por algum motivo o SELECT está puxando o ID errado, diferente do qual o reembolso acontece.
Se conseguir arrumar eu falo