From bde021965759c161623c29bc3db408904d372a13 Mon Sep 17 00:00:00 2001
From: kevinverschoor <61683999+kevinverschoor@users.noreply.github.com>
Date: Thu, 9 Mar 2023 11:01:29 +0100
Subject: [PATCH 1/6] Exchange refactor object manager
---
Model/PayPayment.php | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/Model/PayPayment.php b/Model/PayPayment.php
index ce24c890..80488942 100644
--- a/Model/PayPayment.php
+++ b/Model/PayPayment.php
@@ -45,6 +45,12 @@ class PayPayment
*/
private $builderInterface;
+ /**
+ *
+ * @var Magento\Sales\Model\Order\PaymentFactory
+ */
+ private $paymentFactory;
+
private $paynlConfig;
/**
@@ -57,6 +63,7 @@ class PayPayment
* @param OrderRepository $orderRepository
* @param \Paynl\Payment\Model\Config $paynlConfig
* @param \Magento\Sales\Model\Order\Payment\Transaction\BuilderInterface $builderInterface
+ * @param \Magento\Sales\Model\Order\PaymentFactory $paymentFactory
*/
public function __construct(
\Paynl\Payment\Model\Config $config,
@@ -65,7 +72,8 @@ public function __construct(
\Magento\Framework\Event\ManagerInterface $eventManager,
OrderRepository $orderRepository,
\Paynl\Payment\Model\Config $paynlConfig,
- \Magento\Sales\Model\Order\Payment\Transaction\BuilderInterface $builderInterface
+ \Magento\Sales\Model\Order\Payment\Transaction\BuilderInterface $builderInterface,
+ \Magento\Sales\Model\Order\PaymentFactory $paymentFactory
) {
$this->eventManager = $eventManager;
$this->config = $config;
@@ -74,6 +82,7 @@ public function __construct(
$this->orderRepository = $orderRepository;
$this->paynlConfig = $paynlConfig;
$this->builderInterface = $builderInterface;
+ $this->paymentFactory = $paymentFactory;
}
/**
@@ -254,9 +263,6 @@ private function processB2BPayment(Transaction $transaction, Order $order, Inter
public function processPartiallyPaidOrder(Order $order, string $payOrderId)
{
$returnResult = false;
- $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
- $orderPaymentFactory = $objectManager->get(\Magento\Sales\Model\Order\PaymentFactory::class);
-
try {
$details = \Paynl\Transaction::details($payOrderId);
@@ -278,7 +284,7 @@ public function processPartiallyPaidOrder(Order $order, string $payOrderId)
/** @var Interceptor $orderPayment */
if (!$firstPayment) {
- $orderPayment = $orderPaymentFactory->create();
+ $orderPayment = $this->paymentFactory->create();
} else {
$orderPayment = $order->getPayment();
}
From 43de8b5fcaf5347356575eb97b5d6cba1bd249cb Mon Sep 17 00:00:00 2001
From: kevinverschoor <61683999+kevinverschoor@users.noreply.github.com>
Date: Thu, 16 Mar 2023 14:10:59 +0100
Subject: [PATCH 2/6] Fix Verify payments not getting to finish page
---
Controller/Checkout/Finish.php | 7 ++++++-
Model/Config.php | 1 +
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/Controller/Checkout/Finish.php b/Controller/Checkout/Finish.php
index 54a4c7fb..6f9a6f56 100644
--- a/Controller/Checkout/Finish.php
+++ b/Controller/Checkout/Finish.php
@@ -111,6 +111,7 @@ public function execute()
$bPending = in_array($orderStatusId, Config::ORDERSTATUS_PENDING);
$bDenied = $orderStatusId === Config::ORDERSTATUS_DENIED;
$bCanceled = $orderStatusId === Config::ORDERSTATUS_CANCELED;
+ $bVerify = $orderStatusId === Config::ORDERSTATUS_VERIFY;
$isPinTransaction = false;
try {
@@ -143,7 +144,7 @@ public function execute()
$bSuccess = ($transaction->isPaid() || $transaction->isAuthorized());
}
- if ($bSuccess) {
+ if ($bSuccess || $bVerify) {
$successUrl = $this->config->getSuccessPage($payment->getMethod());
if (empty($successUrl)) {
$successUrl = ($payment->getMethod() == 'paynl_payment_paylink' || $this->config->sendEcommerceAnalytics()) ? Config::FINISH_PAY : Config::FINISH_STANDARD;
@@ -152,6 +153,10 @@ public function execute()
if ($isPinTransaction && $pinStatus->getTransactionState() !== 'approved') {
$this->messageManager->addNoticeMessage(__('Order has been made and the payment is pending.'));
}
+ if ($bVerify) {
+ $order->addStatusHistoryComment(__('PAY. - This payment has been flagged as possibly fraudulent. Please Verify this transaction in the Pay. portal.'));
+ $this->orderRepository->save($order);
+ }
$this->deactivateCart($order, $payOrderId);
} elseif ($bPending) {
$resultRedirect->setPath(Config::PENDING_PAY);
diff --git a/Model/Config.php b/Model/Config.php
index 4a77f31b..8da52ebf 100755
--- a/Model/Config.php
+++ b/Model/Config.php
@@ -19,6 +19,7 @@ class Config
public const ORDERSTATUS_PENDING = array(20, 25, 40, 50, 90);
public const ORDERSTATUS_DENIED = -63;
public const ORDERSTATUS_CANCELED = -90;
+ public const ORDERSTATUS_VERIFY = 85;
/** @var Store */
private $store;
From 78e70f1f123365893e01fff7b5ffb0948b766669 Mon Sep 17 00:00:00 2001
From: kevinverschoor <61683999+kevinverschoor@users.noreply.github.com>
Date: Fri, 17 Mar 2023 14:22:19 +0100
Subject: [PATCH 3/6] Fix incorrect capital letter and add Dutch translation
---
Controller/Checkout/Finish.php | 2 +-
i18n/en_US.csv | 1 +
i18n/nl_NL.csv | 1 +
3 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/Controller/Checkout/Finish.php b/Controller/Checkout/Finish.php
index 6f9a6f56..3c3dfb61 100644
--- a/Controller/Checkout/Finish.php
+++ b/Controller/Checkout/Finish.php
@@ -154,7 +154,7 @@ public function execute()
$this->messageManager->addNoticeMessage(__('Order has been made and the payment is pending.'));
}
if ($bVerify) {
- $order->addStatusHistoryComment(__('PAY. - This payment has been flagged as possibly fraudulent. Please Verify this transaction in the Pay. portal.'));
+ $order->addStatusHistoryComment(__('PAY. - This payment has been flagged as possibly fraudulent. Please verify this transaction in the Pay. portal.'));
$this->orderRepository->save($order);
}
$this->deactivateCart($order, $payOrderId);
diff --git a/i18n/en_US.csv b/i18n/en_US.csv
index 5cfe2528..8adb56b0 100644
--- a/i18n/en_US.csv
+++ b/i18n/en_US.csv
@@ -134,3 +134,4 @@
"Check version","Check version"
"You are up to date with the latest version","You are up to date with the latest version"
"There is a new version available (","There is a new version available ("
+"PAY. - This payment has been flagged as possibly fraudulent. Please verify this transaction in the Pay. portal.","PAY. - This payment has been flagged as possibly fraudulent. Please verify this transaction in the Pay. portal."
diff --git a/i18n/nl_NL.csv b/i18n/nl_NL.csv
index c309d696..c40f2e44 100644
--- a/i18n/nl_NL.csv
+++ b/i18n/nl_NL.csv
@@ -182,3 +182,4 @@
"Check version","Check versie"
"You are up to date with the latest version","U bent up to date met de laatste versie"
"There is a new version available (","Er is een nieuwe versie beschikbaar ("
+"PAY. - This payment has been flagged as possibly fraudulent. Please verify this transaction in the Pay. portal.","PAY. - Deze betaling is gemarkeerd als mogelijk frauduleus. Controleer deze transactie in het Pay. portaal."
From 2d38b99b3c71cb896b438aeb61eaa8a21281cce7 Mon Sep 17 00:00:00 2001
From: kevinverschoor <61683999+kevinverschoor@users.noreply.github.com>
Date: Fri, 24 Mar 2023 15:10:17 +0100
Subject: [PATCH 4/6] Make Finish page for Pending optional with setting
---
Controller/Checkout/Finish.php | 3 ++-
Model/Config.php | 8 ++++++++
etc/adminhtml/system.xml | 8 +++++++-
etc/config.xml | 1 +
i18n/en_US.csv | 1 +
i18n/nl_NL.csv | 1 +
6 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/Controller/Checkout/Finish.php b/Controller/Checkout/Finish.php
index 3c3dfb61..9cddfb15 100644
--- a/Controller/Checkout/Finish.php
+++ b/Controller/Checkout/Finish.php
@@ -159,7 +159,8 @@ public function execute()
}
$this->deactivateCart($order, $payOrderId);
} elseif ($bPending) {
- $resultRedirect->setPath(Config::PENDING_PAY);
+ $successUrl = ($this->config->getPendingPage() || $this->config->sendEcommerceAnalytics()) ? Config::PENDING_PAY : Config::FINISH_STANDARD;
+ $resultRedirect->setPath($successUrl, ['_query' => ['utm_nooverride' => '1']]);
$this->deactivateCart($order, $payOrderId);
} else {
$cancelMessage = $bDenied ? __('Payment denied') : __('Payment canceled');
diff --git a/Model/Config.php b/Model/Config.php
index 8da52ebf..d1df6254 100755
--- a/Model/Config.php
+++ b/Model/Config.php
@@ -329,6 +329,14 @@ public function sendEcommerceAnalytics()
return $this->store->getConfig('payment/paynl/google_analytics_ecommerce') == 1;
}
+ /**
+ * @return boolean
+ */
+ public function getPendingPage()
+ {
+ return $this->store->getConfig('payment/paynl/pay_pending_page') == 1;
+ }
+
/**
* @param string $methodCode
* @return string
diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
index 58eb7ad9..54e313d7 100644
--- a/etc/adminhtml/system.xml
+++ b/etc/adminhtml/system.xml
@@ -21,7 +21,7 @@
Paynl\Payment\Block\Adminhtml\Render\Credentials
-
+
here. Not registered at PAY? Sign up here!]]>
@@ -190,6 +190,12 @@
Paynl\Payment\Model\Config\Source\GoogleAnalyticspayment/paynl/google_analytics_ecommerce
+
+
+
+ Paynl\Payment\Model\Config\Source\OffOn
+ payment/paynl/pay_pending_page
+
diff --git a/etc/config.xml b/etc/config.xml
index 6d849048..3a7d67c6 100755
--- a/etc/config.xml
+++ b/etc/config.xml
@@ -11,6 +11,7 @@
11Order
+ 10
diff --git a/i18n/en_US.csv b/i18n/en_US.csv
index 8adb56b0..62fd4447 100644
--- a/i18n/en_US.csv
+++ b/i18n/en_US.csv
@@ -135,3 +135,4 @@
"You are up to date with the latest version","You are up to date with the latest version"
"There is a new version available (","There is a new version available ("
"PAY. - This payment has been flagged as possibly fraudulent. Please verify this transaction in the Pay. portal.","PAY. - This payment has been flagged as possibly fraudulent. Please verify this transaction in the Pay. portal."
+"Select whether you want to use the PAY. thank you page when transaction is pending.","Select whether you want to use the PAY. thank you page when transaction is pending."
diff --git a/i18n/nl_NL.csv b/i18n/nl_NL.csv
index c40f2e44..02f9922d 100644
--- a/i18n/nl_NL.csv
+++ b/i18n/nl_NL.csv
@@ -183,3 +183,4 @@
"You are up to date with the latest version","U bent up to date met de laatste versie"
"There is a new version available (","Er is een nieuwe versie beschikbaar ("
"PAY. - This payment has been flagged as possibly fraudulent. Please verify this transaction in the Pay. portal.","PAY. - Deze betaling is gemarkeerd als mogelijk frauduleus. Controleer deze transactie in het Pay. portaal."
+"Select whether you want to use the PAY. thank you page when transaction is pending.","Selecteer of u gebruik wilt maken van de PAY. bedankpagina wanneer de transactie in behandeling is."
From 02f8b13604c8b345e247b6069be0bf05765f3b3e Mon Sep 17 00:00:00 2001
From: kevinverschoor <61683999+kevinverschoor@users.noreply.github.com>
Date: Fri, 24 Mar 2023 16:55:32 +0100
Subject: [PATCH 5/6] If setting is turned off & GA via Pay. is turned on,
redirect to Pay. finish
---
Controller/Checkout/Finish.php | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/Controller/Checkout/Finish.php b/Controller/Checkout/Finish.php
index 9cddfb15..ed421692 100644
--- a/Controller/Checkout/Finish.php
+++ b/Controller/Checkout/Finish.php
@@ -3,14 +3,13 @@
namespace Paynl\Payment\Controller\Checkout;
use Magento\Checkout\Model\Session;
-use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Quote\Model\QuoteRepository;
use Magento\Sales\Model\Order;
use Magento\Sales\Model\OrderRepository;
use Paynl\Payment\Controller\PayAction;
-use Paynl\Payment\Model\Config;
use Paynl\Payment\Helper\PayHelper;
+use Paynl\Payment\Model\Config;
/**
* Finishes up the payment and redirects the user to the thank you page.
@@ -105,7 +104,7 @@ public function execute()
$resultRedirect = $this->resultRedirectFactory->create();
$params = $this->getRequest()->getParams();
$payOrderId = empty($params['orderId']) ? (empty($params['orderid']) ? null : $params['orderid']) : $params['orderId'];
- $orderStatusId = empty($params['orderStatusId']) ? null : (int)$params['orderStatusId'];
+ $orderStatusId = empty($params['orderStatusId']) ? null : (int) $params['orderStatusId'];
$magOrderId = empty($params['entityid']) ? null : $params['entityid'];
$bSuccess = $orderStatusId === Config::ORDERSTATUS_PAID;
$bPending = in_array($orderStatusId, Config::ORDERSTATUS_PENDING);
@@ -159,7 +158,12 @@ public function execute()
}
$this->deactivateCart($order, $payOrderId);
} elseif ($bPending) {
- $successUrl = ($this->config->getPendingPage() || $this->config->sendEcommerceAnalytics()) ? Config::PENDING_PAY : Config::FINISH_STANDARD;
+ $successUrl = Config::FINISH_STANDARD;
+ if ($this->config->getPendingPage()) {
+ $successUrl = Config::PENDING_PAY;
+ } elseif ($this->config->sendEcommerceAnalytics()) {
+ $successUrl = Config::FINISH_PAY;
+ }
$resultRedirect->setPath($successUrl, ['_query' => ['utm_nooverride' => '1']]);
$this->deactivateCart($order, $payOrderId);
} else {
From 27a392976808e2680ab88c1ba62061a9fdd056df Mon Sep 17 00:00:00 2001
From: kevinverschoor <61683999+kevinverschoor@users.noreply.github.com>
Date: Fri, 24 Mar 2023 16:57:29 +0100
Subject: [PATCH 6/6] Undo accidental auto-format
---
Controller/Checkout/Finish.php | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/Controller/Checkout/Finish.php b/Controller/Checkout/Finish.php
index ed421692..7e5b5f76 100644
--- a/Controller/Checkout/Finish.php
+++ b/Controller/Checkout/Finish.php
@@ -3,13 +3,14 @@
namespace Paynl\Payment\Controller\Checkout;
use Magento\Checkout\Model\Session;
+use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Quote\Model\QuoteRepository;
use Magento\Sales\Model\Order;
use Magento\Sales\Model\OrderRepository;
use Paynl\Payment\Controller\PayAction;
-use Paynl\Payment\Helper\PayHelper;
use Paynl\Payment\Model\Config;
+use Paynl\Payment\Helper\PayHelper;
/**
* Finishes up the payment and redirects the user to the thank you page.
@@ -104,7 +105,7 @@ public function execute()
$resultRedirect = $this->resultRedirectFactory->create();
$params = $this->getRequest()->getParams();
$payOrderId = empty($params['orderId']) ? (empty($params['orderid']) ? null : $params['orderid']) : $params['orderId'];
- $orderStatusId = empty($params['orderStatusId']) ? null : (int) $params['orderStatusId'];
+ $orderStatusId = empty($params['orderStatusId']) ? null : (int)$params['orderStatusId'];
$magOrderId = empty($params['entityid']) ? null : $params['entityid'];
$bSuccess = $orderStatusId === Config::ORDERSTATUS_PAID;
$bPending = in_array($orderStatusId, Config::ORDERSTATUS_PENDING);