Good day ! The site is implemented multisite , two IM on which you can place orders, connected Yandex cashier. In the account of the Yandex cash register registered links:

Check URL https://site1.ru/bitrix/tools/sale_ps_result.php Aviso URL https://site1.ru/bitrix/tools/sale_ps_result.php Success URL http://site1.ru/bitrix/tools/sale_ps_success.php Fail URL http://site1.ru/bitrix/tools/sale_ps_fail.php 

ie, links from the first site, when a customer places an order on the second site2.ru site , then in case of successful payment, respectively, from site1.ru , I need to redirect to site2.ru, that is, to the site in which the order was made .

In the /bitrix/tools/sale_ps_success.php file I want to make a redirect, as it seemed to me that this can be done by obtaining the order ID from the URL that forms the Yandex cashier in case of a successful payment, which has the parameter orderNumber = 273 . But I noticed that the order number in the Yandex office does not match the order number on the site. For example, if a yak is 273 then on the website 280 . And the result of what I want to do: Get the order number from the URL, in the sale_ps_success.php file , check which site the order belongs to and redirect to the required site https: // site2 / personal / order / make /? ORDER_ID = ". $ OrderID

Has anyone come across a similar? Why are order numbers different?

On the advice of Mihanik71, using the Bitrix \ Sale \ Internals \ PaymentTable class turned out to be the right decision for which many thanks to him, below I have written the code in the file (sale_ps_success.php) on my website:

  $orderNumbder = $_GET['orderNumber']; // Ρ‚ΡƒΡ‚ ΠΏΡ€ΠΈΡ…ΠΎΠ΄ΠΈΡ‚ Π½ΠΎΠΌΠ΅Ρ€ ΠΎΠΏΠ»Π°Ρ‚Ρ‹ CModule::IncludeModule("sale"); c $obj = new Bitrix\Sale\Internals\PaymentTable; // класс с ΠΏΠΎΠΌΠΎΡ‰ΡŒΡŽ ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠ³ΠΎ ΠΌΠΎΠΆΠ½ΠΎ Π²Ρ‹Ρ‚Π°Ρ‰ΠΈΡ‚ΡŒ id Π·Π°ΠΊΠ°Π·Π°, Π±Ρ‹Π» ΠΎΠ±Π½Π°Ρ€ΡƒΠΆΠ΅Π½ с ΠΏΠΎΠΌΠΎΡ‰ΡŒΡŽ модуля live ip $shimpentCode = $obj->getlist(array('select' => array('ID','ORDER_ID'),'filter' => array('ID' => $orderNumbder)))->fetch(); $SiteOrder = CSaleOrder::GetByID($shimpentCode['ORDER_ID']); // вытаскиваСм свойства Π·Π°ΠΊΠ°Π·Π°, нас интСрСсуСт ΠΏΠΎΠ»Π΅ LID $SiteID = $SiteOrder['LID']; // id сайта Π½Π° ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΌ Π±Ρ‹Π»Π° ΠΏΠΎΠΊΡƒΠΏΠΊΠ° $OrderID = $shimpentCode['ORDER_ID']; $successUrl = ""; // простоС условиС , Π²Ρ‹Π±ΠΈΡ€Π°Π΅ΠΌ ΠΊΡƒΠ΄Π° Ρ€Π΅Π΄ΠΈΡ€Π΅ΠΊΡ‚ΠΈΡ‚ΡŒ покупатСля if($SiteID == 's1'){ $successUrl = "https://site1.ru/personal/order/make/?ORDER_ID=".$OrderID . "&PAY=Y"; // ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ PAY=Y Π΄ΠΎΠ±Π°Π²ΠΈΠ» для своих Π½ΡƒΠΆΠ΄ } if($SiteID == 's2'){ $successUrl = "https://site2.ru/personal/order/make/?ORDER_ID=".$OrderID . "&PAY=Y"; } $successPath = COption::GetOptionString("sale", "sale_ps_success_path", "/"); if(!empty($successUrl)){ LocalRedirect($successUrl); } } 
  • And in the order there is no property that would store the order number from UC? The fact that the order number on the site does not match the payment system is absolutely normal - Mihanik71
  • until I found out that "The payment number, not the order number, is transmitted to the cashier’s office, and the same thing happens in response, respectively" - Sergey Zaigraev

