From 442463ff9e8e2e85e1b8a499a7830e4a18328efa Mon Sep 17 00:00:00 2001 From: Vitalij Mik Date: Fri, 26 Apr 2024 15:46:38 +0200 Subject: [PATCH] NTR: fix status --- .../RefundManager/Builder/RefundDataBuilder.php | 8 ++++++++ src/Controller/Api/Order/ShippingControllerBase.php | 8 ++++---- src/Controller/Storefront/Webhook/NotificationFacade.php | 1 + .../component/buy-widget/buy-widget-form.html.twig | 2 +- src/Service/MollieApi/Builder/MollieLineItemBuilder.php | 4 ++-- src/Service/TransactionService.php | 1 + .../MollieApi/Builder/MollieLineItemBuilderTest.php | 4 ++-- 7 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/Components/RefundManager/Builder/RefundDataBuilder.php b/src/Components/RefundManager/Builder/RefundDataBuilder.php index e7e9f362a..fad077cef 100644 --- a/src/Components/RefundManager/Builder/RefundDataBuilder.php +++ b/src/Components/RefundManager/Builder/RefundDataBuilder.php @@ -331,10 +331,18 @@ private function getRefundedQuantity(string $mollieLineItemId, \Mollie\Api\Resou $meta = $refund['metadata']; + // refund initiated within mollie dashboard, so no metadata is set + if ($meta instanceof \stdClass) { + continue; + } + if (is_string($meta)) { + /** @var \stdClass $meta */ $meta = json_decode($meta, true); } + + $metadata = RefundMetadata::fromArray($meta); # if we do have a FULL item refund then diff --git a/src/Controller/Api/Order/ShippingControllerBase.php b/src/Controller/Api/Order/ShippingControllerBase.php index 91cc3dafd..65e120c6e 100644 --- a/src/Controller/Api/Order/ShippingControllerBase.php +++ b/src/Controller/Api/Order/ShippingControllerBase.php @@ -333,10 +333,10 @@ public function shipItemOperational(Request $request, Context $context): JsonRes $orderNumber = (string)$jsonData['orderNumber']; $itemProductNumber = (string)$jsonData['productNumber']; - $quantity = (int)$jsonData['quantity']; - $trackingCarrier = (string)$jsonData['trackingCarrier']; - $trackingCode = (string)$jsonData['trackingCode']; - $trackingUrl = (string)$jsonData['trackingUrl']; + $quantity = (int)($jsonData['quantity'] ?? 0); + $trackingCarrier = (string)($jsonData['trackingCarrier'] ?? ''); + $trackingCode = (string)($jsonData['trackingCode'] ?? ''); + $trackingUrl = (string)($jsonData['trackingUrl'] ?? ''); if ($orderNumber === '') { throw new \InvalidArgumentException('Missing Argument for Order Number!'); diff --git a/src/Controller/Storefront/Webhook/NotificationFacade.php b/src/Controller/Storefront/Webhook/NotificationFacade.php index 0bfadd8b9..0f221fbc1 100644 --- a/src/Controller/Storefront/Webhook/NotificationFacade.php +++ b/src/Controller/Storefront/Webhook/NotificationFacade.php @@ -295,6 +295,7 @@ private function getTransaction(string $transactionId, Context $context): ?Order $criteria->addAssociation('order.lineItems'); $criteria->addAssociation('order.currency'); $criteria->addAssociation('order.transactions'); + $criteria->addAssociation('order.stateMachineState'); $criteria->addAssociation('paymentMethod'); return $this->repoOrderTransactions->search($criteria, $context)->first(); diff --git a/src/Resources/views/storefront/component/buy-widget/buy-widget-form.html.twig b/src/Resources/views/storefront/component/buy-widget/buy-widget-form.html.twig index e7d40411e..d0822a51e 100644 --- a/src/Resources/views/storefront/component/buy-widget/buy-widget-form.html.twig +++ b/src/Resources/views/storefront/component/buy-widget/buy-widget-form.html.twig @@ -1,7 +1,7 @@ {% sw_extends '@Storefront/storefront/component/buy-widget/buy-widget-form.html.twig' %} {% block buy_widget_buy_button %} - + {% if mollie_subscriptions_enabled and product.customFields.mollie_payments_product_subscription_enabled %}