Skip to content

Commit

Permalink
NTR: add auto redirect again
Browse files Browse the repository at this point in the history
  • Loading branch information
boxblinkracer committed Sep 18, 2023
1 parent 41a4029 commit a289dff
Show file tree
Hide file tree
Showing 17 changed files with 651 additions and 550 deletions.
1,131 changes: 605 additions & 526 deletions composer.lock

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ clean: ## Cleans all dependencies and files
rm -rf ./src/Resources/app/storefront/node_modules/*
# ------------------------------------------------------
rm -rf ./src/Resources/app/storefront/dist/storefront
rm -rf ./src/Resources/public
# ------------------------------------------------------
rm -rf ./src/Resources/public/administration
rm -rf ./src/Resources/public/molllie-payments.js

build: ## Installs the plugin, and builds the artifacts using the Shopware build commands.
php switch-composer.php prod
Expand Down
6 changes: 4 additions & 2 deletions src/Controller/Storefront/POS/PosControllerBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\RouterInterface;

class PosControllerBase extends StorefrontController
{
Expand Down Expand Up @@ -166,10 +166,12 @@ public function statusAction(SalesChannelContext $context, string $orderId, stri
);
}

$isSuccess = MolliePaymentStatus::isApprovedStatus($molliePayment->status);

return new JsonResponse([
'ready' => $ready,
'redirectUrl' => $url,
'status' => $status
'success' => $isSuccess
]);
}
}
11 changes: 9 additions & 2 deletions src/MolliePayments.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Kiener\MolliePayments\Compatibility\DependencyLoader;
use Kiener\MolliePayments\Components\Installer\PluginInstaller;
use Kiener\MolliePayments\Repository\CustomFieldSet\CustomFieldSetRepository;
use Psr\Container\ContainerInterface;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\Migration\MigrationCollection;
Expand Down Expand Up @@ -88,10 +89,13 @@ public function install(InstallContext $context): void
{
parent::install($context);

/** @var ContainerInterface $container */
$container = $this->container;

# that's the only part we use the Shopware repository directly,
# and not our custom one, because our repositories are not yet registered in this function
/** @var EntityRepository $shopwareRepoCustomFields */
$shopwareRepoCustomFields = $this->container->get('custom_field_set.repository');
$shopwareRepoCustomFields = $container->get('custom_field_set.repository');

