feat(api): add AI text-to-deck generation, wallet deposit structure, and profile/notification endpoints
Fills the gaps between the admin panel screens and the backend: a full free-text + slide-count + language -> AI-generated presentation flow with new slide-cloning logic in TemplateFillService, a "my presentations" list endpoint, a swappable payment-gateway structure for wallet top-ups (fake driver for now), and avatar upload / public-profile toggle / account deletion / password change / notification preference endpoints. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
89
app/Http/Controllers/Api/WalletDepositController.php
Normal file
89
app/Http/Controllers/Api/WalletDepositController.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Api\InitiateDepositRequest;
|
||||
use App\Http\Resources\WalletDepositResource;
|
||||
use App\Models\WalletDeposit;
|
||||
use App\Services\WalletDepositService;
|
||||
use App\Traits\ApiResponse;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use OpenApi\Attributes as OA;
|
||||
|
||||
class WalletDepositController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
public function __construct(private readonly WalletDepositService $walletDepositService) {}
|
||||
|
||||
#[OA\Post(
|
||||
path: '/wallet/deposits',
|
||||
description: 'Initiate a wallet top-up and get a payment redirect URL',
|
||||
summary: 'Initiate wallet deposit',
|
||||
security: [['sanctum' => []]],
|
||||
tags: ['Wallet'],
|
||||
requestBody: new OA\RequestBody(
|
||||
required: true,
|
||||
content: new OA\JsonContent(
|
||||
required: ['amount'],
|
||||
properties: [
|
||||
new OA\Property(property: 'amount', type: 'integer', example: 500000),
|
||||
]
|
||||
)
|
||||
),
|
||||
responses: [
|
||||
new OA\Response(
|
||||
response: 201,
|
||||
description: 'Deposit initiated successfully',
|
||||
content: new OA\JsonContent(
|
||||
properties: [
|
||||
new OA\Property(property: 'message', type: 'string', example: 'درخواست شارژ کیف پول ثبت شد.'),
|
||||
new OA\Property(
|
||||
property: 'data',
|
||||
properties: [
|
||||
new OA\Property(property: 'deposit', ref: '#/components/schemas/WalletDeposit'),
|
||||
new OA\Property(property: 'payment_url', type: 'string'),
|
||||
],
|
||||
type: 'object'
|
||||
),
|
||||
]
|
||||
)
|
||||
),
|
||||
new OA\Response(response: 401, description: 'Unauthenticated'),
|
||||
new OA\Response(response: 422, description: 'Validation error'),
|
||||
]
|
||||
)]
|
||||
public function store(InitiateDepositRequest $request): JsonResponse
|
||||
{
|
||||
$result = $this->walletDepositService->initiate($request->user(), $request->validated('amount'));
|
||||
|
||||
return $this->success('درخواست شارژ کیف پول ثبت شد.', [
|
||||
'deposit' => new WalletDepositResource($result['deposit']),
|
||||
'payment_url' => $result['payment_url'],
|
||||
], 201);
|
||||
}
|
||||
|
||||
#[OA\Get(
|
||||
path: '/wallet/deposits/{deposit}/callback',
|
||||
description: 'Public callback the payment gateway redirects to after a payment attempt',
|
||||
summary: 'Wallet deposit callback',
|
||||
tags: ['Wallet'],
|
||||
parameters: [
|
||||
new OA\Parameter(name: 'deposit', description: 'Deposit id', in: 'path', required: true, schema: new OA\Schema(type: 'integer')),
|
||||
],
|
||||
responses: [
|
||||
new OA\Response(response: 302, description: 'Redirects to the frontend wallet page with a status query param'),
|
||||
]
|
||||
)]
|
||||
public function callback(WalletDeposit $deposit, Request $request): RedirectResponse
|
||||
{
|
||||
$success = $this->walletDepositService->handleCallback($deposit, $request->query());
|
||||
|
||||
return redirect()->away(
|
||||
rtrim((string) config('app.frontend_url'), '/').'/wallet?status='.($success ? 'success' : 'failed')
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user