Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paid plugins #3040

Open
wants to merge 29 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8af6f5d
paid
sandesh556 Jul 10, 2024
2714667
Apply fixes from StyleCI
StyleCIBot Jul 10, 2024
d3d746d
paid plugins
sandesh556 Jul 15, 2024
b330648
some more changes
sandesh556 Jul 29, 2024
be5ed8d
Apply fixes from StyleCI
StyleCIBot Jul 29, 2024
7518d42
final development push agora
sandesh556 Jul 30, 2024
fa6446c
Apply fixes from StyleCI
StyleCIBot Jul 30, 2024
2c6d4b4
Plugin compatible for purchase
sandesh556 Jul 31, 2024
a0c0e11
Excpetion removed
sandesh556 Jul 31, 2024
c9adaf0
Apply fixes from StyleCI
StyleCIBot Jul 31, 2024
9ce5189
changes
sandesh556 Aug 8, 2024
14f8d68
Apply fixes from StyleCI
StyleCIBot Aug 8, 2024
d35cc3a
description changes
sandesh556 Aug 9, 2024
932e19f
Apply fixes from StyleCI
StyleCIBot Aug 12, 2024
12b3100
dd removal
sandesh556 Aug 16, 2024
3e3d30b
Apply fixes from StyleCI
StyleCIBot Dec 18, 2024
92c9fdd
tinmcye url changes
sandesh556 Jan 16, 2025
dde6fb8
Fixes
sandesh556 Jan 20, 2025
57b971a
verify false removed
sandesh556 Jan 20, 2025
c8c6a5b
Some more fixes
sandesh556 Jan 29, 2025
81a8cf4
Apply fixes from StyleCI
StyleCIBot Jan 29, 2025
769e3b8
Merge pull request #3228 from ladybirdweb/analysis-DygNGB
bhanu2217 Jan 29, 2025
4147d4b
Some more fixes
sandesh556 Jan 31, 2025
3b7578d
Apply fixes from StyleCI
StyleCIBot Jan 31, 2025
86941bd
Merge pull request #3231 from ladybirdweb/analysis-g6GAA6
bhanu2217 Jan 31, 2025
d58c0f6
Some more fixes
sandesh556 Feb 5, 2025
e7c093b
Some more fixes
sandesh556 Feb 7, 2025
7d88fb5
Apply fixes from StyleCI
StyleCIBot Feb 7, 2025
8769f36
Merge pull request #3240 from ladybirdweb/analysis-rr1wlL
bhanu2217 Feb 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/Http/Controllers/Api/ThirdPartyApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ public function saveProduct(Request $request)
]
);
try {
$product_id = Product::whereRaw('LOWER(`name`) LIKE ? ', strtolower($request->input('productname')))->select('id')->first();
$product_id = Product::whereRaw('LOWER(`name`) LIKE ? ', strtolower($request->input('productname')))
->orWhere('id', $request->input('product_id'))
->select('id')
->first();

if ($product_id) {
$this->product_upload->product_id = $product_id->id;
$this->product_upload->title = $request->input('producttitle');
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/BaseHomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public function updateLatestVersion(Request $request)
$existingVersion = $request->input('version');
}
$cont = new \App\Http\Controllers\License\LicenseController();
$cont->updateInstallationLogs($url, $request->input('version'), $ip);
$cont->updateInstallationLogs($url, $request->input('version'), $ip, $licenseCode);
Subscription::where('order_id', $orderForLicense->first()->id)->update(['version' => $existingVersion, 'version_updated_at' => (string) \Carbon\Carbon::now()]);

return ['status' => 'success', 'message' => 'version-updated-successfully'];
Expand Down
80 changes: 80 additions & 0 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

namespace App\Http\Controllers;

use App\ApiKey;
use App\Http\Controllers\Common\CronController;
use App\Http\Controllers\Order\RenewController;
use App\Http\Requests\ProductRenewalRequest;
use App\Model\Common\Country;
use App\Model\Configure\PluginCompatibleWithProducts;
use App\Model\Configure\ProductPluginGroup;
use App\Model\License\LicenseType;
use App\Model\Order\InstallationDetail;
use App\Model\Order\Order;
use App\Model\Payment\Plan;
Expand All @@ -16,6 +20,7 @@
use App\Model\Product\Subscription;
use App\User;
use Exception;
use GuzzleHttp\Client;
use Illuminate\Http\Request;

class HomeController extends BaseHomeController
Expand Down Expand Up @@ -616,4 +621,79 @@

return response()->json(['group' => $group]);
}

