PaymentTransferRequest.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace App\Http\Requests;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. class PaymentTransferRequest extends FormRequest
  5. {
  6. public function authorize(): bool
  7. {
  8. return true;
  9. }
  10. public function rules(): array
  11. {
  12. $rules = [
  13. 'payment_id' => ['sometimes', 'integer', 'exists:payments,id'],
  14. 'provider_id' => ['sometimes', 'integer', 'exists:providers,id'],
  15. 'gateway_provider' => ['sometimes', 'string', 'max:255'],
  16. 'gateway_entity_reference' => ['nullable', 'string', 'max:255'],
  17. 'gateway_entity_label' => ['nullable', 'string', 'max:255'],
  18. 'gateway_operation_reference' => ['nullable', 'string', 'max:255'],
  19. 'gateway_operation_label' => ['nullable', 'string', 'max:255'],
  20. 'gateway_parent_reference' => ['nullable', 'string', 'max:255'],
  21. 'gateway_parent_label' => ['nullable', 'string', 'max:255'],
  22. 'gateway_transfer_target_reference' => ['nullable', 'string', 'max:255'],
  23. 'gateway_transfer_target_label' => ['nullable', 'string', 'max:255'],
  24. 'status' => ['sometimes', 'in:pending,processing,transferred,failed,cancelled'],
  25. 'gross_amount' => ['sometimes', 'numeric', 'min:0'],
  26. 'gateway_fee_amount' => ['sometimes', 'numeric', 'min:0'],
  27. 'net_amount' => ['sometimes', 'numeric', 'min:0'],
  28. 'transferred_at' => ['nullable', 'date'],
  29. 'failed_at' => ['nullable', 'date'],
  30. 'failure_code' => ['nullable', 'string', 'max:255'],
  31. 'failure_message' => ['nullable', 'string'],
  32. 'gateway_payload' => ['nullable', 'array'],
  33. 'metadata' => ['nullable', 'array'],
  34. ];
  35. if ($this->isMethod('POST')) {
  36. $rules['payment_id'] = ['required', 'integer', 'exists:payments,id'];
  37. $rules['provider_id'] = ['required', 'integer', 'exists:providers,id'];
  38. $rules['gross_amount'] = ['required', 'numeric', 'min:0'];
  39. $rules['net_amount'] = ['required', 'numeric', 'min:0'];
  40. }
  41. return $rules;
  42. }
  43. }