G
G
Georgy Kotov2018-11-24 13:21:40
API
Georgy Kotov, 2018-11-24 13:21:40

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

1 answer(s)
G
Georgy Kotov, 2018-11-24
@agsDevelopment

// Создаем заказ и привязываем корзину
$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;

When $SOME_DELIVERY_TYPE_ID changes, the $arPaySystemServiceAll array changes depending on the type of delivery, BUT NOT CORRECT! Not as stipulated in the "Restrictions of the payment system". The code is executed by an AJAX request. What is wrong here?!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question