public function getDetailedBillingInfo(Request $request): \Illuminate\Http\JsonResponse
{
$order = $request->input('order');
// Fetch the order details
$user = Order::where('number', $order)->value('client');

$email = User::where('id', $user)->value('email');

if (! $email) {
return response()->json([]);
}

return response()->json([
'billing_client_email' => $email,
]);
}

public function getDetailsForAClient(Request $request)
{
$client = $request->input('client');

$license = $request->input('license');

$product_id = $request->input('product_id');

$user = User::where('email', $client)->value('id');

$licenseType = LicenseType::where('name', 'plugin')->value('id');

$products = Product::where('type', $licenseType)->pluck('id')->toArray();

$productComp = PluginCompatibleWithProducts::where('product_id', $product_id)->pluck('plugin_id')->toArray();

$product = array_intersect($products, $productComp);

$productsLinked = ProductPluginGroup::where('product_id', $product_id)->pluck('plugin_id')->toArray();

$uniqueElements = array_merge(array_diff($product, $productsLinked), array_diff($productsLinked, $product));

$uniqueElements = array_values($uniqueElements);

$licenses = Order::where('client', $user)->whereIn('product', $uniqueElements)
->pluck('serial_key')
->toArray();

$licenses = array_merge([$license], $licenses);

$client = new Client();

$licenseUrl = ApiKey::value('license_api_url');

Check notice on line 674 in app/Http/Controllers/HomeController.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

app/Http/Controllers/HomeController.php#L674

Avoid using static access to class '\App\ApiKey' in method 'getDetailsForAClient'.
$response = $client->get($licenseUrl.'api/pluginLicense', [
'query' => ['license_code' => json_encode($licenses)],
]);

return json_decode($response->getBody()->getContents(), true);
}

public function getProductRelease(Request $request)
{
$product_id = $request->input('product_id');

$version = $request->input('version');

$product_upload = ProductUpload::where('product_id', $product_id)
->where('is_private', 0)
->where('version', $version)
->orderByDesc('version') // Order by version in descending order
->select('version', 'title', 'description', 'dependencies', 'updated_at')
->first(); // Get the first result (latest version)

$product = Product::where('id', $product_id)->select('name', 'description', 'shoping_cart_link', 'product_description')->first();

return ['product' => $product, 'release' => $product_upload];
}
}
25 changes: 23 additions & 2 deletions app/Http/Controllers/License/LicenseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ public function createNewLicene($orderid, $product, $user_id, $licenseExpiry, $u
$productId = $this->searchProductId($sku);
$OauthDetails = $this->oauthAuthorization();
$token = $OauthDetails->access_token;

$addLicense = $this->postCurl($url.'api/admin/license/add', "api_key_secret=$api_key_secret&product_id=$productId&license_code=$serial_key&license_require_domain=1&license_status=1&license_order_number=$orderNo&license_domain=$domain&license_ip=$ip&license_require_domain=$requireDomain&license_limit=6&license_expire_date=$licenseExpiry&license_updates_date=$updatesExpiry&license_support_date=$supportExpiry&license_disable_ip_verification=0&license_limit=1", $token);
} catch (\Exception $ex) {
throw new \Exception('Please configure the valid license details in Apikey settings.');
Expand Down Expand Up @@ -517,6 +518,26 @@ public function licenseRedirect($orderNumber)
return redirect('/orders/'.Order::where('number', $orderNumber)->value('id'));
}

public function syncTheAddonForALicense($product_ids, $license_code, $options = [])
{
$url = $this->url;
$api_key_secret = $this->api_key_secret;

$OauthDetails = $this->oauthAuthorization();
$token = $OauthDetails->access_token;
// Convert arrays to JSON for proper request formatting
$options = json_encode($options);

$postData = http_build_query([
'api_key_secret' => $api_key_secret,
'license_code' => $license_code,
'product_ids' => $product_ids,
'options' => $options,
]);

$this->postCurl($url.'api/admin/license/syncAddonLicense', $postData, $token);
}