2 answers 2

There is a class Bitrix\Sale\Internals\PaymentTable there by the payment ID field you can get the order number ORDER_ID .

  • Thanks, I will try to use this class. - Sergey Zaigraev
  • @Sergey Zaigraev, is it? - Mihanik71
  • Yes, everything worked out, I’ll add sample code to the question) - Sergey Zaigraev

Your decision is not quite right from the point of view of the new core D7 Bitrix. It is undesirable to use the API of the old kernel when there are analogues of the new In addition, it would be wrong to use Bitrix\Sale\Internals\PaymentTable , because there are no guarantees that this behavior of the function will continue in the future, namely:

The Bitrix \ Sale \ Internals subspace contains classes for working with tables in the online store module.

Important! Direct use of these classes is not recommended and compatibility is not guaranteed.

https://dev.1c-bitrix.ru/api_d7/bitrix/sale/internals/

It is much better to use the available public static methods:

 //ВмСсто CModule::IncludeModule("sale"); \Bitrix\Main\Loader::includeModule('sale'); //ВмСсто создания ΠΎΠ±ΡŠΠ΅ΠΊΡ‚Π° класса Bitrix\Sale\Internals\PaymentTable $payment = \Bitrix\Sale\Payment::getList( array( "filter" => array('ID' => $_GET['orderNumber']), "select" => array('ORDER_ID') ) ); $paymentFields = $payment->fetch(); //ПоднимаСм ΠΎΠ±ΡŠΠ΅ΠΊΡ‚ Π·Π°ΠΊΠ°Π·Π° ΠΏΠΎ id $order = \Bitrix\Sale\Order::load($paymentFields['ORDER_ID']); //ΠŸΠΎΠ»ΡƒΡ‡Π°Π΅ΠΌ ΠΏΠΎΠ»Π΅ 'LID' $SiteID = $order->getField('LID'); //'ID' Π·Π°ΠΊΠ°Π·Π° ΠΌΠΎΠΆΠ½ΠΎ ΠΏΠΎΠ»ΡƒΡ‡ΠΈΡ‚ΡŒ ΠΈ ΠΈΠ· Π·Π°ΠΊΠ°Π·Π° Ρ‚ΠΎΠΆΠ΅, Π½Π°ΠΏΡ€ΠΈΠΌΠ΅Ρ€: $OrderID = $order->getId() $OrderID = $paymentFields['ORDER_ID']; $successUrl = ""; // простоС условиС , Π²Ρ‹Π±ΠΈΡ€Π°Π΅ΠΌ ΠΊΡƒΠ΄Π° Ρ€Π΅Π΄ΠΈΡ€Π΅ΠΊΡ‚ΠΈΡ‚ΡŒ покупатСля if($SiteID == 's1') { $successUrl = "https://site1.ru/personal/order/make/?ORDER_ID=".$OrderID . "&PAY=Y"; // ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ PAY=Y Π΄ΠΎΠ±Π°Π²ΠΈΠ» для своих Π½ΡƒΠΆΠ΄ } if($SiteID == 's2') { $successUrl = "https://site2.ru/personal/order/make/?ORDER_ID=".$OrderID . "&PAY=Y"; } if(!empty($successUrl)) { LocalRedirect($successUrl); } 

You can also receive $_GET['orderNumber'] through the API to receive, but this is already so, a slight OOP perversion:

 $request = \Bitrix\Main\Context::getCurrent()->getRequest(); $request->get("orderNumber");