Skip to content

Commit

Permalink
Implemented CsrfAwareActionInterface in order to process POST requests
Browse files Browse the repository at this point in the history
  • Loading branch information
andy committed May 9, 2019
1 parent 70c94a4 commit 3ede6e5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Controller/Checkout/Exchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,24 @@

namespace Paynl\Payment\Controller\Checkout;

use Magento\Framework\App\Request\InvalidRequestException;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Sales\Model\Order;
use Magento\Sales\Model\Order\Payment\Interceptor;
use Magento\Sales\Model\OrderRepository;
use Paynl\Payment\Controller\CsrfAwareActionInterface;
use Paynl\Result\Transaction\Transaction;



/**
* Description of Index
*
* @author Andy Pieters <[email protected]>
*/
class Exchange extends \Magento\Framework\App\Action\Action
class Exchange extends \Magento\Framework\App\Action\Action implements CsrfAwareActionInterface
// implements CsrfAwareActionInterface
{
/**
*
Expand Down Expand Up @@ -59,6 +65,16 @@ class Exchange extends \Magento\Framework\App\Action\Action

private $paynlConfig;

public function createCsrfValidationException(RequestInterface $request): ?InvalidRequestException

This comment has been minimized.

Copy link
@Kroellie

Kroellie Oct 27, 2019

Contributor

Repositories code generation... 1/7 [====>-----------------------] 14% 1 sec 54.0 MiBPHP Parse error: syntax error, unexpected '?' in /var/www/site/vendor/paynl/magento2-plugin/Controller/Checkout/Exchange.php on line 68

This comment has been minimized.

Copy link
@Krielkip

Krielkip Oct 29, 2019

What PHP version are you using?
Looks like Nullable types; https://www.php.net/manual/en/migration71.new-features.php

This comment has been minimized.

Copy link
@Kroellie

Kroellie Oct 29, 2019

Contributor

You're right... maybe a dependancy could be created for PHP 7 in this version...

{
return null;
}

public function validateForCsrf(RequestInterface $request): bool
{
return true;
}

/**
* Exchange constructor.
*
Expand Down
15 changes: 15 additions & 0 deletions Controller/CsrfAwareActionInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Paynl\Payment\Controller;

//workaround to make sure this works in magento < 2.3

if (interface_exists('\Magento\Framework\App\CsrfAwareActionInterface')) {
interface CsrfAwareActionInterface extends \Magento\Framework\App\CsrfAwareActionInterface
{
}
} else {
interface CsrfAwareActionInterface
{
}
}

0 comments on commit 3ede6e5

Please sign in to comment.