Creating Participation refunds
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\ParticipantRefund\Controllers;
|
||||
|
||||
use App\Domains\ParticipantRefund\Actions\CreateRefundDocument\CreateRefundDocumentCommand;
|
||||
use App\Domains\ParticipantRefund\Actions\CreateRefundDocument\CreateRefundDocumentRequest;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class RefundDocumentController extends CommonController
|
||||
{
|
||||
public function __invoke(string $refundToken): Response
|
||||
{
|
||||
$refund = $this->participantRefunds->getByToken($refundToken);
|
||||
|
||||
// Der Beleg enthält die Bankverbindung -- er gehört der Aktionsleitung, nicht dem Token.
|
||||
if ($refund === null || $this->events->getById($refund->event_id) === null) {
|
||||
abort(403, 'Zugriff verweigert.');
|
||||
}
|
||||
|
||||
$documentResponse = new CreateRefundDocumentCommand(new CreateRefundDocumentRequest($refund))->execute();
|
||||
|
||||
if (!$documentResponse->success) {
|
||||
abort(422, $documentResponse->message ?? 'Der Beleg konnte nicht erstellt werden.');
|
||||
}
|
||||
|
||||
return response($documentResponse->pdfContent, 200, [
|
||||
'Content-Type' => 'application/pdf',
|
||||
'Content-Disposition' => 'attachment; filename="' . $documentResponse->filename . '"',
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user