public function actionErrorDispositionNotification()
 {
     spl_autoload_unregister(array('YiiBase', 'autoload'));
     require_once Yii::getPathOfAlias('ext') . "/yandex-money-payout/lib/autoload.php";
     spl_autoload_register(array('YiiBase', 'autoload'));
     $settings = new \YandexMoney\Settings();
     $settings->host = Yii::app()->params['yandexPayout']['host'];
     $settings->cert = Yii::app()->params['yandexPayout']['cert'];
     $settings->certPassword = Yii::app()->params['yandexPayout']['certPassword'];
     $settings->privateKey = Yii::app()->params['yandexPayout']['privateKey'];
     $settings->yaCert = Yii::app()->params['yandexPayout']['yaCert'];
     $provider = new PKCS7RequestProvider($settings);
     $api = new PayoutAPI($provider, Yii::app()->params['yandexPayout']['cardSynonimUrl']);
     $api->errorDepositionNotification(function ($request) {
         $result = new \YandexMoney\ErrorDepositionParams($request['clientOrderId']);
         $deposition = PayoutDeposition::model()->findByAttributes(array('clientOrderId' => $request['clientOrderId']));
         if ($deposition) {
             $deposition->status = PayoutDeposition::STATUS_REJECTED;
             $deposition->errors = $request['error'];
             $deposition->save();
             /**
              * @var PayoutTask $task
              */
             $task = $deposition->payoutTask;
             $task->status = PayoutTask::STATUS_FAILED;
             $task->save();
         }
         return $result;
     });
 }
Beispiel #2
0
            ?>
                <td><?php 
            echo $disposition->cardMask;
            ?>
</td>
                <td><?php 
            echo implode(' ', array($disposition->payerLastName, $disposition->payerFirstName, $disposition->payerMiddleName));
            ?>
</td>
            <?php 
        }
        ?>
            <td><?php 
        echo $disposition->amount;
        ?>
</td>
            <td><?php 
        echo $disposition->getAttributeLabel($disposition->status);
        ?>
</td>
            <td><?php 
        echo PayoutAPI::translateError($disposition->error);
        ?>
</td>
        </tr>
        <?php 
    }
    ?>
    </table>
<?php 
}
Beispiel #3
0
<?php

/* @var $this PayoutsController */
use YandexMoney\PayoutAPI;
use YandexMoney\PKCS7RequestProvider;
/* @var $model PayoutsSearchForm */
$this->menu = array(array('icon' => 'glyphicon glyphicon-plus-sign', 'label' => 'Создать задачу', 'url' => array('create')));
Yii::app()->clientScript->registerScript('search', "\n   \$('.search-button').click(function(){\n       \$('.search-form').toggle();\n       return false;\n   });\n   \$('.search-form form').submit(function(){\n       \$('#method-of-collection-data-grid').yiiGridView('update', {\n           data: \$(this).serialize()\n       });\n       return false;\n   });\n   ");
$settings = new \YandexMoney\Settings();
$settings->host = Yii::app()->params['yandexPayout']['host'];
$settings->cert = Yii::app()->params['yandexPayout']['cert'];
$settings->certPassword = Yii::app()->params['yandexPayout']['certPassword'];
$settings->privateKey = Yii::app()->params['yandexPayout']['privateKey'];
$settings->yaCert = Yii::app()->params['yandexPayout']['yaCert'];
$provider = new PKCS7RequestProvider($settings);
$api = new PayoutAPI($provider, Yii::app()->params['yandexPayout']['cardSynonimUrl']);
$currentBalance = null;
try {
    $response = $api->getBalance(new \YandexMoney\BalanceRequestParams(Yii::app()->params['yandexPayout']['agentId'], 0));
    $currentBalance = $response['balance'];
} catch (Exception $e) {
}
?>

<h1>Управление массовыми выплатами
    <div class="pull-right label label-warning">
        Баланс: <?php 
echo $currentBalance === null ? 'Не удалось получить' : sprintf('%.2f руб.', $currentBalance);
?>
    </div>
</h1>
 protected function processDeposition(PayoutAPI $api, PayoutTask $task, PayoutDeposition $deposition)
 {
     $depositionParams = new DepositionRequestParams($task->agentId, $deposition->clientOrderId, 'makeDeposition');
     $depositionParams->amount = $deposition->amount;
     $depositionParams->dstAccount = $deposition->dstAccount;
     $depositionParams->currency = $deposition->currency;
     $depositionParams->contract = $task->contract;
     if ($deposition->type == PayoutDeposition::TYPE_MOBILE) {
         $paymentParams = new MobilePaymentParams();
         $paymentParams->operatorCode = $deposition->phoneOperatorCode;
         $paymentParams->phoneNumber = $deposition->phoneNumber;
         $depositionParams->setPaymentParams($paymentParams);
     } elseif ($deposition->type == PayoutDeposition::TYPE_BANK_CARD) {
         $paymentParams = new BankCardPaymentParams();
         $paymentParams->cardSynonim = $deposition->cardSynonim;
         $paymentParams->lastName = $deposition->payerLastName;
         $paymentParams->firstName = $deposition->payerFirstName;
         $paymentParams->middleName = $deposition->payerMiddleName;
         $paymentParams->birthDate = $deposition->payerBirthDate;
         $paymentParams->birthPlace = $deposition->payerBirthPlace;
         $paymentParams->address = $deposition->payerAddress;
         $paymentParams->city = $deposition->payerCity;
         $paymentParams->country = $deposition->payerCountry;
         $paymentParams->postcode = $deposition->payerPostcode;
         $paymentParams->docNumber = $deposition->payerDocNumber;
         $paymentParams->docIssueDate = $deposition->payerDocIssueDate;
         $paymentParams->docIssuedBy = $deposition->payerDocIssuedBy;
         $paymentParams->smsPhoneNumber = $deposition->smsPhoneNumber;
         $depositionParams->setPaymentParams($paymentParams);
     }
     $response = $api->makeDeposition($depositionParams);
     switch (intval($response['status'])) {
         case PayoutAPI::REQ_STATUS_SUCCESS:
             $deposition->status = PayoutDeposition::STATUS_DONE;
             break;
         case PayoutAPI::REQ_STATUS_IN_PROGRESS:
             $deposition->status = PayoutDeposition::STATUS_IN_PROGRESS;
             break;
         case PayoutAPI::REQ_STATUS_REJECTED:
             $deposition->status = PayoutDeposition::STATUS_REJECTED;
             break;
     }
     if (in_array($deposition->status, array(PayoutDeposition::STATUS_DONE, PayoutDeposition::STATUS_REJECTED))) {
         $deposition->payerMiddleName = null;
         $deposition->payerBirthDate = null;
         $deposition->payerBirthPlace = null;
         $deposition->payerAddress = null;
         $deposition->payerCity = null;
         $deposition->payerCountry = null;
         $deposition->payerPostcode = null;
         $deposition->payerDocNumber = null;
         $deposition->payerDocIssueDate = null;
         $deposition->payerDocIssuedBy = null;
     }
     $deposition->error = $response['error'];
     $deposition->processedResponse = serialize($response);
     $deposition->save();
     return $deposition;
 }