/**
  * Processes the payment
  *
  * @param PaymentInstruction $instruction the PaymentInstruction to handle
  * @param array              $data        the decrypted response data
  *
  * @return Result
  */
 public function handle($instruction, $data)
 {
     if (null === ($pendingTransaction = $instruction->getPendingTransaction())) {
         $payment = $this->pluginController->createPayment($instruction->getId(), $instruction->getAmount() - $instruction->getDepositedAmount());
     } else {
         $payment = $pendingTransaction->getPayment();
     }
     foreach ($data as $key => $val) {
         $instruction->getExtendedData()->set($key, $val);
     }
     $result = $this->pluginController->approveAndDeposit($payment->getId(), $payment->getTargetAmount());
     return $result;
 }
 /**
  * @return \JMS\Payment\CoreBundle\Model\PaymentInterface
  */
 private function getPaymentFromOrder(OrderInterface $order)
 {
     if (null === ($pendingTransaction = $order->getPaymentInstruction()->getPendingTransaction())) {
         $this->logger->info('Pending transaction for order not found', array('orderId' => $order->getId(), 'requestId' => $this->request->getId()));
         $payment = $this->pluginController->createPayment($order->getPaymentInstruction()->getId(), round($order->getPaymentInstruction()->getAmount() - $order->getPaymentInstruction()->getDepositedAmount(), 2));
     } else {
         $payment = $pendingTransaction->getPayment();
     }
     return $payment;
 }