/**
  * @expectedException  \Exception
  */
 public function testPostRequestFail()
 {
     $configInterfaceMock = $this->getMockBuilder('\\Magento\\Payment\\Model\\Method\\ConfigInterface')->getMockForAbstractClass();
     $zendResponseMock = $this->getMockBuilder('\\Zend_Http_Response')->setMethods(['getBody'])->disableOriginalConstructor()->getMock();
     $zendResponseMock->expects($this->never())->method('getBody');
     $this->zendClientMock->expects($this->once())->method('request')->willThrowException(new \Exception());
     $object = new \Magento\Framework\DataObject();
     $this->object->postRequest($object, $configInterfaceMock);
 }
Beispiel #2
0
 /**
  * @expectedException  \Zend_Http_Client_Exception
  */
 public function testPostRequestFail()
 {
     /** @var ConfigInterface|\PHPUnit_Framework_MockObject_MockObject $configInterfaceMock */
     $configInterfaceMock = $this->getMockBuilder(ConfigInterface::class)->getMockForAbstractClass();
     $zendResponseMock = $this->getMockBuilder(\Zend_Http_Response::class)->setMethods(['getBody'])->disableOriginalConstructor()->getMock();
     $zendResponseMock->expects(static::never())->method('getBody');
     $this->zendClientMock->expects(static::once())->method('request')->willThrowException(new \Zend_Http_Client_Exception());
     $object = new DataObject();
     $this->object->postRequest($object, $configInterfaceMock);
 }
 public function testInitialize()
 {
     $order = $this->getMock('Magento\\Sales\\Model\\Order', [], [], '', false);
     $this->infoInstance->expects($this->any())->method('getOrder')->will($this->returnValue($order));
     $this->infoInstance->expects($this->any())->method('setAdditionalInformation')->will($this->returnSelf());
     $this->paypalConfig->expects($this->once())->method('getBuildNotationCode')->will($this->returnValue('build notation code'));
     $response = new \Magento\Framework\DataObject(['result' => '0', 'pnref' => 'V19A3D27B61E', 'respmsg' => 'Approved', 'authcode' => '510PNI', 'hostcode' => 'A', 'request_id' => 'f930d3dc6824c1f7230c5529dc37ae5e', 'result_code' => '0']);
     $this->gatewayMock->expects($this->once())->method('postRequest')->willReturn($response);
     $this->payflowRequest->expects($this->exactly(3))->method('setData')->willReturnMap([['user' => null, 'vendor' => null, 'partner' => null, 'pwd' => null, 'verbosity' => null, 'BNCODE' => 'build notation code', 'tender' => 'C'], $this->returnSelf()], ['USER1', 1, $this->returnSelf()], ['USER2', 'a20d3dc6824c1f7780c5529dc37ae5e', $this->returnSelf()]);
     $stateObject = new \Magento\Framework\DataObject();
     $this->model->initialize(\Magento\Paypal\Model\Config::PAYMENT_ACTION_AUTH, $stateObject);
 }
 /**
  * Call payflow gateway request and return response object
  * @return \Magento\Framework\DataObject
  */
 protected function execGatewayRequest()
 {
     $this->initStoreMock();
     $response = $this->getGatewayResponseObject();
     $this->gatewayMock->expects(static::once())->method('postRequest')->with($this->isInstanceOf('Magento\\Framework\\DataObject'), $this->isInstanceOf('Magento\\Paypal\\Model\\PayflowConfig'))->willReturn($response);
     return $response;
 }
 /**
  * Test method
  * with resultCode = RESPONSE_CODE_APPROVED and Origresult != RESPONSE_CODE_FRAUDSERVICE_FILTER
  */
 public function testAuthorize()
 {
     $this->initializationAuthorizeMock();
     $this->buildRequestData();
     $paymentTokenMock = $this->getMock(PaymentTokenInterface::class);
     $extensionAttributes = $this->getMockBuilder('Magento\\Sales\\Api\\Data\\OrderPaymentExtensionInterface')->disableOriginalConstructor()->setMethods(['setVaultPaymentToken'])->getMock();
     $ccDetails = ['cc_type' => 'VI', 'cc_number' => '1111'];
     $this->responseMock->setData('result_code', Payflowpro::RESPONSE_CODE_APPROVED);
     $this->responseMock->setData('origresult', 0);
     $this->responseMock->setData('pnref', 'test-pnref');
     $this->gatewayMock->expects($this->once())->method('postRequest')->willReturn($this->responseMock);
     $this->responseValidator->expects($this->once())->method('validate')->with($this->responseMock);
     $this->paymentMock->expects($this->once())->method('setTransactionId')->with('test-pnref')->willReturnSelf();
     $this->paymentMock->expects($this->once())->method('setIsTransactionClosed')->with(0);
     $this->paymentMock->expects($this->once())->method('getCcExpYear')->willReturn('2017');
     $this->paymentMock->expects($this->once())->method('getCcExpMonth')->willReturn('12');
     $this->paymentMock->expects(static::any())->method('getAdditionalInformation')->willReturnMap([[Transparent::CC_DETAILS, $ccDetails], [Transparent::PNREF, 'test-pnref']]);
     $this->paymentTokenFactory->expects(static::once())->method('create')->willReturn($paymentTokenMock);
     $paymentTokenMock->expects(static::once())->method('setGatewayToken')->with('test-pnref');
     $paymentTokenMock->expects(static::once())->method('setTokenDetails')->with(json_encode($ccDetails));
     $paymentTokenMock->expects(static::once())->method('setExpiresAt')->with('2018-01-01 00:00:00');
     $this->paymentMock->expects(static::once())->method('getExtensionAttributes')->willReturn($extensionAttributes);
     $extensionAttributes->expects(static::once())->method('setVaultPaymentToken')->with($paymentTokenMock);
     $this->assertSame($this->object, $this->object->authorize($this->paymentMock, 33));
 }
