예제 #1
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);
 }
예제 #2
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);
 }