Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

paymentwall osc integration (project specific) #9

Open
wants to merge 1 commit into
base: v2.1-master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions Controller/Gateway/Paymentwall.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
<?php
namespace Paymentwall\Paymentwall\Controller\Gateway;

use Magento\Checkout\Model\Session\SuccessValidator;

class Paymentwall extends \Magento\Checkout\Controller\Onepage
{

public function execute()
{
$session = $this->getOnepage()->getCheckout();
if (!$this->_objectManager->get('Magento\Checkout\Model\Session\SuccessValidator')->isValid()) {
if (!$this->_objectManager->get(SuccessValidator::class)->isValid()) {
return $this->resultRedirectFactory->create()->setPath('checkout/cart');
}
$session->clearQuote();

$resultPage = $this->resultPageFactory->create();
$this->_eventManager->dispatch(
'checkout_onepage_controller_success_action',
['order_ids' => [$session->getLastOrderId()]]
);
return $resultPage;
if ($this->getRequest()->isAjax()) {
$order = $session->getLastRealOrder();
$customer = $this->_customerSession->getCustomer();
$widget = $this->model->generateWidget($order, $customer);

return $this->resultJsonFactory->create()->setData(['url' => $widget->getUrl()]);
}

return $this->resultPageFactory->create();
}
}
15 changes: 13 additions & 2 deletions Controller/Onepage/Success.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@ class Success extends \Magento\Checkout\Controller\Onepage
{
public function execute()
{
$resultPage = $this->resultPageFactory->create();
return $resultPage;
$session = $this->getOnepage()->getCheckout();
$session->clearQuote();

$result = $this->resultRawFactory->create();
$url = $this->urlBuilder->getUrl('checkout/onepage/success');
$result->setContents('<script type="text/javascript">window.parent.location = \'' . $url . '\';</script>');

$this->_eventManager->dispatch(
'checkout_onepage_controller_success_action',
['order_ids' => [$session->getLastOrderId()]]
);

return $result;
}
}
14 changes: 13 additions & 1 deletion view/frontend/web/js/action/redirect-to-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,19 @@ define(
* Provide redirect to page
*/
execute: function () {
window.location.replace(url.build(this.redirectUrl));
fullScreenLoader.startLoader();

storage.get(this.redirectUrl)
.success(function (response) {
var url = response.url;

$('.page-wrapper').append('<div class="payment-wall-modal"><iframe src="' + url + '" frameborder="0" width="100%" height="650px"></iframe></div>');
$('body').addClass('_has-modal');
})
.fail(function () {
window.location.replace(url.build(this.redirectUrl));
});

}
};
}
Expand Down