From 4ebda3863f6dcaa758002cab9fc797719bbd398f Mon Sep 17 00:00:00 2001 From: Aleksei Tikhomirov Date: Sat, 21 Sep 2024 11:17:03 +0300 Subject: [PATCH 1/7] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D1=83=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=86=D0=B5=D0=BD?= =?UTF-8?q?=D1=8B=20=D1=82=D0=BE=D0=B2=D0=B0=D1=80=D0=B0=20=D0=94=D0=BE?= =?UTF-8?q?=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=20=D1=84=D0=B8=D0=BB=D1=8C?= =?UTF-8?q?=D1=82=D1=80=20=D0=B4=D0=BB=D1=8F=20=D0=B8=D1=82=D0=BE=D0=B3?= =?UTF-8?q?=D0=BE=D0=B2=D1=8B=D1=85=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D1=85?= =?UTF-8?q?=20=D1=87=D0=B5=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wp_robokassa.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/wp_robokassa.php b/wp_robokassa.php index a5e1370..2ecfe34 100644 --- a/wp_robokassa.php +++ b/wp_robokassa.php @@ -412,7 +412,7 @@ function getRobokassaPasses() * * @param mixed $order_id * - * @return void + * @return array */ function createRobokassaReceipt($order_id) { @@ -441,8 +441,8 @@ function createRobokassaReceipt($order_id) $current = []; $current['name'] = $product->get_title(); $current['quantity'] = $quantity; - $current['sum'] = $item['line_total']; - $current['cost'] = $item['line_total'] / $quantity; + $current['sum'] = $item['data']->get_price(); + $current['cost'] = $item['data']->get_price() / $quantity; $total_receipt += $current['sum']; @@ -492,8 +492,8 @@ function createRobokassaReceipt($order_id) $current['name'] = $product->get_title(); $current['quantity'] = (float)$item->get_quantity(); - $current['sum'] = $item['line_total']; - $current['cost'] = $item['line_total'] / $quantity; + $current['sum'] = $product->get_price(); + $current['cost'] = $product->get_price() / $current['quantity']; $current['payment_object'] = \get_option('robokassa_payment_paymentObject'); $current['payment_method'] = \get_option('robokassa_payment_paymentMethod'); @@ -536,7 +536,7 @@ function createRobokassaReceipt($order_id) robokassa_payment_DEBUG('Robokassa: общая сумма чека (' . $total_receipt . ') НЕ совпадает с общей суммой заказа (' . $total_order . ')'); } - return $receipt; + return apply_filters('wc_robokassa_receipt', $receipt); } /** @@ -952,7 +952,6 @@ function robokassa_hold_confirm($order_id, $old_status, $new_status, $order) 'tax' => get_option('robokassa_payment_tax'), 'payment_method' => \get_option('robokassa_payment_paymentMethod'), 'payment_object' => \get_option('robokassa_payment_paymentObject'), - 'tax' => get_option('robokassa_payment_tax'), ); } From cfcc4f3144c42f44620d34b06abf04c3494e722c Mon Sep 17 00:00:00 2001 From: Aleksei Date: Sat, 21 Sep 2024 12:42:02 +0300 Subject: [PATCH 2/7] =?UTF-8?q?=D0=9E=D1=87=D0=B8=D1=81=D1=82=D0=BA=D0=B0?= =?UTF-8?q?=20=D0=BA=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wp_robokassa.php | 94 +++++++++++++++++++++--------------------------- 1 file changed, 41 insertions(+), 53 deletions(-) diff --git a/wp_robokassa.php b/wp_robokassa.php index 2ecfe34..4165b9f 100644 --- a/wp_robokassa.php +++ b/wp_robokassa.php @@ -16,31 +16,29 @@ add_action('wp_enqueue_scripts', function () { - \wp_enqueue_style( + wp_enqueue_style( 'robokassa_payment_admin_style_menu', - \plugin_dir_url(__FILE__) . 'assets/css/menu.css' + plugin_dir_url(__FILE__) . 'assets/css/menu.css' ); - \wp_enqueue_style( + wp_enqueue_style( 'robokassa_payment_admin_style_main', - \plugin_dir_url(__FILE__) . 'assets/css/main.css' + plugin_dir_url(__FILE__) . 'assets/css/main.css' ); - \wp_enqueue_style( + wp_enqueue_style( 'robokassa_payment_podeli', - \plugin_dir_url(__FILE__) . 'assets/css/payment_styles.css' + plugin_dir_url(__FILE__) . 'assets/css/payment_styles.css' ); - \wp_enqueue_script( + wp_enqueue_script( 'robokassa_payment_admin_config', - \plugin_dir_url(__FILE__) . 'assets/js/payment_widget.js' + plugin_dir_url(__FILE__) . 'assets/js/payment_widget.js' ); }); -define('ROBOKASSA_PAYMENT_DEBUG_STATUS', false); - -\spl_autoload_register( +spl_autoload_register( function ($className) { - $file = __DIR__ . '/classes/' . \str_replace('\\', '/', $className) . '.php'; + $file = __DIR__ . '/classes/' . str_replace('\\', '/', $className) . '.php'; if (file_exists($file)) require_once $file; @@ -124,13 +122,11 @@ function robokassa_get_privacy_policy_text($text, $type) */ function robokassa_payment_DEBUG($str) { - /** @var string $file */ $file = __DIR__ . '/data/robokassa_DEBUG.txt'; - - $time = \time(); - $DEBUGFile = \fopen($file, 'a+'); - fwrite($DEBUGFile, \date('d.m.Y H:i:s', $time + 10800) . " ($time) : $str\r\n"); + $time = time(); + $DEBUGFile = fopen($file, 'a+'); + fwrite($DEBUGFile, date('d.m.Y H:i:s', $time + 10800) . " ($time) : $str\r\n"); fclose($DEBUGFile); } @@ -246,8 +242,8 @@ function robokassa_payment_wp_robokassa_checkPayment() if ($_REQUEST['robokassa'] === 'result') { /** @var string $crc_confirm */ - $crc_confirm = \strtoupper( - \md5( + $crc_confirm = strtoupper( + md5( implode( ':', [ @@ -283,7 +279,7 @@ function robokassa_payment_wp_robokassa_checkPayment() if ($subscriptions == true) { foreach ($subscriptions as $subscription) { $subscription->update_status('active'); - }; + } } } @@ -371,7 +367,7 @@ function robokassa_payment_wp_robokassa_checkPayment() // Подготовка строки перед кодированием в base64 function formatSignReplace($string) { - return \strtr( + return strtr( $string, [ '+' => '-', @@ -383,14 +379,14 @@ function formatSignReplace($string) // Подготовка строки после кодирования в base64 function formatSignFinish($string) { - return \preg_replace('/^(.*?)(=*)$/', '$1', $string); + return preg_replace('/^(.*?)(=*)$/', '$1', $string); } /** * * Проверка режимы работы * - * @return void + * @return array */ function getRobokassaPasses() { @@ -399,12 +395,12 @@ function getRobokassaPasses() 'pass1' => get_option('robokassa_payment_testshoppass1'), 'pass2' => get_option('robokassa_payment_testshoppass2'), ]; - } else { - return [ - 'pass1' => get_option('robokassa_payment_shoppass1'), - 'pass2' => get_option('robokassa_payment_shoppass2'), - ]; } + + return [ + 'pass1' => get_option('robokassa_payment_shoppass1'), + 'pass2' => get_option('robokassa_payment_shoppass2'), + ]; } /** @@ -473,9 +469,9 @@ function createRobokassaReceipt($order_id) 'quantity' => 1, 'cost' => $additional_item_total, 'sum' => $additional_item_total, - 'payment_object' => \get_option('robokassa_payment_paymentObject'), - 'payment_method' => \get_option('robokassa_payment_paymentMethod'), - 'tax' => \get_option('robokassa_payment_tax'), + 'payment_object' => get_option('robokassa_payment_paymentObject'), + 'payment_method' => get_option('robokassa_payment_paymentMethod'), + 'tax' => get_option('robokassa_payment_tax'), ); $receipt['items'][] = $additional_item_data; @@ -495,8 +491,8 @@ function createRobokassaReceipt($order_id) $current['sum'] = $product->get_price(); $current['cost'] = $product->get_price() / $current['quantity']; - $current['payment_object'] = \get_option('robokassa_payment_paymentObject'); - $current['payment_method'] = \get_option('robokassa_payment_paymentMethod'); + $current['payment_object'] = get_option('robokassa_payment_paymentObject'); + $current['payment_method'] = get_option('robokassa_payment_paymentMethod'); if (isset($receipt['sno']) && ($receipt['sno'] == 'osn')) { $current['tax'] = $tax; @@ -518,8 +514,8 @@ function createRobokassaReceipt($order_id) $current['sum'] = (double)sprintf("%01.2f", $order->get_shipping_total()); if (get_option('robokassa_country_code') == 'RU') { - $current['payment_object'] = \get_option('robokassa_payment_paymentObject'); - $current['payment_method'] = \get_option('robokassa_payment_paymentMethod'); + $current['payment_object'] = get_option('robokassa_payment_paymentObject'); + $current['payment_method'] = get_option('robokassa_payment_paymentMethod'); } if (isset($receipt['sno']) && ($receipt['sno'] == 'osn') || (get_option('robokassa_country_code') == 'KZ')) { @@ -565,7 +561,7 @@ function processRobokassaPayment($order_id, $label) $recurring = false; - if (class_exists('WC_Subscriptions_Order')) { + if (function_exists('wcs_order_contains_subscription')) { $order_subscription = wcs_order_contains_subscription($order_id); if ($order_subscription) { @@ -731,15 +727,11 @@ function robokassa_2check_send($order_id, $old_status, $new_status) $order = new WC_Order($order_id); - if (!$order) { + if (empty($order)) { robokassa_payment_DEBUG("Robokassa: Order not found for order_id: $order_id, exiting function"); return; } - /* if ($order->get_payment_method_title() != get_option('RobokassaOrderPageTitle_all')) { - robokassa_payment_DEBUG("Payment method title does not match: " . $order->get_payment_method_title() . get_option('RobokassaOrderPageTitle_all') . ", exiting function"); - return; - }*/ /** @var array $fields */ $fields = [ @@ -748,7 +740,7 @@ function robokassa_2check_send($order_id, $old_status, $new_status) 'originId' => $order->get_id(), 'operation' => 'sell', 'sno' => $sno, - 'url' => \urlencode('http://' . $_SERVER['HTTP_HOST']), + 'url' => urlencode('http://' .$_SERVER['HTTP_HOST']), 'total' => $order->get_total(), 'items' => [], 'client' => [ @@ -782,8 +774,6 @@ function robokassa_2check_send($order_id, $old_status, $new_status) switch ($tax) { case "vat0": - $fields['vats'][] = ['type' => $tax, 'sum' => 0]; - break; case "none": $fields['vats'][] = ['type' => $tax, 'sum' => 0]; break; @@ -812,7 +802,7 @@ function robokassa_2check_send($order_id, $old_status, $new_status) 'quantity' => 1, 'cost' => $additional_item_total, 'sum' => $additional_item_total, - 'payment_object' => \get_option('robokassa_payment_paymentObject'), + 'payment_object' => get_option('robokassa_payment_paymentObject'), 'payment_method' => 'full_payment', 'tax' => $tax, ); @@ -820,10 +810,8 @@ function robokassa_2check_send($order_id, $old_status, $new_status) $fields['items'][] = $products_items; switch ($tax) { - case "vat0": - $fields['vats'][] = ['type' => $tax, 'sum' => 0]; - break; case "none": + case "vat0": $fields['vats'][] = ['type' => $tax, 'sum' => 0]; break; case "vat10": @@ -880,7 +868,7 @@ function robokassa_2check_send($order_id, $old_status, $new_status) /** @var string $startupHash */ $startupHash = formatSignFinish( - \base64_encode( + base64_encode( formatSignReplace( json_encode($fields) ) @@ -899,8 +887,8 @@ function robokassa_2check_send($order_id, $old_status, $new_status) /** @var string $sign */ $sign = formatSignFinish( - \base64_encode( - \md5( + base64_encode( + md5( $startupHash . ($pass1) ) @@ -950,8 +938,8 @@ function robokassa_hold_confirm($order_id, $old_status, $new_status, $order) 'quantity' => $item_quantity, 'sum' => $item_sum, 'tax' => get_option('robokassa_payment_tax'), - 'payment_method' => \get_option('robokassa_payment_paymentMethod'), - 'payment_object' => \get_option('robokassa_payment_paymentObject'), + 'payment_method' => get_option('robokassa_payment_paymentMethod'), + 'payment_object' => get_option('robokassa_payment_paymentObject'), ); } From b61387d96779c44751fd49e5bfd2952d1941e51c Mon Sep 17 00:00:00 2001 From: Aleksei Date: Sat, 21 Sep 2024 13:10:19 +0300 Subject: [PATCH 3/7] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BF=D0=B5=D1=80=D0=B5=D1=80=D0=B0=D1=81=D1=87=D0=B5?= =?UTF-8?q?=D1=82=20=D0=BA=D0=BE=D1=80=D0=B7=D0=B8=D0=BD=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/robokassa_DEBUG.txt | 232 --------------------------------------- wp_robokassa.php | 9 +- 2 files changed, 4 insertions(+), 237 deletions(-) diff --git a/data/robokassa_DEBUG.txt b/data/robokassa_DEBUG.txt index fb15e48..e69de29 100644 --- a/data/robokassa_DEBUG.txt +++ b/data/robokassa_DEBUG.txt @@ -1,232 +0,0 @@ -05.07.2019 15:24:21 (1562329461) : paytype = false -05.07.2019 15:24:21 (1562329461) : sum = 181.00 -05.07.2019 15:24:29 (1562329469) : paytype = false -05.07.2019 15:24:29 (1562329469) : sum = 181.00 -05.07.2019 15:50:41 (1562331041) : paytype = false -05.07.2019 15:50:41 (1562331041) : sum = 91.00 -05.07.2019 15:50:48 (1562331048) : paytype = false -05.07.2019 15:50:48 (1562331048) : sum = 91.00 -05.07.2019 15:51:03 (1562331063) : paytype = false -05.07.2019 15:51:03 (1562331063) : sum = 91.00 -05.07.2019 15:51:23 (1562331083) : paytype = false -05.07.2019 15:51:23 (1562331083) : sum = 91.00 -05.07.2019 15:51:27 (1562331087) : paytype = false -05.07.2019 15:51:27 (1562331087) : sum = 91.00 -27.07.2019 13:46:00 (1564224360) : paytype = false -27.07.2019 13:46:00 (1564224360) : sum = 201.09 -27.07.2019 13:46:26 (1564224386) : paytype = false -27.07.2019 13:46:26 (1564224386) : sum = 325.80 -27.07.2019 13:51:11 (1564224671) : paytype = false -27.07.2019 13:51:11 (1564224671) : sum = 487.80 -27.07.2019 13:52:00 (1564224720) : paytype = false -27.07.2019 13:52:00 (1564224720) : sum = 487.80 -27.07.2019 13:52:21 (1564224741) : paytype = false -27.07.2019 13:52:21 (1564224741) : sum = 487.80 -27.07.2019 14:44:49 (1564227889) : paytype = false -27.07.2019 14:44:49 (1564227889) : sum = 163.80 -27.07.2019 14:44:55 (1564227895) : paytype = false -27.07.2019 14:44:55 (1564227895) : sum = 163.80 -27.07.2019 14:45:19 (1564227919) : paytype = false -27.07.2019 14:45:19 (1564227919) : sum = 163.80 -27.07.2019 14:45:24 (1564227924) : paytype = false -27.07.2019 14:45:24 (1564227924) : sum = 163.80 -27.07.2019 15:26:23 (1564230383) : paytype = false -27.07.2019 15:26:23 (1564230383) : sum = 91.00 -27.07.2019 15:26:30 (1564230390) : paytype = false -27.07.2019 15:26:30 (1564230390) : sum = 91.00 -27.07.2019 15:26:32 (1564230392) : paytype = false -27.07.2019 15:26:32 (1564230392) : sum = 91.00 -27.07.2019 15:27:10 (1564230430) : paytype = false -27.07.2019 15:27:10 (1564230430) : sum = 91.00 -27.07.2019 15:29:12 (1564230552) : who_commission = client -27.07.2019 15:29:12 (1564230552) : sum = 91.00 -27.07.2019 15:29:18 (1564230558) : who_commission = client -27.07.2019 15:29:18 (1564230558) : sum = 91.00 -27.07.2019 15:30:00 (1564230600) : who_commisson = both -27.07.2019 15:30:00 (1564230600) : aCommission = 0.5 -27.07.2019 15:30:00 (1564230600) : commission = 0 -27.07.2019 15:30:00 (1564230600) : incSum = 91.00 -27.07.2019 15:30:00 (1564230600) : commission = 0 -27.07.2019 15:30:00 (1564230600) : sum = 91.00 -27.07.2019 15:30:22 (1564230622) : who_commisson = both -27.07.2019 15:30:22 (1564230622) : aCommission = 0.5 -27.07.2019 15:30:22 (1564230622) : commission = 0 -27.07.2019 15:30:22 (1564230622) : incSum = 91.00 -27.07.2019 15:30:22 (1564230622) : commission = 0 -27.07.2019 15:30:24 (1564230624) : sum = 91.00 -27.07.2019 15:30:59 (1564230659) : who_commisson = shop -27.07.2019 15:30:59 (1564230659) : commission = 0 -27.07.2019 15:30:59 (1564230659) : incSum = 91.00 -27.07.2019 15:30:59 (1564230659) : commission = 0 -27.07.2019 15:31:00 (1564230660) : sum = 91.00 -27.07.2019 15:31:06 (1564230666) : who_commisson = shop -27.07.2019 15:31:06 (1564230666) : commission = 0 -27.07.2019 15:31:06 (1564230666) : incSum = 91.00 -27.07.2019 15:31:06 (1564230666) : commission = 0 -27.07.2019 15:31:07 (1564230667) : sum = 91.00 -20.02.2021 18:35:11 (1613835311) : paytype = false -20.02.2021 18:35:11 (1613835311) : sum = 1.00 -20.02.2021 18:36:36 (1613835396) : paytype = false -20.02.2021 18:36:36 (1613835396) : sum = 5.00 -20.02.2021 18:47:35 (1613836055) : paytype = false -20.02.2021 18:47:35 (1613836055) : sum = 5.00 -20.02.2021 18:49:02 (1613836142) : paytype = false -20.02.2021 18:49:02 (1613836142) : sum = 5.00 -20.02.2021 19:11:35 (1613837495) : paytype = false -20.02.2021 19:11:35 (1613837495) : sum = 5.00 -20.02.2021 19:12:42 (1613837562) : paytype = false -20.02.2021 19:12:42 (1613837562) : sum = 5.00 -20.02.2021 19:16:35 (1613837795) : paytype = false -20.02.2021 19:16:35 (1613837795) : sum = 5.00 -20.02.2021 19:17:27 (1613837847) : paytype = false -20.02.2021 19:17:27 (1613837847) : sum = 5.00 -20.02.2021 19:17:40 (1613837860) : paytype = false -20.02.2021 19:17:40 (1613837860) : sum = 5.00 -20.02.2021 19:22:48 (1613838168) : paytype = false -20.02.2021 19:22:48 (1613838168) : sum = 5.00 -20.02.2021 19:27:03 (1613838423) : paytype = false -20.02.2021 19:27:03 (1613838423) : sum = 5.00 -20.02.2021 19:27:13 (1613838433) : paytype = false -20.02.2021 19:27:13 (1613838433) : sum = 5.00 -20.02.2021 19:32:55 (1613838775) : paytype = false -20.02.2021 19:32:55 (1613838775) : sum = 5.00 -20.02.2021 19:35:15 (1613838915) : paytype = false -20.02.2021 19:35:15 (1613838915) : sum = 5.00 -20.02.2021 19:40:22 (1613839222) : paytype = false -20.02.2021 19:40:22 (1613839222) : sum = 5.00 -20.02.2021 19:45:00 (1613839500) : paytype = false -20.02.2021 19:45:00 (1613839500) : sum = 5.00 -20.02.2021 19:49:27 (1613839767) : paytype = false -20.02.2021 19:49:27 (1613839767) : sum = 5.00 -20.02.2021 19:50:17 (1613839817) : paytype = false -20.02.2021 19:50:17 (1613839817) : sum = 5.00 -22.02.2021 19:14:02 (1614010442) : paytype = false -22.02.2021 19:14:02 (1614010442) : sum = 10.00 -22.02.2021 19:15:19 (1614010519) : paytype = false -22.02.2021 19:15:19 (1614010519) : sum = 10.00 -22.02.2021 19:16:09 (1614010569) : paytype = false -22.02.2021 19:16:09 (1614010569) : sum = 10.00 -22.02.2021 19:56:07 (1614012967) : paytype = false -22.02.2021 19:56:07 (1614012967) : sum = 5.00 -22.02.2021 19:57:04 (1614013024) : paytype = false -22.02.2021 19:57:04 (1614013024) : sum = 5.00 -22.02.2021 19:58:01 (1614013081) : paytype = false -22.02.2021 19:58:01 (1614013081) : sum = 5.00 -22.02.2021 19:59:17 (1614013157) : paytype = false -22.02.2021 19:59:17 (1614013157) : sum = 5.00 -22.02.2021 20:02:20 (1614013340) : paytype = false -22.02.2021 20:02:20 (1614013340) : sum = 5.00 -22.02.2021 20:04:14 (1614013454) : paytype = false -22.02.2021 20:04:14 (1614013454) : sum = 5.00 -22.02.2021 20:07:55 (1614013675) : paytype = false -22.02.2021 20:07:55 (1614013675) : sum = 5.00 -22.02.2021 20:09:35 (1614013775) : paytype = false -22.02.2021 20:09:35 (1614013775) : sum = 5.00 -22.02.2021 20:12:56 (1614013976) : paytype = false -22.02.2021 20:12:56 (1614013976) : sum = 5.00 -22.02.2021 20:21:13 (1614014473) : paytype = false -22.02.2021 20:21:13 (1614014473) : sum = 5.00 -22.02.2021 20:21:45 (1614014505) : paytype = false -22.02.2021 20:21:45 (1614014505) : sum = 5.00 -22.02.2021 20:23:30 (1614014610) : paytype = false -22.02.2021 20:23:30 (1614014610) : sum = 5.00 -22.02.2021 20:24:16 (1614014656) : paytype = false -22.02.2021 20:24:16 (1614014656) : sum = 5.00 -22.02.2021 20:28:03 (1614014883) : paytype = false -22.02.2021 20:28:03 (1614014883) : sum = 5.00 -22.02.2021 20:28:49 (1614014929) : paytype = false -22.02.2021 20:28:49 (1614014929) : sum = 5.00 -22.02.2021 20:30:32 (1614015032) : paytype = false -22.02.2021 20:30:32 (1614015032) : sum = 5.00 -22.02.2021 20:33:10 (1614015190) : paytype = false -22.02.2021 20:33:10 (1614015190) : sum = 5.00 -22.02.2021 20:33:46 (1614015226) : paytype = false -22.02.2021 20:33:46 (1614015226) : sum = 5.00 -22.02.2021 20:44:01 (1614015841) : paytype = false -22.02.2021 20:44:01 (1614015841) : sum = 5.00 -22.02.2021 21:16:52 (1614017812) : paytype = false -22.02.2021 21:16:52 (1614017812) : sum = 5.00 -22.02.2021 21:16:57 (1614017817) : paytype = false -22.02.2021 21:16:57 (1614017817) : sum = 5.00 -22.02.2021 21:17:34 (1614017854) : paytype = false -22.02.2021 21:17:34 (1614017854) : sum = 5.00 -22.02.2021 21:19:46 (1614017986) : paytype = false -22.02.2021 21:19:46 (1614017986) : sum = 5.00 -22.02.2021 21:20:09 (1614018009) : paytype = false -22.02.2021 21:20:09 (1614018009) : sum = 5.00 -22.02.2021 21:20:19 (1614018019) : paytype = false -22.02.2021 21:20:19 (1614018019) : sum = 5.00 -22.02.2021 21:21:04 (1614018064) : paytype = false -22.02.2021 21:21:04 (1614018064) : sum = 5.00 -22.02.2021 21:21:46 (1614018106) : paytype = false -22.02.2021 21:21:46 (1614018106) : sum = 5.00 -22.02.2021 21:22:42 (1614018162) : paytype = false -22.02.2021 21:22:42 (1614018162) : sum = 5.00 -22.02.2021 22:26:36 (1614021996) : paytype = false -22.02.2021 22:26:36 (1614021996) : sum = 5.00 -22.02.2021 22:32:57 (1614022377) : paytype = false -22.02.2021 22:32:57 (1614022377) : sum = 5.00 -22.02.2021 22:39:05 (1614022745) : paytype = false -22.02.2021 22:39:05 (1614022745) : sum = 5.00 -22.02.2021 22:39:48 (1614022788) : paytype = false -22.02.2021 22:39:48 (1614022788) : sum = 5.00 -22.02.2021 22:40:25 (1614022825) : paytype = false -22.02.2021 22:40:25 (1614022825) : sum = 5.00 -22.02.2021 22:40:59 (1614022859) : paytype = false -22.02.2021 22:40:59 (1614022859) : sum = 5.00 -22.02.2021 22:41:36 (1614022896) : paytype = false -22.02.2021 22:41:36 (1614022896) : sum = 5.00 -22.02.2021 22:46:02 (1614023162) : paytype = false -22.02.2021 22:46:02 (1614023162) : sum = 5.00 -22.02.2021 22:46:28 (1614023188) : paytype = false -22.02.2021 22:46:28 (1614023188) : sum = 5.00 -22.02.2021 22:50:03 (1614023403) : paytype = false -22.02.2021 22:50:03 (1614023403) : sum = 5.00 -22.02.2021 22:50:39 (1614023439) : paytype = false -22.02.2021 22:50:39 (1614023439) : sum = 5.00 -22.02.2021 22:51:54 (1614023514) : paytype = false -22.02.2021 22:51:54 (1614023514) : sum = 5.00 -22.02.2021 22:52:43 (1614023563) : paytype = false -22.02.2021 22:52:43 (1614023563) : sum = 5.00 -22.02.2021 22:53:45 (1614023625) : paytype = false -22.02.2021 22:53:45 (1614023625) : sum = 5.00 -22.02.2021 22:56:06 (1614023766) : paytype = false -22.02.2021 22:56:06 (1614023766) : sum = 5.00 -22.02.2021 22:56:25 (1614023785) : paytype = false -22.02.2021 22:56:25 (1614023785) : sum = 5.00 -22.02.2021 22:57:13 (1614023833) : paytype = false -22.02.2021 22:57:13 (1614023833) : sum = 5.00 -22.02.2021 22:57:55 (1614023875) : paytype = false -22.02.2021 22:57:55 (1614023875) : sum = 5.00 -22.02.2021 22:58:12 (1614023892) : paytype = false -22.02.2021 22:58:12 (1614023892) : sum = 5.00 -22.02.2021 22:58:51 (1614023931) : paytype = false -22.02.2021 22:58:51 (1614023931) : sum = 5.00 -22.02.2021 23:03:42 (1614024222) : paytype = false -22.02.2021 23:03:42 (1614024222) : sum = 115.00 -22.02.2021 23:06:13 (1614024373) : paytype = false -22.02.2021 23:06:13 (1614024373) : sum = 115.00 -22.02.2021 23:07:13 (1614024433) : paytype = false -22.02.2021 23:07:13 (1614024433) : sum = 115.00 -22.02.2021 23:22:26 (1614025346) : paytype = false -22.02.2021 23:22:26 (1614025346) : sum = 115.00 -22.02.2021 23:23:19 (1614025399) : paytype = false -22.02.2021 23:23:19 (1614025399) : sum = 115.00 -22.02.2021 23:24:00 (1614025440) : paytype = false -22.02.2021 23:24:00 (1614025440) : sum = 115.00 -22.02.2021 23:30:54 (1614025854) : paytype = false -22.02.2021 23:30:54 (1614025854) : sum = 115.00 -22.02.2021 23:31:05 (1614025865) : paytype = false -22.02.2021 23:31:05 (1614025865) : sum = 115.00 -12.04.2021 16:02:24 (1618232544) : paytype = false -12.04.2021 16:02:24 (1618232544) : sum = 105.00 -12.04.2021 16:02:47 (1618232567) : paytype = false -12.04.2021 16:02:47 (1618232567) : sum = 105.00 -12.04.2021 16:04:29 (1618232669) : paytype = false -12.04.2021 16:04:29 (1618232669) : sum = 105.00 -12.04.2021 16:04:41 (1618232681) : paytype = false -12.04.2021 16:04:41 (1618232681) : sum = 105.00 -12.04.2021 16:05:24 (1618232724) : paytype = false -12.04.2021 16:05:24 (1618232724) : sum = 106.00 -12.04.2021 16:17:25 (1618233445) : paytype = false -12.04.2021 16:17:25 (1618233445) : sum = 105.00 diff --git a/wp_robokassa.php b/wp_robokassa.php index 4165b9f..4ba2d2e 100644 --- a/wp_robokassa.php +++ b/wp_robokassa.php @@ -412,7 +412,7 @@ function getRobokassaPasses() */ function createRobokassaReceipt($order_id) { - global $woocommerce; + $order = new WC_Order($order_id); $sno = get_option('robokassa_payment_sno'); @@ -423,14 +423,15 @@ function createRobokassaReceipt($order_id) $tax = get_option('robokassa_payment_tax'); if ($tax == "vat118") $tax = "vat120"; - $cart = $woocommerce->cart->get_cart(); + $cart = WC()->cart; + $cart->calculate_totals(); $receipt = array(); $total_order = $order->get_total(); // Сумма OutSum $total_receipt = 0; // Сумма всех $current['sum'] - foreach ($cart as $item) { + foreach ($cart->get_cart_contents() as $item) { $product = wc_get_product($item['product_id']); $quantity = (float)$item['quantity']; @@ -480,7 +481,6 @@ function createRobokassaReceipt($order_id) } if (empty($receipt)) { - foreach ($order->get_items() as $item) { $product = $item->get_product(); @@ -503,7 +503,6 @@ function createRobokassaReceipt($order_id) $receipt['items'][] = $current; $total_receipt += $current['sum']; } - } if ((double)$order->get_shipping_total() > 0) { From 7b11238a4e0d1f731d44f965a4aa0c0952a0b376 Mon Sep 17 00:00:00 2001 From: Aleksei Date: Mon, 23 Sep 2024 16:11:53 +0300 Subject: [PATCH 4/7] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82?= =?UTF-8?q?=D1=80=D1=8B=20=D0=B7=D0=B0=D0=BF=D1=80=D0=BE=D1=81=D0=B0=20?= =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20?= =?UTF-8?q?=D1=81=D0=BE=D0=B2=D0=BC=D0=B5=D1=81=D1=82=D0=B8=D0=BC=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D1=8C=20=D0=B2=D0=B8=D0=B4=D0=B6=D0=B5=D1=82=D0=B0?= =?UTF-8?q?=20=D1=81=20PHP=208.1+?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- payment-widget.php | 129 ++++++++++++++++++++------------------------- wp_robokassa.php | 12 ++--- 2 files changed, 63 insertions(+), 78 deletions(-) diff --git a/payment-widget.php b/payment-widget.php index 1dcc495..faeb476 100644 --- a/payment-widget.php +++ b/payment-widget.php @@ -1,15 +1,18 @@ get_price(); $product_id = $product->get_id(); - setlocale(LC_TIME, 'ru_RU.UTF-8'); - $podeli_2w_date = strftime('%d %b', strtotime('+2 weeks')); - $podeli_4w_date = strftime('%d %b', strtotime('+4 weeks')); - $podeli_6w_date = strftime('%d %b', strtotime('+6 weeks')); + $podeli_2w_date = wp_date('%d %b', strtotime('+2 weeks')); + $podeli_4w_date = wp_date('%d %b', strtotime('+4 weeks')); + $podeli_6w_date = wp_date('%d %b', strtotime('+6 weeks')); if (get_option('robokassa_payment_podeli_widget_onoff') === 'true' && $price > 300 && $price < 35000) { if (get_option('robokassa_podeli_widget_style') == 0) { @@ -673,24 +676,14 @@ function payment_cart_widget() return; } - global $woocommerce; - - if (!isset($woocommerce->cart)) { + $cart = WC()->cart; + if (empty($cart) || $cart->get_total() <= 0) { return; } - $cart = $woocommerce->cart; - - if ($cart) { - $price = $cart->get_total(); - $price = preg_replace('/[^\d.,]/', '', $price); - $price = number_format(floatval(str_replace(',', '.', $price)), 2, '.', ''); - } - - setlocale(LC_TIME, 'ru_RU.UTF-8'); - $podeli_2w_date = strftime('%d %b', strtotime('+2 weeks')); - $podeli_4w_date = strftime('%d %b', strtotime('+4 weeks')); - $podeli_6w_date = strftime('%d %b', strtotime('+6 weeks')); + $price = $cart->get_total(); + $price = preg_replace('/[^\d.,]/', '', $price); + $price = number_format(floatval(str_replace(',', '.', $price)), 2, '.', ''); if (get_option('robokassa_payment_podeli_widget_onoff') === 'true' && $price > 300 && $price < 35000) { echo ' @@ -787,24 +780,19 @@ function podeli_checkout_widget() return; } - global $woocommerce; - - if (!isset($woocommerce->cart)) { + $cart = WC()->cart; + if (empty($cart) || $cart->get_total() <= 0) { return; } - $cart = $woocommerce->cart; + $price = $cart->get_total(); + $price = preg_replace('/[^\d.,]/', '', $price); + $price = number_format(floatval(str_replace(',', '.', $price)), 2, '.', ''); - if ($cart) { - $price = $cart->get_total(); - $price = preg_replace('/[^\d.,]/', '', $price); - $price = number_format(floatval(str_replace(',', '.', $price)), 2, '.', ''); - } - setlocale(LC_TIME, 'ru_RU.UTF-8'); - $podeli_2w_date = strftime('%d %b', strtotime('+2 weeks')); - $podeli_4w_date = strftime('%d %b', strtotime('+4 weeks')); - $podeli_6w_date = strftime('%d %b', strtotime('+6 weeks')); + $podeli_2w_date = wp_date('%d %b', strtotime('+2 weeks')); + $podeli_4w_date = wp_date('%d %b', strtotime('+4 weeks')); + $podeli_6w_date = wp_date('%d %b', strtotime('+6 weeks')); if (get_option('robokassa_payment_podeli_widget_onoff') === 'true' && $price > 300 && $price < 35000) { echo ' @@ -862,19 +850,15 @@ function credit_checkout_widget() return; } - global $woocommerce; - - if (!isset($woocommerce->cart)) { + $cart = WC()->cart; + if (empty($cart) || $cart->get_total() <= 0) { return; } - $cart = $woocommerce->cart; + $price = $cart->get_total(); + $price = preg_replace('/[^\d.,]/', '', $price); + $price = number_format(floatval(str_replace(',', '.', $price)), 2, '.', ''); - if ($cart) { - $price = $cart->get_total(); - $price = preg_replace('/[^\d.,]/', '', $price); - $price = number_format(floatval(str_replace(',', '.', $price)), 2, '.', ''); - } $monthlyInterestRate = 0.02333; // Месячная процентная ставка (2,333% в десятичной форме) $months = 23; // Количество месяцев @@ -883,37 +867,40 @@ function credit_checkout_widget() $monthlyPayment = round($monthlyPayment); if (get_option('robokassa_payment_podeli_widget_onoff') === 'true' && $price > 300 && $price < 35000) { - echo ' -
-
-
- - - - - - - - - - - + ?> +
+
+
+ + + + + + + + + + + -
-
-
- Кредит или рассрочка от ' . $monthlyPayment . ' ₽/мес -
-

- Индивидуальные условия по кредиту
или рассрочке для вас -

-
+
+
+
+ Кредит или рассрочка от ' . $monthlyPayment . ' ₽/мес +
+

+ Индивидуальные условия по кредиту
или рассрочке для вас +

- '; +
+ get_title(); $current['quantity'] = $quantity; - $current['sum'] = $item['data']->get_price(); - $current['cost'] = $item['data']->get_price() / $quantity; - + $current['cost'] = $item['data']->get_price(); + $current['sum'] = $item['data']->get_price() * $quantity; $total_receipt += $current['sum']; if (get_option('robokassa_country_code') == 'RU') { @@ -486,10 +485,9 @@ function createRobokassaReceipt($order_id) $product = $item->get_product(); $current['name'] = $product->get_title(); - $current['quantity'] = (float)$item->get_quantity(); - - $current['sum'] = $product->get_price(); - $current['cost'] = $product->get_price() / $current['quantity']; + $current['quantity'] = $item->get_quantity(); + $current['cost'] = $item['data']->get_price(); + $current['sum'] = $item['data']->get_price() * $item->get_quantity(); $current['payment_object'] = get_option('robokassa_payment_paymentObject'); $current['payment_method'] = get_option('robokassa_payment_paymentMethod'); From d4d37386ebfb8ccc793f9888d6489e86fcb41ac1 Mon Sep 17 00:00:00 2001 From: Aleksei Date: Tue, 1 Oct 2024 18:12:28 +0300 Subject: [PATCH 5/7] =?UTF-8?q?=3D=201.1.5.4=20=3D=20-=20=D0=9D=D0=B5?= =?UTF-8?q?=D0=B7=D0=BD=D0=B0=D1=87=D0=B8=D1=82=D0=B5=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D1=8B=D0=B5=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/robokassa_DEBUG.txt | 41 ++++++++++++++++++++++++++++++++++++++++ wp_robokassa.php | 2 +- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/data/robokassa_DEBUG.txt b/data/robokassa_DEBUG.txt index e69de29..3121bd4 100644 --- a/data/robokassa_DEBUG.txt +++ b/data/robokassa_DEBUG.txt @@ -0,0 +1,41 @@ +21.09.2024 20:32:26 (1726939946) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +21.09.2024 21:31:58 (1726943518) : Robokassa: общая сумма чека (1190) НЕ совпадает с общей суммой заказа (1690.00) +21.09.2024 22:11:50 (1726945910) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +21.09.2024 22:35:26 (1726947326) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +21.09.2024 22:35:27 (1726947327) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +22.09.2024 09:29:18 (1726986558) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +22.09.2024 09:29:19 (1726986559) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +22.09.2024 15:51:05 (1727009465) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +22.09.2024 16:11:19 (1727010679) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +22.09.2024 16:32:07 (1727011927) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +22.09.2024 17:59:03 (1727017143) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +23.09.2024 14:17:30 (1727090250) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +23.09.2024 14:53:00 (1727092380) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +23.09.2024 15:13:56 (1727093636) : Robokassa: общая сумма чека (518) НЕ совпадает с общей суммой заказа (623.00) +23.09.2024 15:17:01 (1727093821) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +23.09.2024 15:25:19 (1727094319) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +23.09.2024 15:27:46 (1727094466) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +23.09.2024 15:29:35 (1727094575) : Robokassa: общая сумма чека (518) НЕ совпадает с общей суммой заказа (623.00) +23.09.2024 15:33:31 (1727094811) : Robokassa: общая сумма чека (518) НЕ совпадает с общей суммой заказа (623.00) +23.09.2024 15:34:40 (1727094880) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +23.09.2024 15:36:31 (1727094991) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +23.09.2024 15:40:53 (1727095253) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +23.09.2024 15:45:25 (1727095525) : Robokassa: общая сумма чека (450) НЕ совпадает с общей суммой заказа (315.00) +23.09.2024 15:48:04 (1727095684) : Robokassa: общая сумма чека (150) НЕ совпадает с общей суммой заказа (315.00) +23.09.2024 15:51:52 (1727095912) : Robokassa: общая сумма чека (150) НЕ совпадает с общей суммой заказа (315.00) +23.09.2024 15:54:19 (1727096059) : Robokassa: общая сумма чека (150) НЕ совпадает с общей суммой заказа (315.00) +23.09.2024 16:43:55 (1727099035) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +23.09.2024 17:19:01 (1727101141) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +23.09.2024 17:19:02 (1727101142) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +23.09.2024 19:28:54 (1727108934) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +23.09.2024 19:57:12 (1727110632) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +23.09.2024 20:09:15 (1727111355) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +23.09.2024 20:19:14 (1727111954) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +23.09.2024 21:29:16 (1727116156) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +23.09.2024 21:29:16 (1727116156) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +23.09.2024 21:29:16 (1727116156) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +23.09.2024 21:29:16 (1727116156) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +23.09.2024 21:29:16 (1727116156) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +23.09.2024 21:29:16 (1727116156) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +23.09.2024 21:29:17 (1727116157) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +23.09.2024 21:29:17 (1727116157) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken diff --git a/wp_robokassa.php b/wp_robokassa.php index 99dc577..efee1b1 100644 --- a/wp_robokassa.php +++ b/wp_robokassa.php @@ -238,7 +238,7 @@ function robokassa_payment_wp_robokassa_checkPayment() /** @var string $returner */ $returner = ''; - + $_REQUEST['InvId'] = $_REQUEST['InvId'] ?? 0; if ($_REQUEST['robokassa'] === 'result') { /** @var string $crc_confirm */ From 89d37246b106d0ea54b498ca95b3612bb6f754fe Mon Sep 17 00:00:00 2001 From: Aleksei Date: Sat, 18 Jan 2025 18:35:40 +0300 Subject: [PATCH 6/7] fix page error --- data/robokassa_DEBUG.txt | 48 ++++++++++++++++++++++++++++++++++++++++ main_settings_credit.php | 2 +- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/data/robokassa_DEBUG.txt b/data/robokassa_DEBUG.txt index e69de29..80277d5 100644 --- a/data/robokassa_DEBUG.txt +++ b/data/robokassa_DEBUG.txt @@ -0,0 +1,48 @@ +03.12.2024 22:14:06 (1733253246) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +03.12.2024 22:15:13 (1733253313) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +06.12.2024 14:51:00 (1733485860) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +06.12.2024 14:51:27 (1733485887) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +06.12.2024 15:02:31 (1733486551) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +06.12.2024 23:14:04 (1733516044) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +06.12.2024 23:14:11 (1733516051) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +23.12.2024 16:21:37 (1734960097) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +23.12.2024 16:30:38 (1734960638) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +23.12.2024 16:47:32 (1734961652) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +23.12.2024 17:04:30 (1734962670) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +24.12.2024 13:08:29 (1735034909) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +26.12.2024 18:54:21 (1735228461) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 17:00:54 (1735394454) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 17:02:12 (1735394532) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 20:24:51 (1735406691) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 20:25:59 (1735406759) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 20:29:28 (1735406968) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 20:29:55 (1735406995) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 20:35:51 (1735407351) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 20:39:48 (1735407588) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 20:47:56 (1735408076) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 20:49:59 (1735408199) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 20:56:22 (1735408582) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 20:56:33 (1735408593) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 20:56:43 (1735408603) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 20:56:52 (1735408612) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 20:57:02 (1735408622) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 20:57:12 (1735408632) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 20:57:24 (1735408644) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 20:57:34 (1735408654) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 20:57:44 (1735408664) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 20:57:54 (1735408674) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 20:58:05 (1735408685) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 20:58:07 (1735408687) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 21:00:57 (1735408857) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 21:16:03 (1735409763) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 21:18:47 (1735409927) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 22:15:22 (1735413322) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 22:27:21 (1735414041) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 22:30:59 (1735414259) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 22:34:00 (1735414440) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 22:35:50 (1735414550) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +28.12.2024 22:36:22 (1735414582) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +13.01.2025 19:10:00 (1736784600) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +13.01.2025 19:29:30 (1736785770) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +17.01.2025 16:00:49 (1737118849) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken +17.01.2025 16:44:38 (1737121478) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken diff --git a/main_settings_credit.php b/main_settings_credit.php index fe81d1c..72207f9 100644 --- a/main_settings_credit.php +++ b/main_settings_credit.php @@ -45,7 +45,7 @@ function searchAlias($data, &$show_podeli, &$show_credit) { - foreach ($data as $key => $value) { + foreach ($data ?? [] as $key => $value) { if ($key === 'Alias') { if ($value === 'Podeli') { $show_podeli = true; From 19f08db095cc6d4b35d9579c5040cd9ccb8943a6 Mon Sep 17 00:00:00 2001 From: Aleksei Tikhomirov Date: Thu, 26 Feb 2026 12:03:07 +0300 Subject: [PATCH 7/7] Add filters with order_id for custom receipt generation This PR adds two filters to allow developers to customize receipt generation: 1. `robokassa_receipt_pre` - Called at the start of createRobokassaReceipt(). Return non-null value to bypass default receipt creation. 2. `wc_robokassa_receipt` - Now passes $order_id as second argument. Allows modifying the generated receipt with access to order data. Both filters pass $order_id, enabling: - Custom pricing calculations (discounts, dynamic prices) - Integration with other plugins without core modifications - Access to order data for receipt customization Usage examples: // Pre-filter: complete override add_filter('robokassa_receipt_pre', function($receipt, $order_id) { $order = wc_get_order($order_id); // Custom receipt generation logic return $receipt; }, 10, 2); // Post-filter: modify existing receipt add_filter('wc_robokassa_receipt', function($receipt, $order_id) { $order = wc_get_order($order_id); // Modify receipt items, totals, etc. return $receipt; }, 10, 2); Backward compatible: existing filters without order_id argument will continue to work. --- data/robokassa_DEBUG.txt | 48 ---------------------------------------- wp_robokassa.php | 17 +++++++++++++- 2 files changed, 16 insertions(+), 49 deletions(-) diff --git a/data/robokassa_DEBUG.txt b/data/robokassa_DEBUG.txt index 80277d5..e69de29 100644 --- a/data/robokassa_DEBUG.txt +++ b/data/robokassa_DEBUG.txt @@ -1,48 +0,0 @@ -03.12.2024 22:14:06 (1733253246) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -03.12.2024 22:15:13 (1733253313) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -06.12.2024 14:51:00 (1733485860) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -06.12.2024 14:51:27 (1733485887) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -06.12.2024 15:02:31 (1733486551) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -06.12.2024 23:14:04 (1733516044) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -06.12.2024 23:14:11 (1733516051) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -23.12.2024 16:21:37 (1734960097) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -23.12.2024 16:30:38 (1734960638) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -23.12.2024 16:47:32 (1734961652) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -23.12.2024 17:04:30 (1734962670) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -24.12.2024 13:08:29 (1735034909) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -26.12.2024 18:54:21 (1735228461) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 17:00:54 (1735394454) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 17:02:12 (1735394532) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 20:24:51 (1735406691) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 20:25:59 (1735406759) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 20:29:28 (1735406968) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 20:29:55 (1735406995) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 20:35:51 (1735407351) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 20:39:48 (1735407588) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 20:47:56 (1735408076) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 20:49:59 (1735408199) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 20:56:22 (1735408582) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 20:56:33 (1735408593) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 20:56:43 (1735408603) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 20:56:52 (1735408612) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 20:57:02 (1735408622) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 20:57:12 (1735408632) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 20:57:24 (1735408644) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 20:57:34 (1735408654) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 20:57:44 (1735408664) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 20:57:54 (1735408674) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 20:58:05 (1735408685) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 20:58:07 (1735408687) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 21:00:57 (1735408857) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 21:16:03 (1735409763) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 21:18:47 (1735409927) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 22:15:22 (1735413322) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 22:27:21 (1735414041) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 22:30:59 (1735414259) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 22:34:00 (1735414440) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 22:35:50 (1735414550) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -28.12.2024 22:36:22 (1735414582) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -13.01.2025 19:10:00 (1736784600) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -13.01.2025 19:29:30 (1736785770) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -17.01.2025 16:00:49 (1737118849) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken -17.01.2025 16:44:38 (1737121478) : Robokassa: Payment method is not advance, full_prepayment, or prepayment, no action taken diff --git a/wp_robokassa.php b/wp_robokassa.php index 33f5672..dbc55fe 100644 --- a/wp_robokassa.php +++ b/wp_robokassa.php @@ -618,6 +618,21 @@ function getRobokassaPasses() */ function createRobokassaReceipt($order_id) { + /** + * Filter to allow custom receipt generation. + * Return a non-null value to bypass default receipt creation. + * + * @param array|null $pre_receipt Custom receipt data or null to use default. + * @param int $order_id Order ID. + * + * @since 1.6.6 + */ + $pre_receipt = apply_filters('robokassa_receipt_pre', null, $order_id); + + if ($pre_receipt !== null) { + return $pre_receipt; + } + global $woocommerce; $order = new WC_Order($order_id); @@ -722,7 +737,7 @@ function createRobokassaReceipt($order_id) robokassa_payment_DEBUG('Robokassa: общая сумма чека (' . $total_receipt . ') НЕ совпадает с общей суммой заказа (' . $total_order . ')'); } - return apply_filters('wc_robokassa_receipt', $receipt); + return apply_filters('wc_robokassa_receipt', $receipt, $order_id); } /**