From 49038e680c1a6c686f328c272875f8198e2cc911 Mon Sep 17 00:00:00 2001 From: "k.verschoor@pay.nl" Date: Tue, 8 Dec 2020 08:58:14 +0100 Subject: [PATCH 1/8] Update paylink --- Model/Paymentmethod/Paylink.php | 24 ++++++++++++++++++- etc/adminhtml/paymentmethods/paylink.xml | 26 +++++++++++++++------ etc/config.xml | 12 +++++++++- i18n/en_US.csv | 2 +- view/adminhtml/templates/form/paylink.phtml | 2 +- 5 files changed, 55 insertions(+), 11 deletions(-) diff --git a/Model/Paymentmethod/Paylink.php b/Model/Paymentmethod/Paylink.php index 590e6f54..d9b18855 100644 --- a/Model/Paymentmethod/Paylink.php +++ b/Model/Paymentmethod/Paylink.php @@ -90,7 +90,27 @@ public function initialize($paymentAction, $stateObject) $show_order_in_mail = 0; } + $subject = $this->_scopeConfig->getValue('payment/paynl_payment_paylink/paylink_subject', 'store'); + $subject = str_replace('((paylink))',''.__('PAY. paylink').'',$subject); + $subject = str_replace('((customer_name))',$order->getCustomerName(),$subject); + $subject = str_replace('((store_name))',$order->getStore()->getName(),$subject); + $subject = str_replace('((support_email))',''.$supportEmail.'',$subject); + $subject = str_replace('((order_id))',$order->getIncrementId(),$subject); + + $body = $this->_scopeConfig->getValue('payment/paynl_payment_paylink/paylink_body', 'store');; + $body = nl2br($body); + $body = str_replace('((paylink))',''.__('PAY. paylink').'',$body); + $body = str_replace('((customer_name))',$order->getCustomerName(),$body); + $body = str_replace('((store_name))',$order->getStore()->getName(),$body); + $body = str_replace('((support_email))',''.$supportEmail.'',$body); + $body = str_replace('((order_id))',$order->getIncrementId(),$body); + + echo $body; + echo $order->getId(); + $templateVars = array( + 'subject' => $subject, + 'body' => $body, 'order' => $order, 'store' => $store, 'customer_name' => $order->getCustomerName(), @@ -109,7 +129,7 @@ public function initialize($paymentAction, $stateObject) 'is_not_virtual' => $order->getIsNotVirtual(), 'email_customer_note' => $order->getEmailCustomerNote(), 'frontend_status_label' => $order->getFrontendStatusLabel(), - 'show_order_in_mail' => $show_order_in_mail + 'show_order_in_mail' => $show_order_in_mail ], ); @@ -125,6 +145,8 @@ public function initialize($paymentAction, $stateObject) ->getTransport(); $transport->sendMessage(); + exit('sending'); + parent::initialize($paymentAction, $stateObject); } } diff --git a/etc/adminhtml/paymentmethods/paylink.xml b/etc/adminhtml/paymentmethods/paylink.xml index ae06b555..084d582b 100644 --- a/etc/adminhtml/paymentmethods/paylink.xml +++ b/etc/adminhtml/paymentmethods/paylink.xml @@ -114,21 +114,33 @@ 1 payment/paynl_payment_paylink/show_order_in_mail - - - - - Paynl\Payment\Model\Config\Source\showCompanyOptions + + + + + payment/paynl_payment_paylink/paylink_subject 1 - payment/paynl_payment_paylink/showforcompany - + + + Paynl\Payment\Model\Config\Source\SendNewOrderEmail + payment/paynl_payment_paylink/paylink_body + + 1 + + In order to insert variables into the email use the following text in the subject/body: ((customer_name)), ((paylink)), ((order_id)), ((store_name)), ((support_email)) + + Paynl\Payment\Model\Config\Source\SendNewOrderEmail payment/paynl_payment_paylink/custom_success_page 1 diff --git a/etc/config.xml b/etc/config.xml index 1ce9d11b..9bee8fa1 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -14,7 +14,7 @@ 1 - PAY. betaallink + PAY. paylink 961 pending processing @@ -24,6 +24,16 @@ paynl_payment valid_days before_payment + Order Paylink #((order_id))# + ((customer_name)), +Thank you for your order from ((store_name)). + +If you have questions about your order, you can email us at ((support_email)) + +In order to pay for your order click the link below +((paylink)) + + 0 diff --git a/i18n/en_US.csv b/i18n/en_US.csv index 6f0c5424..9cee002c 100644 --- a/i18n/en_US.csv +++ b/i18n/en_US.csv @@ -22,7 +22,7 @@ "Choose your bank","Choose your bank" "Choose the pin terminal","Choose the pin terminal" "Caution!","Caution!" -"An e-mail containing a PAY. payment link will be send.","An e-mail containing a PAY. payment link will be send." +"An e-mail containing a PAY. paylink will be send.","An e-mail containing a PAY. paylink will be send." "Valid for","Valid for" "days","days" "Enabled","Enabled" diff --git a/view/adminhtml/templates/form/paylink.phtml b/view/adminhtml/templates/form/paylink.phtml index a8ff6d21..94b8de6e 100644 --- a/view/adminhtml/templates/form/paylink.phtml +++ b/view/adminhtml/templates/form/paylink.phtml @@ -16,7 +16,7 @@ $code = $block->escapeHtml( $block->getMethodCode() );

