diff --git a/Controller/Checkout/Finish.php b/Controller/Checkout/Finish.php index 4f3c7da5..cb0e2703 100644 --- a/Controller/Checkout/Finish.php +++ b/Controller/Checkout/Finish.php @@ -94,14 +94,16 @@ public function __construct( * @param Order $order * @param string $orderId * @param Session $session + * @param boolean $pickupMode * @return void */ - private function checkSession(Order $order, string $orderId, Session $session) + private function checkSession(Order $order, string $orderId, Session $session, $pickupMode = null) { if ($session->getLastOrderId() != $order->getId()) { $additionalInformation = $order->getPayment()->getAdditionalInformation(); $transactionId = (isset($additionalInformation['transactionId'])) ? $additionalInformation['transactionId'] : null; - if ($orderId == $transactionId) { + + if ($orderId == $transactionId || !empty($pickupMode)) { $this->checkoutSession->setLastQuoteId($order->getQuoteId()) ->setLastSuccessQuoteId($order->getQuoteId()) ->setLastOrderId($order->getId()) @@ -139,6 +141,7 @@ public function execute() $orderStatusId = empty($params['orderStatusId']) ? null : (int)$params['orderStatusId']; $magOrderId = empty($params['entityid']) ? null : $params['entityid']; $orderIds = empty($params['order_ids']) ? null : $params['order_ids']; + $pickupMode = !empty($params['pickup']); $bSuccess = $orderStatusId === Config::ORDERSTATUS_PAID; $bPending = in_array($orderStatusId, Config::ORDERSTATUS_PENDING); $bDenied = $orderStatusId === Config::ORDERSTATUS_DENIED; @@ -148,12 +151,17 @@ public function execute() $multiShipFinish = is_array($orderIds); try { - $this->checkEmpty($payOrderId, 'payOrderid', 101); $this->checkEmpty($magOrderId, 'magOrderId', 1012); - $order = $this->orderRepository->get($magOrderId); $this->checkEmpty($order, 'order', 1013); + if ($pickupMode) { + $this->deactivateCart($order, '', true); + $resultRedirect->setPath(Config::FINISH_PICKUP, ['_query' => ['utm_nooverride' => '1']]); + return $resultRedirect; + } + + $this->checkEmpty($payOrderId, 'payOrderid', 101); $this->config->setStore($order->getStore()); $payment = $order->getPayment(); @@ -268,14 +276,15 @@ private function handlePin(string $hash, Order $order) /** * @param Order $order * @param string $payOrderId + * @param boolean $pickupMode * @return void */ - private function deactivateCart(Order $order, string $payOrderId) + private function deactivateCart(Order $order, string $payOrderId, $pickupMode = null) { # Make the cart inactive $session = $this->checkoutSession; - $this->checkSession($order, $payOrderId, $session); + $this->checkSession($order, $payOrderId, $session, $pickupMode); $quote = $session->getQuote(); $quote->setIsActive(false); diff --git a/Controller/Order/Pickup.php b/Controller/Order/Pickup.php new file mode 100644 index 00000000..51d1f26a --- /dev/null +++ b/Controller/Order/Pickup.php @@ -0,0 +1,30 @@ +_pageFactory = $pageFactory; + return parent::__construct($context); + } + + /** + * @return object + */ + public function execute() + { + return $this->_pageFactory->create(); + } +} diff --git a/Model/Config.php b/Model/Config.php index 92ea6fa1..4d2b0987 100755 --- a/Model/Config.php +++ b/Model/Config.php @@ -16,6 +16,7 @@ class Config public const PENDING_PAY = 'paynl/order/pending'; public const CANCEL_PAY = 'paynl/order/cancel'; public const FINISH_STANDARD = 'checkout/onepage/success'; + public const FINISH_PICKUP = 'paynl/order/pickup'; public const ORDERSTATUS_PAID = 100; public const ORDERSTATUS_PENDING = array(20, 25, 40, 50, 90); public const ORDERSTATUS_DENIED = -63; diff --git a/Model/Config/Source/PinMoment.php b/Model/Config/Source/PinMoment.php new file mode 100644 index 00000000..d12082ff --- /dev/null +++ b/Model/Config/Source/PinMoment.php @@ -0,0 +1,42 @@ +toArray(); + + $arrResult = []; + foreach ($arrOptions as $value => $label) { + $arrResult[] = ['value' => $value, 'label' => $label]; + } + return $arrResult; + } + + /** + * Get options in "key-value" format + * + * @return array + */ + public function toArray() + { + return [ + '0' => __("Direct checkout payment (default)"), + '1' => __("Payment takes place at the pickup location, only create a backorder"), + '2' => __("Provide this choice in the checkout"), + ]; + } +} diff --git a/Model/ConfigProvider.php b/Model/ConfigProvider.php index 8fc86439..80ed9d82 100755 --- a/Model/ConfigProvider.php +++ b/Model/ConfigProvider.php @@ -139,6 +139,8 @@ public function getConfig() $config['payment']['showkvk'][$code] = $this->getKVK($code); $config['payment']['showvat'][$code] = $this->getVAT($code); $config['payment']['showdob'][$code] = $this->getDOB($code); + $config['payment']['showpinmoment'][$code] = $this->getPinMoment($code); + $config['payment']['pinmomentterminal'][$code] = $this->getPinLocationTerminal($code); $config['payment']['showforcompany'][$code] = $this->getCompany($code); $config['payment']['showforgroup'][$code] = $this->getCustomerGroup($code); @@ -238,6 +240,24 @@ protected function getDOB($code) return $this->methods[$code]->getDOB(); } + /** + * @param string $code + * @return mixed + */ + protected function getPinMoment($code) + { + return $this->methods[$code]->getPinMoment(); + } + + /** + * @param string $code + * @return mixed + */ + protected function getPinLocationTerminal($code) + { + return $this->methods[$code]->getPinLocationTerminal(); + } + /** * @param string $code * @return string diff --git a/Model/Paymentmethod/Instore.php b/Model/Paymentmethod/Instore.php index eb3c8222..4572c41c 100644 --- a/Model/Paymentmethod/Instore.php +++ b/Model/Paymentmethod/Instore.php @@ -4,6 +4,7 @@ use Magento\Sales\Model\Order; use Paynl\Payment\Helper\PayHelper; +use Paynl\Payment\Model\Config\Source\PinMoment; use Paynl\Payment\Model\PayPaymentCreate; class Instore extends PaymentMethod @@ -60,9 +61,20 @@ public function initialize($paymentAction, $stateObject) public function startTransaction(Order $order, $fromAdmin = false) { $store = $order->getStore(); - $url = $store->getBaseUrl() . 'checkout/cart/'; + $redirectUrl = $store->getBaseUrl() . 'checkout/cart/'; $additionalData = $order->getPayment()->getAdditionalInformation(); + $pinLocation = PinMoment::LOCATION_CHECKOUT; + + if ($fromAdmin === false) { + $pinLocation = $this->getPinMoment(); + # Payment starts from checkout + if ($pinLocation == PinMoment::LOCATION_CHOICE) { + # Checkout user chooses pinlocation + $pinLocation = $additionalData['pinmoment'] ?? PinMoment::LOCATION_CHECKOUT; + } + } + $terminalId = null; if (isset($additionalData['payment_option'])) { $terminalId = $additionalData['payment_option']; @@ -71,21 +83,38 @@ public function startTransaction(Order $order, $fromAdmin = false) try { if (empty($terminalId)) { + if (!$fromAdmin) { + $this->messageManager->addNoticeMessage(__('Please select a pin-terminal')); + return; + } throw new \Exception(__('Please select a pin-terminal'), 201); } - $transaction = (new PayPaymentCreate($order, $this))->create(); + $this->payHelper->logDebug('pinlocation', [$pinLocation], $store); - if ($this->getPaymentOptionId() === 1927) { - $additionalData['terminal_hash'] = $transaction->getData()['terminal']['hash']; - $url = $transaction->getRedirectUrl(); + if ($pinLocation == PinMoment::LOCATION_PICKUP) { + $redirectUrl = $order->getStore()->getBaseUrl() . 'paynl/checkout/finish/?entityid=' . $order->getEntityId() . '&pickup=1'; + $order->addStatusHistoryComment(__('PAY.: Payment at pick-up')); } else { - $instorePayment = \Paynl\Instore::payment(['transactionId' => $transaction->getTransactionId(), 'terminalId' => $terminalId]); - $additionalData['terminal_hash'] = $instorePayment->getHash(); - $url = $instorePayment->getRedirectUrl(); + $transaction = (new PayPaymentCreate($order, $this))->create(); + + if ($this->getPaymentOptionId() === 1927) { + if (array_key_exists('terminal', $transaction->getData())) { + $additionalData['terminal_hash'] = $transaction->getData()['terminal']['hash']; + } else { + throw new \Exception(__('Pin transaction can not be started in test mode')); + } + + $redirectUrl = $transaction->getRedirectUrl(); + } else { + $instorePayment = \Paynl\Instore::payment(['transactionId' => $transaction->getTransactionId(), 'terminalId' => $terminalId]); + $additionalData['terminal_hash'] = $instorePayment->getHash(); + $redirectUrl = $instorePayment->getRedirectUrl(); + } + + $additionalData['transactionId'] = $transaction->getTransactionId(); } - $additionalData['transactionId'] = $transaction->getTransactionId(); $additionalData['payment_option'] = $terminalId; $order->getPayment()->setAdditionalInformation($additionalData); @@ -108,7 +137,7 @@ public function startTransaction(Order $order, $fromAdmin = false) } } - return $url; + return $redirectUrl; } /** @@ -193,6 +222,14 @@ public function getDefaultPaymentOption() return $this->_scopeConfig->getValue('payment/' . $this->_code . '/default_terminal', 'store'); } + /** + * @return mixed + */ + public function getPinLocationTerminal() + { + return $this->_scopeConfig->getValue('payment/' . $this->_code . '/pinmoment_terminal', 'store'); + } + /** * @return boolean */ diff --git a/Model/Paymentmethod/PaymentMethod.php b/Model/Paymentmethod/PaymentMethod.php index 6bc7d3bb..0f600196 100644 --- a/Model/Paymentmethod/PaymentMethod.php +++ b/Model/Paymentmethod/PaymentMethod.php @@ -279,6 +279,14 @@ public function getDOB() return $this->_scopeConfig->getValue('payment/' . $this->_code . '/showdob', 'store'); } + /** + * @return mixed + */ + public function getPinMoment() + { + return $this->_scopeConfig->getValue('payment/' . $this->_code . '/pinmoment', 'store'); + } + /** * @return integer */ @@ -592,6 +600,10 @@ public function assignData(\Magento\Framework\DataObject $data) if (isset($additional_data['dob'])) { $this->getInfoInstance()->setAdditionalInformation('dob', $additional_data['dob']); } + + if (isset($additional_data['pinmoment'])) { + $this->getInfoInstance()->setAdditionalInformation('pinmoment', $additional_data['pinmoment']); + } } return $this; } diff --git a/Plugin/InstoreButton.php b/Plugin/InstoreButton.php index 33913f00..78830046 100644 --- a/Plugin/InstoreButton.php +++ b/Plugin/InstoreButton.php @@ -67,7 +67,12 @@ public function beforePushButtons( $currentUrl = $this->urlInterface->getCurrentUrl(); if (!isset($buttonList->getItems()['paynl']['start_instore_payment'])) { - if ($payment_method == 'paynl_payment_instore' && !$order->hasInvoices() && $store->getConfig('payment/paynl_payment_instore/show_pin_button') == 1) { + if ( + $payment_method == 'paynl_payment_instore' + && !$order->hasInvoices() + && ($store->getConfig('payment/paynl_payment_instore/show_pin_button') == 1 + || $store->getConfig('payment/paynl_payment_instore/pinmoment') > 0) + ) { $instoreUrl = $this->backendUrl->getUrl('paynl/order/instore') . '?order_id=' . $order_id . '&return_url=' . urlencode($currentUrl); $buttonList->add( 'start_instore_payment', diff --git a/etc/adminhtml/paymentmethods/instore.xml b/etc/adminhtml/paymentmethods/instore.xml index 0d522d37..ec1c76e0 100644 --- a/etc/adminhtml/paymentmethods/instore.xml +++ b/etc/adminhtml/paymentmethods/instore.xml @@ -45,6 +45,25 @@ + + + Paynl\Payment\Model\Config\Source\PinMoment + + 1 + + payment/paynl_payment_instore/pinmoment + + + + + + + Paynl\Payment\Model\Config\Source\PinTerminals + + 0 + + payment/paynl_payment_instore/pinmoment_terminal + diff --git a/i18n/de_AT.csv b/i18n/de_AT.csv index 8294e76a..95d74622 100644 --- a/i18n/de_AT.csv +++ b/i18n/de_AT.csv @@ -162,6 +162,13 @@ "Enter your company name","Geben Sie Ihren Firmennamen ein" "Invalid company","Ungültiger firma" "Enter a valid company name","Geben Sie einen gültigen Firmennamen ein" +"Payment location","Pin-Moment" +"Pay by card","Jetzt pinnen" +"Pay later, at pickup","PIN bei der Abholung im Geschäft" +"Setting for where the payment should take place: instant, or at pickup location. Or provide this choice in the checkout.","Ermöglichen Sie den Kunden, bei der Abholung der Bestellung im Geschäft zu bezahlen. In der Bestellansicht wird ein Pin-Button angezeigt." +"Don't show in checkout (default)","Nicht im Checkout anzeigen (Standard)" +"Show in checkout by pickup","Bei Abholung an der Kasse anzeigen" +"PAY.: Payment at pick-up","Pay.: Die Bestellung wurde zum Zeitpunkt der Abholung im Geschäft zur Zahlung erstellt" "Follow payment method","Follow payment method" "This will ensure the order is updated with the actual payment method used to complete the order. This can differ from the payment method initially selected","Dadurch wird sichergestellt, dass die Bestellung mit der tatsächlichen Zahlungsmethode aktualisiert wird, die zum Abschluss der Bestellung verwendet wurde. Diese kann von der ursprünglich gewählten Zahlungsart abweichen" "PAY.: Updated payment method from %1 to %2","PAY.: Zahlungsmethode geändert von %1 bis %2" diff --git a/i18n/de_CH.csv b/i18n/de_CH.csv index de311960..520e0383 100644 --- a/i18n/de_CH.csv +++ b/i18n/de_CH.csv @@ -162,6 +162,13 @@ "Enter your company name","Geben Sie Ihren Firmennamen ein" "Invalid company","Ungültiger firma" "Enter a valid company name","Geben Sie einen gültigen Firmennamen ein" +"Payment location","Pin-Moment" +"Pay by card","Jetzt pinnen" +"Pay later, at pickup","PIN bei der Abholung im Geschäft" +"Setting for where the payment should take place: instant, or at pickup location. Or provide this choice in the checkout.","Ermöglichen Sie den Kunden, bei der Abholung der Bestellung im Geschäft zu bezahlen. In der Bestellansicht wird ein Pin-Button angezeigt." +"Don't show in checkout (default)","Nicht im Checkout anzeigen (Standard)" +"Show in checkout by pickup","Bei Abholung an der Kasse anzeigen" +"PAY.: Payment at pick-up","Pay.: Die Bestellung wurde zum Zeitpunkt der Abholung im Geschäft zur Zahlung erstellt" "Follow payment method","Follow payment method" "This will ensure the order is updated with the actual payment method used to complete the order. This can differ from the payment method initially selected","Dadurch wird sichergestellt, dass die Bestellung mit der tatsächlichen Zahlungsmethode aktualisiert wird, die zum Abschluss der Bestellung verwendet wurde. Diese kann von der ursprünglich gewählten Zahlungsart abweichen" "PAY.: Updated payment method from %1 to %2","PAY.: Zahlungsmethode geändert von %1 bis %2" diff --git a/i18n/de_DE.csv b/i18n/de_DE.csv index de311960..520e0383 100644 --- a/i18n/de_DE.csv +++ b/i18n/de_DE.csv @@ -162,6 +162,13 @@ "Enter your company name","Geben Sie Ihren Firmennamen ein" "Invalid company","Ungültiger firma" "Enter a valid company name","Geben Sie einen gültigen Firmennamen ein" +"Payment location","Pin-Moment" +"Pay by card","Jetzt pinnen" +"Pay later, at pickup","PIN bei der Abholung im Geschäft" +"Setting for where the payment should take place: instant, or at pickup location. Or provide this choice in the checkout.","Ermöglichen Sie den Kunden, bei der Abholung der Bestellung im Geschäft zu bezahlen. In der Bestellansicht wird ein Pin-Button angezeigt." +"Don't show in checkout (default)","Nicht im Checkout anzeigen (Standard)" +"Show in checkout by pickup","Bei Abholung an der Kasse anzeigen" +"PAY.: Payment at pick-up","Pay.: Die Bestellung wurde zum Zeitpunkt der Abholung im Geschäft zur Zahlung erstellt" "Follow payment method","Follow payment method" "This will ensure the order is updated with the actual payment method used to complete the order. This can differ from the payment method initially selected","Dadurch wird sichergestellt, dass die Bestellung mit der tatsächlichen Zahlungsmethode aktualisiert wird, die zum Abschluss der Bestellung verwendet wurde. Diese kann von der ursprünglich gewählten Zahlungsart abweichen" "PAY.: Updated payment method from %1 to %2","PAY.: Zahlungsmethode geändert von %1 bis %2" diff --git a/i18n/de_LU.csv b/i18n/de_LU.csv index de311960..36abf4a1 100644 --- a/i18n/de_LU.csv +++ b/i18n/de_LU.csv @@ -162,6 +162,14 @@ "Enter your company name","Geben Sie Ihren Firmennamen ein" "Invalid company","Ungültiger firma" "Enter a valid company name","Geben Sie einen gültigen Firmennamen ein" +"Payment location","Pin-Moment" +"Pay by card","Jetzt pinnen" +"Pay later, at pickup","PIN bei der Abholung im Geschäft" +"Setting for where the payment should take place: instant, or at pickup location. Or provide this choice in the checkout.","Ermöglichen Sie den Kunden, bei der Abholung der Bestellung im Geschäft zu bezahlen. In der Bestellansicht wird ein Pin-Button angezeigt." +"PAY.: Payment at pick-up","Pay.: Die Bestellung wurde zum Zeitpunkt der Abholung im Geschäft zur Zahlung erstellt" +"Directly payment initialization(default)","Nur Direktzahlungsoption bereitstellen (Standard)" +"Let payment take place at the pickup location, only create a backorder","Verwenden Sie die Zahlung nur, wenn die Abholung im Geschäft ausgewählt ist" +"Show a selection for the checkout-user to choose between direct payment or payment at location","Bieten Sie dem Kunden eine Option" "Follow payment method","Follow payment method" "This will ensure the order is updated with the actual payment method used to complete the order. This can differ from the payment method initially selected","Dadurch wird sichergestellt, dass die Bestellung mit der tatsächlichen Zahlungsmethode aktualisiert wird, die zum Abschluss der Bestellung verwendet wurde. Diese kann von der ursprünglich gewählten Zahlungsart abweichen" "PAY.: Updated payment method from %1 to %2","PAY.: Zahlungsmethode geändert von %1 bis %2" diff --git a/i18n/en_US.csv b/i18n/en_US.csv index 53d1ba0e..6fc5434a 100644 --- a/i18n/en_US.csv +++ b/i18n/en_US.csv @@ -213,6 +213,14 @@ "Enter your company name","Enter your company name" "Invalid company","Invalid company" "Enter a valid company name","Enter a valid company name" +"Payment location","Payment location" +"Pay by card","Pay by card" +"Pay later, at pickup","Pay later, at pickup" +"Setting for where the payment should take place: instant, or at pickup location. Or provide this choice in the checkout.","Setting for where the payment should take place: instant, or at pickup location. Or provide this choice in the checkout." +"PAY.: Payment at pick-up","PAY.: Payment at pick-up" +"Directly payment initialization(default)","Directly payment initialization(default)" +"Let payment take place at the pickup location, only create a backorder","Let payment take place at the pickup location, only create a backorder" +"Show a selection for the checkout-user to choose between direct payment or payment at location","Show a selection for the checkout-user to choose between direct payment or payment at location" "Follow payment method","Follow payment method" "This will ensure the order is updated with the actual payment method used to complete the order. This can differ from the payment method initially selected","This will ensure the order is updated with the actual payment method used to complete the order. This can differ from the payment method initially selected" "PAY.: Updated payment method from %1 to %2","PAY.: Updated payment method from %1 to %2" diff --git a/i18n/fr_BE.csv b/i18n/fr_BE.csv index a5f9c739..450a9811 100644 --- a/i18n/fr_BE.csv +++ b/i18n/fr_BE.csv @@ -161,6 +161,14 @@ "Enter your company name","Entrez le nom de votre entreprise" "Invalid company","Entreprise invalide" "Entrez un nom d'entreprise valide","Voer een geldige bedrijfsnaam in" +"Payment location","Moment de code PIN" +"Pay by card","Épingler maintenant" +"Pay later, at pickup","Épinglez en magasin lors du retrait" +"Setting for where the payment should take place: instant, or at pickup location. Or provide this choice in the checkout.","Permettez aux clients de choisir de payer lors du retrait de la commande en magasin. Un bouton épingle sera visible dans la vue commande." +"PAY.: Payment at pick-up","Pay.: La commande a été créée pour le paiement au moment du retrait au magasin" +"Directly payment initialization(default)","Proposez uniquement l'option de paiement direct (par défaut)" +"Let payment take place at the pickup location, only create a backorder","Utiliser le paiement uniquement lorsque le retrait en magasin est sélectionné" +"Show a selection for the checkout-user to choose between direct payment or payment at location","Offrir le choix au client" "Follow payment method","Follow payment method" "This will ensure the order is updated with the actual payment method used to complete the order. This can differ from the payment method initially selected","Cela garantira que la commande est mise à jour avec le mode de paiement réel utilisé pour finaliser la commande. Celui-ci peut différer du mode de paiement initialement sélectionné" "PAY.: Updated payment method from %1 to %2","PAY.: Mode de paiement modifié de %1 à %2" diff --git a/i18n/fr_CA.csv b/i18n/fr_CA.csv index a5f9c739..450a9811 100644 --- a/i18n/fr_CA.csv +++ b/i18n/fr_CA.csv @@ -161,6 +161,14 @@ "Enter your company name","Entrez le nom de votre entreprise" "Invalid company","Entreprise invalide" "Entrez un nom d'entreprise valide","Voer een geldige bedrijfsnaam in" +"Payment location","Moment de code PIN" +"Pay by card","Épingler maintenant" +"Pay later, at pickup","Épinglez en magasin lors du retrait" +"Setting for where the payment should take place: instant, or at pickup location. Or provide this choice in the checkout.","Permettez aux clients de choisir de payer lors du retrait de la commande en magasin. Un bouton épingle sera visible dans la vue commande." +"PAY.: Payment at pick-up","Pay.: La commande a été créée pour le paiement au moment du retrait au magasin" +"Directly payment initialization(default)","Proposez uniquement l'option de paiement direct (par défaut)" +"Let payment take place at the pickup location, only create a backorder","Utiliser le paiement uniquement lorsque le retrait en magasin est sélectionné" +"Show a selection for the checkout-user to choose between direct payment or payment at location","Offrir le choix au client" "Follow payment method","Follow payment method" "This will ensure the order is updated with the actual payment method used to complete the order. This can differ from the payment method initially selected","Cela garantira que la commande est mise à jour avec le mode de paiement réel utilisé pour finaliser la commande. Celui-ci peut différer du mode de paiement initialement sélectionné" "PAY.: Updated payment method from %1 to %2","PAY.: Mode de paiement modifié de %1 à %2" diff --git a/i18n/fr_CH.csv b/i18n/fr_CH.csv index a5f9c739..450a9811 100644 --- a/i18n/fr_CH.csv +++ b/i18n/fr_CH.csv @@ -161,6 +161,14 @@ "Enter your company name","Entrez le nom de votre entreprise" "Invalid company","Entreprise invalide" "Entrez un nom d'entreprise valide","Voer een geldige bedrijfsnaam in" +"Payment location","Moment de code PIN" +"Pay by card","Épingler maintenant" +"Pay later, at pickup","Épinglez en magasin lors du retrait" +"Setting for where the payment should take place: instant, or at pickup location. Or provide this choice in the checkout.","Permettez aux clients de choisir de payer lors du retrait de la commande en magasin. Un bouton épingle sera visible dans la vue commande." +"PAY.: Payment at pick-up","Pay.: La commande a été créée pour le paiement au moment du retrait au magasin" +"Directly payment initialization(default)","Proposez uniquement l'option de paiement direct (par défaut)" +"Let payment take place at the pickup location, only create a backorder","Utiliser le paiement uniquement lorsque le retrait en magasin est sélectionné" +"Show a selection for the checkout-user to choose between direct payment or payment at location","Offrir le choix au client" "Follow payment method","Follow payment method" "This will ensure the order is updated with the actual payment method used to complete the order. This can differ from the payment method initially selected","Cela garantira que la commande est mise à jour avec le mode de paiement réel utilisé pour finaliser la commande. Celui-ci peut différer du mode de paiement initialement sélectionné" "PAY.: Updated payment method from %1 to %2","PAY.: Mode de paiement modifié de %1 à %2" diff --git a/i18n/fr_FR.csv b/i18n/fr_FR.csv index f45bd656..0af04c18 100644 --- a/i18n/fr_FR.csv +++ b/i18n/fr_FR.csv @@ -161,6 +161,14 @@ "Enter your company name","Entrez le nom de votre entreprise" "Invalid company","Entreprise invalide" "Entrez un nom d'entreprise valide","Voer een geldige bedrijfsnaam in" +"Payment location","Moment de code PIN" +"Pay by card","Épingler maintenant" +"Pay later, at pickup","Épinglez en magasin lors du retrait" +"Setting for where the payment should take place: instant, or at pickup location. Or provide this choice in the checkout.","Permettez aux clients de choisir de payer lors du retrait de la commande en magasin. Un bouton épingle sera visible dans la vue commande." +"PAY.: Payment at pick-up","Pay.: La commande a été créée pour le paiement au moment du retrait au magasin" +"Directly payment initialization(default)","Proposez uniquement l'option de paiement direct (par défaut)" +"Let payment take place at the pickup location, only create a backorder","Utiliser le paiement uniquement lorsque le retrait en magasin est sélectionné" +"Show a selection for the checkout-user to choose between direct payment or payment at location","Offrir le choix au client" "Follow payment method","Follow payment method" "This will ensure the order is updated with the actual payment method used to complete the order. This can differ from the payment method initially selected","Cela garantira que la commande est mise à jour avec le mode de paiement réel utilisé pour finaliser la commande. Celui-ci peut différer du mode de paiement initialement sélectionné" "PAY.: Updated payment method from %1 to %2","PAY.: Mode de paiement modifié de %1 à %2" diff --git a/i18n/fr_LU.csv b/i18n/fr_LU.csv index e58afcb6..d4a2c110 100644 --- a/i18n/fr_LU.csv +++ b/i18n/fr_LU.csv @@ -161,6 +161,14 @@ "Enter your company name","Entrez le nom de votre entreprise" "Invalid company","Entreprise invalide" "Entrez un nom d'entreprise valide","Voer een geldige bedrijfsnaam in" +"Payment location","Moment de code PIN" +"Pay by card","Épingler maintenant" +"Pay later, at pickup","Épinglez en magasin lors du retrait" +"Setting for where the payment should take place: instant, or at pickup location. Or provide this choice in the checkout.","Permettez aux clients de choisir de payer lors du retrait de la commande en magasin. Un bouton épingle sera visible dans la vue commande." +"PAY.: Payment at pick-up","Pay.: La commande a été créée pour le paiement au moment du retrait au magasin" +"Directly payment initialization(default)","Proposez uniquement l'option de paiement direct (par défaut)" +"Let payment take place at the pickup location, only create a backorder","Utiliser le paiement uniquement lorsque le retrait en magasin est sélectionné" +"Show a selection for the checkout-user to choose between direct payment or payment at location","Offrir le choix au client" "Follow payment method","Follow payment method" "This will ensure the order is updated with the actual payment method used to complete the order. This can differ from the payment method initially selected","Cela garantira que la commande est mise à jour avec le mode de paiement réel utilisé pour finaliser la commande. Celui-ci peut différer du mode de paiement initialement sélectionné" "PAY.: Updated payment method from %1 to %2","PAY.: Mode de paiement modifié de %1 à %2" diff --git a/i18n/nl_BE.csv b/i18n/nl_BE.csv index 4418ca4a..885ac9d0 100644 --- a/i18n/nl_BE.csv +++ b/i18n/nl_BE.csv @@ -217,6 +217,14 @@ "Enter your company name","Entrez le nom de votre entreprise" "Invalid company","Entreprise invalide" "Entrez un nom d'entreprise valide","Voer een geldige bedrijfsnaam in" +"Payment location","Pin-moment" +"Pay by card","Nu pinnen" +"Pay later, at pickup","Bij afhalen in de winkel pinnen" +"Setting for where the payment should take place: instant, or at pickup location. Or provide this choice in the checkout.","Geef klanten de mogelijkheid om te kiezen om te betalen bij het ophalen van de bestelling in de winkel. In het orderoverzicht is een pinknop zichtbaar." +"PAY.: Payment at pick-up","De bestelling is aangemaakt voor betaling op het moment van ophalen in de winkel" +"Directly payment initialization(default)","Bied de betaaloptie direct aan aan (standaard)" +"Let payment take place at the pickup location, only create a backorder","Gebruik alleen betaling als ophalen in de winkel is geselecteerd" +"Show a selection for the checkout-user to choose between direct payment or payment at location","Geef de klant de optie om te kiezen" "Follow payment method","Follow payment method" "This will ensure the order is updated with the actual payment method used to complete the order. This can differ from the payment method initially selected","Dit zorgt ervoor dat de bestelling wordt bijgewerkt met de daadwerkelijke betaalmethode die is gebruikt om de bestelling te voltooien. Dit kan afwijken van de aanvankelijk gekozen betaalmethode" "PAY.: Updated payment method from %1 to %2","PAY.: Betaalmethode gewijzigd van %1 naar %2" diff --git a/i18n/nl_NL.csv b/i18n/nl_NL.csv index 1eb823fc..1f4baac6 100644 --- a/i18n/nl_NL.csv +++ b/i18n/nl_NL.csv @@ -217,6 +217,14 @@ "Enter your company name","Voer uw bedrijfsnaam in" "Invalid company","Ongeldig bedrijf" "Enter a valid company name","Voer een geldige bedrijfsnaam in" +"Payment location","Pin locatie" +"Pay by card","Nu pinnen" +"Pay later, at pickup","Bij afhalen in de winkel pinnen" +"Setting for where the payment should take place: instant, or at pickup location. Or provide this choice in the checkout.","Geef klanten de mogelijkheid om te kiezen om te betalen bij het ophalen van de bestelling in de winkel. In het orderoverzicht is een pinknop zichtbaar." +"PAY.: Payment at pick-up","De bestelling is aangemaakt voor betaling op het moment van ophalen in de winkel" +"Directly payment initialization(default)","Bied de betaaloptie direct aan aan (standaard)" +"Let payment take place at the pickup location, only create a backorder","Gebruik alleen betaling als ophalen in de winkel is geselecteerd" +"Show a selection for the checkout-user to choose between direct payment or payment at location","Geef de klant de optie om te kiezen" "Follow payment method","Follow payment method" "This will ensure the order is updated with the actual payment method used to complete the order. This can differ from the payment method initially selected","Dit zorgt ervoor dat de bestelling wordt bijgewerkt met de daadwerkelijke betaalmethode die is gebruikt om de bestelling te voltooien. Dit kan afwijken van de aanvankelijk gekozen betaalmethode" "PAY.: Updated payment method from %1 to %2","PAY.: Betaalmethode gewijzigd van %1 naar %2" @@ -232,4 +240,4 @@ Aan - via Sherpa - Capture automatisch via Sherpa." "When the store currency deviates from the base currency setting in Magento, this setting will ensure the payment starts in the base currency instead of the store currency.","Wanneer de winkelvaluta afwijkt van de basisvaluta-instelling in Magento, zorgt deze instelling ervoor dat de betalingen worden gestart in de basisvaluta in plaats van de winkelvaluta." "Chargebacks","Chargebacks" "Set to `on` to accept chargebacks initiated from Pay.","Stel in op `aan` om chargebacks te accepteren die zijn geïnitieerd vanuit Pay." -"When this settings is enabled, chargebacks initiated by customers will refund the order in Magento.","Als deze instelling is ingeschakeld, zullen chargebacks die door klanten worden geïnitieerd de bestelling refunden in Magento." \ No newline at end of file +"When this settings is enabled, chargebacks initiated by customers will refund the order in Magento.","Als deze instelling is ingeschakeld, zullen chargebacks die door klanten worden geïnitieerd de bestelling refunden in Magento." diff --git a/view/frontend/layout/paynl_order_pickup.xml b/view/frontend/layout/paynl_order_pickup.xml new file mode 100644 index 00000000..624241bc --- /dev/null +++ b/view/frontend/layout/paynl_order_pickup.xml @@ -0,0 +1,25 @@ + + + + + Pickup Page + + + + + + Your order is reserved + + + + + + + + + \ No newline at end of file diff --git a/view/frontend/web/css/paycheckout.css b/view/frontend/web/css/paycheckout.css index b3744a09..2d18ba7e 100644 --- a/view/frontend/web/css/paycheckout.css +++ b/view/frontend/web/css/paycheckout.css @@ -51,4 +51,9 @@ .paynl .payment-method-content p { margin-bottom: 10px; position: inherit; +} + +.paynl .payment-method-content label[for="pinmoment"] { + margin: 20px 0 10px 18px; + display: inline-block; } \ No newline at end of file diff --git a/view/frontend/web/js/view/payment/method-renderer/default.js b/view/frontend/web/js/view/payment/method-renderer/default.js index 4d61c14f..b12e6570 100755 --- a/view/frontend/web/js/view/payment/method-renderer/default.js +++ b/view/frontend/web/js/view/payment/method-renderer/default.js @@ -10,9 +10,10 @@ define( 'Magento_Ui/js/modal/alert', 'Magento_Checkout/js/model/payment/additional-validators', 'mage/translate', - 'Magento_Customer/js/model/customer' + 'Magento_Customer/js/model/customer', + 'ko' ], - function ($, Component, url, placeOrderAction, quote, alert, additionalValidators, translate, customer) { + function ($, Component, url, placeOrderAction, quote, alert, additionalValidators, translate, customer, ko) { 'use strict'; return Component.extend({ redirectAfterPlaceOrder: false, @@ -26,6 +27,7 @@ define( dateofbirth: null, billink_agree: null, companyfield: null, + pinmoment: null, initialize: function () { this._super(); @@ -58,9 +60,7 @@ define( } var disallowedShippingMethods = this.getDisallowedShipping(); if (disallowedShippingMethods) { - var carrier_code = typeof quote.shippingMethod().carrier_code !== 'undefined' ? quote.shippingMethod().carrier_code + '_' : ''; - var method_code = typeof quote.shippingMethod().method_code !== 'undefined' ? quote.shippingMethod().method_code : ''; - var currentShippingMethod = carrier_code + method_code; + var currentShippingMethod = this.getCurrentShippingMethod(); var disallowedShippingMethodsSplitted = disallowedShippingMethods.split(','); if (disallowedShippingMethodsSplitted.includes(currentShippingMethod) && currentShippingMethod.length > 0) { return false; @@ -78,8 +78,17 @@ define( if (!this.currentAgentIsValid()) { return false; } + if (!this.showPin()){ + return false; + } return true; }, + getCurrentShippingMethod: function () { + var carrier_code = typeof quote.shippingMethod().carrier_code !== 'undefined' ? quote.shippingMethod().carrier_code + '_' : ''; + var method_code = typeof quote.shippingMethod().method_code !== 'undefined' ? quote.shippingMethod().method_code : ''; + var currentShippingMethod = carrier_code + method_code; + return currentShippingMethod; + }, currentIpIsValid: function () { return window.checkoutConfig.payment.currentipisvalid[this.item.method]; }, @@ -145,15 +154,59 @@ define( getDOB: function () { return (typeof window.checkoutConfig.payment.showdob !== 'undefined') ? window.checkoutConfig.payment.showdob[this.item.method] : ''; }, + showPinMoment: function () { + return this.getPinMoment() > 0; + }, + getPinMoment: function () { + var currentShippingMethod = this.getCurrentShippingMethod(); + return (typeof window.checkoutConfig.payment.showpinmoment !== 'undefined' && window.checkoutConfig.payment.showpinmoment[this.item.method] === '2' && currentShippingMethod === 'instore_pickup') ? window.checkoutConfig.payment.showpinmoment[this.item.method] : ''; + }, + showPin: function () { + var currentShippingMethod = this.getCurrentShippingMethod(); + var showPinMomentConfig = (typeof window.checkoutConfig.payment.showpinmoment !== 'undefined') ? window.checkoutConfig.payment.showpinmoment[this.item.method] : ''; + + if (showPinMomentConfig === '1' && currentShippingMethod !== 'instore_pickup') { + return false + } + + return true + }, showKVKDOB: function () { return this.getKVKDOB() > 0; }, getKVKDOB: function () { return (this.getDOB() > 0 && this.getKVK() > 0); }, + showPinOption: ko.observable(true), showPaymentOptions: function () { + var pinmoment = window.checkoutConfig.payment.showpinmoment[this.item.method]; + var currentShippingMethod = this.getCurrentShippingMethod(); + + if ( + currentShippingMethod === 'instore_pickup' + && pinmoment === '1' + && typeof window.checkoutConfig.payment.pinmomentterminal !== 'undefined' + && window.checkoutConfig.payment.pinmomentterminal[this.item.method] !== '0' + ) { + this.paymentOption = this.getDefaultPaymomentTerminal(); + return false; + } + return window.checkoutConfig.payment.paymentoptions[this.item.method].length > 0 && window.checkoutConfig.payment.showpaymentoptions[this.item.method] == 1; }, + pinmomentChange: function (obj, event) { + if ( + event.target.value === '1' + && window.checkoutConfig.payment.showpinmoment[this.item.method] === '2' + && typeof window.checkoutConfig.payment.pinmomentterminal !== 'undefined' + && window.checkoutConfig.payment.pinmomentterminal[this.item.method] !== '0' + ) { + this.paymentOption = this.getDefaultPaymomentTerminal(); + this.showPinOption(false); + } else { + this.showPinOption(true); + } + }, showPaymentOptionsList: function () { return window.checkoutConfig.payment.paymentoptions[this.item.method].length >= 1 && window.checkoutConfig.payment.showpaymentoptions[this.item.method] == 2; }, @@ -199,6 +252,9 @@ define( getDefaultPaymentOption: function () { return window.checkoutConfig.payment.defaultpaymentoption[this.item.method]; }, + getDefaultPaymomentTerminal: function () { + return window.checkoutConfig.payment.pinmomentterminal[this.item.method]; + }, afterPlaceOrder: function () { window.location.replace(url.build('paynl/checkout/redirect?nocache=' + (new Date().getTime()))); }, @@ -220,7 +276,8 @@ define( "companyfield": this.companyfield, "dob": dob_format, "billink_agree": this.billink_agree, - "payment_option": this.paymentOption + "payment_option": this.paymentOption, + "pinmoment": this.pinmoment } }; }, diff --git a/view/frontend/web/template/payment/default.html b/view/frontend/web/template/payment/default.html index 102ab173..0caf27ee 100644 --- a/view/frontend/web/template/payment/default.html +++ b/view/frontend/web/template/payment/default.html @@ -23,7 +23,7 @@

- +
@@ -39,6 +39,13 @@
+
+ + +