Skip to content
This repository has been archived by the owner on Feb 16, 2022. It is now read-only.

Commit

Permalink
Merge pull request #124 from heidelpay/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Ryouzanpaku authored Oct 17, 2019
2 parents 2b391b1 + e78088f commit cedc4b9
Show file tree
Hide file tree
Showing 15 changed files with 367 additions and 161 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
## Versioning

This project does not follow a versioning standard. Versions are crafted after the dates; for example, the version 17.7.25 was released on July, 25th in 2017
## 19.10.17
### Added
- Hash validation to push requests.
- Compatibility with Magento 2.3

### Fixed
- Use the correct store config now for orders made in sub stores.
- online refund failed with orders via invoice payment methods.

### Changed
- Redirect controller: redirect to cart if oder could not be loaded correctly.

## 19.7.29

### Added
Expand Down
12 changes: 6 additions & 6 deletions Controller/Adminhtml/Order/Shipment/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public function beforeExecute()
// get the payment method instance and the heidelpay method instance
/** @var HeidelpayAbstractPaymentMethod $method */
$method = $order->getPayment()->getMethodInstance();
$storeId = $order->getStoreId();

// only fire the shipping when a heidelpay payment method is used.
if ($method instanceof HeidelpayAbstractPaymentMethod) {
Expand All @@ -108,13 +109,12 @@ public function beforeExecute()

/** @var HgwBasePaymentConfigInterface $methodConfig */
$methodConfig = $method->getConfig();

$heidelpayMethod->getRequest()->authentification(
$mainConfig->getSecuritySender(),
$mainConfig->getUserLogin(),
$mainConfig->getUserPasswd(),
$methodConfig->getChannel(),
$mainConfig->isSandboxModeActive()
$mainConfig->getSecuritySender($storeId),
$mainConfig->getUserLogin($storeId),
$mainConfig->getUserPasswd($storeId),
$methodConfig->getChannel($storeId),
$mainConfig->isSandboxModeActive($storeId)
);

// set the basket data (for amount and currency and a secret hash for fraud checking)
Expand Down
20 changes: 15 additions & 5 deletions Controller/HgwAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
namespace Heidelpay\Gateway\Controller;

use Heidelpay\Gateway\Helper\Payment as HeidelpayHelper;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Controller\ResultInterface;
use Magento\Quote\Model\QuoteManagement;
use Magento\Sales\Model\Order\Email\Sender\OrderSender;
use Magento\Sales\Model\Order\Email\Sender\OrderCommentSender;
use Magento\Sales\Model\Order\Email\Sender\InvoiceSender;
use Netresearch\Compatibility\Controller\CsrfAware\Action as CsrfAwareAction;

/**
* Abstract controller class
Expand All @@ -18,7 +21,7 @@
* @subpackage Magento2
* @category Magento2
*/
abstract class HgwAbstract extends \Magento\Framework\App\Action\Action
abstract class HgwAbstract extends CsrfAwareAction
{
protected $resultPageFactory;
protected $logger;
Expand Down Expand Up @@ -59,10 +62,6 @@ abstract class HgwAbstract extends \Magento\Framework\App\Action\Action
*/
protected $_orderCommentSender;

/*
*
*/

protected $_invoiceSender;

/**
Expand Down Expand Up @@ -144,4 +143,15 @@ protected function getQuote()
}
return $this->_quote;
}

protected function getCsrfExceptionResponse(RequestInterface $request)
{
}

protected function proxyValidateForCsrf(RequestInterface $request)
{
return true;
}


}
15 changes: 14 additions & 1 deletion Controller/Index/Push.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Heidelpay\Gateway\Controller\Index;

use Heidelpay\Gateway\Helper\Response as ResponseHelper;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Sales\Model\Order\Email\Sender\InvoiceSender;
use Magento\Sales\Model\Order\Email\Sender\OrderCommentSender;
Expand Down Expand Up @@ -37,6 +38,9 @@ class Push extends \Heidelpay\Gateway\Controller\HgwAbstract
/** @var SearchCriteriaBuilder */
private $searchCriteriaBuilder;

/** @var ResponseHelper */
private $repsonseHelper;

/**
* @param \Magento\Framework\App\Action\Context $context
* @param \Magento\Customer\Model\Session $customerSession
Expand All @@ -56,6 +60,7 @@ class Push extends \Heidelpay\Gateway\Controller\HgwAbstract
* @param OrderRepository $orderRepository
* @param \Heidelpay\PhpPaymentApi\Push $heidelpayPush
* @param SearchCriteriaBuilder $searchCriteriaBuilder
* @param ResponseHelper $repsonseHelper
*/
public function __construct(
\Magento\Framework\App\Action\Context $context,
Expand All @@ -75,7 +80,8 @@ public function __construct(
\Magento\Customer\Model\Url $customerUrl,
OrderRepository $orderRepository,
\Heidelpay\PhpPaymentApi\Push $heidelpayPush,
SearchCriteriaBuilder $searchCriteriaBuilder
SearchCriteriaBuilder $searchCriteriaBuilder,
ResponseHelper $repsonseHelper
) {
parent::__construct(
$context,
Expand All @@ -98,6 +104,7 @@ public function __construct(
$this->orderRepository = $orderRepository;
$this->heidelpayPush = $heidelpayPush;
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
$this->repsonseHelper = $repsonseHelper;
}

/**
Expand Down Expand Up @@ -136,6 +143,12 @@ public function execute()
$pushResponse = $this->heidelpayPush->getResponse();
$this->_logger->debug('Push Response: ' . print_r($pushResponse, true));

// Stop processing if hash validation fails.
$remoteAddress = $this->getRequest()->getServer('REMOTE_ADDR');
if(!$this->repsonseHelper->validateSecurityHash($pushResponse, $remoteAddress)) {
return;
}

list($paymentMethod, $paymentType) = $this->_paymentHelper->splitPaymentCode(
$pushResponse->getPayment()->getCode()
);
Expand Down
Loading

0 comments on commit cedc4b9

Please sign in to comment.