示例#1
0
文件: Money.php 项目: krvd/cms-Inji
 public function reciver($data, $system, $status, $mr)
 {
     if ($system) {
         $merchant = \Money\Merchant::get($system, 'object_name');
     } else {
         $merchant = false;
     }
     if ($merchant) {
         $this->currentMerchant = $system;
     }
     $className = 'Money\\MerchantHelper\\' . $this->currentMerchant;
     $result = $className::reciver($data, $status);
     $result['pay'] = null;
     if (!empty($result['payId'])) {
         $result['pay'] = Money\Pay::get($result['payId']);
         $mr->pay_id = $result['payId'];
     }
     if ($result['pay'] && $result['pay']->pay_status_id == 1) {
         $statuses = \Money\Pay\Status::getList(['key' => 'code']);
         if (!empty($statuses[$result['status']])) {
             $result['pay']->pay_status_id = $statuses[$result['status']]->id;
         }
         $result['pay']->date_recive = date('Y-m-d H:i:s');
         $result['pay']->save();
         if ($result['status'] == 'success' && $result['pay']->callback_module && $result['pay']->callback_method) {
             App::$cur->{$result['pay']->callback_module}->{$result['pay']->callback_method}($result);
         }
     }
     if (!empty($result['callback'])) {
         echo $result['callback'];
         $mr->result_callback = $result['callback'];
     }
     if (!empty($result['status'])) {
         $mr->status = $result['status'];
     }
     $mr->save();
 }
示例#2
0
 public function goAction($pay_id, $merchant_id, $currency_id)
 {
     $pay = Money\Pay::get($pay_id);
     if (!$pay) {
         Tools::redirect('/', 'Такой платеж не найден', 'danger');
     }
     if ($pay->pay_status_id != 1) {
         Tools::redirect('/', 'Счет уже обработан');
     }
     $merchant = \Money\Merchant::get($merchant_id);
     if (!$merchant || !$merchant->active) {
         Tools::redirect('/', 'Такой способ оплаты не найден', 'danger');
     }
     $allowCurrencies = $merchant->allowCurrencies($pay);
     $method = [];
     foreach ($allowCurrencies as $allowCurrency) {
         if ($allowCurrency['currency']->id == $currency_id) {
             $method = $allowCurrency;
             break;
         }
     }
     if (!$method) {
         Tools::redirect('/', 'Валюта для этого способа оплаты не найдена', 'danger');
     }
     $merchantOptions = ['description' => $pay->description ? '#' . $pay->id . ' ' . $pay->description : 'Оплата счета №' . $pay->id . ' на сайте: ' . idn_to_utf8(INJI_DOMAIN_NAME), 'success' => 'http://' . INJI_DOMAIN_NAME . '/', 'false' => 'http://' . INJI_DOMAIN_NAME . '/'];
     $this->Money->goToMerchant($pay, $merchant, $method, $merchantOptions);
 }