if ($shopwareRepoCustomFields !== null) {
$mollieRepoCustomFields = new CustomFieldSetRepository($shopwareRepoCustomFields);
Expand Down Expand Up @@ -166,8 +170,11 @@ public function deactivate(DeactivateContext $context): void
*/
private function preparePlugin(Context $context): void
{
/** @var ContainerInterface $container */
$container = $this->container;

/** @var PluginInstaller $pluginInstaller */
$pluginInstaller = $this->container->get(PluginInstaller::class);
$pluginInstaller = $container->get(PluginInstaller::class);

$pluginInstaller->install($context);
}
Expand Down
1 change: 1 addition & 0 deletions src/Resources/config/compatibility/controller.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<argument type="service" id="Kiener\MolliePayments\Controller\Storefront\Webhook\NotificationFacade"/>
<argument type="service" id="Kiener\MolliePayments\Components\Subscription\SubscriptionManager"/>
<argument type="service" id="Kiener\MolliePayments\Repository\Order\OrderRepository"/>
<argument type="service" id="Kiener\MolliePayments\Repository\OrderTransaction\OrderTransactionRepository"/>
<argument type="service" id="mollie_payments.logger"/>
<call method="setContainer">
<argument type="service" id="service_container"/>
Expand Down
1 change: 1 addition & 0 deletions src/Resources/config/compatibility/controller_6.5.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<argument type="service" id="Kiener\MolliePayments\Controller\Storefront\Webhook\NotificationFacade"/>
<argument type="service" id="Kiener\MolliePayments\Components\Subscription\SubscriptionManager"/>
<argument type="service" id="Kiener\MolliePayments\Repository\Order\OrderRepository"/>
<argument type="service" id="Kiener\MolliePayments\Repository\OrderTransaction\OrderTransactionRepository"/>
<argument type="service" id="mollie_payments.logger"/>
<call method="setContainer">
<argument type="service" id="service_container"/>
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
45 changes: 27 additions & 18 deletions src/Resources/views/mollie/pos/checkout.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -177,36 +177,40 @@
</style>



<div class="mollie-content js-mollie-content">
<div class="mollie-info-container js-info-loading m-info-show">
<div class="mollie-headline-container">
<div class="mollie-headline">
<span>Terminal name</span>
<div class="mollie-headline">
<h2 class="m-headline loading">Follow the instructions on the terminal</h2>
<h2 class="m-headline success" style="display:none">Your payment was successful!</h2>
<h2 class="m-headline failed" style="display:none">Your payment was not successful!</h2>
<p class="failed" style="display:none">No money has been debited from the debit card</p>
<a href="#" title="Return to website" id="returnButton" class="m-button" style="display:none">
Return to website
<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"><path d="M17.17 32.92l9.17-9.17-9.17-9.17 2.83-2.83 12 12-12 12z"/><path d="M0-.25h48v48h-48z" fill="none"/></svg>
<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M17.17 32.92l9.17-9.17-9.17-9.17 2.83-2.83 12 12-12 12z"/>
<path d="M0-.25h48v48h-48z" fill="none"/>
</svg>
</a>
</div>
{% if changeStatusUrl %}
<a href="{{ changeStatusUrl }}" title="Change Status in Test Mode" target="_blank" id="statusChange" class="m-button">
Change Status in Test Mode
<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"><path d="M17.17 32.92l9.17-9.17-9.17-9.17 2.83-2.83 12 12-12 12z"/><path d="M0-.25h48v48h-48z" fill="none"/></svg>
<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M17.17 32.92l9.17-9.17-9.17-9.17 2.83-2.83 12 12-12 12z"/>
<path d="M0-.25h48v48h-48z" fill="none"/>
</svg>
</a>
{% endif %}
</div>
<div class="mollie-image-container loading">
<img srcset="{{ asset('bundles/molliepayments/static/img/pos/[email protected]', 'asset') }} 2x {{ asset('bundles/molliepayments/static/img/pos/[email protected]', 'asset') }} 3x" src="{{ asset('bundles/molliepayments/static/img/pos/loading.png', 'asset') }}" alt="Mollie" />
<img srcset="{{ asset('bundles/molliepayments/static/[email protected]', 'asset') }} 2x {{ asset('bundles/molliepayments/static/[email protected]', 'asset') }} 3x" src="{{ asset('bundles/molliepayments/static/loading.png', 'asset') }}" alt="Mollie"/>
</div>
<div class="mollie-image-container success" style="display:none">
<img srcset="{{ asset('bundles/molliepayments/static/img/pos/[email protected]', 'asset') }} 2x {{ asset('bundles/molliepayments/static/img/pos/[email protected]', 'asset') }} 3x" src="{{ asset('bundles/molliepayments/static/img/pos/success.png', 'asset') }}" alt="Mollie" />
<img srcset="{{ asset('bundles/molliepayments/static/[email protected]', 'asset') }} 2x {{ asset('bundles/molliepayments/static/[email protected]', 'asset') }} 3x" src="{{ asset('bundles/molliepayments/static/success.png', 'asset') }}" alt="Mollie"/>
</div>
<div class="mollie-image-container failed" style="display:none">
<img srcset="{{ asset('bundles/molliepayments/static/img/pos/[email protected]', 'asset') }} 2x {{ asset('bundles/molliepayments/static/img/pos/[email protected]', 'asset') }} 3x" src="{{ asset('bundles/molliepayments/static/img/pos/failed.png', 'asset') }}" alt="Mollie" />
<img srcset="{{ asset('bundles/molliepayments/static/[email protected]', 'asset') }} 2x {{ asset('bundles/molliepayments/static/[email protected]', 'asset') }} 3x" src="{{ asset('bundles/molliepayments/static/failed.png', 'asset') }}" alt="Mollie"/>
</div>
</div>
</div>
Expand All @@ -219,39 +223,44 @@
const successElements = Array.from(document.getElementsByClassName('success'));
const failedElements = Array.from(document.getElementsByClassName('failed'));
function handleResponse(response){
console.log(response.target.response);
function handleResponse(response) {
const json = JSON.parse(response.target.response);
if (json.ready) {
clearInterval(interval);
if(statusChangeButton !== null){
if (statusChangeButton !== null) {
statusChangeButton.style.display = 'none';
}
loadingElements.forEach(function(element){
loadingElements.forEach(function (element) {
element.style.display = 'none';
});
returnButton.style.display = 'block';
returnButton.href= json.redirectUrl;
if(json.status === 'open' || json.status === 'paid'){
successElements.forEach(function(element){
returnButton.href = json.redirectUrl;
if (json.success) {
successElements.forEach(function (element) {
element.style.display = 'block';
});
}else{
failedElements.forEach(function(element){
} else {
failedElements.forEach(function (element) {
element.style.display = 'block';
});
}
window.location.href = json.redirectUrl;
}
}
function requestStatus() {
const xhr = new XMLHttpRequest();
xhr.open('GET', '/mollie/pos/{{ swOrderId }}/{{ molliePaymentId }}/status');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onload = handleResponse;
xhr.onerror = handleResponse;
xhr.send();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('POS Terminals', () => {
shopware.prepareDomainChange();
checkout.placeOrderOnConfirm();

cy.contains('waiting for payment');
cy.contains('Follow the instructions on the terminal');
})
})
})
Expand Down

0 comments on commit a289dff

Please sign in to comment.