Skip to content

Commit

Permalink
[ECP-8719] Fix capture, refund and notifications blocks in admin orde…
Browse files Browse the repository at this point in the history
…r detail page (#431)

* [ECP-8719] Fix capture, refund and notifications blocks in admin order detail page

* [ECP-8719] Extend extra block to support Shopware 6.4

* [ECP-8719] Remove unused left-over block from prepared payment project

* [ECP-8719] Extend partial payment information block

* [ECP-8719] Remove leftover comment block
  • Loading branch information
candemiralp authored Nov 14, 2023
1 parent ecc3b5c commit 65c4c93
Show file tree
Hide file tree
Showing 12 changed files with 203 additions and 83 deletions.
3 changes: 1 addition & 2 deletions src/Controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@
use Symfony\Component\Routing\Annotation\Route;

/**
* @Route(defaults={"_routeScope"={"administration"}})
*
* Class AdminController
* @package Adyen\Shopware\Controller
* @Route(defaults={"_routeScope"={"administration"}})
*/
class AdminController
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
<div v-if="showWidget">
<sw-card :title="$tc('adyen.notificationsTitle')">
<sw-data-grid
v-if="notifications.length"
:dataSource="notifications"
:columns="columns"
:showActions="true"
:showSelection="false"
:showSettings="true"
>
{% block sw_data_grid_body_columns %}
{% block sw_data_grid_column_actions %}
<template #actions="{ item }">
{% block sw_data_grid_column_actions_reschedule %}
<sw-context-menu-item
v-if="item.canBeRescheduled"
@click="onReschedule(item)"
>
{{ $tc('adyen.reprocessNotification') }}
</sw-context-menu-item>
{% endblock %}
</template>
{% block adyen_notifications %}
<div v-if="showWidget">
<sw-card :title="$tc('adyen.notificationsTitle')">
<sw-data-grid
v-if="notifications.length"
:dataSource="notifications"
:columns="columns"
:showActions="true"
:showSelection="false"
:showSettings="true"
>
{% block sw_data_grid_body_columns %}
{% block sw_data_grid_column_actions %}
<template #actions="{ item }">
{% block sw_data_grid_column_actions_reschedule %}
<sw-context-menu-item
v-if="item.canBeRescheduled"
@click="onReschedule(item)"
>
{{ $tc('adyen.reprocessNotification') }}
</sw-context-menu-item>
{% endblock %}
</template>
{% endblock %}
{% endblock %}
{% endblock %}
</sw-data-grid>
<p v-if="!notifications.length">{{ $tc('adyen.noNotificationsReceived') }}</p>
</sw-card>
</div>
</sw-data-grid>
<p v-if="!notifications.length">{{ $tc('adyen.noNotificationsReceived') }}</p>
</sw-card>
</div>
{% endblock %}
Original file line number Diff line number Diff line change
@@ -1,9 +1,59 @@
<ul v-if="showWidget">
<dt>{{ $tc('adyen.authorisedPayments') }}</dt>
<dd v-for="payment in partialPayments">
<a v-bind:href="payment.caLink" target="_blank">{{ payment.pspReference }}</a> -
<span>{{ payment.method }}</span> -
<span>{{ payment.amount }}</span>
</dd>
<dd>{{ errorMessage }}</dd>
</ul>
<div v-if="showWidget">
<ul v-if="isVersionOlderThan65">
<dt>{{ $tc('adyen.authorisedPayments') }}</dt>
<dd v-for="payment in partialPayments">
<a v-bind:href="payment.caLink" target="_blank">{{ payment.pspReference }}</a> -
<span>{{ payment.method }}</span> -
<span>{{ payment.amount }}</span>
</dd>
<dd>{{ errorMessage }}</dd>
</ul>
<ul v-else>
<label>{{ $tc('adyen.authorisedPayments') }}</label>
<div class="sw-data-grid is--compact sw-data-grid--plain-appearance">
<div class="sw-data-grid__wrapper">
<table class="sw-data-grid__table">
<thead class="sw-data-grid__header">
<tr class="sw-data-grid__rx ow">
<th class="sw-data-grid__cell sw-data-grid__cell--header sw-data-grid__cell--property sw-data-grid__cell--sortable sw-data-grid__cell--align-left">
<div class="sw-data-grid__cell-content">
PSP Reference
</div>
</th>
<th class="sw-data-grid__cell sw-data-grid__cell--header sw-data-grid__cell--property sw-data-grid__cell--sortable sw-data-grid__cell--align-left">
<div class="sw-data-grid__cell-content">
Payment Method
</div>
</th>
<th class="sw-data-grid__cell sw-data-grid__cell--header sw-data-grid__cell--property sw-data-grid__cell--sortable sw-data-grid__cell--align-left">
<div class="sw-data-grid__cell-content">
Amount
</div>
</th>
</tr>
</thead>
<tbody class="sw-data-grid__body">
<tr v-for="payment in partialPayments" class="sw-data-grid__row">
<td class="sw-data-grid__cell sw-data-grid__cell--order sw-data-grid__cell--align-left">
<div class="sw-data-grid__cell-content">
<a v-bind:href="payment.caLink" target="_blank">{{ payment.pspReference }}</a>
</div>
</td>
<td class="sw-data-grid__cell sw-data-grid__cell--order sw-data-grid__cell--align-left">
<div class="sw-data-grid__cell-content">
{{ payment.method }}
</div>
</td>
<td class="sw-data-grid__cell sw-data-grid__cell--order sw-data-grid__cell--align-left">
<div class="sw-data-grid__cell-content">
{{ payment.amount }}
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<span>{{ errorMessage }}</span>
</ul>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

const { Component } = Shopware;
import template from './adyen-partial-payments.html.twig';
import VersionHelper from '../../helper/versionHelper';

Component.register('adyen-partial-payments', {
template,
Expand Down Expand Up @@ -52,11 +53,14 @@ Component.register('adyen-partial-payments', {
errorMessage: "",
partialPayments: [],
showWidget: false,
isVersionOlderThan65: false
}
},

beforeMount() {
this.isVersionOlderThan65 = VersionHelper.isVersionOlderThan65();
this.showWidget = this.adyenService.isAdyenOrder(this.order);

if (this.showWidget) {
this.fetchAdyenPartialPayments();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,44 +1,46 @@
<sw-card :isLoading="isLoading" :title="$tc('adyen.adyenPaymentCaptureTitle')" v-if="showWidget" :large="false" :hero="false">
<div v-if="!errorOccurred">
<div class="adyen-card-header">
<div class="adyen-card-header-first">
<span v-if="!captureRequests.length">{{ $tc('adyen.noCaptureRequests') }}</span>
</div>
<div id="modalButtonContainer">
<sw-button
:disabled="!allowCapture"
:square="false"
:block="false"
@click="openModal"
class="sw-button--small">
{{ $tc('adyen.sendCaptureRequest') }}
</sw-button>
</div>
<sw-modal v-if="showModal"
@modal-close="onCloseModal"
:title="$tc('adyen.captureConfirm') + ': ' + order.orderNumber"
variant="small">
<template #modal-footer>
<sw-button @click="onCloseModal" size="small">
{{ $tc('global.default.cancel') }}
</sw-button>

<sw-button @click="onSubmitCapture" variant="primary" size="small" :isLoading="isLoading">
{% block adyen_capture %}
<sw-card :isLoading="isLoading" :title="$tc('adyen.adyenPaymentCaptureTitle')" v-if="showWidget" :large="false" :hero="false">
<div v-if="!errorOccurred">
<div class="adyen-card-header">
<div class="adyen-card-header-first">
<span v-if="!captureRequests.length">{{ $tc('adyen.noCaptureRequests') }}</span>
</div>
<div id="modalButtonContainer">
<sw-button
:disabled="!allowCapture"
:square="false"
:block="false"
@click="openModal"
class="sw-button--small">
{{ $tc('adyen.sendCaptureRequest') }}
</sw-button>
</template>
</sw-modal>
</div>
<sw-modal v-if="showModal"
@modal-close="onCloseModal"
:title="$tc('adyen.captureConfirm') + ': ' + order.orderNumber"
variant="small">
<template #modal-footer>
<sw-button @click="onCloseModal" size="small">
{{ $tc('global.default.cancel') }}
</sw-button>

<sw-button @click="onSubmitCapture" variant="primary" size="small" :isLoading="isLoading">
{{ $tc('adyen.sendCaptureRequest') }}
</sw-button>
</template>
</sw-modal>
</div>
<sw-data-grid
v-if="captureRequests.length"
:dataSource="captureRequests"
:columns="columns"
:showSelection="false"
:showActions="false"
:isLoading="isLoading">
</sw-data-grid>
</div>
<div v-else>
{{ $tc('adyen.error') }}
</div>
<sw-data-grid
v-if="captureRequests.length"
:dataSource="captureRequests"
:columns="columns"
:showSelection="false"
:showActions="false"
:isLoading="isLoading">
</sw-data-grid>
</div>
<div v-else>
{{ $tc('adyen.error') }}
</div>
</sw-card>
</sw-card>
{% endblock %}
44 changes: 44 additions & 0 deletions src/Resources/app/administration/src/helper/versionHelper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen plugin for Shopware 6
*
* Copyright (c) 2023 Adyen N.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
*/
let exports = {};

exports.isVersionOlderThan65 = () => {
function semverCompare(a, b) {
if (a.startsWith(b + "-")) {
return -1
} else if (b.startsWith(a + "-")) {
return 1
}

return a.localeCompare(b, undefined, { numeric: true, sensitivity: "case", caseFirst: "upper" })
};

const version = Shopware.Context.app.config.version;

if (semverCompare(version, "6.5.0.0") === -1) {
return true
} else {
return false;
}
};

export default exports;
2 changes: 2 additions & 0 deletions src/Resources/app/administration/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ import './component/adyen-payment-capture';
import './component/adyen-refund';
import './component/adyen-notifications';
import './component/adyen-partial-payments';
import './sw-order-detail-general-override/index';
import './sw-order-detail-base-override/index';
import './sw-order-user-card-override/index';
import './sw-order-detail-details-override/index';
import './component/entity/sw-entity-single-select-override';

import localeEnGb from './snippet/en_GB.json';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import template from './sw-order-detail-details.html.twig';

Shopware.Component.override('sw-order-detail-details', {
template
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% block sw_order_detail_details_payment_method_select %}
{% parent %}

<adyen-partial-payments :order="order"></adyen-partial-payments>
{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import template from './sw-order-detail-general.html.twig';

Shopware.Component.override('sw-order-detail-general', {
template
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% block sw_order_detail_general_line_items_card %}
{% parent %}
<adyen-payment-capture :order="order"></adyen-payment-capture>
<adyen-refund :order="order"></adyen-refund>
<adyen-notifications :order="order"></adyen-notifications>
{% endblock %}

This file was deleted.

0 comments on commit 65c4c93

Please sign in to comment.