Пример #1
0
 /**
  * Retrieves the order matching $transaction and adds it to $transaction
  *
  * @param TransactionInterface $transaction The request's transaction (will be linked to the order in the process)
  *
  * @return \Sonata\Component\Order\OrderInterface
  * @throws \Doctrine\ORM\EntityNotFoundException
  * @throws InvalidTransactionException
  */
 protected function getValidOrder(TransactionInterface $transaction)
 {
     $payment = $this->getPayment($transaction->getPaymentCode());
     // retrieve the related order
     $reference = $payment->getOrderReference($transaction);
     if (!$reference) {
         throw new InvalidTransactionException();
     }
     $order = $this->orderManager->findOneby(array('reference' => $reference));
     if (!$order) {
         throw new EntityNotFoundException(sprintf('Order %s', $reference));
     }
     $transaction->setOrder($order);
     // control the handshake value
     if (!$payment->isRequestValid($transaction)) {
         throw new InvalidTransactionException($order->getReference());
     }
     return $order;
 }