/**
  * @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);
 }
 /**
  * @param PaymentMethodInterface $method
  * @param integer $amount
  *
  * @throws PaymentException
  */
 public function processPayment(PaymentMethodInterface $method, $amount)
 {
     /**
      * @var RedsysApiMethod $method
      */
     $paymentData = array('number' => $method->getCreditCartNumber(), 'holder' => $method->getCreditCartOwner(), 'expiration' => sprintf('%s%s', substr($method->getCreditCartExpirationYear(), -2, 2), str_pad($method->getCreditCartExpirationMonth(), 2, '0', STR_PAD_LEFT)), 'cvc' => $method->getCreditCartSecurity(), 'amount' => $amount);
     $this->setPayment($paymentData);
     try {
         $r = $this->_callSoap();
     } catch (\Exception $e) {
         /*
          * The Soap call failed
          */
         $this->eventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $method);
         throw new PaymentException($e->getMessage());
     }
     $this->storeTransaction($r);
     $this->eventDispatcher->notifyPaymentOrderLoad($this->paymentBridge, $method);
     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));
     }
     /*
      * Everything is ok, emitting the
      * payment.order.create event
      */
     $transaction = $this->getResponseData($r);
     $method->setTransactionId($transaction['DS_AUTHORISATIONCODE'])->setTransactionStatus('paid')->setTransactionResponse($transaction);
     $this->eventDispatcher->notifyPaymentOrderCreated($this->paymentBridge, $method);
     /*
      * Return if we are only authorizing, meaning
      * we don't have to fire a payment success
      * event
      */
     if ($this->transactionType == '1') {
         return;
     }
     /**
      * 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);
 }