diff --git a/CHANGELOG.md b/CHANGELOG.md index ea69e86..58f2d2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 7.3.2 +- Fix for partial refunds using standard refund option +- Fixed issue with undefined array key +- Fixed issue with recurring payments +- Fixed concrete class reference; used interface instead + # 7.3.1 - Shopware 6.7.7.0 compatibility - Fix for missing payment icons diff --git a/CHANGELOG_de-DE.md b/CHANGELOG_de-DE.md index 15a6683..2bd6511 100644 --- a/CHANGELOG_de-DE.md +++ b/CHANGELOG_de-DE.md @@ -1,3 +1,8 @@ +# 7.3.2 +- Problem mit Teilrückerstattungen über die Standardrückerstattungsoption behoben +- Problem mit undefiniertem Array-Schlüssel behoben +- Problem mit einziehenden Zahlungen behoben +- Konkrete Klasse durch Verwendung einer Schnittstelle korrigiert # 7.3.1 - Kompatibilität mit Shopware 6.7.7.0 - Fehlende Zahlungssymbole behoben diff --git a/README.md b/README.md index a14a947..a49c04c 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,10 @@ Please note that this plugin is for versions 6.5, 6.6 or 6.7. For the 6.4 plugin ## Documentation -- For English documentation click [here](https://docs.plugin-documentation.vr-payment.de/vr-payment/shopware-6/7.3.1/docs/en/documentation.html) -- Für die deutsche Dokumentation klicken Sie [hier](https://docs.plugin-documentation.vr-payment.de/vr-payment/shopware-6/7.3.1/docs/de/documentation.html) -- Pour la documentation Française, cliquez [ici](https://docs.plugin-documentation.vr-payment.de/vr-payment/shopware-6/7.3.1/docs/fr/documentation.html) -- Per la documentazione in tedesco, clicca [qui](https://docs.plugin-documentation.vr-payment.de/vr-payment/shopware-6/7.3.1/docs/it/documentation.html) +- For English documentation click [here](https://docs.plugin-documentation.vr-payment.de/vr-payment/shopware-6/7.3.2/docs/en/documentation.html) +- Für die deutsche Dokumentation klicken Sie [hier](https://docs.plugin-documentation.vr-payment.de/vr-payment/shopware-6/7.3.2/docs/de/documentation.html) +- Pour la documentation Française, cliquez [ici](https://docs.plugin-documentation.vr-payment.de/vr-payment/shopware-6/7.3.2/docs/fr/documentation.html) +- Per la documentazione in tedesco, clicca [qui](https://docs.plugin-documentation.vr-payment.de/vr-payment/shopware-6/7.3.2/docs/it/documentation.html) ## Installation diff --git a/composer.json b/composer.json index fa9c91d..f879647 100644 --- a/composer.json +++ b/composer.json @@ -59,5 +59,5 @@ "vrpayment/sdk": "^4.0.0" }, "type": "shopware-platform-plugin", - "version": "7.3.1" + "version": "7.3.2" } diff --git a/docs/de/documentation.html b/docs/de/documentation.html index 413ba6b..fbab069 100644 --- a/docs/de/documentation.html +++ b/docs/de/documentation.html @@ -23,7 +23,7 @@
  • - + Source
  • diff --git a/docs/en/documentation.html b/docs/en/documentation.html index cddf243..eed16e0 100644 --- a/docs/en/documentation.html +++ b/docs/en/documentation.html @@ -23,7 +23,7 @@
  • - + Source
  • diff --git a/docs/fr/documentation.html b/docs/fr/documentation.html index 4afed24..47f5c69 100644 --- a/docs/fr/documentation.html +++ b/docs/fr/documentation.html @@ -23,7 +23,7 @@
  • - + Source
  • diff --git a/docs/it/documentation.html b/docs/it/documentation.html index b0a8ca7..c8b3bf3 100644 --- a/docs/it/documentation.html +++ b/docs/it/documentation.html @@ -23,7 +23,7 @@
  • - + Source
  • diff --git a/src/Core/Api/Refund/Controller/RefundController.php b/src/Core/Api/Refund/Controller/RefundController.php index cce0025..7ec5f4e 100644 --- a/src/Core/Api/Refund/Controller/RefundController.php +++ b/src/Core/Api/Refund/Controller/RefundController.php @@ -14,7 +14,8 @@ use Symfony\Component\{ use VRPaymentPayment\Core\{ Api\Refund\Service\RefundService, Api\Transaction\Service\TransactionService, - Settings\Service\SettingsService + Settings\Service\SettingsService, + Util\Exception\RefundNotSupportedException }; /** @@ -105,7 +106,12 @@ class RefundController extends AbstractController return new Response('refundExceedsQuantity', Response::HTTP_BAD_REQUEST); } - $refund = $this->refundService->create($transaction, $context, $lineItemId, $quantity); + try { + $refund = $this->refundService->create($transaction, $context, $lineItemId, $quantity); + } catch (RefundNotSupportedException $exception) { + $this->logger->info('Payment method does not support online refunds for transaction: ' . $transactionId); + return new Response('methodDoesNotSupportRefund', Response::HTTP_BAD_REQUEST); + } if ($refund === null) { return new Response('Refund was not created. Please check the refund amound or if the item was not refunded before', Response::HTTP_BAD_REQUEST); @@ -148,7 +154,12 @@ class RefundController extends AbstractController return new Response('refundExceedsAmount', Response::HTTP_BAD_REQUEST); } - $refund = $this->refundService->createRefundByAmount($transaction, $refundableAmount, $context); + try { + $refund = $this->refundService->createRefundByAmount($transaction, $refundableAmount, $context); + } catch (RefundNotSupportedException $exception) { + $this->logger->info('Payment method does not support online refunds for transaction: ' . $transactionId); + return new Response('methodDoesNotSupportRefund', Response::HTTP_BAD_REQUEST); + } if ($refund === null) { return new Response('refundExceedsAmount', Response::HTTP_BAD_REQUEST); @@ -179,7 +190,13 @@ class RefundController extends AbstractController $apiClient = $settings->getApiClient(); $transaction = $apiClient->getTransactionService()->read($settings->getSpaceId(), $transactionId); - $this->refundService->createPartialRefund($transaction, $context, $lineItemId, $refundableAmount); + + try { + $refund = $this->refundService->createPartialRefund($transaction, $context, $lineItemId, $refundableAmount); + } catch (RefundNotSupportedException $exception) { + $this->logger->info('Payment method does not support online refunds for transaction: ' . $transactionId); + return new Response('methodDoesNotSupportRefund', Response::HTTP_BAD_REQUEST); + } return new Response(null, Response::HTTP_NO_CONTENT); } diff --git a/src/Core/Api/Refund/Service/RefundService.php b/src/Core/Api/Refund/Service/RefundService.php index d49540b..ad1b7d0 100644 --- a/src/Core/Api/Refund/Service/RefundService.php +++ b/src/Core/Api/Refund/Service/RefundService.php @@ -17,13 +17,15 @@ use VRPayment\Sdk\{ Model\EntityQueryFilter, Model\EntityQueryFilterType, Model\EntityQuery, + ApiException }; use VRPaymentPayment\Core\{ Api\Refund\Entity\RefundEntity, Api\Transaction\Entity\TransactionEntity, Api\Transaction\Entity\TransactionEntityDefinition, Settings\Service\SettingsService, - Util\Payload\RefundPayload + Util\Payload\RefundPayload, + Util\Exception\RefundNotSupportedException }; /** @@ -103,6 +105,12 @@ class RefundService $this->upsert($refund, $context); return $refund; } + } catch (ApiException $exception) { + $message = $exception->getMessage(); + $this->logger->critical($message); + if ($exception->getCode() === 442 && str_contains($message, 'does not support online refunds')) { + throw new RefundNotSupportedException($message, 0, $exception); + } } catch (\Exception $exception) { $this->logger->critical($exception->getMessage()); } @@ -138,6 +146,12 @@ class RefundService $this->upsert($refund, $context); return $refund; } + } catch (ApiException $exception) { + $message = $exception->getMessage(); + $this->logger->critical($message); + if ($exception->getCode() === 442 && str_contains($message, 'does not support online refunds')) { + throw new RefundNotSupportedException($message, 0, $exception); + } } catch (\Exception $exception) { $this->logger->critical($exception->getMessage()); } @@ -174,6 +188,12 @@ class RefundService $this->upsert($refund, $context); return $refund; } + } catch (ApiException $exception) { + $message = $exception->getMessage(); + $this->logger->critical($message); + if ($exception->getCode() === 442 && str_contains($message, 'does not support online refunds')) { + throw new RefundNotSupportedException($message, 0, $exception); + } } catch (\Exception $exception) { $this->logger->critical($exception->getMessage()); } diff --git a/src/Core/Api/Transaction/Service/TransactionService.php b/src/Core/Api/Transaction/Service/TransactionService.php index 0d52f1c..d1aea07 100644 --- a/src/Core/Api/Transaction/Service/TransactionService.php +++ b/src/Core/Api/Transaction/Service/TransactionService.php @@ -313,8 +313,8 @@ class TransactionService public function upsert( Transaction $transaction, Context $context, - string $paymentMethodId = null, - string $salesChannelId = null + ?string $paymentMethodId = null, + ?string $salesChannelId = null ): void { try { @@ -328,6 +328,13 @@ class TransactionService $orderId = $transactionMetaData[TransactionPayload::VRPAYMENT_METADATA_ORDER_ID]; $orderTransactionId = $transactionMetaData[TransactionPayload::VRPAYMENT_METADATA_ORDER_TRANSACTION_ID]; + if (!$paymentMethodId) { + $criteria = new Criteria([$orderTransactionId]); + $criteria->addAssociation('order'); + $orderTransaction = $this->container->get('order_transaction.repository')->search($criteria, $context)->first(); + $paymentMethodId = $orderTransaction->getPaymentMethodId(); + } + $dataParamValue = json_decode(strval($transaction), true); $brandName = ''; if (isset($dataParamValue['paymentConnectorConfiguration'])) { diff --git a/src/Core/Api/WebHooks/Controller/WebHookController.php b/src/Core/Api/WebHooks/Controller/WebHookController.php index c6e42b2..2f2636b 100644 --- a/src/Core/Api/WebHooks/Controller/WebHookController.php +++ b/src/Core/Api/WebHooks/Controller/WebHookController.php @@ -486,7 +486,7 @@ class WebHookController extends AbstractController { $transaction = $this->settings->getApiClient() ->getTransactionService() ->read($callBackData->getSpaceId(), $callBackData->getEntityId()); - $orderId = $transaction->getMetaData()[TransactionPayload::VRPAYMENT_METADATA_ORDER_ID]; + $orderId = $transaction->getMetaData()[TransactionPayload::VRPAYMENT_METADATA_ORDER_ID] ?? null; if(!empty($orderId) && !$transaction->getParent()) { $this->executeLocked($orderId, $context, function () use ($orderId, $transaction, $context, $callBackData) { $this->transactionService->upsert($transaction, $context); diff --git a/src/Core/Api/WebHooks/Strategy/WebHookRefundStrategy.php b/src/Core/Api/WebHooks/Strategy/WebHookRefundStrategy.php index 1359aea..0a4dce7 100644 --- a/src/Core/Api/WebHooks/Strategy/WebHookRefundStrategy.php +++ b/src/Core/Api/WebHooks/Strategy/WebHookRefundStrategy.php @@ -64,7 +64,7 @@ class WebHookRefundStrategy extends WebHookStrategyBase implements WebhookStrate /** * @inheritDoc */ - public function getOrderIdByTransaction($transaction): string + public function getOrderIdByTransaction($transaction): string|null { /** @var \VRPayment\Sdk\Model\Refund $transaction */ return $transaction->getTransaction() diff --git a/src/Core/Api/WebHooks/Strategy/WebHookTransactionInvoiceStrategy.php b/src/Core/Api/WebHooks/Strategy/WebHookTransactionInvoiceStrategy.php index 9053367..d6924b2 100644 --- a/src/Core/Api/WebHooks/Strategy/WebHookTransactionInvoiceStrategy.php +++ b/src/Core/Api/WebHooks/Strategy/WebHookTransactionInvoiceStrategy.php @@ -63,10 +63,10 @@ class WebHookTransactionInvoiceStrategy extends WebHookStrategyBase implements W /** * @inheritDoc */ - public function getOrderIdByTransaction($transaction): string + public function getOrderIdByTransaction($transactionInvoice): string|null { /** @var \VRPayment\Sdk\Model\TransactionInvoice $transaction */ - return $transaction->getCompletion() + return $transactionInvoice->getCompletion() ->getLineItemVersion() ->getTransaction() ->getMetaData()[TransactionPayload::VRPAYMENT_METADATA_ORDER_ID]; diff --git a/src/Core/Api/WebHooks/Strategy/WebHookTransactionStrategy.php b/src/Core/Api/WebHooks/Strategy/WebHookTransactionStrategy.php index 4c3aa6d..e85a90f 100644 --- a/src/Core/Api/WebHooks/Strategy/WebHookTransactionStrategy.php +++ b/src/Core/Api/WebHooks/Strategy/WebHookTransactionStrategy.php @@ -61,7 +61,7 @@ class WebHookTransactionStrategy extends WebHookStrategyBase implements WebhookS /** * @inheritDoc */ - public function getOrderIdByTransaction(Transaction $transaction): string + public function getOrderIdByTransaction(Transaction $transaction): string|null { /** @var \VRPayment\Sdk\Model\Transaction $transaction */ return $transaction->getMetaData()[TransactionPayload::VRPAYMENT_METADATA_ORDER_ID]; @@ -116,7 +116,7 @@ class WebHookTransactionStrategy extends WebHookStrategyBase implements WebhookS /** @var \Shopware\Core\Checkout\Order\OrderEntity $order */ $transaction = $this->getTransaction($request); $token = $transaction->getToken(); - $orderId = $transaction->getMetaData()[TransactionPayload::VRPAYMENT_METADATA_ORDER_ID]; + $orderId = $transaction->getMetaData()[TransactionPayload::VRPAYMENT_METADATA_ORDER_ID] ?? null; if (!empty($orderId) && !$transaction->getParent()) { $this->executeLocked($orderId, $context, function () use ($orderId, $transaction, $context, $request, $token) { if ($this->allowUpsert($transaction, $orderId, $context)) { diff --git a/src/Core/Api/WebHooks/Strategy/WebhookStrategyActionsInterface.php b/src/Core/Api/WebHooks/Strategy/WebhookStrategyActionsInterface.php index 250db67..9253458 100644 --- a/src/Core/Api/WebHooks/Strategy/WebhookStrategyActionsInterface.php +++ b/src/Core/Api/WebHooks/Strategy/WebhookStrategyActionsInterface.php @@ -57,5 +57,5 @@ interface WebhookStrategyActionsInterface { * @param Transaction|TransactionInvoiceState|Refund|mixed $transaction The transaction object from which the order ID should be extracted. * @return string The order ID as a string. */ - public function getOrderIdByTransaction(Transaction $transaction): string; + public function getOrderIdByTransaction(Transaction $transaction): string|null; } diff --git a/src/Core/Checkout/PaymentHandler/VRPaymentPaymentHandler.php b/src/Core/Checkout/PaymentHandler/VRPaymentPaymentHandler.php index fa8a5bc..8f3a734 100644 --- a/src/Core/Checkout/PaymentHandler/VRPaymentPaymentHandler.php +++ b/src/Core/Checkout/PaymentHandler/VRPaymentPaymentHandler.php @@ -25,7 +25,7 @@ use Shopware\Core\{ Framework\Struct\Struct, Framework\Validation\DataBag\RequestDataBag, System\StateMachine\Aggregation\StateMachineState\StateMachineStateEntity, - System\SalesChannel\Context\SalesChannelContextService, + System\SalesChannel\Context\SalesChannelContextServiceInterface, System\SalesChannel\Context\SalesChannelContextServiceParameters }; use Shopware\Core\Framework\Util\Random; @@ -71,7 +71,7 @@ class VRPaymentPaymentHandler extends AbstractPaymentHandler */ private $orderTransactionStateHandler; - protected SalesChannelContextService $salesChannelContextService; + protected SalesChannelContextServiceInterface $salesChannelContextService; protected EntityRepository $orderTransactionRepository; @@ -84,7 +84,7 @@ class VRPaymentPaymentHandler extends AbstractPaymentHandler CustomCartPersister $cartPersister, PluginTransactionService $pluginTransactionService, OrderTransactionStateHandler $orderTransactionStateHandler, - SalesChannelContextService $salesChannelContextService, + SalesChannelContextServiceInterface $salesChannelContextService, EntityRepository $orderTransactionRepository, ?EntityRepository $subscriptionRepository, ) { diff --git a/src/Core/Util/Analytics/Analytics.php b/src/Core/Util/Analytics/Analytics.php index 4c9e174..f9adc82 100644 --- a/src/Core/Util/Analytics/Analytics.php +++ b/src/Core/Util/Analytics/Analytics.php @@ -26,7 +26,7 @@ class Analytics { self::SHOP_SYSTEM => 'shopware', self::SHOP_SYSTEM_VERSION => '6', self::SHOP_SYSTEM_AND_VERSION => 'shopware-6', - self::PLUGIN_SYSTEM_VERSION => '7.3.1', + self::PLUGIN_SYSTEM_VERSION => '7.3.2', ]; } diff --git a/src/Core/Util/Exception/RefundNotSupportedException.php b/src/Core/Util/Exception/RefundNotSupportedException.php new file mode 100644 index 0000000..ccfd5ef --- /dev/null +++ b/src/Core/Util/Exception/RefundNotSupportedException.php @@ -0,0 +1,8 @@ + { try { + var errorTitle = errorResponse?.response?.data?.errors?.[0]?.title ?? this.$tc('vrpayment-order.refundAction.refundCreateError.errorTitle') + var errorMessage; + switch(errorResponse.response.data) { + case 'methodDoesNotSupportRefund': + errorMessage = this.$tc('vrpayment-order.refundAction.refundCreateError.messagePaymentMethodDoesNotSupportRefund'); + break; + default: + errorMessage = errorResponse.response.data.errors[0].detail; + } this.createNotificationError({ - title: errorResponse.response.data.errors[0].title, - message: errorResponse.response.data.errors[0].detail, + title: errorTitle, + message: errorMessage, autoClose: false }); } catch (e) { diff --git a/src/Resources/app/administration/src/module/vrpayment-order/component/vrpayment-order-action-refund-selected/index.js b/src/Resources/app/administration/src/module/vrpayment-order/component/vrpayment-order-action-refund-selected/index.js index e2862b7..abbdb6c 100644 --- a/src/Resources/app/administration/src/module/vrpayment-order/component/vrpayment-order-action-refund-selected/index.js +++ b/src/Resources/app/administration/src/module/vrpayment-order/component/vrpayment-order-action-refund-selected/index.js @@ -70,9 +70,18 @@ Component.register('vrpayment-order-action-refund-selected', { }); }).catch((errorResponse) => { try { + var errorTitle = errorResponse?.response?.data?.errors?.[0]?.title ?? this.$tc('vrpayment-order.refundAction.refundCreateError.errorTitle') + var errorMessage; + switch(errorResponse.response.data) { + case 'methodDoesNotSupportRefund': + errorMessage = this.$tc('vrpayment-order.refundAction.refundCreateError.messagePaymentMethodDoesNotSupportRefund'); + break; + default: + errorMessage = errorResponse.response.data.errors[0].detail; + } this.createNotificationError({ - title: errorResponse.response.data.errors[0].title, - message: errorResponse.response.data.errors[0].detail, + title: errorTitle, + message: errorMessage, autoClose: false }); } catch (e) { diff --git a/src/Resources/app/administration/src/module/vrpayment-order/component/vrpayment-order-action-refund/index.js b/src/Resources/app/administration/src/module/vrpayment-order/component/vrpayment-order-action-refund/index.js index 3020b70..f389fe6 100644 --- a/src/Resources/app/administration/src/module/vrpayment-order/component/vrpayment-order-action-refund/index.js +++ b/src/Resources/app/administration/src/module/vrpayment-order/component/vrpayment-order-action-refund/index.js @@ -77,6 +77,9 @@ Component.register('vrpayment-order-action-refund', { case 'refundExceedsQuantity': errorMessage = this.$tc('vrpayment-order.refundAction.refundCreateError.messageRefundQuantityExceedsAvailableBalance'); break; + case 'methodDoesNotSupportRefund': + errorMessage = this.$tc('vrpayment-order.refundAction.refundCreateError.messagePaymentMethodDoesNotSupportRefund'); + break; default: errorMessage = errorResponse.response.data.errors[0].detail; } diff --git a/src/Resources/app/administration/src/module/vrpayment-order/page/vrpayment-order-detail/index.html.twig b/src/Resources/app/administration/src/module/vrpayment-order/page/vrpayment-order-detail/index.html.twig index 30d37cc..0dcf431 100644 --- a/src/Resources/app/administration/src/module/vrpayment-order/page/vrpayment-order-detail/index.html.twig +++ b/src/Resources/app/administration/src/module/vrpayment-order/page/vrpayment-order-detail/index.html.twig @@ -98,7 +98,7 @@