- +

From aa07fae41d7973c4a885f4a84eaca4bf5fea1e84 Mon Sep 17 00:00:00 2001 From: kevinverschoor <61683999+kevinverschoor@users.noreply.github.com> Date: Tue, 8 Dec 2020 18:59:52 +0100 Subject: [PATCH 2/8] Remove test --- Model/Paymentmethod/Paylink.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Model/Paymentmethod/Paylink.php b/Model/Paymentmethod/Paylink.php index d9b18855..51c1b0a6 100644 --- a/Model/Paymentmethod/Paylink.php +++ b/Model/Paymentmethod/Paylink.php @@ -145,8 +145,6 @@ public function initialize($paymentAction, $stateObject) ->getTransport(); $transport->sendMessage(); - exit('sending'); - parent::initialize($paymentAction, $stateObject); } } @@ -158,4 +156,4 @@ public function assignData(\Magento\Framework\DataObject $data) return parent::assignData($data); } -} \ No newline at end of file +} From 8dff916689d054ea34653645dc8d566701a43a88 Mon Sep 17 00:00:00 2001 From: "k.verschoor@pay.nl" Date: Tue, 8 Dec 2020 19:05:24 +0100 Subject: [PATCH 3/8] fix 2 --- i18n/nl_NL.csv | 2 +- view/frontend/email/paylink_email.html | 17 +++-------------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/i18n/nl_NL.csv b/i18n/nl_NL.csv index 9ff75fc4..31130ae8 100644 --- a/i18n/nl_NL.csv +++ b/i18n/nl_NL.csv @@ -22,7 +22,7 @@ "Choose your bank","Kies uw bank" "Choose the pin terminal","Kies de pin terminal" "Caution!","Let op!" -"An e-mail containing a PAY. payment link will be send.","Een e-mail met een PAY. betaallink zal worden verzonden." +"An e-mail containing a PAY. paylink will be send.","Een e-mail met een PAY. betaallink zal worden verzonden." "Valid for","Geldig voor" "days","dagen" "Enabled","Ingeschakeld" diff --git a/view/frontend/email/paylink_email.html b/view/frontend/email/paylink_email.html index 98e311cd..ac37d65f 100644 --- a/view/frontend/email/paylink_email.html +++ b/view/frontend/email/paylink_email.html @@ -1,4 +1,4 @@ - + + + + Success Page + + + + + + Thank you for your purchase! + + + + + + + \ No newline at end of file diff --git a/view/frontend/templates/success.phtml b/view/frontend/templates/success.phtml new file mode 100644 index 00000000..86a9be32 --- /dev/null +++ b/view/frontend/templates/success.phtml @@ -0,0 +1,25 @@ + +
+ getOrderId()) :?> + getCanViewOrder()) :?> +

escapeHtml(__('Your order number is: %1.', sprintf('%s', $block->escapeUrl($block->getViewOrderUrl()), $block->getOrderId())), ['a', 'strong']) ?>

+ +

escapeHtml(__('Your order # is: %1.', $block->getOrderId()), ['span']) ?>

+ +

escapeHtml(__('We\'ll email you an order confirmation with details and tracking info.')) ?>

