Changeset 3180252
- Timestamp:
- 11/02/2024 07:20:28 AM (17 months ago)
- Location:
- robokassa/trunk
- Files:
-
- 2 added
- 6 edited
-
blocks.js (added)
-
checkout-block.php (added)
-
classes/Robokassa/Payment/RobokassaPayAPI.php (modified) (5 diffs)
-
labelsClasses.php (modified) (3 diffs)
-
main_settings_rb.php (modified) (2 diffs)
-
payment-widget.php (modified) (6 diffs)
-
readme.txt (modified) (1 diff)
-
wp_robokassa.php (modified) (30 diffs)
Legend:
- Unmodified
- Added
- Removed
-
robokassa/trunk/classes/Robokassa/Payment/RobokassaPayAPI.php
r3147422 r3180252 102 102 { 103 103 $outCurrency = get_option('robokassa_out_currency'); 104 $holdPaymentParam = (get_option('robokassa_payment_hold_onoff') == ' true') ? 'true' : '';104 $holdPaymentParam = (get_option('robokassa_payment_hold_onoff') == '1') ? 'true' : ''; 105 105 106 106 return \implode( … … 149 149 150 150 /** 151 * Генерирует форму, в Opencart модуле НЕ ИСПОЛЬЗУЕТСЯ!151 * 152 152 * 153 153 * @param float $sum … … 202 202 ); 203 203 204 if (get_option('robokassa_payment_hold_onoff') == 'true') {204 if (get_option('robokassa_payment_hold_onoff') == 1) { 205 205 $formData['StepByStep'] = 'true'; 206 206 } … … 419 419 420 420 /** 421 * Запрашиват размер комиссии в процентах для конкретного способа оплаты422 *423 * @param string $incCurrLabel Кодовое имя метода оплаты424 * @param int $sum Стоимость товара425 *426 * @return float Комиссия метода в %427 */428 public function getCommission($incCurrLabel, $sum = 10000) {429 if ($incCurrLabel == 'all') {430 $incCurrLabel = '';431 }432 433 $parsed = $this->sendRequest('CalcOutSumm', array(434 'MerchantLogin' => $this->mrh_login,435 'IncCurrLabel' => $incCurrLabel,436 'IncSum' => (int) $sum,437 ));438 439 if($parsed['OutSum'] != 0){440 return abs(round(($sum - $parsed['OutSum']) / $parsed['OutSum'] * 100));441 }else{442 return $sum;443 }444 }445 446 /**447 * Возвращает сумму к оплате с учетом комиссий.448 *449 * @param string $incCurrLabel Кодовое имя метода оплаты450 * @param int $sum Стоимость товара451 *452 * @return float Стоимость, которую необходимо передавать в Робокассу.453 */454 public function getCommissionSum($incCurrLabel, $sum) {455 $parsed = $this->sendRequest('CalcOutSumm', array(456 'MerchantLogin' => $this->mrh_login,457 'IncCurrLabel' => $incCurrLabel,458 'IncSum' => $sum,459 ));460 461 return $parsed['OutSum'];462 }463 464 /**465 421 * Запрашивает и парсит в массив все возможные способы оплаты для данного магазина 466 422 * … … 517 473 'PreviousInvoiceID' => $parentInvoiceId, 518 474 'Description' => '', 519 'SignatureValue' => md5("{$this->mrh_login}:{$amount}:{$invoiceId}:{$receiptJson}:{$this->mrh_pass1}:shp_label=official_wordpress "),475 'SignatureValue' => md5("{$this->mrh_login}:{$amount}:{$invoiceId}:{$receiptJson}:{$this->mrh_pass1}:shp_label=official_wordpress:Shp_merchant_id=" . get_option('robokassa_payment_MerchantLogin') . ":Shp_order_id={$invoiceId}:Shp_result_url=" . site_url('/?robokassa=result')), 520 476 'OutSum' => $amount, 521 477 'shp_label' => 'official_wordpress', 478 'Shp_merchant_id' => get_option('robokassa_payment_MerchantLogin'), 479 'Shp_order_id' => $invoiceId, 480 'Shp_result_url' => site_url('/?robokassa=result'), 522 481 'Receipt' => $receiptJson 523 ], function($val) { return $val !== null; }); 482 ], function($val) { 483 return $val !== null; 484 }); 524 485 525 486 return $data; 526 487 } 527 528 488 } -
robokassa/trunk/labelsClasses.php
r3147067 r3180252 3 3 class payment_robokassa_pay_method_request_all extends \Robokassa\Payment\WC_WP_robokassa { 4 4 public function __construct() { 5 $this->id = ' all';5 $this->id = 'robokassa'; 6 6 $this->method_title = 'Robokassa'; 7 7 $this->long_name = 'Оплата через Robokassa'; … … 14 14 class payment_robokassa_pay_method_request_Podeli extends \Robokassa\Payment\WC_WP_robokassa { 15 15 public function __construct() { 16 $this->id = ' Podeli';16 $this->id = 'robokassa_podeli'; 17 17 $this->method_title = 'Robokassa'; 18 18 $this->long_name='Оплата через Robokassa'; … … 31 31 class payment_robokassa_pay_method_request_Credit extends \Robokassa\Payment\WC_WP_robokassa { 32 32 public function __construct() { 33 $this->id = ' Credit';33 $this->id = 'robokassa_credit'; 34 34 $this->method_title = 'Robokassa'; 35 35 $this->long_name='Оплата через Robokassa'; -
robokassa/trunk/main_settings_rb.php
r3147067 r3180252 136 136 <th scope="row">Заголовок на странице оформления заказа</th> 137 137 <td> 138 <input type="text" name="RobokassaOrderPageTitle_ all"139 value="<?php echo get_option('RobokassaOrderPageTitle_ all'); ?>"/>138 <input type="text" name="RobokassaOrderPageTitle_robokassa" 139 value="<?php echo get_option('RobokassaOrderPageTitle_robokassa'); ?>"/> 140 140 </td> 141 141 </tr> … … 143 143 <th scope="row">Описание на странице оформления заказа</th> 144 144 <td> 145 <input type="text" name="RobokassaOrderPageDescription_ all"146 value="<?php echo get_option('RobokassaOrderPageDescription_ all'); ?>"/>145 <input type="text" name="RobokassaOrderPageDescription_robokassa" 146 value="<?php echo get_option('RobokassaOrderPageDescription_robokassa'); ?>"/> 147 147 </td> 148 148 </tr> -
robokassa/trunk/payment-widget.php
r3147067 r3180252 1 1 <?php 2 3 add_filter('woocommerce_available_payment_gateways', 'select_payment_method'); 4 add_action('woocommerce_single_product_summary', 'payment_product_widget', 25); 5 add_action('woocommerce_proceed_to_checkout', 'payment_cart_widget'); 2 6 3 7 function payment_product_widget() … … 7 11 $product_id = $product->get_id(); 8 12 9 setlocale(LC_TIME, 'ru_RU.UTF-8'); 10 $podeli_2w_date = strftime('%d %b', strtotime('+2 weeks')); 11 $podeli_4w_date = strftime('%d %b', strtotime('+4 weeks')); 12 $podeli_6w_date = strftime('%d %b', strtotime('+6 weeks')); 13 $podeli_2w_date = wp_date('%d %b', strtotime('+2 weeks')); 14 $podeli_4w_date = wp_date('%d %b', strtotime('+4 weeks')); 15 $podeli_6w_date = wp_date('%d %b', strtotime('+6 weeks')); 13 16 14 17 if (get_option('robokassa_payment_podeli_widget_onoff') === 'true' && $price > 300 && $price < 35000) { … … 674 677 } 675 678 676 global $woocommerce; 677 678 if (!isset($woocommerce->cart)) { 679 $cart = WC()->cart; 680 if (empty($cart) || $cart->get_total() <= 0) { 679 681 return; 680 682 } 681 683 682 $cart = $woocommerce->cart; 683 684 if ($cart) { 685 $price = $cart->get_total(); 686 $price = preg_replace('/[^\d.,]/', '', $price); 687 $price = number_format(floatval(str_replace(',', '.', $price)), 2, '.', ''); 688 } 689 690 setlocale(LC_TIME, 'ru_RU.UTF-8'); 691 $podeli_2w_date = strftime('%d %b', strtotime('+2 weeks')); 692 $podeli_4w_date = strftime('%d %b', strtotime('+4 weeks')); 693 $podeli_6w_date = strftime('%d %b', strtotime('+6 weeks')); 684 $price = $cart->get_total(); 685 $price = preg_replace('/[^\d.,]/', '', $price); 686 $price = number_format(floatval(str_replace(',', '.', $price)), 2, '.', ''); 694 687 695 688 if (get_option('robokassa_payment_podeli_widget_onoff') === 'true' && $price > 300 && $price < 35000) { … … 788 781 } 789 782 790 global $woocommerce; 791 792 if (!isset($woocommerce->cart)) { 783 $cart = WC()->cart; 784 if (empty($cart) || $cart->get_total() <= 0) { 793 785 return; 794 786 } 795 787 796 $cart = $woocommerce->cart; 797 798 if ($cart) { 799 $price = $cart->get_total(); 800 $price = preg_replace('/[^\d.,]/', '', $price); 801 $price = number_format(floatval(str_replace(',', '.', $price)), 2, '.', ''); 802 } 803 804 setlocale(LC_TIME, 'ru_RU.UTF-8'); 805 $podeli_2w_date = strftime('%d %b', strtotime('+2 weeks')); 806 $podeli_4w_date = strftime('%d %b', strtotime('+4 weeks')); 807 $podeli_6w_date = strftime('%d %b', strtotime('+6 weeks')); 788 $price = $cart->get_total(); 789 $price = preg_replace('/[^\d.,]/', '', $price); 790 $price = number_format(floatval(str_replace(',', '.', $price)), 2, '.', ''); 791 792 793 $podeli_2w_date = wp_date('%d %b', strtotime('+2 weeks')); 794 $podeli_4w_date = wp_date('%d %b', strtotime('+4 weeks')); 795 $podeli_6w_date = wp_date('%d %b', strtotime('+6 weeks')); 808 796 809 797 if (get_option('robokassa_payment_podeli_widget_onoff') === 'true' && $price > 300 && $price < 35000) { … … 863 851 } 864 852 865 global $woocommerce; 866 867 if (!isset($woocommerce->cart)) { 853 $cart = WC()->cart; 854 if (empty($cart) || $cart->get_total() <= 0) { 868 855 return; 869 856 } 870 857 871 $cart = $woocommerce->cart; 872 873 if ($cart) { 874 $price = $cart->get_total(); 875 $price = preg_replace('/[^\d.,]/', '', $price); 876 $price = number_format(floatval(str_replace(',', '.', $price)), 2, '.', ''); 877 } 858 $price = $cart->get_total(); 859 $price = preg_replace('/[^\d.,]/', '', $price); 860 $price = number_format(floatval(str_replace(',', '.', $price)), 2, '.', ''); 861 878 862 $monthlyInterestRate = 0.02333; // Месячная процентная ставка (2,333% в десятичной форме) 879 863 $months = 23; // Количество месяцев … … 884 868 885 869 if (get_option('robokassa_payment_podeli_widget_onoff') === 'true' && $price > 300 && $price < 35000) { 886 echo ' 887 <div class="wiget-block" style="margin-bottom: 0px"> 888 <div class="wiget-block__content"> 889 <div class="wiget-action-button__icons podeli-action-button__icons_v2"> 890 <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> 891 <rect width="24" height="24" rx="12" fill="white"></rect> 892 <path d="M4.5 5V19H18.5L4.5 5Z" fill="#FF5722"></path> 893 <path d="M18.5 5H4.5V19L18.5 5Z" fill="#023D5E"></path> 894 </svg> 895 <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> 896 <rect width="24" height="24" rx="12" fill="#CDFC68"></rect> 897 <path fill-rule="evenodd" clip-rule="evenodd" d="M4 12C4 7.61042 7.55556 4.09876 12 4.09876V6.9276C9.1358 6.9276 6.8642 9.17116 6.8642 12C6.8642 14.8288 9.1358 17.0724 12 17.0724C14.7654 17.0724 17.1358 14.8288 17.1358 12H20C20 16.3896 16.4444 19.9012 12 19.9012C7.55556 19.9012 4 16.3896 4 12Z" fill="#222222"></path> 898 <path d="M8.44446 12C8.44446 10.049 10.0247 8.4883 12 8.4883C13.9753 8.4883 15.5556 10.049 15.5556 12C15.5556 13.9509 13.9753 15.5116 12 15.5116C10.0247 15.5116 8.44446 13.9509 8.44446 12Z" fill="#222222"></path> 899 <path d="M14.4692 7.51297C14.4692 6.43996 15.3581 5.4645 16.5433 5.4645C17.6297 5.4645 18.6173 6.34242 18.6173 7.51297C18.6173 8.58598 17.7284 9.56144 16.5433 9.56144C15.3581 9.56144 14.4692 8.68352 14.4692 7.51297Z" fill="#222222"></path> 900 </svg> 901 902 </div> 903 <div class="wiget-block__title-subtitle"> 904 <h5 class="wiget-block__title"> 905 <span class="wiget-block__months">Кредит или рассрочка от </span><span class="wiget-block__payment">' . $monthlyPayment . '</span> ₽/мес 906 </h5> 907 <p class="wiget-block__subtitle"> 908 Индивидуальные условия по кредиту<br>или рассрочке для вас 909 </p> 910 </div> 911 </div> 912 </div> 913 '; 870 ?> 871 <div class="wiget-block" style="margin-bottom: 0px"> 872 <div class="wiget-block__content"> 873 <div class="wiget-action-button__icons podeli-action-button__icons_v2"> 874 <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> 875 <rect width="24" height="24" rx="12" fill="white"></rect> 876 <path d="M4.5 5V19H18.5L4.5 5Z" fill="#FF5722"></path> 877 <path d="M18.5 5H4.5V19L18.5 5Z" fill="#023D5E"></path> 878 </svg> 879 <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> 880 <rect width="24" height="24" rx="12" fill="#CDFC68"></rect> 881 <path fill-rule="evenodd" clip-rule="evenodd" 882 d="M4 12C4 7.61042 7.55556 4.09876 12 4.09876V6.9276C9.1358 6.9276 6.8642 9.17116 6.8642 12C6.8642 14.8288 9.1358 17.0724 12 17.0724C14.7654 17.0724 17.1358 14.8288 17.1358 12H20C20 16.3896 16.4444 19.9012 12 19.9012C7.55556 19.9012 4 16.3896 4 12Z" 883 fill="#222222"></path> 884 <path 885 d="M8.44446 12C8.44446 10.049 10.0247 8.4883 12 8.4883C13.9753 8.4883 15.5556 10.049 15.5556 12C15.5556 13.9509 13.9753 15.5116 12 15.5116C10.0247 15.5116 8.44446 13.9509 8.44446 12Z" 886 fill="#222222"></path> 887 <path 888 d="M14.4692 7.51297C14.4692 6.43996 15.3581 5.4645 16.5433 5.4645C17.6297 5.4645 18.6173 6.34242 18.6173 7.51297C18.6173 8.58598 17.7284 9.56144 16.5433 9.56144C15.3581 9.56144 14.4692 8.68352 14.4692 7.51297Z" 889 fill="#222222"></path> 890 </svg> 891 892 </div> 893 <div class="wiget-block__title-subtitle"> 894 <h5 class="wiget-block__title"> 895 <span class="wiget-block__months">Кредит или рассрочка от </span><span 896 class="wiget-block__payment">' . $monthlyPayment . '</span> ₽/мес 897 </h5> 898 <p class="wiget-block__subtitle"> 899 Индивидуальные условия по кредиту<br>или рассрочке для вас 900 </p> 901 </div> 902 </div> 903 </div> 904 <?php 914 905 } 915 906 } 916 917 add_filter('woocommerce_available_payment_gateways', 'select_payment_method');918 add_action('woocommerce_single_product_summary', 'payment_product_widget', 25);919 add_action('woocommerce_proceed_to_checkout', 'payment_cart_widget'); -
robokassa/trunk/readme.txt
r3147067 r3180252 2 2 Tags: robokassa payment gateway, robokassa, robokassa woocommerce, ecommerce, payment gateway, woo-commerce, woocommerce === 3 3 Requires at least: 5.7 4 Tested up to: 6.6. 15 Stable tag: 1.6. 24 Tested up to: 6.6.2 5 Stable tag: 1.6.3 6 6 Requires PHP: 7.4 7 7 License: GPLv2 or later -
robokassa/trunk/wp_robokassa.php
r3147067 r3180252 6 6 * Author: Robokassa 7 7 * Author URI: https://robokassa.com 8 * Version: 1.6. 28 * Version: 1.6.3 9 9 */ 10 10 … … 14 14 use Robokassa\Payment\RobokassaPayAPI; 15 15 use Robokassa\Payment\RobokassaSms; 16 16 use Automattic\WooCommerce\Utilities\OrderUtil; 17 use Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry; 17 18 18 19 add_action('wp_enqueue_scripts', function () { 19 \wp_enqueue_style(20 wp_enqueue_style( 20 21 'robokassa_payment_admin_style_menu', 21 \plugin_dir_url(__FILE__) . 'assets/css/menu.css'22 plugin_dir_url(__FILE__) . 'assets/css/menu.css' 22 23 ); 23 24 24 \wp_enqueue_style(25 wp_enqueue_style( 25 26 'robokassa_payment_admin_style_main', 26 \plugin_dir_url(__FILE__) . 'assets/css/main.css'27 plugin_dir_url(__FILE__) . 'assets/css/main.css' 27 28 ); 28 29 29 \wp_enqueue_style(30 wp_enqueue_style( 30 31 'robokassa_payment_podeli', 31 \plugin_dir_url(__FILE__) . 'assets/css/payment_styles.css'32 plugin_dir_url(__FILE__) . 'assets/css/payment_styles.css' 32 33 ); 33 \wp_enqueue_script(34 wp_enqueue_script( 34 35 'robokassa_payment_admin_config', 35 \plugin_dir_url(__FILE__) . 'assets/js/payment_widget.js'36 plugin_dir_url(__FILE__) . 'assets/js/payment_widget.js' 36 37 ); 37 38 }); … … 39 40 define('ROBOKASSA_PAYMENT_DEBUG_STATUS', false); 40 41 41 \spl_autoload_register(42 spl_autoload_register( 42 43 function ($className) { 43 $file = __DIR__ . '/classes/' . \str_replace('\\', '/', $className) . '.php';44 $file = __DIR__ . '/classes/' . str_replace('\\', '/', $className) . '.php'; 44 45 45 46 if (file_exists($file)) … … 100 101 add_action('robokassa_cancel_payment_event', 'robokassa_hold_cancel_after5', 10, 1); 101 102 102 103 103 register_activation_hook(__FILE__, 'robokassa_payment_wp_robokassa_activate'); //Хук при активации плагина. Дефолтовые настройки и таблица в БД для СМС. 104 104 … … 129 129 $file = __DIR__ . '/data/robokassa_DEBUG.txt'; 130 130 131 $time = \time();132 $DEBUGFile = \fopen($file, 'a+');133 fwrite($DEBUGFile, \date('d.m.Y H:i:s', $time + 10800) . " ($time) : $str\r\n");131 $time = time(); 132 $DEBUGFile = fopen($file, 'a+'); 133 fwrite($DEBUGFile, date('d.m.Y H:i:s', $time + 10800) . " ($time) : $str\r\n"); 134 134 fclose($DEBUGFile); 135 135 } … … 247 247 248 248 /** @var string $crc_confirm */ 249 $crc_confirm = \strtoupper(250 \md5(249 $crc_confirm = strtoupper( 250 md5( 251 251 implode( 252 252 ':', … … 284 284 foreach ($subscriptions as $subscription) { 285 285 $subscription->update_status('active'); 286 } ;286 } 287 287 } 288 288 } … … 347 347 } 348 348 } else { 349 $order = new WC_Order($_REQUEST['InvId']);350 $order->add_order_note('Bad CRC '. $crc_confirm .' . '. $_REQUEST['SignatureValue']);351 $order->update_status('failed');352 353 349 $returner = 'BAD SIGN'; 350 351 try { 352 $order = new WC_Order($_REQUEST['InvId']); 353 $order->add_order_note('Bad CRC '. $crc_confirm .' . '. $_REQUEST['SignatureValue']); 354 $order->update_status('failed'); 355 } catch (Exception $e) {} 354 356 } 355 357 } … … 372 374 function formatSignReplace($string) 373 375 { 374 return \strtr(376 return strtr( 375 377 $string, 376 378 [ … … 384 386 function formatSignFinish($string) 385 387 { 386 return \preg_replace('/^(.*?)(=*)$/', '$1', $string);388 return preg_replace('/^(.*?)(=*)$/', '$1', $string); 387 389 } 388 390 … … 391 393 * Проверка режимы работы 392 394 * 393 * @return void395 * @return array 394 396 */ 395 397 function getRobokassaPasses() … … 400 402 'pass2' => get_option('robokassa_payment_testshoppass2'), 401 403 ]; 402 } else {403 return [ 404 'pass1' => get_option('robokassa_payment_shoppass1'),405 'pass2' => get_option('robokassa_payment_shoppass2'),406 ];407 }404 } 405 406 return [ 407 'pass1' => get_option('robokassa_payment_shoppass1'), 408 'pass2' => get_option('robokassa_payment_shoppass2'), 409 ]; 408 410 } 409 411 … … 413 415 * @param mixed $order_id 414 416 * 415 * @return void417 * @return array 416 418 */ 417 419 function createRobokassaReceipt($order_id) 418 420 { 419 global $woocommerce;420 421 $order = new WC_Order($order_id); 421 422 … … 424 425 $receipt['sno'] = $sno; 425 426 } 427 $receipt['sno'] = $sno; 426 428 427 429 $tax = get_option('robokassa_payment_tax'); 428 430 if ($tax == "vat118") $tax = "vat120"; 429 431 430 $cart = $woocommerce->cart->get_cart(); 432 $cart = WC()->cart; 433 $cart->calculate_totals(); 431 434 432 435 $receipt = array(); 433 436 434 $total_order = $order->get_total(); // Сумма OutSum435 $total_receipt = 0; // Сумма всех $current['sum']436 437 foreach ($cart as $item) {437 $total_order = $order->get_total(); 438 $total_receipt = 0; 439 440 foreach ($cart->get_cart_contents() as $item) { 438 441 $product = wc_get_product($item['product_id']); 439 442 $quantity = (float)$item['quantity']; … … 442 445 $current['name'] = $product->get_title(); 443 446 $current['quantity'] = $quantity; 444 $current[' sum'] = $item['line_total'];445 $current[' cost'] = $item['line_total'] /$quantity;447 $current['cost'] = $item['data']->get_price(); 448 $current['sum'] = $item['data']->get_price() * $quantity; 446 449 447 450 $total_receipt += $current['sum']; … … 452 455 } 453 456 454 if ( isset($receipt['sno']) && $receipt['sno'] == 'osn' || get_option('robokassa_country_code') == 'KZ') {457 if ((isset($receipt['sno']) && $receipt['sno'] == 'osn') || get_option('robokassa_country_code') == 'RU') { 455 458 $current['tax'] = $tax; 456 459 } else { … … 474 477 'cost' => $additional_item_total, 475 478 'sum' => $additional_item_total, 476 'payment_object' => \get_option('robokassa_payment_paymentObject'),477 'payment_method' => \get_option('robokassa_payment_paymentMethod'),478 'tax' => \get_option('robokassa_payment_tax'),479 'payment_object' => get_option('robokassa_payment_paymentObject'), 480 'payment_method' => get_option('robokassa_payment_paymentMethod'), 481 'tax' => get_option('robokassa_payment_tax'), 479 482 ); 480 483 … … 485 488 486 489 if (empty($receipt)) { 487 488 490 foreach ($order->get_items() as $item) { 489 491 … … 491 493 492 494 $current['name'] = $product->get_title(); 493 $current['quantity'] = (float)$item->get_quantity(); 494 495 $current['sum'] = $item['line_total']; 496 $current['cost'] = $item['line_total'] / $quantity; 497 498 $current['payment_object'] = \get_option('robokassa_payment_paymentObject'); 499 $current['payment_method'] = \get_option('robokassa_payment_paymentMethod'); 495 $current['quantity'] = $item->get_quantity(); 496 $current['cost'] = $item['data']->get_price(); 497 $current['sum'] = $item['data']->get_price() * $item->get_quantity(); 498 499 $current['payment_object'] = get_option('robokassa_payment_paymentObject'); 500 $current['payment_method'] = get_option('robokassa_payment_paymentMethod'); 500 501 501 502 if (isset($receipt['sno']) && ($receipt['sno'] == 'osn')) { … … 508 509 $total_receipt += $current['sum']; 509 510 } 510 511 511 } 512 512 … … 519 519 520 520 if (get_option('robokassa_country_code') == 'RU') { 521 $current['payment_object'] = \get_option('robokassa_payment_paymentObject');522 $current['payment_method'] = \get_option('robokassa_payment_paymentMethod');523 } 524 525 if (isset($receipt['sno']) && ($receipt['sno'] == 'osn') || (get_option('robokassa_country_code') == 'KZ')) {521 $current['payment_object'] = get_option('robokassa_payment_paymentObject'); 522 $current['payment_method'] = get_option('robokassa_payment_paymentMethod'); 523 } 524 525 if (isset($receipt['sno']) && ($receipt['sno'] == 'osn') || (get_option('robokassa_country_code') != 'KZ')) { 526 526 $current['tax'] = $tax; 527 527 } else { … … 537 537 } 538 538 539 return $receipt;539 return apply_filters('wc_robokassa_receipt', $receipt); 540 540 } 541 541 … … 566 566 $recurring = false; 567 567 568 if ( class_exists('WC_Subscriptions_Order')) {568 if (function_exists('wcs_order_contains_subscription')) { 569 569 $order_subscription = wcs_order_contains_subscription($order_id); 570 570 … … 732 732 $order = new WC_Order($order_id); 733 733 734 if ( !$order) {734 if (empty($order)) { 735 735 robokassa_payment_DEBUG("Robokassa: Order not found for order_id: $order_id, exiting function"); 736 736 return; 737 737 } 738 739 /* if ($order->get_payment_method_title() != get_option('RobokassaOrderPageTitle_all')) {740 robokassa_payment_DEBUG("Payment method title does not match: " . $order->get_payment_method_title() . get_option('RobokassaOrderPageTitle_all') . ", exiting function");741 return;742 }*/743 738 744 739 /** @var array $fields */ … … 749 744 'operation' => 'sell', 750 745 'sno' => $sno, 751 'url' => \urlencode('http://' . $_SERVER['HTTP_HOST']),746 'url' => urlencode('http://' . $_SERVER['HTTP_HOST']), 752 747 'total' => $order->get_total(), 753 748 'items' => [], … … 813 808 'cost' => $additional_item_total, 814 809 'sum' => $additional_item_total, 815 'payment_object' => \get_option('robokassa_payment_paymentObject'),810 'payment_object' => get_option('robokassa_payment_paymentObject'), 816 811 'payment_method' => 'full_payment', 817 812 'tax' => $tax, … … 881 876 /** @var string $startupHash */ 882 877 $startupHash = formatSignFinish( 883 \base64_encode(878 base64_encode( 884 879 formatSignReplace( 885 880 json_encode($fields) … … 900 895 /** @var string $sign */ 901 896 $sign = formatSignFinish( 902 \base64_encode(903 \md5(897 base64_encode( 898 md5( 904 899 $startupHash . 905 900 ($pass1) … … 951 946 'sum' => $item_sum, 952 947 'tax' => get_option('robokassa_payment_tax'), 953 'payment_method' => \get_option('robokassa_payment_paymentMethod'), 954 'payment_object' => \get_option('robokassa_payment_paymentObject'), 955 'tax' => get_option('robokassa_payment_tax'), 948 'payment_method' => get_option('robokassa_payment_paymentMethod'), 949 'payment_object' => get_option('robokassa_payment_paymentObject'), 956 950 ); 957 951 } … … 1057 1051 } 1058 1052 } 1053 1054 /** 1055 * Woocommerce blocks support 1056 */ 1057 function declare_cart_checkout_blocks_compatibility() { 1058 if (class_exists('\Automattic\WooCommerce\Utilities\FeaturesUtil')) { 1059 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('cart_checkout_blocks', __FILE__, true); 1060 } 1061 } 1062 add_action('before_woocommerce_init', 'declare_cart_checkout_blocks_compatibility'); 1063 add_action('woocommerce_blocks_loaded', 'robokassa_woocommerce_block_support'); 1064 1065 function robokassa_woocommerce_block_support() 1066 { 1067 if (class_exists('Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType')) 1068 { 1069 require_once dirname(__FILE__) . '/checkout-block.php'; 1070 1071 add_action( 1072 'woocommerce_blocks_payment_method_type_registration', 1073 function (PaymentMethodRegistry $payment_method_registry) { 1074 $container = Automattic\WooCommerce\Blocks\Package::container(); 1075 $container->register( 1076 WC_Robokassa_Blocks::class, 1077 function () { 1078 return new WC_Robokassa_Blocks(); 1079 } 1080 ); 1081 $payment_method_registry->register($container->get(WC_Robokassa_Blocks::class)); 1082 }, 1083 5 1084 ); 1085 } 1086 }
Note: See TracChangeset
for help on using the changeset viewer.