diff --git a/src/Jobs/RenewRecursiveProductUser.php b/src/Jobs/RenewRecursiveProductUser.php index e26c4b2..54860e1 100644 --- a/src/Jobs/RenewRecursiveProductUser.php +++ b/src/Jobs/RenewRecursiveProductUser.php @@ -59,7 +59,7 @@ public function handle(OrderServiceContract $orderService): void $paymentProcessor = $newOrder->process(); $parameters = [ - 'return_url' => config(), + 'return_url' => url('/'), 'email' => $user->email, 'type' => $product->type, 'gateway' => $prevPayment->driver, diff --git a/src/Services/ProductService.php b/src/Services/ProductService.php index 77a38da..c5f9daa 100644 --- a/src/Services/ProductService.php +++ b/src/Services/ProductService.php @@ -435,11 +435,13 @@ public function attachProductToUser(Product $product, User $user, int $quantity $productUserPivot = ProductUser::query()->firstOrCreate(['user_id' => $user->getKey(), 'product_id' => $product->getKey()], ['quantity' => $quantity]); - if (!$productUserPivot->wasRecentlyCreated && !is_null($product->limit_per_user)) { - if ($product->limit_per_user < ($productUserPivot->quantity + $quantity)) { - $quantity = $product->limit_per_user - $productUserPivot->quantity; + if (!$productUserPivot->wasRecentlyCreated) { + if (!is_null($product->limit_per_user)) { + if ($product->limit_per_user < ($productUserPivot->quantity + $quantity)) { + $quantity = $product->limit_per_user - $productUserPivot->quantity; + } + $productUserPivot->quantity += $quantity; } - $productUserPivot->quantity += $quantity; if (ProductType::isSubscriptionType($product->type)) { $productUserPivot->end_date = PeriodEnum::calculatePeriod($productUserPivot->end_date, $product->subscription_period, $product->subscription_duration);