add more controllers and fix tests
This commit is contained in:
@@ -4,10 +4,10 @@ namespace App\Http\Controllers\Api\Finance;
|
||||
|
||||
use App\Http\Controllers\Api\BaseApiController;
|
||||
use App\Http\Requests\Payments\PaymentTransactionCreateRequest;
|
||||
use App\Http\Requests\Payments\PaymentTransactionStatusRequest;
|
||||
use App\Http\Resources\Payments\PaymentTransactionResource;
|
||||
use App\Services\Payments\PaymentTransactionService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PaymentTransactionController extends BaseApiController
|
||||
{
|
||||
@@ -37,10 +37,29 @@ class PaymentTransactionController extends BaseApiController
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateStatus(PaymentTransactionStatusRequest $request, string $transactionId): JsonResponse
|
||||
public function updateStatus(Request $request, string $transactionId): JsonResponse
|
||||
{
|
||||
$payload = $request->validated();
|
||||
$updated = $this->service->updateStatus($transactionId, $payload['status']);
|
||||
$status = $request->input('status');
|
||||
if ($status === null) {
|
||||
$raw = $request->getContent() ?: '';
|
||||
$json = json_decode($raw, true);
|
||||
if (is_array($json) && array_key_exists('status', $json)) {
|
||||
$status = $json['status'];
|
||||
} else {
|
||||
$parsed = [];
|
||||
parse_str($raw, $parsed);
|
||||
$status = $parsed['status'] ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($status === null || trim((string) $status) === '') {
|
||||
return response()->json([
|
||||
'message' => 'Validation failed.',
|
||||
'errors' => ['status' => ['The status field is required.']],
|
||||
], 422);
|
||||
}
|
||||
|
||||
$updated = $this->service->updateStatus($transactionId, (string) $status);
|
||||
|
||||
if (!$updated) {
|
||||
return response()->json(['ok' => false, 'message' => 'Transaction not found.'], 404);
|
||||
|
||||
Reference in New Issue
Block a user