Answer the question
In order to leave comments, you need to log in
How to get a list of available Bitrix/Sale payment methods?
Can you please tell me how to get a list of available payment methods, knowing the ID of the payer type and the ID of the delivery service? I'm digging in the direction of PaySystem\Manager::getListWithRestrictions(), but I couldn't get this method to work, or rather, it returns all payment methods, regardless of the delivery service ID.
CSalePaySystem::GetList() - does not accept||don't know, create conditions by delivery service ID.
Are there any other options how to get a list of payment systems, taking into account the "limitations of payment systems"?
Answer the question
In order to leave comments, you need to log in
// Создаем заказ и привязываем корзину
$order = Order::create(SITE_ID, $USER_ID);
$order->setPersonTypeId($SOME_PERSON_TYPE_ID);
$basket = Sale\Basket::loadItemsForFUser(Sale\Fuser::getId(), Bitrix\Main\Context::getCurrent()->getSite());
$price = $basket->getPrice();
$fullPrice = $basket->getBasePrice();
$order->setBasket($basket);
// Добавляем Доставку(Отгрузку?)
$shipmentCollection = $order->getShipmentCollection();
$shipment = $shipmentCollection->createItem(
Bitrix\Sale\Delivery\Services\Manager::getObjectById($SOME_DELIVERY_TYPE_ID)
);
// Отгрузку наполняем товарами из корзины
$shipmentItemCollection = $shipment->getShipmentItemCollection();
foreach ($basket as $basketItem) {
$item = $shipmentItemCollection->createItem($basketItem);
$item->setQuantity($basketItem->getQuantity());
}
// PAYMENT
$arPaySystemServiceAll = [];
$paymentCollection = $order->getPaymentCollection();
$extPayment = $paymentCollection->createItem();
$extPayment->setField("SUM", $order->getPrice());
$arPaySystemServiceAll = Sale\PaySystem\Manager::getListWithRestrictions($extPayment);
reset($arPaySystemServiceAll);
$arPaySystem = current($arPaySystemServiceAll);
if(!empty($arPaySystem)) {
$extPayment->setFields(array(
"PAY_SYSTEM_ID" => $arPaySystem["ID"],
"PAY_SYSTEM_NAME" => $arPaySystem["NAME"]
));
} else
$extPayment->delete();
$arPaySystemServiceAll;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question