From b598fe94c913e4eec8e4cf13b2a5dc6bb76937f8 Mon Sep 17 00:00:00 2001 From: Christian Hofer Date: Tue, 19 Apr 2016 10:16:14 +0200 Subject: [PATCH] redirects the customer back to the shopping cart when the popup is closed --- Helper/Data.php | 10 ++++++++++ Model/ConfigProvider.php | 1 + view/frontend/web/js/action/set-payment-method.js | 7 +++++++ .../web/js/view/payment/method-renderer/standard.js | 8 +++++++- view/frontend/web/template/payment/method-eps.html | 3 ++- view/frontend/web/template/payment/method-ideal.html | 3 ++- .../template/payment/method-invoiceinstallment.html | 1 + .../frontend/web/template/payment/method-standard.html | 3 ++- 8 files changed, 32 insertions(+), 4 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index 7f00b82..e1a3fc2 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -363,4 +363,14 @@ public function compareQuoteChecksum($quote, $his) return true; } + + /** + * Creates return url that is called when the transaction is completed + * + * @return string + */ + public function getReturnUrl() + { + return $this->_getUrl('wirecardcheckoutpage/checkout/back', ['_secure' => true, '_nosid' => true]); + } } diff --git a/Model/ConfigProvider.php b/Model/ConfigProvider.php index aa2e841..5ada966 100644 --- a/Model/ConfigProvider.php +++ b/Model/ConfigProvider.php @@ -137,6 +137,7 @@ public function getConfig() $config['payment'][$code]['instructions'] = $this->getInstructions($code); $config['payment'][$code]['displaymode'] = $this->methods[$code]->getDisplayMode(); $config['payment'][$code]['logo_url'] = $this->getLogoUrl($code); + $config['payment'][$code]['back_url'] = $this->_dataHelper->getReturnUrl(); } /* diff --git a/view/frontend/web/js/action/set-payment-method.js b/view/frontend/web/js/action/set-payment-method.js index c0a4b33..52cc203 100644 --- a/view/frontend/web/js/action/set-payment-method.js +++ b/view/frontend/web/js/action/set-payment-method.js @@ -95,6 +95,13 @@ define( iframe.modal({ title: 'Wirecard Checkout Page', autoOpen: true, + closed: function() { + var redirectUrl = $('#' + methodeCode + '-back-url').val(); + + // get rid of onbeforeunload events + document.write(""); + location.href = redirectUrl; + }, closeText: '', buttons: [] }); diff --git a/view/frontend/web/js/view/payment/method-renderer/standard.js b/view/frontend/web/js/view/payment/method-renderer/standard.js index faf4e82..e8ef6ec 100644 --- a/view/frontend/web/js/view/payment/method-renderer/standard.js +++ b/view/frontend/web/js/view/payment/method-renderer/standard.js @@ -63,6 +63,12 @@ define( return window.checkoutConfig.payment[this.getCode()].logo_url }, + getBackUrl: function() { + if (!window.checkoutConfig.payment[this.getCode()]) + return false; + + return window.checkoutConfig.payment[this.getCode()].back_url + }, placeWirecardOrder: function () { if (this.validate() && additionalValidators.validate()) @@ -75,4 +81,4 @@ define( } }); } -); \ No newline at end of file +); diff --git a/view/frontend/web/template/payment/method-eps.html b/view/frontend/web/template/payment/method-eps.html index 4563628..6aea459 100644 --- a/view/frontend/web/template/payment/method-eps.html +++ b/view/frontend/web/template/payment/method-eps.html @@ -79,6 +79,7 @@ +
@@ -97,4 +98,4 @@
- \ No newline at end of file + diff --git a/view/frontend/web/template/payment/method-ideal.html b/view/frontend/web/template/payment/method-ideal.html index af90a68..0dbb7c9 100644 --- a/view/frontend/web/template/payment/method-ideal.html +++ b/view/frontend/web/template/payment/method-ideal.html @@ -79,6 +79,7 @@ +
@@ -97,4 +98,4 @@
- \ No newline at end of file + diff --git a/view/frontend/web/template/payment/method-invoiceinstallment.html b/view/frontend/web/template/payment/method-invoiceinstallment.html index f7fb9a9..9e4de3f 100644 --- a/view/frontend/web/template/payment/method-invoiceinstallment.html +++ b/view/frontend/web/template/payment/method-invoiceinstallment.html @@ -97,6 +97,7 @@ + diff --git a/view/frontend/web/template/payment/method-standard.html b/view/frontend/web/template/payment/method-standard.html index d790f80..cbb0234 100644 --- a/view/frontend/web/template/payment/method-standard.html +++ b/view/frontend/web/template/payment/method-standard.html @@ -61,6 +61,7 @@ +
@@ -79,4 +80,4 @@
- \ No newline at end of file +