コード例 #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
 /**
  * @covers       \PayStand\PayStandMagento\Model\Directpost::fetchTransactionInfo
  *
  * @param $transactionId
  * @param $resultStatus
  * @param $responseStatus
  * @param $responseCode
  * @return void
  *
  * @dataProvider dataProviderTransaction
  */
 public function testFetchVoidedTransactionInfo($transactionId, $resultStatus, $responseStatus, $responseCode)
 {
     $paymentId = 36;
     $orderId = 36;
     $this->paymentMock->expects(static::once())->method('getId')->willReturn($paymentId);
     $orderMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->setMethods(['getId', '__wakeup'])->getMock();
     $orderMock->expects(static::once())->method('getId')->willReturn($orderId);
     $this->paymentMock->expects(static::once())->method('getOrder')->willReturn($orderMock);
     $transactionMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Payment\\Transaction')->disableOriginalConstructor()->getMock();
     $this->transactionRepositoryMock->expects(static::once())->method('getByTransactionId')->with($transactionId, $paymentId, $orderId)->willReturn($transactionMock);
     $document = $this->getTransactionXmlDocument($transactionId, TransactionService::PAYMENT_UPDATE_STATUS_CODE_SUCCESS, $resultStatus, $responseStatus, $responseCode);
     $this->transactionServiceMock->expects(static::once())->method('getTransactionDetails')->with($this->directpost, $transactionId)->willReturn($document);
     // transaction should be closed
     $this->paymentMock->expects(static::once())->method('setIsTransactionDenied')->with(true);
     $this->paymentMock->expects(static::once())->method('setIsTransactionClosed')->with(true);
     $transactionMock->expects(static::once())->method('close');
     $this->directpost->fetchTransactionInfo($this->paymentMock, $transactionId);
 }
コード例 #3
0
 /**
  * @covers \Magento\Authorizenet\Model\Directpost::refund()
  * @return void
  */
 public function testSuccessRefund()
 {
     $card = 1111;
     $this->paymentMock->expects(static::exactly(2))->method('getCcLast4')->willReturn($card);
     $this->paymentMock->expects(static::once())->method('decrypt')->willReturn($card);
     $this->paymentMock->expects(static::exactly(3))->method('getParentTransactionId')->willReturn(self::TRANSACTION_ID . '-capture');
     $this->paymentMock->expects(static::once())->method('getPoNumber')->willReturn(self::INVOICE_NUM);
     $this->paymentMock->expects(static::once())->method('setIsTransactionClosed')->with(true)->willReturnSelf();
     $orderMock = $this->getOrderMock();
     $this->paymentMock->expects(static::exactly(2))->method('getOrder')->willReturn($orderMock);
     $transactionMock = $this->getMockBuilder(Order\Payment\Transaction::class)->disableOriginalConstructor()->setMethods(['getAdditionalInformation'])->getMock();
     $transactionMock->expects(static::once())->method('getAdditionalInformation')->with(Directpost::REAL_TRANSACTION_ID_KEY)->willReturn(self::TRANSACTION_ID);
     $this->transactionRepositoryMock->expects(static::once())->method('getByTransactionId')->willReturn($transactionMock);
     $response = $this->getRefundResponseBody(Directpost::RESPONSE_CODE_APPROVED, Directpost::RESPONSE_REASON_CODE_APPROVED, 'Successful');
     $this->httpClientMock->expects(static::once())->method('getBody')->willReturn($response);
     $this->responseMock->expects(static::once())->method('getXResponseCode')->willReturn(Directpost::RESPONSE_CODE_APPROVED);
     $this->responseMock->expects(static::once())->method('getXResponseReasonCode')->willReturn(Directpost::RESPONSE_REASON_CODE_APPROVED);
     $this->dataHelperMock->expects(static::never())->method('wrapGatewayError');
     $this->directpost->refund($this->paymentMock, self::TOTAL_AMOUNT);
 }
コード例 #4
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;
 }