예제 #1
0
 public function testGetByTransactionTypeFromCache()
 {
     $transactionType = Transaction::TYPE_AUTH;
     $paymentId = 1;
     $orderId = 3;
     $cacheStorage = 'txn_type';
     $transaction = "transaction";
     $identityFieldsForCache = [$transactionType, $paymentId];
     $this->entityStorage->method('getByIdentifyingFields')->with($identityFieldsForCache, $cacheStorage)->willReturn($transaction);
     $this->assertEquals($transaction, $this->repository->getByTransactionType($transactionType, $paymentId, $orderId));
 }
예제 #2
0
 /**
  * Void payment
  * Void is in regards to the payment on the order invoice - to void the authorization, for instance - so that
  * the funds aren't subsequently captured. Payments have to be refunded after capture and cannot be voided.
  *
  * map this operation to APPROVEREVERSAL
  *
  * @param \Magento\Framework\DataObject|InfoInterface|\Magento\Sales\Model\Order\Payment $payment
  *
  * @return $this
  * @throws \Exception
  * @api
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function void(\Magento\Payment\Model\InfoInterface $payment)
 {
     if (!$this->_dataHelper->isBackendAvailable()) {
         return $this;
     }
     $orderNumber = $payment->getAdditionalInformation('orderNumber');
     if (!strlen($orderNumber)) {
         /* dont throw an exception here, might be a pending payment */
         $this->_logger->debug(__METHOD__ . ':No order number found.');
         return $this;
     }
     $orderDetails = $this->getOrderDetails($orderNumber);
     $backendClient = $this->_dataHelper->getBackendClient();
     $approveDone = false;
     foreach ($orderDetails->getOrder()->getPayments() as $wdPayment) {
         /** @var \WirecardCEE_QPay_Response_Toolkit_Order_Payment $wdPayment */
         $this->_logger->debug(__METHOD__ . ':operations allowed:' . implode(',', $wdPayment->getOperationsAllowed()));
         if (in_array('APPROVEREVERSAL', $wdPayment->getOperationsAllowed())) {
             $this->_logger->debug(__METHOD__ . ":{$orderNumber}");
             $ret = $backendClient->approveReversal($orderNumber);
             if ($ret->hasFailed()) {
                 throw new \Exception($ret->getError()->getMessage());
             }
             $approveDone = true;
             $orderTransaction = $this->_transactionRepository->getByTransactionType(Transaction::TYPE_ORDER, $payment->getId(), $payment->getOrder()->getId());
             if ($orderTransaction) {
                 $payment->setParentTransactionId($orderTransaction->getTxnId());
                 $payment->setTransactionId($orderTransaction->getTxnId() . '-void');
             }
             $payment->addTransactionCommentsToOrder($orderTransaction, 'approveReversal');
         }
     }
     if (!$approveDone) {
         throw new \Exception($this->_dataHelper->__('Void not possible anymore for this payment, please try cancel instead!'));
     }
     return $this;
 }