+ + + getAdditionalInfoHtml() ?> + + +
\ No newline at end of file From 7f0e1cc6894acdc69cb41d144ebcc7d9d96f0cbd Mon Sep 17 00:00:00 2001 From: kevinverschoor <61683999+kevinverschoor@users.noreply.github.com> Date: Mon, 11 Jan 2021 13:16:29 +0100 Subject: [PATCH 5/8] Remove the mistake --- etc/adminhtml/paymentmethods/paylink.xml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/etc/adminhtml/paymentmethods/paylink.xml b/etc/adminhtml/paymentmethods/paylink.xml index 084d582b..f0c5561b 100644 --- a/etc/adminhtml/paymentmethods/paylink.xml +++ b/etc/adminhtml/paymentmethods/paylink.xml @@ -128,8 +128,7 @@ - - Paynl\Payment\Model\Config\Source\SendNewOrderEmail + payment/paynl_payment_paylink/paylink_body 1 @@ -148,4 +147,4 @@ - \ No newline at end of file + From 072e37dc1b0642340a79f97ca0165314acd3c290 Mon Sep 17 00:00:00 2001 From: "k.verschoor@pay.nl" Date: Wed, 13 Jan 2021 10:05:46 +0100 Subject: [PATCH 6/8] Remove SendNewOrderEmail source_model --- etc/adminhtml/paymentmethods/paylink.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/etc/adminhtml/paymentmethods/paylink.xml b/etc/adminhtml/paymentmethods/paylink.xml index f0c5561b..edf94044 100644 --- a/etc/adminhtml/paymentmethods/paylink.xml +++ b/etc/adminhtml/paymentmethods/paylink.xml @@ -139,7 +139,6 @@ showInWebsite="1" showInStore="1"> - Paynl\Payment\Model\Config\Source\SendNewOrderEmail payment/paynl_payment_paylink/custom_success_page 1 From 70fa4678c2a40f8f46e09506a05debf6c8da8a7b Mon Sep 17 00:00:00 2001 From: woutse Date: Sat, 16 Jan 2021 17:16:50 +0100 Subject: [PATCH 7/8] Updated composer version --- Controller/Checkout/Finish.php | 19 +++++++++----- Model/Config.php | 28 ++++++++++----------- i18n/en_US.csv | 4 +-- i18n/nl_NL.csv | 2 +- view/adminhtml/templates/form/paylink.phtml | 2 +- 5 files changed, 31 insertions(+), 24 deletions(-) diff --git a/Controller/Checkout/Finish.php b/Controller/Checkout/Finish.php index e126bee2..ae420df7 100644 --- a/Controller/Checkout/Finish.php +++ b/Controller/Checkout/Finish.php @@ -114,13 +114,14 @@ public function execute() if ($transaction->isPaid() || $transaction->isAuthorized() || ($transaction->isPending() && $pinStatus == null)) { $successUrl = $this->config->getSuccessPage($payment->getMethod()); - $resultRedirect->setPath($successUrl, ['_query' => ['utm_nooverride' => '1']]); - - if($payment->toArray()['method'] == 'paynl_payment_paylink'){ - $resultRedirect->setPath('paynl/checkout/paylink/'); + + if(empty($successUrl)) { + $successUrl = ($payment->getMethod() == 'paynl_payment_paylink') ? Config::FINISH_PAYLINK : Config::FINISH_STANDARD; } - // make the cart inactive + $resultRedirect->setPath($successUrl, ['_query' => ['utm_nooverride' => '1']]); + + # Make the cart inactive $session = $this->checkoutSession; $quote = $session->getQuote(); @@ -131,7 +132,13 @@ public function execute() } $this->messageManager->addNoticeMessage(__('Payment canceled')); - $cancelURL = $this->config->getCancelURL(); + + if ($payment->getMethod() == 'paynl_payment_paylink') { + $cancelURL = Config::FINISH_PAYLINK . '?cancel=1'; + } else { + $cancelURL = $this->config->getCancelURL(); + } + $resultRedirect->setPath($cancelURL); diff --git a/Model/Config.php b/Model/Config.php index b0168285..2416262c 100644 --- a/Model/Config.php +++ b/Model/Config.php @@ -14,6 +14,8 @@ */ class Config { + const FINISH_PAYLINK = 'paynl/checkout/paylink'; + const FINISH_STANDARD = 'checkout/onepage/success'; /** @var Store */ private $store; @@ -73,20 +75,20 @@ public function isTestMode() { $remoteIP = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; $ip = isset($_SERVER['HTTP_CLIENT_IP']) ? $_SERVER['HTTP_CLIENT_IP'] : $remoteIP; - + $ipconfig = $this->store->getConfig('payment/paynl/testipaddress'); - $allowed_ips = explode(',', $ipconfig); + $allowed_ips = explode(',', $ipconfig); if(in_array($ip, $allowed_ips) && filter_var($ip, FILTER_VALIDATE_IP) && strlen($ip) > 0 && count($allowed_ips) > 0){ return true; - } + } return $this->store->getConfig('payment/paynl/testmode') == 1; } - + public function isSendDiscountTax() { return $this->store->getConfig('payment/paynl/discount_tax') == 1; } - + public function isNeverCancel() { return $this->store->getConfig('payment/paynl/never_cancel') == 1; @@ -113,7 +115,7 @@ public function getPendingStatus($methodCode) { return $this->store->getConfig('payment/' . $methodCode . '/order_status'); } - + public function getAuthorizedStatus($methodCode) { return $this->store->getConfig('payment/' . $methodCode . '/order_status_authorized'); @@ -127,11 +129,9 @@ public function getPaidStatus($methodCode){ * @param $methodCode string * @return string */ - public function getSuccessPage($methodCode){ - $success_page = $this->store->getConfig('payment/' . $methodCode . '/custom_success_page'); - if(empty($success_page)) $success_page = 'checkout/onepage/success'; - - return $success_page; + public function getSuccessPage($methodCode) + { + return $this->store->getConfig('payment/' . $methodCode . '/custom_success_page'); } /** @@ -174,15 +174,15 @@ public function getServiceId() return trim($this->store->getConfig('payment/paynl/serviceid')); } - public function getIconUrl() + public function getIconUrl() { $url = 'https://static.pay.nl/payment_profiles/50x32/#paymentOptionId#.png'; $iconUrl = trim($this->store->getConfig('payment/paynl/iconurl')); return empty($iconUrl)?$url:$iconUrl; } - - public function getCancelURL() + + public function getCancelURL() { return $this->store->getConfig('payment/paynl/cancelurl'); } diff --git a/i18n/en_US.csv b/i18n/en_US.csv index 9cee002c..4b4ad06b 100644 --- a/i18n/en_US.csv +++ b/i18n/en_US.csv @@ -21,7 +21,7 @@ "Before payment","Before payment" "Choose your bank","Choose your bank" "Choose the pin terminal","Choose the pin terminal" -"Caution!","Caution!" +"Notice","Notice" "An e-mail containing a PAY. paylink will be send.","An e-mail containing a PAY. paylink will be send." "Valid for","Valid for" "days","days" @@ -81,4 +81,4 @@ "Shipping & Handling","Shipping & Handling" "Grand Total","Grand Total" "Offline refund","Offline refund" -"This will create an offline refund. To create an online refund, open an invoice and create credit memo for it. Do you want to continue?","This will create an offline refund. To create an online refund, open an invoice and create credit memo for it. Do you want to continue?" \ No newline at end of file +"This will create an offline refund. To create an online refund, open an invoice and create credit memo for it. Do you want to continue?","This will create an offline refund. To create an online refund, open an invoice and create credit memo for it. Do you want to continue?" diff --git a/i18n/nl_NL.csv b/i18n/nl_NL.csv index 31130ae8..0bb0ac04 100644 --- a/i18n/nl_NL.csv +++ b/i18n/nl_NL.csv @@ -21,7 +21,7 @@ "Before payment","Voor betaling" "Choose your bank","Kies uw bank" "Choose the pin terminal","Kies de pin terminal" -"Caution!","Let op!" +"Notice","Opmerking" "An e-mail containing a PAY. paylink will be send.","Een e-mail met een PAY. betaallink zal worden verzonden." "Valid for","Geldig voor" "days","dagen" diff --git a/view/adminhtml/templates/form/paylink.phtml b/view/adminhtml/templates/form/paylink.phtml index 94b8de6e..d87bfb3a 100644 --- a/view/adminhtml/templates/form/paylink.phtml +++ b/view/adminhtml/templates/form/paylink.phtml @@ -14,7 +14,7 @@ $code = $block->escapeHtml( $block->getMethodCode() );