diff --git a/Block/Page/Paylink.php b/Block/Page/Paylink.php new file mode 100644 index 00000000..956b76bc --- /dev/null +++ b/Block/Page/Paylink.php @@ -0,0 +1,18 @@ +_storeManager->getStore()->getBaseUrl(); + } +} \ No newline at end of file diff --git a/Controller/Checkout/Finish.php b/Controller/Checkout/Finish.php index 94988d66..339ba08e 100644 --- a/Controller/Checkout/Finish.php +++ b/Controller/Checkout/Finish.php @@ -114,9 +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']]); - // make the cart inactive + if(empty($successUrl)) { + $successUrl = ($payment->getMethod() == 'paynl_payment_paylink') ? Config::FINISH_PAYLINK : Config::FINISH_STANDARD; + } + + $resultRedirect->setPath($successUrl, ['_query' => ['utm_nooverride' => '1']]); + + # Make the cart inactive $session = $this->checkoutSession; $quote = $session->getQuote(); @@ -127,11 +132,15 @@ public function execute() } $orderStatus = empty($params['orderStatusId']) ? null : $params['orderStatusId']; - $cancelMessage = $orderStatus == -63 ? __('Payment denied') : __('Payment canceled'); - $this->messageManager->addNoticeMessage($cancelMessage); - $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/Controller/Checkout/Paylink.php b/Controller/Checkout/Paylink.php new file mode 100644 index 00000000..d81a9db5 --- /dev/null +++ b/Controller/Checkout/Paylink.php @@ -0,0 +1,25 @@ +_pageFactory = $pageFactory; + return parent::__construct($context); + } + + public function execute() + { + return $this->_pageFactory->create(); + } +} \ No newline at end of file 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/Model/Paymentmethod/Paylink.php b/Model/Paymentmethod/Paylink.php index 590e6f54..51c1b0a6 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 ], ); @@ -136,4 +156,4 @@ public function assignData(\Magento\Framework\DataObject $data) return parent::assignData($data); } -} \ No newline at end of file +} diff --git a/etc/adminhtml/paymentmethods/paylink.xml b/etc/adminhtml/paymentmethods/paylink.xml index ae06b555..edf94044 100644 --- a/etc/adminhtml/paymentmethods/paylink.xml +++ b/etc/adminhtml/paymentmethods/paylink.xml @@ -114,17 +114,27 @@ 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 - + + + 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)) + @@ -136,4 +146,4 @@ - \ No newline at end of file + 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..0270448a 100644 --- a/i18n/en_US.csv +++ b/i18n/en_US.csv @@ -21,8 +21,8 @@ "Before payment","Before payment" "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." +"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" "Enabled","Enabled" @@ -81,4 +81,6 @@ "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?" +"Thank you for your purchase!","Thank you for your purchase!" +"The payment has been canceled.","The payment has been canceled." \ No newline at end of file diff --git a/i18n/nl_NL.csv b/i18n/nl_NL.csv index 65bd2c6b..223a70ef 100644 --- a/i18n/nl_NL.csv +++ b/i18n/nl_NL.csv @@ -22,8 +22,8 @@ "Before payment","Voor betaling" "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." +"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" "Enabled","Ingeschakeld" @@ -82,4 +82,6 @@ "Shipping & Handling","Verzendkosten" "Grand Total","Totaalbedrag" "Offline refund","Offline terugbetaling" -"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?","Dit zorgt voor een offline terugbetaling. Om een ​​online terugbetaling te creëren, opent u een factuur en maakt u er een creditnota voor aan. Wilt u doorgaan?" \ 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?","Dit zorgt voor een offline terugbetaling. Om een ​​online terugbetaling te creëren, opent u een factuur en maakt u er een creditnota voor aan. Wilt u doorgaan?" +"Thank you for your purchase!","Bedankt voor uw aankoop!" +"The payment has been canceled.","De betaling is geannuleerd." \ No newline at end of file diff --git a/view/adminhtml/templates/form/paylink.phtml b/view/adminhtml/templates/form/paylink.phtml index a8ff6d21..d87bfb3a 100644 --- a/view/adminhtml/templates/form/paylink.phtml +++ b/view/adminhtml/templates/form/paylink.phtml @@ -14,9 +14,9 @@ $code = $block->escapeHtml( $block->getMethodCode() );