Add PayPal checkout provider

This commit is contained in:
Codex Agent
2026-02-04 12:18:14 +01:00
parent 56a39d0535
commit fc5dfb272c
33 changed files with 1586 additions and 571 deletions

View File

@@ -0,0 +1,56 @@
<?php
namespace App\Http\Requests\PayPal;
use App\Models\CheckoutSession;
use Illuminate\Foundation\Http\FormRequest;
class PayPalCaptureRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
$user = $this->user();
if (! $user) {
return false;
}
$sessionId = $this->input('checkout_session_id');
if (! is_string($sessionId) || $sessionId === '') {
return false;
}
$session = CheckoutSession::find($sessionId);
if (! $session) {
return false;
}
return (int) $session->user_id === (int) $user->id;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'checkout_session_id' => ['required', 'uuid', 'exists:checkout_sessions,id'],
'order_id' => ['required', 'string'],
];
}
public function messages(): array
{
return [
'checkout_session_id.required' => 'Checkout-Session fehlt.',
'order_id.required' => 'Order ID fehlt.',
];
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace App\Http\Requests\PayPal;
use Illuminate\Foundation\Http\FormRequest;
class PayPalCheckoutRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return (bool) $this->user();
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'package_id' => ['required', 'exists:packages,id'],
'return_url' => ['nullable', 'url'],
'cancel_url' => ['nullable', 'url'],
'coupon_code' => ['nullable', 'string', 'max:64'],
'accepted_terms' => ['required', 'boolean', 'accepted'],
'locale' => ['nullable', 'string', 'max:10'],
];
}
public function messages(): array
{
return [
'package_id.exists' => 'Das ausgewählte Paket ist ungültig.',
'accepted_terms.accepted' => 'Bitte akzeptiere die Nutzungsbedingungen.',
];
}
}