From 12dc031daf13926d6f8ab544264441e9e8eaeeb5 Mon Sep 17 00:00:00 2001
From: kevinverschoor <61683999+kevinverschoor@users.noreply.github.com>
Date: Fri, 1 Nov 2024 13:56:04 +0100
Subject: [PATCH 1/2] PLUG-3911 - Reserve order Id
---
Controller/Checkout/FastCheckoutStart.php | 8 +++++++-
Model/PayPaymentCreateFastCheckout.php | 10 ++++++++--
etc/adminhtml/paymentmethods/ideal.xml | 7 +++++++
i18n/de_AT.csv | 5 ++++-
i18n/de_CH.csv | 5 ++++-
i18n/de_DE.csv | 5 ++++-
i18n/de_LU.csv | 5 ++++-
i18n/en_US.csv | 3 +++
i18n/fr_BE.csv | 5 ++++-
i18n/nl_BE.csv | 5 ++++-
i18n/nl_NL.csv | 5 ++++-
11 files changed, 53 insertions(+), 10 deletions(-)
diff --git a/Controller/Checkout/FastCheckoutStart.php b/Controller/Checkout/FastCheckoutStart.php
index 7a76e6ea..5ceeb480 100644
--- a/Controller/Checkout/FastCheckoutStart.php
+++ b/Controller/Checkout/FastCheckoutStart.php
@@ -244,13 +244,19 @@ public function execute()
throw new \Exception('empty amount', FastCheckoutStart::FC_EMPTY_BASKET);
}
+ if (!empty($store->getConfig('payment/paynl_payment_ideal/fast_checkout_reserveOrderId')) && $store->getConfig('payment/paynl_payment_ideal/fast_checkout_reserveOrderId') == 1) { // phpcs:ignore
+ $quote->reserveOrderId();
+ $quote->save();
+ }
+
$payTransaction = (new PayPaymentCreateFastCheckout(
$methodInstance,
$fcAmount * 100,
$arrProducts,
$this->storeManager->getStore()->getBaseUrl(),
$this->cart->getQuote()->getId(),
- $this->storeManager->getStore()->getCurrentCurrencyCode()
+ $this->storeManager->getStore()->getCurrentCurrencyCode(),
+ $quote->getReservedOrderId() ?? null
))->create();
$this->getResponse()->setNoCacheHeaders();
diff --git a/Model/PayPaymentCreateFastCheckout.php b/Model/PayPaymentCreateFastCheckout.php
index abe01ef8..1cf77207 100644
--- a/Model/PayPaymentCreateFastCheckout.php
+++ b/Model/PayPaymentCreateFastCheckout.php
@@ -21,6 +21,11 @@ class PayPaymentCreateFastCheckout extends PayPaymentCreate
*/
private $reference = '';
+ /**
+ * @var string
+ */
+ private $reservedOrderId = '';
+
/**
* @param \Paynl\Payment\Model\Paymentmethod\Paymentmethod $methodInstance
* @param string $amount Amount to start fastCheckout with
@@ -31,7 +36,7 @@ class PayPaymentCreateFastCheckout extends PayPaymentCreate
* @throws \Exception
* @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing
*/
- public function __construct($methodInstance, $amount, $products, $baseUrl, $quoteId, $currency)
+ public function __construct($methodInstance, $amount, $products, $baseUrl, $quoteId, $currency, $reservedOrderId)
{
$fastCheckout = parent::__construct(null, $methodInstance);
@@ -44,6 +49,7 @@ public function __construct($methodInstance, $amount, $products, $baseUrl, $quot
$fastCheckout->setExchangeURL($exchangeUrl);
$fastCheckout->setProducts($products);
$fastCheckout->reference = 'fastcheckout' . $quoteId;
+ $fastCheckout->reservedOrderId = $reservedOrderId;
}
/**
@@ -96,7 +102,7 @@ public function getData()
$this->_add($stats, 'info', '');
$this->_add($stats, 'tool', '');
$this->_add($stats, 'object', $this->methodInstance->getVersion() . ' | fc');
- $this->_add($stats, 'extra1', '');
+ $this->_add($stats, 'extra1', $this->reservedOrderId);
$this->_add($stats, 'extra2', '');
$this->_add($stats, 'extra3', $this->reference);
$this->_add($parameters, 'stats', $stats);
diff --git a/etc/adminhtml/paymentmethods/ideal.xml b/etc/adminhtml/paymentmethods/ideal.xml
index de1075d4..de273af5 100644
--- a/etc/adminhtml/paymentmethods/ideal.xml
+++ b/etc/adminhtml/paymentmethods/ideal.xml
@@ -246,6 +246,13 @@ Using the intermediate screen will allow users to select their own shipping meth
This setting does not effect the product page. If fast checkout is enabled for the product page, the fast checkout button will always be shown.
Show the fast checkout button on the cart page, only for guest customers.
+
+
+ Paynl\Payment\Block\Adminhtml\Render\Checkbox
+ payment/paynl_payment_ideal/fast_checkout_reserveOrderId
+ When enabled, the fast checkout order id will be reserved on start and send to Pay.
+ Reserve the order id on fast checkout start.
+
diff --git a/i18n/de_AT.csv b/i18n/de_AT.csv
index 327f7a80..1fbe5ab2 100644
--- a/i18n/de_AT.csv
+++ b/i18n/de_AT.csv
@@ -298,4 +298,7 @@ Diese Einstellung wirkt sich nicht auf die Produktseite aus. Wenn der schnelle C
"On - as Required","Ein - nach Bedarf"
"Show notice and abort fast checkout","Hinweis anzeigen und Schnellkasse abbrechen"
"Show intermediate screen to select shipping method","Zwischenbildschirm zur Auswahl der Versandart anzeigen"
-"Thank you for your purchase, as soon as the payment is completed you will receive an email.","Vielen Dank für Ihren Kauf, sobald die Zahlung abgeschlossen ist, erhalten Sie eine E-Mail."
\ No newline at end of file
+"Thank you for your purchase, as soon as the payment is completed you will receive an email.","Vielen Dank für Ihren Kauf, sobald die Zahlung abgeschlossen ist, erhalten Sie eine E-Mail."
+"Reserve order Id","Reservieren Sie Bestellnummer"
+"When enabled, the fast checkout order id will be reserved on start and send to Pay.","Wenn aktiviert, wird die fastcheckout Bestellnummer beim Start reserviert und an Pay. gesendet."
+"Reserve the order id on fast checkout start.","Reservieren Sie die Bestellnummer beim Start des fastcheckout."
\ No newline at end of file
diff --git a/i18n/de_CH.csv b/i18n/de_CH.csv
index ea9bbbfb..5c16d451 100644
--- a/i18n/de_CH.csv
+++ b/i18n/de_CH.csv
@@ -300,4 +300,7 @@ Diese Einstellung wirkt sich nicht auf die Produktseite aus. Wenn der schnelle C
"On - as Required","Ein - nach Bedarf"
"Show notice and abort fast checkout","Hinweis anzeigen und Schnellkasse abbrechen"
"Show intermediate screen to select shipping method","Zwischenbildschirm zur Auswahl der Versandart anzeigen"
-"Thank you for your purchase, as soon as the payment is completed you will receive an email.","Vielen Dank für Ihren Kauf, sobald die Zahlung abgeschlossen ist, erhalten Sie eine E-Mail."
\ No newline at end of file
+"Thank you for your purchase, as soon as the payment is completed you will receive an email.","Vielen Dank für Ihren Kauf, sobald die Zahlung abgeschlossen ist, erhalten Sie eine E-Mail."
+"Reserve order Id","Reservieren Sie Bestellnummer"
+"When enabled, the fast checkout order id will be reserved on start and send to Pay.","Wenn aktiviert, wird die fastcheckout Bestellnummer beim Start reserviert und an Pay. gesendet."
+"Reserve the order id on fast checkout start.","Reservieren Sie die Bestellnummer beim Start des fastcheckout."
\ No newline at end of file
diff --git a/i18n/de_DE.csv b/i18n/de_DE.csv
index ea9bbbfb..5c16d451 100644
--- a/i18n/de_DE.csv
+++ b/i18n/de_DE.csv
@@ -300,4 +300,7 @@ Diese Einstellung wirkt sich nicht auf die Produktseite aus. Wenn der schnelle C
"On - as Required","Ein - nach Bedarf"
"Show notice and abort fast checkout","Hinweis anzeigen und Schnellkasse abbrechen"
"Show intermediate screen to select shipping method","Zwischenbildschirm zur Auswahl der Versandart anzeigen"
-"Thank you for your purchase, as soon as the payment is completed you will receive an email.","Vielen Dank für Ihren Kauf, sobald die Zahlung abgeschlossen ist, erhalten Sie eine E-Mail."
\ No newline at end of file
+"Thank you for your purchase, as soon as the payment is completed you will receive an email.","Vielen Dank für Ihren Kauf, sobald die Zahlung abgeschlossen ist, erhalten Sie eine E-Mail."
+"Reserve order Id","Reservieren Sie Bestellnummer"
+"When enabled, the fast checkout order id will be reserved on start and send to Pay.","Wenn aktiviert, wird die fastcheckout Bestellnummer beim Start reserviert und an Pay. gesendet."
+"Reserve the order id on fast checkout start.","Reservieren Sie die Bestellnummer beim Start des fastcheckout."
\ No newline at end of file
diff --git a/i18n/de_LU.csv b/i18n/de_LU.csv
index dba32db4..9183081d 100644
--- a/i18n/de_LU.csv
+++ b/i18n/de_LU.csv
@@ -301,4 +301,7 @@ Diese Einstellung wirkt sich nicht auf die Produktseite aus. Wenn der schnelle C
"On - as Required","Ein - nach Bedarf"
"Show notice and abort fast checkout","Hinweis anzeigen und Schnellkasse abbrechen"
"Show intermediate screen to select shipping method","Zwischenbildschirm zur Auswahl der Versandart anzeigen"
-"Thank you for your purchase, as soon as the payment is completed you will receive an email.","Vielen Dank für Ihren Kauf, sobald die Zahlung abgeschlossen ist, erhalten Sie eine E-Mail."
\ No newline at end of file
+"Thank you for your purchase, as soon as the payment is completed you will receive an email.","Vielen Dank für Ihren Kauf, sobald die Zahlung abgeschlossen ist, erhalten Sie eine E-Mail."
+"Reserve order Id","Reservieren Sie Bestellnummer"
+"When enabled, the fast checkout order id will be reserved on start and send to Pay.","Wenn aktiviert, wird die fastcheckout Bestellnummer beim Start reserviert und an Pay. gesendet."
+"Reserve the order id on fast checkout start.","Reservieren Sie die Bestellnummer beim Start des fastcheckout."
\ No newline at end of file
diff --git a/i18n/en_US.csv b/i18n/en_US.csv
index 520829c3..0af93b35 100644
--- a/i18n/en_US.csv
+++ b/i18n/en_US.csv
@@ -366,3 +366,6 @@ This setting does not effect the product page. If fast checkout is enabled for t
"Show notice and abort fast checkout","Show notice and abort fast checkout"
"Show intermediate screen to select shipping method","Show intermediate screen to select shipping method"
"Thank you for your purchase, as soon as the payment is completed you will receive an email.","Thank you for your purchase, as soon as the payment is completed you will receive an email."
+"Reserve order Id","Reserve order Id"
+"When enabled, the fast checkout order id will be reserved on start and send to Pay.","When enabled, the fast checkout order id will be reserved on start and send to Pay."
+"Reserve the order id on fast checkout start.","Reserve the order id on fast checkout start."
\ No newline at end of file
diff --git a/i18n/fr_BE.csv b/i18n/fr_BE.csv
index 6956967c..714f0435 100644
--- a/i18n/fr_BE.csv
+++ b/i18n/fr_BE.csv
@@ -302,4 +302,7 @@ Ce paramètre n'affecte pas la page produit. Si le paiement rapide est activé p
"On - as Required","Activé - en requis"
"Show notice and abort fast checkout","Afficher un avis et abandonner le fastcheckout"
"Show intermediate screen to select shipping method","Afficher l'écran intermédiaire pour sélectionner la méthode d'expédition"
-"Thank you for your purchase, as soon as the payment is completed you will receive an email.","Nous vous remercions pour votre commande. Dès que le paiement aura été traité, vous recevrez un e-mail."
\ No newline at end of file
+"Thank you for your purchase, as soon as the payment is completed you will receive an email.","Nous vous remercions pour votre commande. Dès que le paiement aura été traité, vous recevrez un e-mail."
+"Reserve order Id","Numéro de commande de réserve"
+"When enabled, the fast checkout order id will be reserved on start and send to Pay.","Lorsqu'elle est activée, l'identifiant de commande de fastcheckout sera réservé au démarrage et envoyé à Pay."
+"Reserve the order id on fast checkout start.","Réservez l'identifiant de commande au démarrage du fastcheckout."
\ No newline at end of file
diff --git a/i18n/nl_BE.csv b/i18n/nl_BE.csv
index 2d443f75..2891959b 100644
--- a/i18n/nl_BE.csv
+++ b/i18n/nl_BE.csv
@@ -359,4 +359,7 @@ Deze instelling heeft geen effect op de productpagina. Als snel bestellen is ing
"On - as Required","Aan - als Verplicht"
"Show notice and abort fast checkout","Toon melding en annuleer snel bestellen"
"Show intermediate screen to select shipping method","Toon tussenscherm om verzendmethode te selecteren"
-"Thank you for your purchase, as soon as the payment is completed you will receive an email.","Bedankt voor uw bestelling, zodra de betaling afgerond is ontvangt u een email."
\ No newline at end of file
+"Thank you for your purchase, as soon as the payment is completed you will receive an email.","Bedankt voor uw bestelling, zodra de betaling afgerond is ontvangt u een email."
+"Reserve order Id","Reserveer order Id"
+"When enabled, the fast checkout order id will be reserved on start and send to Pay.","Als deze optie is ingeschakeld, wordt de Fast Checkout order Id bij de start gereserveerd en naar Pay verzonden."
+"Reserve the order id on fast checkout start.","Reserveer de order Id bij het starten van de fast checkout."
\ No newline at end of file
diff --git a/i18n/nl_NL.csv b/i18n/nl_NL.csv
index 8eda341c..f149b94d 100644
--- a/i18n/nl_NL.csv
+++ b/i18n/nl_NL.csv
@@ -351,4 +351,7 @@ Deze instelling heeft geen effect op de productpagina. Als snel bestellen is ing
"On - as Required","Aan - als Verplicht"
"Show notice and abort fast checkout","Toon melding en annuleer snel bestellen"
"Show intermediate screen to select shipping method","Toon tussenscherm om verzendmethode te selecteren"
-"Thank you for your purchase, as soon as the payment is completed you will receive an email.","Bedankt voor uw bestelling, zodra de betaling afgerond is ontvangt u een email."
\ No newline at end of file
+"Thank you for your purchase, as soon as the payment is completed you will receive an email.","Bedankt voor uw bestelling, zodra de betaling afgerond is ontvangt u een email."
+"Reserve order Id","Reserveer order Id"
+"When enabled, the fast checkout order id will be reserved on start and send to Pay.","Als deze optie is ingeschakeld, wordt de Fast Checkout order Id bij de start gereserveerd en naar Pay verzonden."
+"Reserve the order id on fast checkout start.","Reserveer de order Id bij het starten van de fast checkout."
\ No newline at end of file
From 0e90ae457a0da866775ab67c4d8dd9475e45eb8a Mon Sep 17 00:00:00 2001
From: woutse
Date: Wed, 27 Nov 2024 13:47:25 +0100
Subject: [PATCH 2/2] Updated desc field
---
Model/PayPaymentCreate.php | 4 ++--
Model/PayPaymentCreateFastCheckout.php | 4 +++-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/Model/PayPaymentCreate.php b/Model/PayPaymentCreate.php
index 984b75aa..e74b9224 100644
--- a/Model/PayPaymentCreate.php
+++ b/Model/PayPaymentCreate.php
@@ -79,7 +79,7 @@ class PayPaymentCreate
/**
* @var float|string|null
*/
- private $orderId;
+ protected $orderId;
/**
* @var Order
@@ -258,7 +258,7 @@ public function setCurrency($currency)
/**
* @return float|string|null
*/
- private function getDescription()
+ public function getDescription()
{
$prefix = $this->scopeConfig->getValue('payment/paynl/order_description_prefix', 'store');
return !empty($prefix) ? $prefix . $this->orderId : $this->orderId;
diff --git a/Model/PayPaymentCreateFastCheckout.php b/Model/PayPaymentCreateFastCheckout.php
index 1cf77207..e987cdeb 100644
--- a/Model/PayPaymentCreateFastCheckout.php
+++ b/Model/PayPaymentCreateFastCheckout.php
@@ -43,6 +43,8 @@ public function __construct($methodInstance, $amount, $products, $baseUrl, $quot
$finishUrl = $baseUrl . 'paynl/checkout/finish/?entityid=fc';
$exchangeUrl = $baseUrl . 'paynl/checkout/exchange/';
+ $this->orderId = $reservedOrderId;
+
$fastCheckout->setAmount($amount);
$fastCheckout->setCurrency($currency);
$fastCheckout->setFinishURL($finishUrl);
@@ -78,7 +80,7 @@ public function getData()
$parameters['paymentMethod'] = ['id' => $this->paymentMethodId];
$this->_add($parameters, 'returnUrl', $this->paymentData['returnURL']);
- $this->_add($parameters, 'description', '');
+ $this->_add($parameters, 'description', $this->getDescription());
$this->_add($parameters, 'reference', $this->reference);
$this->_add($parameters, 'exchangeUrl', $this->paymentData['exchangeURL']);