feat: add bylaw management features including documents, legal authorities, subject categories, and nodes
This commit is contained in:
@@ -30,6 +30,7 @@ class SubscribePlanController extends Controller
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $q->id,
|
||||
'name' => $q->name,
|
||||
@@ -37,7 +38,7 @@ class SubscribePlanController extends Controller
|
||||
'expired_day' => $q->expired_day,
|
||||
'is_free' => $q->is_free == 1 ? true : false,
|
||||
'type' => $q->type,
|
||||
'transaction' => $q->transaction
|
||||
'transaction' => $q->transaction,
|
||||
|
||||
];
|
||||
})->filter(function ($q) {
|
||||
@@ -60,7 +61,7 @@ class SubscribePlanController extends Controller
|
||||
->where('expired_at', '>', now())
|
||||
->first();
|
||||
|
||||
if ($activeSubscription && !$activeSubscription?->subscribe?->is_free && !$subscribePlan->is_free) {
|
||||
if ($activeSubscription && ! $activeSubscription?->subscribe?->is_free && ! $subscribePlan->is_free) {
|
||||
return $this->failed(null, ['title' => 'Subscribe Plan', 'message' => 'You already have an active subscription. Please wait until it expires.']);
|
||||
}
|
||||
|
||||
@@ -102,7 +103,8 @@ class SubscribePlanController extends Controller
|
||||
|
||||
return $this->success(['url' => $payment]);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Payment initiation failed: ' . $e->getMessage());
|
||||
Log::error('Payment initiation failed: '.$e->getMessage());
|
||||
|
||||
return $this->failed(null, 'درگاه پرداخت در دسترس نیست');
|
||||
}
|
||||
}
|
||||
@@ -112,7 +114,7 @@ class SubscribePlanController extends Controller
|
||||
$request->validate([
|
||||
'subscribe_plan_id' => 'required|exists:subscribe_plans,id',
|
||||
'subscription_id' => 'nullable',
|
||||
'purchase_token' => 'nullable'
|
||||
'purchase_token' => 'nullable',
|
||||
]);
|
||||
|
||||
$subscribePlan = SubscribePlan::findOrFail($request->subscribe_plan_id);
|
||||
@@ -139,7 +141,7 @@ class SubscribePlanController extends Controller
|
||||
$user->userSubscribers()->create([
|
||||
'subscribe_plan_id' => $subscribePlan->id,
|
||||
'expired_at' => $expiredAt,
|
||||
'is_free' => true
|
||||
'is_free' => true,
|
||||
]);
|
||||
|
||||
return $this->success(null, 'Subscribe Plan', 'Free Subscribe Plan Successfully Activated');
|
||||
@@ -148,14 +150,14 @@ class SubscribePlanController extends Controller
|
||||
$subscription_id = $request->input('subscription_id');
|
||||
$purchase_token = $request->input('purchase_token');
|
||||
|
||||
if (!$subscription_id || !$purchase_token) {
|
||||
if (! $subscription_id || ! $purchase_token) {
|
||||
return $this->failed(null, ['title' => 'Subscribe Plan', 'message' => 'Invalid subscription details.']);
|
||||
}
|
||||
|
||||
try {
|
||||
$bazaarExpiredAt = $this->marketVerifier->verifyBazaarSubscription($subscription_id, $purchase_token);
|
||||
|
||||
if (!$bazaarExpiredAt) {
|
||||
if (! $bazaarExpiredAt) {
|
||||
return $this->failed(null, ['title' => 'Subscribe Plan', 'message' => 'Invalid or expired subscription.']);
|
||||
}
|
||||
|
||||
@@ -172,12 +174,13 @@ class SubscribePlanController extends Controller
|
||||
'purchase_token' => $purchase_token,
|
||||
'market_provider' => 'bazaar',
|
||||
'last_verified_at' => now(),
|
||||
'is_free' => false
|
||||
'is_free' => false,
|
||||
]);
|
||||
|
||||
return $this->success(null, 'Subscribe Plan', 'Subscription successfully activated.');
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Error in subscription', ['Error' => $e->getMessage()]);
|
||||
|
||||
return $this->failed(null, ['title' => 'Subscribe Plan', 'message' => 'Failed to verify subscription.']);
|
||||
}
|
||||
}
|
||||
@@ -207,7 +210,7 @@ class SubscribePlanController extends Controller
|
||||
try {
|
||||
$purchase = $this->marketVerifier->verifyMyketProduct($request->sku_id, $token);
|
||||
|
||||
if (!$purchase) {
|
||||
if (! $purchase) {
|
||||
return $this->failed(null, ['title' => 'Subscribe Plan', 'message' => 'Invalid or failed Myket purchase.']);
|
||||
}
|
||||
|
||||
@@ -306,16 +309,16 @@ class SubscribePlanController extends Controller
|
||||
return $this->success(null, 'Subscribe Plan', 'No Subscribe Plan');
|
||||
}
|
||||
|
||||
|
||||
private function send($url, $api, $amount, $redirect, $factorId, $name, $email, $description)
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, "api=$api&amount=$amount&redirect=$redirect&factorId=$factorId&name=$name&email=$email&description=$description");
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$res = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
@@ -324,10 +327,11 @@ class SubscribePlanController extends Controller
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, "api=$api&id_get=$id_get&trans_id=$trans_id&json=1");
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$res = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user