Example #1
0
 /**
  * Post request into gateway
  *
  * @param DataObject $request
  * @param ConfigInterface $config
  *
  * @return DataObject
  * @throws \Zend_Http_Client_Exception
  */
 public function postRequest(DataObject $request, ConfigInterface $config)
 {
     $result = new DataObject();
     $clientConfig = ['maxredirects' => 5, 'timeout' => 30, 'verifypeer' => $config->getValue('verify_peer')];
     if ($config->getValue('use_proxy')) {
         $clientConfig['proxy'] = $config->getValue('proxy_host') . ':' . $config->getValue('proxy_port');
         $clientConfig['httpproxytunnel'] = true;
         $clientConfig['proxytype'] = CURLPROXY_HTTP;
     }
     /** @var ZendClient $client */
     $client = $this->httpClientFactory->create();
     $client->setUri((bool) $config->getValue('sandbox_flag') ? $config->getValue('transaction_url_test_mode') : $config->getValue('transaction_url'));
     $client->setConfig($clientConfig);
     $client->setMethod(\Zend_Http_Client::POST);
     $client->setParameterPost($request->getData());
     $client->setHeaders(['X-VPS-VIT-CLIENT-CERTIFICATION-ID' => '33baf5893fc2123d8b191d2d011b7fdc', 'X-VPS-Request-ID' => $this->mathRandom->getUniqueHash(), 'X-VPS-CLIENT-TIMEOUT' => 45]);
     $client->setUrlEncodeBody(false);
     try {
         $response = $client->request();
         $responseArray = [];
         parse_str(strstr($response->getBody(), 'RESULT'), $responseArray);
         $result->setData(array_change_key_case($responseArray, CASE_LOWER));
         $result->setData('result_code', $result->getData('result'));
     } catch (\Zend_Http_Client_Exception $e) {
         $result->addData(['response_code' => -1, 'response_reason_code' => $e->getCode(), 'response_reason_text' => $e->getMessage()]);
         throw $e;
     } finally {
         $this->logger->debug(['request' => $request->getData(), 'result' => $result->getData()], (array) $config->getValue('getDebugReplacePrivateDataKeys'), (bool) $config->getValue('debug'));
     }
     return $result;
 }
 /**
  * @param bool $expectedResult
  * @param \Magento\Framework\DataObject $response
  * @param string $avsSecurityCodeFlag
  *
  * @dataProvider validationDataProvider
  */
 public function testValidation($expectedResult, \Magento\Framework\DataObject $response, $avsSecurityCodeFlag)
 {
     $this->configMock->expects($this->once())->method('getValue')->with(CVV2Match::CONFIG_NAME)->willReturn($avsSecurityCodeFlag);
     $this->assertEquals($expectedResult, $this->validator->validate($response));
     if (!$expectedResult) {
         $this->assertNotEmpty($response->getRespmsg());
     }
 }
Example #3
0
 /**
  * @param bool $expectedResult
  * @param \Magento\Framework\Object $response
  * @param array $configMap
  * @param int $exactlyCount
  *
  * @dataProvider validationDataProvider
  */
 public function testValidation($expectedResult, \Magento\Framework\Object $response, array $configMap, $exactlyCount)
 {
     $this->configMock->expects($this->exactly($exactlyCount))->method('getValue')->willReturnMap($configMap);
     $this->assertEquals($expectedResult, $this->validator->validate($response));
     if (!$expectedResult) {
         $this->assertNotEmpty($response->getRespmsg());
     }
 }
 /**
  * @param bool $expectedResult
  * @param \Magento\Framework\DataObject $response
  * @param array $configMap
  * @param int $exactlyCount
  *
  * @dataProvider validationDataProvider
  */
 public function testValidation($expectedResult, \Magento\Framework\DataObject $response, array $configMap, $exactlyCount)
 {
     $this->payflowproFacade->expects(static::once())->method('getConfig')->willReturn($this->configMock);
     $this->configMock->expects(static::exactly($exactlyCount))->method('getValue')->willReturnMap($configMap);
     static::assertEquals($expectedResult, $this->validator->validate($response, $this->payflowproFacade));
     if (!$expectedResult) {
         static::assertNotEmpty($response->getRespmsg());
     }
 }
 /**
  * test for _buildBasicRequest (BDCODE)
  */
 public function testFetchTransactionInfoForBN()
 {
     $response = $this->getGatewayResponseObject();
     $this->gatewayMock->expects($this->once())->method('postRequest')->willReturn($response);
     $this->initStoreMock();
     $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');
 }
Example #6
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');
 }
Example #7
0
 /**
  * Get Config instance
  *
  * @return PayflowConfig
  */
 public function getConfig()
 {
     if (!$this->config) {
         $storeId = $this->storeManager->getStore($this->getStore())->getId();
         $this->config = $this->configFactory->create();
         $this->config->setStoreId($storeId);
         $this->config->setMethodInstance($this);
         $this->config->setMethod($this);
     }
     return $this->config;
 }
Example #8
0
 /**
  * Logs payment related information used for debug
  *
  * @param mixed $logData
  * @param ConfigInterface $config
  *
  * @return void
  */
 public function debug($logData, ConfigInterface $config)
 {
     if ($config->getConfigValue('debug')) {
         $this->logger->debug(var_export($logData, true));
     }
 }