40 lines
1.5 KiB
PHP
40 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Domains\ParticipantRefund\Controllers;
|
|
|
|
use App\Domains\ParticipantRefund\Actions\AcceptRefund\AcceptRefundCommand;
|
|
use App\Domains\ParticipantRefund\Actions\AcceptRefund\AcceptRefundRequest;
|
|
use App\Scopes\CommonController;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
/**
|
|
* Öffentlich erreichbar -- der Token aus der Mail ist die Autorisierung.
|
|
*/
|
|
class AcceptRefundController extends CommonController
|
|
{
|
|
public function __invoke(string $refundToken, Request $request): JsonResponse
|
|
{
|
|
$refund = $this->participantRefunds->getByToken($refundToken);
|
|
|
|
$acceptRequest = new AcceptRefundRequest(
|
|
refund: $refund,
|
|
accountOwner: (string) $request->input('accountOwner'),
|
|
accountIban: (string) $request->input('accountIban'),
|
|
declarationAccepted: $request->boolean('declarationAccepted'),
|
|
donation: $request->boolean('donation'),
|
|
accountDeclarationAccepted: $request->boolean('accountDeclarationAccepted'),
|
|
);
|
|
|
|
$response = new AcceptRefundCommand($acceptRequest)->execute();
|
|
|
|
// Immer Status 200: der HttpClient des Frontends verwirft Antworten mit Fehlerstatus, die
|
|
// Feldfehler kämen dort nie an (siehe resources/js/components/HttpClient.js).
|
|
return response()->json([
|
|
'status' => $response->success ? 'success' : 'error',
|
|
'message' => $response->message,
|
|
'error_types' => $response->errorTypes,
|
|
]);
|
|
}
|
|
}
|