A
A
Alexander2016-11-01 12:31:40
1C-Bitrix
Alexander, 2016-11-01 12:31:40

How can I pay for an order by its ID in Bitrix?

Good afternoon, is it possible to implement this and how best to do it?
A page with a field for entering the order number and, if the order is found, provide an opportunity to choose how it can be paid and, accordingly, pay for it in the future?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Zakharov, 2016-11-01
@Dil0ng

you can display the payment handler on the page in this way

$orderObj = Sale\Order::load($order['ORDER']['ID']);
                        $paymentCollection = $orderObj->getPaymentCollection();
                        $payment = $paymentCollection[0];
                        $service = Sale\PaySystem\Manager::getObjectById($payment->getPaymentSystemId());
                        $context = \Bitrix\Main\Application::getInstance()->getContext();
                        $service->initiatePay($payment, $context->getRequest());

Can be rendered as a component
<?$APPLICATION->IncludeComponent(
    "bitrix:sale.order.payment",
    "",
    Array(
    )
);?>

But judging by the code of the component, it performs approximately the same as the code above.
If you want to display with the site template, then you can do this through buffering
<?
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
$APPLICATION->SetTitle("Оплата заказа");
ob_start();
?>
<?$APPLICATION->IncludeComponent(
    "bitrix:sale.order.payment",
    "",
    Array(
    )
);?>
<?
$formPay = ob_get_contents();
ob_end_clean();
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_after.php");
$APPLICATION->SetTitle("Оплата заказа");
?>
<div class="formPayment">
<?
echo $formPay;
?>
</div>
<?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");?>

E
Evgeny Nikolaev, 2019-05-20
@nikolaevevge

Here is a very simple way: CSaleOrder::PayOrder($orderId, "Y");
At the same time, in the bitrix documentation, it is written about it as an obsolete method. It is also recommended to use Order
Who knows how to do the same through Order, please unsubscribe in the comments.

O
Oleg Maksimenko, 2016-11-01
@olegprof

You can do everything (almost). Have you tried anything yourself yet? The new store has more or less api. The old one is worse.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question