示例#1
0
 /**
  * @param string $payuplOrderId
  * @param string $status
  * @param float $amount
  * @param bool $newest
  * @return bool
  * @throws LocalizedException
  */
 public function processStatusChange($payuplOrderId, $status = '', $amount = null, $newest = true)
 {
     if (!in_array($status, [Order::STATUS_NEW, Order::STATUS_PENDING, Order::STATUS_CANCELLED, Order::STATUS_REJECTED, Order::STATUS_WAITING, Order::STATUS_REJECTED_CANCELLED, Order::STATUS_COMPLETED, Order::STATUS_ERROR])) {
         throw new LocalizedException(new Phrase('Invalid status.'));
     }
     if (!$newest) {
         $close = in_array($status, [Order::STATUS_CANCELLED, Order::STATUS_REJECTED, Order::STATUS_COMPLETED]);
         $this->orderProcessor->processOld($payuplOrderId, $status, $close);
         return true;
     }
     switch ($status) {
         case Order::STATUS_NEW:
         case Order::STATUS_PENDING:
             $this->orderProcessor->processPending($payuplOrderId, $status);
             return true;
         case Order::STATUS_CANCELLED:
         case Order::STATUS_REJECTED:
         case Order::STATUS_REJECTED_CANCELLED:
         case Order::STATUS_ERROR:
             $this->orderProcessor->processHolded($payuplOrderId, $status);
             return true;
         case Order::STATUS_WAITING:
             $this->orderProcessor->processWaiting($payuplOrderId, $status);
             return true;
         case Order::STATUS_COMPLETED:
             $this->orderProcessor->processCompleted($payuplOrderId, $status, $amount);
             return true;
     }
 }
示例#2
0
 public function testProcessHoldedSuccess()
 {
     $payuplOrderId = 'ABC';
     $status = 'WAITING';
     $order = $this->getOrderMock();
     $this->orderHelper->expects($this->once())->method('loadOrderByPayuplOrderId')->willReturn($order);
     $this->orderHelper->expects($this->once())->method('setHoldedOrderStatus')->with($this->equalTo($order), $this->equalTo($status));
     $this->transactionService->expects($this->once())->method('updateStatus')->with($this->equalTo($payuplOrderId), $this->equalTo($status), $this->equalTo(true));
     $this->model->processHolded($payuplOrderId, $status);
 }