diff --git a/Config/module.xml b/Config/module.xml index aee6a55..8c36158 100755 --- a/Config/module.xml +++ b/Config/module.xml @@ -17,7 +17,7 @@ en_US fr_FR - 3.2.0 + 3.2.1 Vincent Lopes-Vicente diff --git a/Config/routing.xml b/Config/routing.xml index 3b4338b..5202397 100755 --- a/Config/routing.xml +++ b/Config/routing.xml @@ -18,7 +18,7 @@ PayPlugModule\Controller\NotificationController::entryPoint - + PayPlugModule\Controller\CardController::deleteCurrentCustomerCard diff --git a/Controller/CardController.php b/Controller/CardController.php index 5efd510..7aae7b9 100755 --- a/Controller/CardController.php +++ b/Controller/CardController.php @@ -3,13 +3,22 @@ namespace PayPlugModule\Controller; use PayPlugModule\Model\PayPlugCardQuery; +use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; +use Symfony\Component\Security\Csrf\CsrfToken; +use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; use Thelia\Controller\Front\BaseFrontController; use Thelia\Core\HttpFoundation\Request; class CardController extends BaseFrontController { - public function deleteCurrentCustomerCard(Request $request) + public const DELETE_TOKEN_ID = 'payplug_card_delete'; + + public function deleteCurrentCustomerCard(Request $request, CsrfTokenManagerInterface $csrfTokenManager) { + if (!$csrfTokenManager->isTokenValid(new CsrfToken(self::DELETE_TOKEN_ID, (string) $request->request->get('_token')))) { + throw new AccessDeniedHttpException('Invalid CSRF token.'); + } + if (!$request->hasSession()) { return $this->generateRedirect('/'); } diff --git a/Event/PayPlugPaymentEvent.php b/Event/PayPlugPaymentEvent.php index e217bd7..b886e1c 100755 --- a/Event/PayPlugPaymentEvent.php +++ b/Event/PayPlugPaymentEvent.php @@ -789,7 +789,7 @@ public function getPaymentId() * @param string $paymentId * @return PayPlugPaymentEvent */ - public function setPaymentId(string $paymentId = null): PayPlugPaymentEvent + public function setPaymentId(?string $paymentId = null): PayPlugPaymentEvent { $this->paymentId = $paymentId; return $this; @@ -953,7 +953,7 @@ public function getPaymentMethod() * @param string $paymentMethod * @return PayPlugPaymentEvent */ - public function setPaymentMethod(string $paymentMethod = null): PayPlugPaymentEvent + public function setPaymentMethod(?string $paymentMethod = null): PayPlugPaymentEvent { $this->paymentMethod = $paymentMethod; return $this; @@ -1583,7 +1583,7 @@ public function getHostedPaymentReturnUrl() * @param string $hostedPaymentReturnUrl * @return PayPlugPaymentEvent */ - public function setHostedPaymentReturnUrl(string $hostedPaymentReturnUrl = null): PayPlugPaymentEvent + public function setHostedPaymentReturnUrl(?string $hostedPaymentReturnUrl = null): PayPlugPaymentEvent { $this->hostedPaymentReturnUrl = $hostedPaymentReturnUrl; return $this; @@ -1601,7 +1601,7 @@ public function getHostedPaymentCancelUrl() * @param string $hostedPaymentCancelUrl * @return PayPlugPaymentEvent */ - public function setHostedPaymentCancelUrl(string $hostedPaymentCancelUrl = null): PayPlugPaymentEvent + public function setHostedPaymentCancelUrl(?string $hostedPaymentCancelUrl = null): PayPlugPaymentEvent { $this->hostedPaymentCancelUrl = $hostedPaymentCancelUrl; return $this; diff --git a/Event/PayPlugProduct.php b/Event/PayPlugProduct.php index 46fa790..d295497 100644 --- a/Event/PayPlugProduct.php +++ b/Event/PayPlugProduct.php @@ -38,7 +38,7 @@ class PayPlugProduct /** @var integer */ protected $totalAmount; - public function buildFromOrderProduct(OrderProduct $orderProduct, PayPlugModuleDeliveryType $payPlugModuleDeliveryType = null) + public function buildFromOrderProduct(OrderProduct $orderProduct, ?PayPlugModuleDeliveryType $payPlugModuleDeliveryType = null) { $storeName = ConfigQuery::read( 'store_name', diff --git a/PayPlugModule.php b/PayPlugModule.php index 5b49435..5cb4efe 100755 --- a/PayPlugModule.php +++ b/PayPlugModule.php @@ -33,7 +33,7 @@ class PayPlugModule extends AbstractPaymentModule const DOMAIN_NAME = 'payplugmodule'; - public function postActivation(ConnectionInterface $con = null): void + public function postActivation(?ConnectionInterface $con = null): void { if (!$this->getConfigValue('is_initialized', false)) { $database = new Database($con); @@ -41,7 +41,7 @@ public function postActivation(ConnectionInterface $con = null): void } } - public function update($currentVersion, $newVersion, ConnectionInterface $con = null): void + public function update($currentVersion, $newVersion, ?ConnectionInterface $con = null): void { $finder = Finder::create() ->name('*.sql') diff --git a/Service/PaymentService.php b/Service/PaymentService.php index 48b13a4..4124a27 100755 --- a/Service/PaymentService.php +++ b/Service/PaymentService.php @@ -130,7 +130,7 @@ public function doOrderCapture(Order $order) $this->dispatcher->dispatch($paymentEvent, PayPlugPaymentEvent::ORDER_CAPTURE_EVENT); } - public function doOrderRefund(Order $order, int $amountRefund = null) + public function doOrderRefund(Order $order, ?int $amountRefund = null) { $paymentEvent = (new PayPlugPaymentEvent()) ->buildFromOrder($order); diff --git a/templates/frontOffice/default/PayPlugModule/payment-extra.html.twig b/templates/frontOffice/default/PayPlugModule/payment-extra.html.twig index 8a7c72a..3125be0 100644 --- a/templates/frontOffice/default/PayPlugModule/payment-extra.html.twig +++ b/templates/frontOffice/default/PayPlugModule/payment-extra.html.twig @@ -7,7 +7,10 @@

{{ savedCard.title }}

{{ savedCard.notice }} - {{ savedCard.deleteLabel }} +

+
+ +
{% endif %}