public function getInstallationLogsDetails($license_code)
{
$url = $this->url;
Expand All @@ -542,14 +563,14 @@ public function getInstallationLogsDetails($license_code)
return $installation_details;
}

public function updateInstallationLogs($root_url, $version_number, $installation_ip)
public function updateInstallationLogs($root_url, $version_number, $installation_ip, $licenseCode)
{
try {
$url = $this->url;
$api_key_secret = $this->api_key_secret;
$OauthDetails = $this->oauthAuthorization();
$token = $OauthDetails->access_token;
$details = json_decode($this->postCurl($url.'api/admin/updateInstallationLogs', "api_key_secret=$api_key_secret&root_url=$root_url&version_number=$version_number&installation_ip=$installation_ip", $token));
$details = json_decode($this->postCurl($url.'api/admin/updateInstallationLogs', "api_key_secret=$api_key_secret&root_url=$root_url&version_number=$version_number&installation_ip=$installation_ip&license_code=$licenseCode", $token));
} catch (\Exception $ex) {
throw new \Exception('Please configure the valid license details in Apikey settings.');
}
Expand Down
42 changes: 42 additions & 0 deletions app/Http/Controllers/Order/BaseOrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

namespace App\Http\Controllers\Order;

use App\Http\Controllers\License\LicenseController;
use App\Http\Controllers\License\LicensePermissionsController;
use App\Model\Common\StatusSetting;
use App\Model\Common\TemplateType;
use App\Model\Configure\ProductPluginGroup;
use App\Model\Order\Order;
use App\Model\Payment\Plan;
use App\Model\Product\Product;
Expand Down Expand Up @@ -121,6 +123,12 @@ public function getIfItemPresent($item, $invoiceid, $user_id, $order_status, $ad
$this->addOrderInvoiceRelation($invoiceid, $order->id);
if ($plan_id != 0) {
$this->addSubscription($order->id, $plan_id, $version, $product, $serial_key, $admin);

$addOnIds = implode(',', $this->product->find($product)->productPluginGroupsAsProduct->pluck('plugin_id')->toArray());

$options = $this->formatConfigurableOptions($product);

(new LicenseController())->syncTheAddonForALicense($addOnIds, $serial_key, $options);
}

if (emailSendingStatus()) {
Expand Down Expand Up @@ -412,4 +420,38 @@ public function downloadUrl($userid, $orderid)

return $url;
}

public function formatConfigurableOptions($productId)
{
// Retrieve the product ID and related plugin IDs in one query
$productIds = ProductPluginGroup::where('product_id', $productId)
->pluck('plugin_id')
->prepend($productId)
->toArray();

// Fetch all products with related configurations in one query
$products = $this->product->with('configOptions.configOptionValues')
->whereIn('id', $productIds)
->get();

// Check if any products were found
if ($products->isEmpty()) {
return [];
}

// Format the configuration options
return $products->flatMap(function ($product) {
return $product->configOptions->flatMap(function ($configOption) use ($product) {
return $configOption->configOptionValues->map(function ($configOptionValue) use ($product, $configOption) {
return [
'product_id' => $product->id,
'option_group' => $configOption->configGroup->config_group_name,
'option_name' => $configOption->config_option_name,
'key' => $configOptionValue->key,
'value' => $configOptionValue->value,
];
});
});
});
}
}
2 changes: 2 additions & 0 deletions app/Http/Controllers/Product/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ public function store(Request $request)
'name' => 'required|unique:products,name',
'type' => 'required',
'description' => 'required',
'product_description' => 'required',
'image' => 'sometimes|mimes:jpeg,png,jpg|max:2048',
'product_sku' => 'required|unique:products,product_sku',
'group' => 'required',
Expand Down Expand Up @@ -439,6 +440,7 @@ public function update($id, Request $request)
'name' => 'required',
'type' => 'required',
'description' => 'required',
'product_description' => 'required',
'image' => 'sometimes|mimes:jpeg,png,jpg|max:2048',
'product_sku' => 'required',
'group' => 'required',
Expand Down
21 changes: 21 additions & 0 deletions app/Model/Configure/ConfigGroup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace App\Model\Configure;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ConfigGroup extends Model

Check notice on line 8 in app/Model/Configure/ConfigGroup.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

app/Model/Configure/ConfigGroup.php#L8

Missing doc comment for class ConfigGroup
{
use HasFactory;

protected $table = 'config_group';

protected $guarded = [];

// Define the relationship with ConfigOption
public function configOptions()

Check notice on line 17 in app/Model/Configure/ConfigGroup.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

app/Model/Configure/ConfigGroup.php#L17

You must use "/**" style comments for a function comment
{
return $this->hasMany(ConfigOption::class, 'group_id');
}
}
40 changes: 40 additions & 0 deletions app/Model/Configure/ConfigOption.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace App\Model\Configure;

use App\Model\Payment\Plan;
use App\Model\Product\Product;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ConfigOption extends Model
{
use HasFactory;

protected $table = 'config_option';

protected $guarded = [];

// Define the relationship with ConfigGroup
public function configGroup()
{
return $this->belongsTo(ConfigGroup::class, 'group_id');
}

// Define the relationship with Plan
public function plan()

Check notice on line 25 in app/Model/Configure/ConfigOption.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

app/Model/Configure/ConfigOption.php#L25

You must use "/**" style comments for a function comment
{
return $this->belongsTo(Plan::class);
}

// Define the relationship with ConfigOptionValue
public function configOptionValues()
{
return $this->hasMany(ConfigOptionValue::class, 'option_id');
}

public function product()
{
return $this->belongsTo(Product::class);
}
}
20 changes: 20 additions & 0 deletions app/Model/Configure/ConfigOptionValue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace App\Model\Configure;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ConfigOptionValue extends Model

Check notice on line 8 in app/Model/Configure/ConfigOptionValue.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

app/Model/Configure/ConfigOptionValue.php#L8

Missing doc comment for class ConfigOptionValue
{
use HasFactory;

protected $table = 'config_option_values';
protected $guarded = [];

// Define the relationship with ConfigOption
public function configOption()
{
return $this->belongsTo(ConfigOption::class, 'option_id');
}
}
28 changes: 28 additions & 0 deletions app/Model/Configure/PluginCompatibleWithProducts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

Check notice on line 2 in app/Model/Configure/PluginCompatibleWithProducts.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

app/Model/Configure/PluginCompatibleWithProducts.php#L2

Missing file doc comment
namespace App\Model\Configure;

use App\Model\Product\Product;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class PluginCompatibleWithProducts extends Model
{
use HasFactory;

protected $table = 'plugin_compatible_with_products';

protected $guarded = [];

// Define the relationship with Product (as product)
public function productComp()

Check notice on line 18 in app/Model/Configure/PluginCompatibleWithProducts.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

app/Model/Configure/PluginCompatibleWithProducts.php#L18

You must use "/**" style comments for a function comment
{
return $this->belongsTo(Product::class, 'product_id');
}

// Define the relationship with Product (as plugin)
public function pluginComp()

Check notice on line 24 in app/Model/Configure/PluginCompatibleWithProducts.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

app/Model/Configure/PluginCompatibleWithProducts.php#L24

You must use "/**" style comments for a function comment
{
return $this->belongsTo(Product::class, 'plugin_id');
}
}
28 changes: 28 additions & 0 deletions app/Model/Configure/ProductPluginGroup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Model\Configure;

use App\Model\Product\Product;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ProductPluginGroup extends Model

Check notice on line 9 in app/Model/Configure/ProductPluginGroup.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

app/Model/Configure/ProductPluginGroup.php#L9

Missing doc comment for class ProductPluginGroup
{
use HasFactory;

protected $table = 'product_plugin_group';

protected $guarded = [];

// Define the relationship with Product (as product)
public function product()
{
return $this->belongsTo(Product::class, 'product_id');
}

// Define the relationship with Product (as plugin)
public function plugin()

Check notice on line 24 in app/Model/Configure/ProductPluginGroup.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

app/Model/Configure/ProductPluginGroup.php#L24

You must use "/**" style comments for a function comment
{
return $this->belongsTo(Product::class, 'plugin_id');
}
}
Loading