/**
  * Получить статус перевода
  *
  * @param     $transferId (ID перевода)
  * @param     $channelId
  * @param int $billNumber (ID перевода, полученного в результате doTransfer)
  *
  * @param     $fromDate   (дата - с, полученная в результате doTransfer)
  * @param     $toDate     (дата - по, полученная в результате doTransfer)
  *
  * @return bool|int
  */
 public function getTransferStatus($transferId, $channelId, $billNumber, $fromDate = null, $toDate = null)
 {
     if (!$this->_setProvider($channelId)) {
         return false;
     }
     $creditPilotTransfer = CreditPilot::whereRaw('transfer_queue_id = ' . $transferId . ' AND bill_number = ' . $billNumber)->first();
     if (empty($creditPilotTransfer)) {
         return false;
     }
     $methodArgs = array();
     if (!empty($fromDate) && !empty($toDate)) {
         $methodArgs = array('fromDate' => urlencode($fromDate), 'toDate' => urlencode($toDate));
     }
     if ($billNumber > 0) {
         $methodArgs['billNumber'] = $billNumber;
     } else {
         $methodArgs['dealerTransactionId'] = $transferId;
     }
     $result = $this->_performRequest('FINDPAY', $methodArgs, $transferId);
     if (!$this->isError()) {
         switch ($result->payment->result['resultCode']) {
             case 20000:
             case 20002:
                 $creditPilotTransfer->status = PaymentsInfo::C_STATUS_WAITING;
                 break;
             case 1:
                 $creditPilotTransfer->status = PaymentsInfo::C_STATUS_PAID;
                 break;
             case 2:
                 $creditPilotTransfer->status = PaymentsInfo::C_STATUS_UNRECOGNIZED;
                 break;
                 // отказ
             // отказ
             default:
                 $creditPilotTransfer->status = PaymentsInfo::C_ERROR_TRANSFER_SYSTEM;
         }
         $creditPilotTransfer->save();
         return $creditPilotTransfer->status;
     }
     return false;
 }
 /**
  * Пробуем сделать платеж на тот же номер с той же суммой, должна быть не временная ошибка "платеж уже существует"
  */
 public function testFour()
 {
     $transferId = time();
     $creditPilotPayment = $this->creditPilotPayment;
     $amount = round(rand(0, 10000) / 100, 2);
     $result = $creditPilotPayment->doTransfer($transferId, '4652060320881342', CreditPilotPayment::CHANNEL_CREDIT_PILOT_BANK_CARD, $amount);
     $this->assertEmpty($creditPilotPayment->getErrorMessage(), $creditPilotPayment->getErrorMessage());
     $this->assertTrue($result);
     $transfer = CreditPilot::whereRaw('transfer_queue_id = ' . $transferId)->first();
     $status = $creditPilotPayment->getTransferStatus($transferId, CreditPilotPayment::CHANNEL_CREDIT_PILOT_BANK_CARD, $transfer->bill_number);
     $this->assertEquals(PaymentsInfo::C_STATUS_WAITING, $status);
     sleep(2);
     $status = $creditPilotPayment->getTransferStatus($transferId, CreditPilotPayment::CHANNEL_CREDIT_PILOT_BANK_CARD, $transfer->bill_number);
     $this->assertEquals(PaymentsInfo::C_STATUS_PAID, $status);
     $this->assertEmpty($creditPilotPayment->getErrorMessage(), $creditPilotPayment->getErrorMessage());
     $transferId = time();
     // пробуем платеж на тот же номер с той же суммой, но с другим ID - должна быь постоянная ошибка
     $result = $creditPilotPayment->doTransfer($transferId, '4652060320881342', CreditPilotPayment::CHANNEL_CREDIT_PILOT_BANK_CARD, $amount);
     $this->assertNotEmpty($creditPilotPayment->getErrorMessage(), $creditPilotPayment->getErrorMessage());
     $this->assertEquals(PaymentsInfo::C_ERROR_PAYMENT_ID_ALREADY_EXIST, $creditPilotPayment->getErrorCode());
     $this->assertFalse($result);
     $this->assertFalse($creditPilotPayment->isTempError());
 }