Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Payment_Controller extends Base_Controller {
- public function action_index() {
- // Получим список разделов
- $VL = IoC::resolve('VL');
- $arrList = $VL->getRootGroups();
- // Разложим на строки по 6 элементов
- $arrT = array();
- $intC = 0;
- $intR = 1;
- foreach ($arrList as $arrI) {
- $intC++;
- $arrT[$intR][] = $arrI;
- if ($intC == 6) {
- $intC = 0;
- $intR++;
- }//\\ if
- }//\\ foreach
- return View::make('sd.payment')->with('arrList', $arrT);
- }//\\ action_index
- public function action_vendors($intGroupID) {
- // Получим список вендоров из этого раздела
- $VL = IoC::resolve('VL');
- $arrList = $VL->getListVendors($intGroupID);
- // Разложим на строки по 6 элементов
- $arrT = array();
- $intC = 0;
- $intR = 1;
- foreach ($arrList as $arrI) {
- $intC++;
- $arrT[$intR][] = $arrI;
- if ($intC == 6) {
- $intC = 0;
- $intR++;
- }//\\ if
- }//\\ foreach
- return View::make('sd.payment_vendors')->with('arrList', $arrT);
- }//\\ action_index
- public function action_pay($intAcct) {
- // Получим инфу о вендоре
- $VL = IoC::resolve('VL');
- $arrVendor = $VL->getVendor($intAcct);
- // Получим счета и карты
- $arrA = Accts::getAcctsAndCards();
- if (count($arrA['accts'])) {
- foreach ($arrA['accts'] as $arrT) {
- if ($arrT['Type'] == 1)
- $arrVendor['accts'][] = array(
- 'Acct' => $arrT['Acct'],
- 'AcctNum' => $arrT['AcctNum'],
- 'Available' => Utils::getMoney($arrT['Available']),
- 'Currency' => $arrT['Currency'],
- 'CurrencyCode' => MessagesVtbi::getCurrencyCode($arrT['Currency']),
- );
- }//\\ foreach
- }//\\ if
- return View::make('sd.payment_pay')->with('arrVendor', $arrVendor);
- }//\\ action_index
- public function action_schedule() {
- $arrResult = array();
- $strFromAcct = Input::get('OperationAcctSelect');
- $intToAcct = intval(Input::get('ToAcct'));
- $strAmount = floatval(Input::get('Amount'));
- $strCurrency = intval(Input::get('Currency'));
- $strComment = Input::get('Comment');
- $strSEQ = '';
- // Получим поля от вендора
- $VL = IoC::resolve('VL');
- $arrVendor = $VL->getVendor($intToAcct);
- if (count($arrVendor['fields'])) {
- $intNum = 1;
- foreach($arrVendor['fields'] as $arrField) {
- $strSEQ .= '
- <Row>
- <SEQ>'.$intNum.'</SEQ>
- <ID>'.$arrField->name.'</ID>
- <VAL>'.Input::get('FF_'.$arrField->name).'</VAL>
- </Row>';
- $intNum++;
- }//\\ foreach
- }//\\ if
- $strXML = '
- <FromAcct>'.$strFromAcct.'</FromAcct>
- <ToAcct>'.$intToAcct.'</ToAcct>
- <CustAcct>'.$strSEQ.'
- </CustAcct>
- <Amount>'.$strAmount.'</Amount>
- <Currency>'.$strCurrency.'</Currency>
- <Comment>'.$strComment.'</Comment>
- <Date/>
- <Period>0</Period>
- <Count>1</Count>';
- // Сделаем запрос
- $TB = IoC::resolve('TWO');
- // Разберемся с SMS кодом
- if (Input::has('SmsCode')) {
- // Установим динамический пароль
- $TB->setDynamicPassword(Input::get('SmsCode'));
- }//\\ if
- try {
- $objXml = $TB->exec('Schedule', $strXML);
- } catch (Exception $e) {
- $arrResult['responseCode'] = $e->getCode();
- $arrResult['responseMessage'] = $e->getMessage();
- // требуется динамическая авторизация
- if ($e->getCode() == 18) {
- // Запросим список получателей динамической аунтификации
- $arrList = $TB->getDynAuthAddressList();
- $arrAuthAddress = array();
- // Найдем активного
- if (count($arrList)) {
- foreach ($arrList as $arrItem) {
- if ($arrItem['Default'] == true)
- $arrAuthAddress = $arrItem;
- }//\\ foreach
- }//\\ if
- if (isset($arrAuthAddress['Channel'])) {
- // Сгенерируем пароль
- $objXml = $TB->exec('GenerateDynPassword', '<Channel>'.$arrAuthAddress['Channel'].'</Channel><Address>'.$arrAuthAddress['Address'].'</Address>');
- // Получим номер SMS
- $objResult = $objXml->xpath('//PasswordCount');
- if (count($objResult)) {
- $intNumSMS = (integer)$objResult[0];
- }//\\ if
- $arrResult['smsNum'] = $intNumSMS;
- //return Response::make(json_encode($arrResult), 200, array('Content-type' => 'application/json'));
- /* $intCount = 3;
- if ($intCount > 99) $intCount = 99;
- $strXML = '<?xml version="1.0" encoding="utf-8" ?>
- <badge value="'.($intCount > 0 ? $intCount : 'none').'"/>';
- return Response::make($strXML, 200, array('Content-type' => 'application/xml'));*/
- }//\\ if
- } else {
- //throw $e;
- }//\\ if
- }//\\ try
- return Response::make(json_encode($arrResult), 200, array('Content-type' => 'application/json'));
- }
- }//\\ Payment_Controller
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement