Creating Participation refunds
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?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'),
|
||||
);
|
||||
|
||||
$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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user