/**
  * @param PaymentMethodInterface $method
  * @param integer $amount
  *
  * @throws PaymentException
  */
 public function processPayment(PaymentMethodInterface $method, $amount)
 {
     /**
      * @var AdyenMethod $method
      */
     $paymentData = [];
     $paymentData['additionalData'] = ['card.encrypted.json' => $method->getAdditionalData()];
     $paymentData['amount'] = ['value' => $amount, 'currency' => $this->currency];
     $paymentData['reference'] = $method->getTransactionId();
     $paymentData['merchantAccount'] = $this->merchantCode;
     try {
         $r = $this->callApi($paymentData);
     } catch (\Exception $e) {
         /*
          * The Soap call failed
          */
         $this->eventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $method);
         $this->logger->addError('PaymentException: ' . $e->getMessage());
         $this->paymentBridge->setError($e->getMessage());
         $this->paymentBridge->setErrorCode($e->getCode());
         throw new PaymentException($e->getMessage());
     }
     $r['amount'] = $amount;
     $this->storeTransaction($r);
     if (!$this->isAuthorized($r)) {
         $this->paymentBridge->setError($this->getError($r));
         $this->paymentBridge->setErrorCode($this->getErrorCode($r));
         /**
          * The payment was not successful
          */
         $this->eventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $method);
         throw new PaymentException($this->getErrorCode($r));
     }
     $this->eventDispatcher->notifyPaymentOrderLoad($this->paymentBridge, $method);
     /*
      * Everything is ok, emitting the
      * payment.order.create event
      */
     $method->setTransactionId($r['pspReference'])->setTransactionStatus('paid');
     $this->eventDispatcher->notifyPaymentOrderCreated($this->paymentBridge, $method);
     /**
      * Payment process has returned control
      */
     $this->eventDispatcher->notifyPaymentOrderDone($this->paymentBridge, $method);
     /**
      * Payment paid successfully
      *
      * Paid process has ended successfully
      */
     $this->eventDispatcher->notifyPaymentOrderSuccess($this->paymentBridge, $method);
 }