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); } }