Skip to content

Commit

Permalink
Merge pull request #515 from Adyen/develop
Browse files Browse the repository at this point in the history
Release 4.0.0
  • Loading branch information
RokPopov authored Jul 17, 2024
2 parents 573e355 + 2fc9de1 commit a7b2473
Show file tree
Hide file tree
Showing 15 changed files with 67 additions and 47 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}
],
"description": "Official Shopware 6 Plugin to connect to Payment Service Provider Adyen",
"version": "4.0.0-rc1",
"version": "4.0.0",
"type": "shopware-platform-plugin",
"license": "MIT",
"require": {
Expand Down
34 changes: 33 additions & 1 deletion src/Controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use Adyen\Shopware\Entity\AdyenPayment\AdyenPaymentEntity;
use Adyen\Shopware\Entity\Notification\NotificationEntity;
use Adyen\Shopware\Exception\CaptureException;
use Adyen\Shopware\Provider\AdyenPluginProvider;
use Adyen\Shopware\Service\AdyenPaymentService;
use Adyen\Shopware\Service\CaptureService;
use Adyen\Shopware\Service\ConfigurationService;
Expand Down Expand Up @@ -92,6 +93,9 @@ class AdminController
/** @var OrderTransactionRepository */
private OrderTransactionRepository $orderTransactionRepository;

/** @var AdyenPluginProvider */
private AdyenPluginProvider $pluginProvider;

/**
* AdminController constructor.
*
Expand All @@ -107,6 +111,7 @@ class AdminController
* @param ConfigurationService $configurationService
* @param AdyenPaymentService $adyenPaymentService
* @param OrderTransactionRepository $orderTransactionRepository
* @param AdyenPluginProvider $pluginProvider
*/
public function __construct(
LoggerInterface $logger,
Expand All @@ -120,7 +125,8 @@ public function __construct(
Currency $currencyUtil,
ConfigurationService $configurationService,
AdyenPaymentService $adyenPaymentService,
OrderTransactionRepository $orderTransactionRepository
OrderTransactionRepository $orderTransactionRepository,
AdyenPluginProvider $pluginProvider
) {
$this->logger = $logger;
$this->orderRepository = $orderRepository;
Expand All @@ -134,6 +140,7 @@ public function __construct(
$this->configurationService = $configurationService;
$this->adyenPaymentService = $adyenPaymentService;
$this->orderTransactionRepository = $orderTransactionRepository;
$this->pluginProvider = $pluginProvider;
}

/**
Expand Down Expand Up @@ -506,4 +513,29 @@ public function rescheduleNotification(string $notificationId): JsonResponse

return new JsonResponse($notificationId);
}

/**
* @param string $orderId
* @return JsonResponse
*/
#[Route(
'/api/adyen/orders/{orderId}/is-adyen-order',
name: 'api.adyen_is_adyen_order.get',
methods: ['GET']
)]
public function isAdyenOrder(string $orderId): JsonResponse
{
try {
$transaction = $this->orderTransactionRepository->getFirstAdyenOrderTransaction($orderId);

if (!is_null($transaction)) {
return new JsonResponse(['status' => true]);
}

return new JsonResponse(['status' => false]);
} catch (Throwable $t) {
$this->logger->error($t->getMessage());
return new JsonResponse(['message' => 'adyen.error'], 500);
}
}
}
2 changes: 1 addition & 1 deletion src/Migration/Migration1713255011AlterAdyenPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function getCreationTimestamp(): int
public function update(Connection $connection): void
{
$connection->executeStatement(<<<SQL
ALTER TABLE `adyen_payment` ADD COLUMN `total_refunded` int DEFAULT(0) NOT NULL;
ALTER TABLE `adyen_payment` ADD COLUMN `total_refunded` int DEFAULT 0 NOT NULL;
SQL);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ Component.register('adyen-notifications', {
}
},

beforeMount() {
this.showWidget = this.adyenService.isAdyenOrder(this.order);
async beforeMount() {
this.showWidget = await this.adyenService.isAdyenOrder(this.order);
if (this.showWidget) {
this.fetchNotifications();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ Component.register('adyen-partial-payments', {
}
},

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

if (this.showWidget) {
this.fetchAdyenPartialPayments();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,24 +118,10 @@ Component.register('adyen-refund', {

this.allowRefund = this.order.amountTotal > (refundedAmount / 100);
},

isAdyenOrder() {
const orderTransactions = this.order.transactions;
let isAdyen = false;
for (let i = 0; i < orderTransactions.length; i++) {
if (orderTransactions[i].customFields !== undefined) {
if (orderTransactions[i].customFields.originalPspReference !== undefined) {
isAdyen = true;
}
}
}

this.showWidget = isAdyen;
}
},

beforeMount() {
this.isAdyenOrder();
async beforeMount() {
this.showWidget = await this.adyenService.isAdyenOrder(this.order);
if (this.showWidget) {
this.fetchRefunds();
}
Expand Down
28 changes: 16 additions & 12 deletions src/Resources/app/administration/src/service/adyenService.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,22 @@ class ApiClient extends ApiService {
});
}

isAdyenOrder(order) {
const orderTransactions = order.transactions;
let isAdyen = false;
for (let i = 0; i < orderTransactions.length; i++) {
if (orderTransactions[i].customFields !== undefined) {
if (orderTransactions[i].customFields.originalPspReference !== undefined) {
isAdyen = true;
}
}
}

return isAdyen;
isAdyenOrder(order){
const headers = this.getBasicHeaders({});
return this.httpClient
.get(this.getApiBasePath() + '/orders/' + order.id + '/is-adyen-order', {
headers
})
.then((response) => {
return ApiService.handleResponse(response);
})
.then((response) => {
return response.status
})
.catch((error) => {
console.error('An error occurred: ' + error.message);
return false;
});
}

fetchAdyenPartialPayments(orderId) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
.adyen-capture-card-header{display:flex;height:30px;margin-bottom:15px}.adyen-capture-card-header-first{margin-top:auto;width:100%}
.adyen-refund-card-header{display:flex;height:30px;margin-bottom:15px}.adyen-refund-card-header-first{margin-top:auto;width:100%}

/*# sourceMappingURL=adyen-payment-shopware6.css.map*/

Large diffs are not rendered by default.

Loading

0 comments on commit a7b2473

Please sign in to comment.