Plugin Directory

Changeset 3180252


Ignore:
Timestamp:
11/02/2024 07:20:28 AM (17 months ago)
Author:
robokassa
Message:

1.6.3 release

Location:
robokassa/trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • robokassa/trunk/classes/Robokassa/Payment/RobokassaPayAPI.php

    r3147422 r3180252  
    102102    {
    103103        $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' : '';
    105105
    106106        return \implode(
     
    149149
    150150    /**
    151      * Генерирует форму, в Opencart модуле НЕ ИСПОЛЬЗУЕТСЯ!
     151     *
    152152     *
    153153     * @param float $sum
     
    202202        );
    203203
    204         if (get_option('robokassa_payment_hold_onoff') == 'true') {
     204        if (get_option('robokassa_payment_hold_onoff') == 1) {
    205205            $formData['StepByStep'] = 'true';
    206206        }
     
    419419
    420420    /**
    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     /**
    465421     * Запрашивает и парсит в массив все возможные способы оплаты для данного магазина
    466422     *
     
    517473            'PreviousInvoiceID' => $parentInvoiceId,
    518474            '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')),
    520476            'OutSum'            => $amount,
    521477            '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'),
    522481            'Receipt'           => $receiptJson
    523         ], function($val) { return $val !== null; });
     482        ], function($val) {
     483            return $val !== null;
     484        });
    524485
    525486        return $data;
    526487    }
    527 
    528488}
  • robokassa/trunk/labelsClasses.php

    r3147067 r3180252  
    33class payment_robokassa_pay_method_request_all extends \Robokassa\Payment\WC_WP_robokassa {
    44    public function __construct() {
    5         $this->id = 'all';
     5        $this->id = 'robokassa';
    66        $this->method_title = 'Robokassa';
    77        $this->long_name = 'Оплата через Robokassa';
     
    1414class payment_robokassa_pay_method_request_Podeli extends \Robokassa\Payment\WC_WP_robokassa {
    1515    public function __construct() {
    16         $this->id = 'Podeli';
     16        $this->id = 'robokassa_podeli';
    1717        $this->method_title = 'Robokassa';
    1818        $this->long_name='Оплата через Robokassa';
     
    3131class payment_robokassa_pay_method_request_Credit extends \Robokassa\Payment\WC_WP_robokassa {
    3232    public function __construct() {
    33         $this->id = 'Credit';
     33        $this->id = 'robokassa_credit';
    3434        $this->method_title = 'Robokassa';
    3535        $this->long_name='Оплата через Robokassa';
  • robokassa/trunk/main_settings_rb.php

    r3147067 r3180252  
    136136                    <th scope="row">Заголовок на странице оформления заказа</th>
    137137                    <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'); ?>"/>
    140140                    </td>
    141141                </tr>
     
    143143                    <th scope="row">Описание на странице оформления заказа</th>
    144144                    <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'); ?>"/>
    147147                    </td>
    148148                </tr>
  • robokassa/trunk/payment-widget.php

    r3147067 r3180252  
    11<?php
     2
     3add_filter('woocommerce_available_payment_gateways', 'select_payment_method');
     4add_action('woocommerce_single_product_summary', 'payment_product_widget', 25);
     5add_action('woocommerce_proceed_to_checkout', 'payment_cart_widget');
    26
    37function payment_product_widget()
     
    711    $product_id = $product->get_id();
    812
    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'));
    1316
    1417    if (get_option('robokassa_payment_podeli_widget_onoff') === 'true' && $price > 300 && $price < 35000) {
     
    674677    }
    675678
    676     global $woocommerce;
    677 
    678     if (!isset($woocommerce->cart)) {
     679    $cart = WC()->cart;
     680    if (empty($cart) || $cart->get_total() <= 0) {
    679681        return;
    680682    }
    681683
    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, '.', '');
    694687
    695688    if (get_option('robokassa_payment_podeli_widget_onoff') === 'true' && $price > 300 && $price < 35000) {
     
    788781    }
    789782
    790     global $woocommerce;
    791 
    792     if (!isset($woocommerce->cart)) {
     783    $cart = WC()->cart;
     784    if (empty($cart) || $cart->get_total() <= 0) {
    793785        return;
    794786    }
    795787
    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'));
    808796
    809797    if (get_option('robokassa_payment_podeli_widget_onoff') === 'true' && $price > 300 && $price < 35000) {
     
    863851    }
    864852
    865     global $woocommerce;
    866 
    867     if (!isset($woocommerce->cart)) {
     853    $cart = WC()->cart;
     854    if (empty($cart) || $cart->get_total() <= 0) {
    868855        return;
    869856    }
    870857
    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
    878862    $monthlyInterestRate = 0.02333; // Месячная процентная ставка (2,333% в десятичной форме)
    879863    $months = 23; // Количество месяцев
     
    884868
    885869    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">Кредит или рассрочка от&nbsp;</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">Кредит или рассрочка от&nbsp;</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
    914905    }
    915906}
    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  
    22Tags: robokassa payment gateway, robokassa, robokassa woocommerce, ecommerce, payment gateway, woo-commerce, woocommerce ===
    33Requires at least: 5.7
    4 Tested up to: 6.6.1
    5 Stable tag: 1.6.2
     4Tested up to: 6.6.2
     5Stable tag: 1.6.3
    66Requires PHP: 7.4
    77License: GPLv2 or later
  • robokassa/trunk/wp_robokassa.php

    r3147067 r3180252  
    66 * Author: Robokassa
    77 * Author URI: https://robokassa.com
    8  * Version: 1.6.2
     8 * Version: 1.6.3
    99 */
    1010
     
    1414use Robokassa\Payment\RobokassaPayAPI;
    1515use Robokassa\Payment\RobokassaSms;
    16 
     16use Automattic\WooCommerce\Utilities\OrderUtil;
     17use Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry;
    1718
    1819add_action('wp_enqueue_scripts', function () {
    19     \wp_enqueue_style(
     20    wp_enqueue_style(
    2021        'robokassa_payment_admin_style_menu',
    21         \plugin_dir_url(__FILE__) . 'assets/css/menu.css'
     22        plugin_dir_url(__FILE__) . 'assets/css/menu.css'
    2223    );
    2324
    24     \wp_enqueue_style(
     25    wp_enqueue_style(
    2526        'robokassa_payment_admin_style_main',
    26         \plugin_dir_url(__FILE__) . 'assets/css/main.css'
     27        plugin_dir_url(__FILE__) . 'assets/css/main.css'
    2728    );
    2829
    29     \wp_enqueue_style(
     30    wp_enqueue_style(
    3031        'robokassa_payment_podeli',
    31         \plugin_dir_url(__FILE__) . 'assets/css/payment_styles.css'
     32        plugin_dir_url(__FILE__) . 'assets/css/payment_styles.css'
    3233    );
    33     \wp_enqueue_script(
     34    wp_enqueue_script(
    3435        'robokassa_payment_admin_config',
    35         \plugin_dir_url(__FILE__) . 'assets/js/payment_widget.js'
     36        plugin_dir_url(__FILE__) . 'assets/js/payment_widget.js'
    3637    );
    3738});
     
    3940define('ROBOKASSA_PAYMENT_DEBUG_STATUS', false);
    4041
    41 \spl_autoload_register(
     42spl_autoload_register(
    4243    function ($className) {
    43         $file = __DIR__ . '/classes/' . \str_replace('\\', '/', $className) . '.php';
     44        $file = __DIR__ . '/classes/' . str_replace('\\', '/', $className) . '.php';
    4445
    4546        if (file_exists($file))
     
    100101add_action('robokassa_cancel_payment_event', 'robokassa_hold_cancel_after5', 10, 1);
    101102
    102 
    103103register_activation_hook(__FILE__, 'robokassa_payment_wp_robokassa_activate'); //Хук при активации плагина. Дефолтовые настройки и таблица в БД для СМС.
    104104
     
    129129    $file = __DIR__ . '/data/robokassa_DEBUG.txt';
    130130
    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");
    134134    fclose($DEBUGFile);
    135135}
     
    247247
    248248            /** @var string $crc_confirm */
    249             $crc_confirm = \strtoupper(
    250                 \md5(
     249            $crc_confirm = strtoupper(
     250                md5(
    251251                    implode(
    252252                        ':',
     
    284284                        foreach ($subscriptions as $subscription) {
    285285                            $subscription->update_status('active');
    286                         };
     286                        }
    287287                    }
    288288                }
     
    347347                }
    348348            } 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 
    353349                $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) {}
    354356            }
    355357        }
     
    372374function formatSignReplace($string)
    373375{
    374     return \strtr(
     376    return strtr(
    375377        $string,
    376378        [
     
    384386function formatSignFinish($string)
    385387{
    386     return \preg_replace('/^(.*?)(=*)$/', '$1', $string);
     388    return preg_replace('/^(.*?)(=*)$/', '$1', $string);
    387389}
    388390
     
    391393 * Проверка режимы работы
    392394 *
    393  * @return void
     395 * @return array
    394396 */
    395397function getRobokassaPasses()
     
    400402            'pass2' => get_option('robokassa_payment_testshoppass2'),
    401403        ];
    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    ];
    408410}
    409411
     
    413415 * @param mixed $order_id
    414416 *
    415  * @return void
     417 * @return array
    416418 */
    417419function createRobokassaReceipt($order_id)
    418420{
    419     global $woocommerce;
    420421    $order = new WC_Order($order_id);
    421422
     
    424425        $receipt['sno'] = $sno;
    425426    }
     427    $receipt['sno'] = $sno;
    426428
    427429    $tax = get_option('robokassa_payment_tax');
    428430    if ($tax == "vat118") $tax = "vat120";
    429431
    430     $cart = $woocommerce->cart->get_cart();
     432    $cart = WC()->cart;
     433    $cart->calculate_totals();
    431434
    432435    $receipt = array();
    433436
    434     $total_order = $order->get_total(); // Сумма OutSum
    435     $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) {
    438441        $product = wc_get_product($item['product_id']);
    439442        $quantity = (float)$item['quantity'];
     
    442445        $current['name'] = $product->get_title();
    443446        $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;
    446449
    447450        $total_receipt += $current['sum'];
     
    452455        }
    453456
    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') {
    455458            $current['tax'] = $tax;
    456459        } else {
     
    474477                'cost' => $additional_item_total,
    475478                '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'),
    479482            );
    480483
     
    485488
    486489    if (empty($receipt)) {
    487 
    488490        foreach ($order->get_items() as $item) {
    489491
     
    491493
    492494            $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');
    500501
    501502            if (isset($receipt['sno']) && ($receipt['sno'] == 'osn')) {
     
    508509            $total_receipt += $current['sum'];
    509510        }
    510 
    511511    }
    512512
     
    519519
    520520        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')) {
    526526            $current['tax'] = $tax;
    527527        } else {
     
    537537    }
    538538
    539     return $receipt;
     539    return apply_filters('wc_robokassa_receipt', $receipt);
    540540}
    541541
     
    566566    $recurring = false;
    567567
    568     if (class_exists('WC_Subscriptions_Order')) {
     568    if (function_exists('wcs_order_contains_subscription')) {
    569569        $order_subscription = wcs_order_contains_subscription($order_id);
    570570
     
    732732        $order = new WC_Order($order_id);
    733733
    734         if (!$order) {
     734        if (empty($order)) {
    735735            robokassa_payment_DEBUG("Robokassa: Order not found for order_id: $order_id, exiting function");
    736736            return;
    737737        }
    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                 }*/
    743738
    744739        /** @var array $fields */
     
    749744            'operation' => 'sell',
    750745            'sno' => $sno,
    751             'url' => \urlencode('http://' . $_SERVER['HTTP_HOST']),
     746            'url' => urlencode('http://' . $_SERVER['HTTP_HOST']),
    752747            'total' => $order->get_total(),
    753748            'items' => [],
     
    813808                    'cost' => $additional_item_total,
    814809                    'sum' => $additional_item_total,
    815                     'payment_object' => \get_option('robokassa_payment_paymentObject'),
     810                    'payment_object' => get_option('robokassa_payment_paymentObject'),
    816811                    'payment_method' => 'full_payment',
    817812                    'tax' => $tax,
     
    881876        /** @var string $startupHash */
    882877        $startupHash = formatSignFinish(
    883             \base64_encode(
     878            base64_encode(
    884879                formatSignReplace(
    885880                    json_encode($fields)
     
    900895        /** @var string $sign */
    901896        $sign = formatSignFinish(
    902             \base64_encode(
    903                 \md5(
     897            base64_encode(
     898                md5(
    904899                    $startupHash .
    905900                    ($pass1)
     
    951946                'sum' => $item_sum,
    952947                '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'),
    956950            );
    957951        }
     
    10571051    }
    10581052}
     1053
     1054/**
     1055 * Woocommerce blocks support
     1056 */
     1057function 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}
     1062add_action('before_woocommerce_init', 'declare_cart_checkout_blocks_compatibility');
     1063add_action('woocommerce_blocks_loaded', 'robokassa_woocommerce_block_support');
     1064
     1065function 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.