Moved bank transfer logic to special module
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\EventPaymentModules\ProvidesGiroCode;
|
||||
use App\Models\EventParticipant;
|
||||
use App\Providers\GiroCodeProvider;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class GiroCodeGetController {
|
||||
@@ -14,18 +14,16 @@ class GiroCodeGetController {
|
||||
return response()->json(['message' => 'Participant not found'], 404);
|
||||
}
|
||||
|
||||
$amount = $participant->amount;
|
||||
$amount->subtractAmount($participant->amount_paid);
|
||||
// Die GiroCode-Erzeugung gehört zum Zahlungsmodul; ohne diese Fähigkeit (z.B. Barzahlung) -> 404.
|
||||
$module = $participant->paymentModule();
|
||||
$girocode = $module instanceof ProvidesGiroCode
|
||||
? $module->giroCode($participant, $participant->paymentConfiguration())
|
||||
: null;
|
||||
|
||||
$girocodeProvider = new GiroCodeProvider(
|
||||
$participant->event()->first()->account_owner,
|
||||
$participant->event()->first()->account_iban,
|
||||
$participant->amount->getAmount(),
|
||||
$participant->payment_purpose
|
||||
);
|
||||
if ($girocode === null) {
|
||||
return response()->json(['message' => 'No giro code for this payment method'], 404);
|
||||
}
|
||||
|
||||
return response($girocodeProvider->create(), 200,
|
||||
['Content-Type' => 'image/png']
|
||||
);
|
||||
return response($girocode, 200, ['Content-Type' => 'image/png']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user