Апрель 28, 2018
Теги: Магазин
Работа с платежными системами средствами классов "\Bitrix\Sale\PaySystem\Manager", "\Bitrix\Sale\Internals\PaySystemActionTable" и других.
Выборка активных платежных систем с получением массива ограничений:
$paySystemResult = \Bitrix\Sale\PaySystem\Manager::getList(array(
'filter' => array(
'ACTIVE' => 'Y',
)
));
//$helper = \Bitrix\Main\Application::getConnection()->getSqlHelper();
while ($paySystem = $paySystemResult->fetch())
{
echo "<pre>"; print_r($paySystem); echo "</pre>";
$dbRestriction = \Bitrix\Sale\Internals\ServiceRestrictionTable::getList(array(
'select' => array('PARAMS'),
'filter' => array(
'SERVICE_ID' => $paySystem['ID'],
//'CLASS_NAME' => $helper->forSql('\Bitrix\Sale\Services\PaySystem\Restrictions\PersonType'),
'SERVICE_TYPE' => \Bitrix\Sale\Services\PaySystem\Restrictions\Manager::SERVICE_TYPE_PAYMENT
)
));
$restrictions = array();
while ($restriction = $dbRestriction->fetch())
{
if(is_array($restriction['PARAMS']))
$restrictions = array_merge($restrictions,$restriction['PARAMS']);
}
$restriction = \Bitrix\Sale\Services\PaySystem\Restrictions\Delivery::prepareParamsValues(array(),$paySystem['ID']);
$restrictions['DELIVERY'] = $restriction['DELIVERY'];
echo "<pre>"; print_r($restrictions); echo "</pre>";
}
/*
Array
(
[ID] => 2
[PAY_SYSTEM_ID] => 2
[PERSON_TYPE_ID] =>
[NAME] => Ассист
[PSA_NAME] => Картой на сайте
[CODE] =>
[SORT] => 100
[ACTION_FILE] => assist
[RESULT_FILE] =>
[DESCRIPTION] =>
[NEW_WINDOW] => N
[PARAMS] => a:1:{s:16:"BX_PAY_SYSTEM_ID";i:2;}
[TARIF] =>
[PS_MODE] =>
[HAVE_PAYMENT] => Y
[HAVE_ACTION] => N
[HAVE_RESULT] => Y
[HAVE_PREPAY] => N
[HAVE_PRICE] => N
[HAVE_RESULT_RECEIVE] => Y
[ENCODING] =>
[LOGOTIP] =>
[ACTIVE] => Y
[ALLOW_EDIT_PAYMENT] => Y
[IS_CASH] => N
[AUTO_CHANGE_1C] => N
[CAN_PRINT_CHECK] => N
[ENTITY_REGISTRY_TYPE] => ORDER
)
Array
(
[CURRENCY] => Array
(
[0] => RUB
[1] => USD
[2] => EUR
)
[SITE_ID] => Array
(
[0] => s1
[1] => s2
)
[DELIVERY] => Array
(
[0] => 4
[1] => 5
)
)
*/
/*
Все классы связанные с ограничениями платежных систем:
\Bitrix\Sale\Services\PaySystem\Restrictions\Delivery
\Bitrix\Sale\Services\PaySystem\Restrictions\Currency
\Bitrix\Sale\Services\PaySystem\Restrictions\PercentPrice
\Bitrix\Sale\Services\PaySystem\Restrictions\PersonType
\Bitrix\Sale\Services\PaySystem\Restrictions\Price
\Bitrix\Sale\Services\PaySystem\Restrictions\Site
\Bitrix\Sale\Services\PaySystem\Restrictions\TradeBinding
*/
Выборка информации о платежной системе с ID=12 одной строкой:
Другой способ:
$rsPaySystem = \Bitrix\Sale\Internals\PaySystemActionTable::getList(array(
'filter' => array('ACTIVE'=>'Y'),
));
while($arPaySystem = $rsPaySystem->fetch())
{
echo "<pre>"; print_r($arPaySystem); echo "</pre>";
}
/* Пример результата:
Array
(
[ID] => 12
[PAY_SYSTEM_ID] => 12
[PERSON_TYPE_ID] =>
[NAME] => Банковские карты
[PSA_NAME] => Оплата картой сбербанка
[CODE] => SBR
[SORT] => 1
[ACTION_FILE] => /bitrix/php_interface/include/sale_payment/sbr
[RESULT_FILE] =>
[DESCRIPTION] => Мы принимаем к оплате банковские карты:
[NEW_WINDOW] => Y
[PARAMS] => a:1:{s:16:"BX_PAY_SYSTEM_ID";i:12;}
[TARIF] =>
[PS_MODE] =>
[HAVE_PAYMENT] => Y
[HAVE_ACTION] => N
[HAVE_RESULT] => N
[HAVE_PREPAY] => N
[HAVE_PRICE] => N
[HAVE_RESULT_RECEIVE] => Y
[ENCODING] => utf-8
[LOGOTIP] => 78709
[ACTIVE] => Y
[ALLOW_EDIT_PAYMENT] => Y
[IS_CASH] => N
[AUTO_CHANGE_1C] => N
)
*/
Получение значения настроек (зависящих от обработчика) платежной системы с ID=17:
Получение всех активных платежных систем сайта с идентификатором в переменной $siteId:
$personTypeId = \Bitrix\Sale\PersonType::load($siteId));
$innerPaySystemId = \Bitrix\Sale\PaySystem\Manager::getInnerPaySystemId();
$paySystemResult = \Bitrix\Sale\PaySystem\Manager::getList(array(
'filter' => array('ACTIVE' => 'Y'),
'order' => array('SORT' => 'ASC', 'NAME' => 'ASC'),
));
while ($paySystem = $paySystemResult->fetch())
{
if($paySystem['ID']==$innerPaySystemId)
continue;
$dbRestriction = \Bitrix\Sale\Internals\ServiceRestrictionTable::getList(array(
'select' => array('PARAMS'),
'filter' => array(
'SERVICE_ID' => $paySystem['ID'],
'SERVICE_TYPE' => \Bitrix\Sale\Services\PaySystem\Restrictions\Manager::SERVICE_TYPE_PAYMENT
)
));
$restrictions = array();
while ($restriction = $dbRestriction->fetch())
$restrictions = array_merge($restrictions,$restriction['PARAMS']);
if(is_array($restrictions['SITE_ID']) && !in_array($siteId,$restrictions['SITE_ID']))
continue;
if(is_array($restrictions['PERSON_TYPE_ID']) && count($restrictions['PERSON_TYPE_ID'])>0 && is_array($personTypeId))
{
$hasOne = false;
foreach($personTypeId as $pid)
foreach($restrictions['PERSON_TYPE_ID'] as $pid2)
if($pid==$pid2)
$hasOne = true;
if(!$hasOne)
continue;
print_r($paySystem);
}
}
/*
Array
(
[ID] => 1
[PAY_SYSTEM_ID] => 1
[PERSON_TYPE_ID] => 1
[NAME] => Наличные курьеру
[PSA_NAME] => Наличные курьеру
[CODE] =>
[SORT] => 50
[ACTION_FILE] => cash
[RESULT_FILE] =>
[DESCRIPTION] => Оплата наличными при получении заказа курьеру.
[NEW_WINDOW] => N
[PARAMS] => a:1:{s:16:"BX_PAY_SYSTEM_ID";a:2:{s:4:"TYPE";s:0:"";s:5:"VALUE";s:1:"1";}}
[TARIF] =>
[PS_MODE] =>
[HAVE_PAYMENT] => Y
[HAVE_ACTION] => N
[HAVE_RESULT] => N
[HAVE_PREPAY] => N
[HAVE_PRICE] => N
[HAVE_RESULT_RECEIVE] => N
[ENCODING] =>
[LOGOTIP] => 121
[ACTIVE] => Y
[ALLOW_EDIT_PAYMENT] => Y
[IS_CASH] => N
[AUTO_CHANGE_1C] => N
[CAN_PRINT_CHECK] => N
[ENTITY_REGISTRY_TYPE] => ORDER
)
Array
(
[ID] => 5
[PAY_SYSTEM_ID] => 5
[PERSON_TYPE_ID] => 1
[NAME] => Сбербанк
[PSA_NAME] => Сбербанк
[CODE] =>
[SORT] => 90
[ACTION_FILE] => sberbank
[RESULT_FILE] =>
[DESCRIPTION] => Вы можете оплатить заказ в любом отделении Сбербанка. За услугу по переводу денег с Вас возьмут от 3 до 7% от стоимости заказа, в зависимости от региона. Перечисление денег займет порядка 10 дней.
[NEW_WINDOW] => Y
[PARAMS] => a:17:{s:19:"SELLER_COMPANY_NAME";a:2:{s:4:"TYPE";s:0:"";s:5:"VALUE";s:40:"ООО "Интернет-магазин"";}s:18:"SELLER_COMPANY_INN";a:2:{s:4:"TYPE";s:0:"";s:5:"VALUE";s:10:"1234567890";}s:18:"SELLER_COMPANY_KPP";a:2:{s:4:"TYPE";s:0:"";s:5:"VALUE";s:9:"123456789";}s:27:"SELLER_COMPANY_BANK_ACCOUNT";a:2:{s:4:"TYPE";s:0:"";s:5:"VALUE";s:24:"0000 0000 0000 0000 0000";}s:24:"SELLER_COMPANY_BANK_NAME";a:2:{s:4:"TYPE";s:0:"";s:5:"VALUE";s:56:"ОАО "Сбербанк России", г. Москва";}s:23:"SELLER_COMPANY_BANK_BIC";a:2:{s:4:"TYPE";s:0:"";s:5:"VALUE";s:16:"БИК 044525225";}s:32:"SELLER_COMPANY_BANK_ACCOUNT_CORR";a:2:{s:4:"TYPE";s:0:"";s:5:"VALUE";s:24:"30101 810 4 0000 0000225";}s:10:"PAYMENT_ID";a:2:{s:4:"TYPE";s:7:"PAYMENT";s:5:"VALUE";s:2:"ID";}s:19:"PAYMENT_DATE_INSERT";a:2:{s:4:"TYPE";s:7:"PAYMENT";s:5:"VALUE";s:14:"DATE_BILL_DATE";}s:16:"BUYER_PERSON_FIO";a:2:{s:4:"TYPE";s:8:"PROPERTY";s:5:"VALUE";s:3:"FIO";}s:16:"BUYER_PERSON_ZIP";a:2:{s:4:"TYPE";s:8:"PROPERTY";s:5:"VALUE";s:3:"ZIP";}s:20:"BUYER_PERSON_COUNTRY";a:2:{s:4:"TYPE";s:8:"PROPERTY";s:5:"VALUE";s:16:"LOCATION_COUNTRY";}s:17:"BUYER_PERSON_CITY";a:2:{s:4:"TYPE";s:8:"PROPERTY";s:5:"VALUE";s:13:"LOCATION_CITY";}s:25:"BUYER_PERSON_ADDRESS_FACT";a:2:{s:4:"TYPE";s:8:"PROPERTY";s:5:"VALUE";s:7:"ADDRESS";}s:18:"PAYMENT_SHOULD_PAY";a:2:{s:4:"TYPE";s:7:"PAYMENT";s:5:"VALUE";s:3:"SUM";}s:19:"BUYER_PERSON_REGION";a:2:{s:5:"VALUE";s:0:"";s:4:"TYPE";s:0:"";}s:16:"BX_PAY_SYSTEM_ID";a:2:{s:4:"TYPE";s:0:"";s:5:"VALUE";s:1:"5";}}
[TARIF] =>
[PS_MODE] =>
[HAVE_PAYMENT] => Y
[HAVE_ACTION] => N
[HAVE_RESULT] => N
[HAVE_PREPAY] => N
[HAVE_PRICE] => N
[HAVE_RESULT_RECEIVE] => N
[ENCODING] =>
[LOGOTIP] => 125
[ACTIVE] => Y
[ALLOW_EDIT_PAYMENT] => Y
[IS_CASH] => N
[AUTO_CHANGE_1C] => N
[CAN_PRINT_CHECK] => N
[ENTITY_REGISTRY_TYPE] => ORDER
)
*/