/** * @magentoDataFixture Magento/Sales/_files/order_paid_with_payflowpro.php */ public function testReviewPaymentNullResponce() { /** @var \Magento\Sales\Model\Order $order */ $order = $this->_objectManager->create('Magento\\Sales\\Model\\Order'); $order->loadByIncrementId('100000001'); $this->_httpClientMock->expects($this->any())->method('request')->will($this->returnValue(new \Magento\Framework\Object(['body' => 'RESULTval=12&val2=34']))); $expectedResult = ['resultval' => '12', 'val2' => '34', 'result_code' => null, 'respmsg' => null]; $this->assertEquals($expectedResult, $this->_model->acceptPayment($order->getPayment())); }
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); }
/** * @param array $expectsMethods * @param bool $result * * @dataProvider dataProviderForTestIsActive */ public function testIsActive(array $expectsMethods, $result) { $storeId = 15; $i = 0; foreach ($expectsMethods as $method => $isActive) { $this->scopeConfigMock->expects($this->at($i++))->method('getValue')->with("payment/{$method}/active", ScopeInterface::SCOPE_STORE, $storeId)->willReturn($isActive); } $this->assertEquals($result, $this->payflowpro->isActive($storeId)); }
/** * @covers \Magento\Paypal\Model\Payflowpro::assignData */ public function testAssignData() { $data = ['cc_type' => 'VI', 'cc_last_4' => 1111, 'cc_exp_month' => 12, 'cc_exp_year' => 2023]; $dataObject = new DataObject($data); $infoInstance = $this->getMockForAbstractClass(InfoInterface::class); $this->payflowpro->setData('info_instance', $infoInstance); $this->eventManager->expects(static::exactly(2))->method('dispatch'); $this->payflowpro->assignData($dataObject); }
/** * @covers \Magento\Paypal\Model\Payflowpro::refund() */ public function testRefund() { /** @var \Magento\Sales\Model\Order\Payment $paymentMock */ $paymentMock = $this->getPaymentMock(); $response = $this->execGatewayRequest(); $amount = 213.04; $this->payflowpro->refund($paymentMock, $amount); static::assertEquals($response['pnref'], $paymentMock->getTransactionId()); static::assertTrue($paymentMock->getIsTransactionClosed()); }
/** * @covers \Magento\Paypal\Model\Payflowpro::authorize */ public function testAuthorize() { $paymentMock = $this->getPaymentMock(); $orderMock = $this->getOrderMock(); $paymentMock->expects(static::exactly(2))->method('getOrder')->willReturn($orderMock); $response = $this->execGatewayRequest(); $amount = 43.2; $this->payflowpro->authorize($paymentMock, $amount); static::assertEquals($response['pnref'], $paymentMock->getTransactionId()); static::assertFalse((bool) $paymentMock->getIsTransactionPending()); }
/** * Capture payment * * @param InfoInterface|Payment $payment * @param float $amount * @return $this * @throws \Magento\Framework\Exception\LocalizedException * @throws \Magento\Framework\Exception\State\InvalidTransitionException */ public function capture(InfoInterface $payment, $amount) { /** @var Payment $payment */ $token = $payment->getAdditionalInformation(self::PNREF); parent::capture($payment, $amount); if ($token && !$payment->getAuthorizationTransaction()) { $this->createPaymentToken($payment, $token); } return $this; }
/** * Return request object with basic information for gateway request * * @return \Magento\Paypal\Model\Payflow\Request */ public function buildBasicRequest() { /** @var \Magento\Paypal\Model\Payflow\Request $request */ $request = $this->_requestFactory->create(); $cscEditable = $this->getConfigData('csc_editable'); $data = parent::buildBasicRequest(); $request->setData($data->getData()); $request->setCancelurl($this->_getCallbackUrl('cancelPayment'))->setErrorurl($this->_getCallbackUrl('returnUrl'))->setSilentpost('TRUE')->setSilentposturl($this->_getCallbackUrl('silentPost'))->setReturnurl($this->_getCallbackUrl('returnUrl'))->setTemplate(self::LAYOUT_TEMPLATE)->setDisablereceipt('TRUE')->setCscrequired($cscEditable && $this->getConfigData('csc_required') ? 'TRUE' : 'FALSE')->setCscedit($cscEditable ? 'TRUE' : 'FALSE')->setEmailcustomer($this->getConfigData('email_confirmation') ? 'TRUE' : 'FALSE')->setUrlmethod($this->getConfigData('url_method')); return $request; }
/** * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Logger\AdapterFactory $logAdapterFactory * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\Module\ModuleListInterface $moduleList * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Centinel\Model\Service $centinelService * @param \Magento\Framework\StoreManagerInterface $storeManager * @param \Magento\Paypal\Model\ConfigFactory $configFactory * @param \Magento\Framework\Math\Random $mathRandom * @param \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory * @param \Magento\Paypal\Model\Payflow\RequestFactory $requestFactory * @param \Magento\Sales\Model\QuoteFactory $quoteFactory * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Framework\App\RequestInterface $requestHttp * @param \Magento\Store\Model\WebsiteFactory $websiteFactory * @param OrderSender $orderSender * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct(\Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Payment\Helper\Data $paymentData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Logger\AdapterFactory $logAdapterFactory, \Magento\Framework\Logger $logger, \Magento\Framework\Module\ModuleListInterface $moduleList, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Centinel\Model\Service $centinelService, \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Paypal\Model\ConfigFactory $configFactory, \Magento\Framework\Math\Random $mathRandom, \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory, \Magento\Paypal\Model\Payflow\RequestFactory $requestFactory, \Magento\Sales\Model\QuoteFactory $quoteFactory, \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Framework\App\RequestInterface $requestHttp, \Magento\Store\Model\WebsiteFactory $websiteFactory, OrderSender $orderSender, array $data = array()) { $this->_requestFactory = $requestFactory; $this->_quoteFactory = $quoteFactory; $this->_orderFactory = $orderFactory; $this->_requestHttp = $requestHttp; $this->_websiteFactory = $websiteFactory; $this->orderSender = $orderSender; parent::__construct($eventManager, $paymentData, $scopeConfig, $logAdapterFactory, $logger, $moduleList, $localeDate, $centinelService, $storeManager, $configFactory, $mathRandom, $httpClientFactory, $data); }
/** * {inheritdoc} */ public function getConfigInterface() { return parent::getConfig(); }