diff --git a/controllers/front/ajax.php b/controllers/front/ajax.php index cc93f30a7..42a85cd38 100644 --- a/controllers/front/ajax.php +++ b/controllers/front/ajax.php @@ -193,7 +193,7 @@ private function validateProduct(): void $cartValidation->validate((int) $product['id_product_attribute']); } catch (SubscriptionProductValidationException $e) { $productCanBeAdded = false; - $message = $this->module->l('Subscription product cannot be added if you have other products in your cart', self::FILE_NAME); + $message = $this->module->l('Please note: Only one subscription product can be added to the cart at a time.', self::FILE_NAME); } $this->ajaxRender( diff --git a/controllers/front/subscriptionWebhook.php b/controllers/front/subscriptionWebhook.php index e01c99c98..0fe91601f 100644 --- a/controllers/front/subscriptionWebhook.php +++ b/controllers/front/subscriptionWebhook.php @@ -64,7 +64,7 @@ protected function executeWebhook() try { $recurringOrderHandler->handle($transactionId); - } catch (Exception $exception) { + } catch (\Throwable $exception) { $errorHandler->handle($exception, null, false); $this->respond('failed', HttpStatusCode::HTTP_BAD_REQUEST); diff --git a/controllers/front/webhook.php b/controllers/front/webhook.php index 6b2e86d01..699298883 100644 --- a/controllers/front/webhook.php +++ b/controllers/front/webhook.php @@ -14,7 +14,6 @@ use Mollie\Config\Config; use Mollie\Controller\AbstractMollieController; use Mollie\Errors\Http\HttpStatusCode; -use Mollie\Exception\TransactionException; use Mollie\Handler\ErrorHandler\ErrorHandler; use Mollie\Service\TransactionService; use Mollie\Utility\TransactionUtility; @@ -73,6 +72,9 @@ protected function executeWebhook() /** @var TransactionService $transactionService */ $transactionService = $this->module->getService(TransactionService::class); + /** @var ErrorHandler $errorHandler */ + $errorHandler = $this->module->getService(ErrorHandler::class); + $transactionId = Tools::getValue('id'); if (!$transactionId) { $this->respond('failed', HttpStatusCode::HTTP_UNPROCESSABLE_ENTITY, 'Missing transaction id'); @@ -95,9 +97,7 @@ protected function executeWebhook() $cartId = $metaData->cart_id ?? 0; $this->setContext($cartId); $payment = $transactionService->processTransaction($transaction); - } catch (TransactionException $e) { - /** @var ErrorHandler $errorHandler */ - $errorHandler = $this->module->getService(ErrorHandler::class); + } catch (\Throwable $e) { $errorHandler->handle($e, $e->getCode(), false); $this->respond('failed', $e->getCode(), $e->getMessage()); } diff --git a/subscription/Factory/CreateSubscriptionDataFactory.php b/subscription/Factory/CreateSubscriptionDataFactory.php index 7dd1b8d78..16aea2474 100644 --- a/subscription/Factory/CreateSubscriptionDataFactory.php +++ b/subscription/Factory/CreateSubscriptionDataFactory.php @@ -92,8 +92,9 @@ public function build(Order $order): SubscriptionDataDTO $currency = $this->currencyAdapter->getById((int) $order->id_currency); $description = $this->subscriptionDescription->getSubscriptionDescription($order); - // TODO if we decide to include shipping, add it here (new cart instance is needed) - + /** + * NOTE: we will only send product price as total for subscriptions + */ $orderAmount = new Amount((float) $subscriptionProduct['total_price_tax_incl'], $currency->iso_code); $subscriptionData = new SubscriptionDataDTO( $molCustomer->customer_id, diff --git a/subscription/Handler/RecurringOrderHandler.php b/subscription/Handler/RecurringOrderHandler.php index 6e8a268ee..7d4ac50da 100644 --- a/subscription/Handler/RecurringOrderHandler.php +++ b/subscription/Handler/RecurringOrderHandler.php @@ -184,10 +184,6 @@ private function createSubscription(Payment $transaction, MolRecurringOrder $rec $specificPrice = $this->createSpecificPrice($recurringOrderProduct, $recurringOrder); - // TODO set delivery option from back office settings - $newCart->setDeliveryOption([(int) $recurringOrder->id_address_delivery => sprintf('%d,', 8)]); - $newCart->update(); - $this->mollie->validateOrder( (int) $newCart->id, (int) $this->configuration->get(Config::MOLLIE_STATUS_AWAITING), diff --git a/subscription/Validator/CanProductBeAddedToCartValidator.php b/subscription/Validator/CanProductBeAddedToCartValidator.php index 94382bc21..1060d0139 100644 --- a/subscription/Validator/CanProductBeAddedToCartValidator.php +++ b/subscription/Validator/CanProductBeAddedToCartValidator.php @@ -32,8 +32,7 @@ public function __construct( /** * Validates if product can be added to the cart. - * Only 1 subscription product can be in cart and no other products can be added if there are subscription products - * For now we only allow one subscription product with any quantities, later might need to add logic to allow more products + * Only 1 subscription product can be to the cart * * @param int $productAttributeId * diff --git a/subscription/Validator/SubscriptionOrderValidator.php b/subscription/Validator/SubscriptionOrderValidator.php index 7adb56572..d6948f6aa 100644 --- a/subscription/Validator/SubscriptionOrderValidator.php +++ b/subscription/Validator/SubscriptionOrderValidator.php @@ -16,7 +16,7 @@ public function __construct(SubscriptionProductValidator $subscriptionProduct) $this->subscriptionProduct = $subscriptionProduct; } - /** Returns true if cart has subscription products */ + /** Returns true if cart has subscription product */ public function validate(Cart $cart): bool { $products = $cart->getProducts();