Exemplo n.º 1
0
 /**
  * Triggers the approveAndDeposit or reverseDeposit method of the plugin controller after
  * checking if the feedback response has a valid hash and that the payment instruction has pending transactions.
  *
  * @param PaymentInstructionInterface $instruction
  * @param $ogonePlugin
  * @param bool|false $isCaa
  * @return \JMS\Payment\CoreBundle\PluginController\Result|void
  * @throws \LogicException               If hash is not valid or if there is no pending transaction
  * @throws NoPendingTransactionException If no pending transaction is found in payment instruction
  */
 public function handleTransactionFeedback(PaymentInstructionInterface $instruction, $ogonePlugin, $isCaa = false)
 {
     if (!$isCaa && !$this->isHashValid($this->feedbackResponse->getValues(), $this->feedbackResponse->getHash())) {
         throw new \LogicException(sprintf('[Ogone - callback] hash verification failed with values [%s] and hash [%s]', print_r($this->feedbackResponse->getValues(), true), $this->feedbackResponse->getHash()));
     }
     $pendingTransaction = $this->init($instruction, $ogonePlugin);
     if ($this->feedbackResponse->isReimbursement()) {
         return $this->pluginController->reverseDeposit($pendingTransaction->getPayment()->getId(), $this->feedbackResponse->getAmount());
     }
     return $this->pluginController->approveAndDeposit($pendingTransaction->getPayment()->getId(), $this->feedbackResponse->getAmount());
 }
 public function testConstructor()
 {
     $feedbackResponse = new FeedbackResponse($this->requestStubber->getStubbedRequest());
     $this->assertSame($this->requestStubber->getMapForParameterBags(false), $feedbackResponse->getValues());
     $this->assertSame($this->requestStubber->getHashFromMap(), $feedbackResponse->getHash());
 }