Beispiel #6
0
 public function testPostRequestException()
 {
     $this->setExpectedException(LocalizedException::class, __('Payment Gateway is unreachable at the moment. Please use another payment option.'));
     $request = new DataObject();
     /** @var ConfigInterface $config */
     $config = $this->getMock(ConfigInterface::class);
     $this->gatewayMock->expects(static::once())->method('postRequest')->with($request, $config)->willThrowException(new \Zend_Http_Client_Exception());
     $this->payflowpro->postRequest($request, $config);
 }
Beispiel #7
0
 /**
  * test for _buildBasicRequest (BDCODE)
  */
 public function testFetchTransactionInfoForBN()
 {
     $storeMock = $this->getMock('Magento\\Store\\Model\\Store', ['getId'], [], '', false);
     $response = new \Magento\Framework\Object(['result' => '0', 'pnref' => 'V19A3D27B61E', 'respmsg' => 'Approved', 'authcode' => '510PNI', 'hostcode' => 'A', 'request_id' => 'f930d3dc6824c1f7230c5529dc37ae5e', 'result_code' => '0']);
     $this->gatewayMock->expects($this->once())->method('postRequest')->willReturn($response);
     $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($storeMock);
     $storeMock->expects($this->once())->method('getId')->willReturn(77);
     $this->configMock->expects($this->once())->method('getBuildNotationCode')->will($this->returnValue('BNCODE'));
     $payment = $this->getMock('Magento\\Payment\\Model\\Info', ['setTransactionId', '__wakeup'], [], '', false);
     $payment->expects($this->once())->method('setTransactionId')->will($this->returnSelf());
     $this->payflowpro->fetchTransactionInfo($payment, 'AD49G8N825');
 }
Beispiel #8
0
 /**
  * Test method
  * with resultCode = RESPONSE_CODE_APPROVED and Origresult != RESPONSE_CODE_FRAUDSERVICE_FILTER
  */
 public function testAuthorize()
 {
     $this->initializationAuthorizeMock();
     $this->buildRequestData();
     $this->responseMock->expects($this->any())->method('getResultCode')->willReturn(Payflowpro::RESPONSE_CODE_APPROVED);
     $this->responseMock->expects($this->any())->method('getOrigresult')->willReturn(0);
     $this->gatewayMock->expects($this->once())->method('postRequest')->willReturn($this->responseMock);
     $this->responseValidator->expects($this->once())->method('validate')->with($this->responseMock);
     $this->responseMock->expects($this->once())->method('getPnref')->willReturn('test-pnref');
     $this->paymentMock->expects($this->once())->method('setTransactionId')->with('test-pnref')->willReturnSelf();
     $this->paymentMock->expects($this->once())->method('setIsTransactionClosed')->with(0);
     $this->assertSame($this->object, $this->object->authorize($this->paymentMock, 33));
 }
Beispiel #9
0
 /**
  * {inheritdoc}
  */
 public function postRequest(DataObject $request, ConfigInterface $config)
 {
     try {
         return $this->gateway->postRequest($request, $config);
     } catch (\Zend_Http_Client_Exception $e) {
         throw new LocalizedException(__('Payment Gateway is unreachable at the moment. Please use another payment option.'), $e);
     }
 }
 /**
  * {inheritdoc}
  */
 public function postRequest(DataObject $request, ConfigInterface $config)
 {
     return $this->gateway->postRequest($request, $config);
 }