diff --git a/app/Http/Controllers/ClientPortal/PaymentMethodController.php b/app/Http/Controllers/ClientPortal/PaymentMethodController.php index 150a323054..f7878e767f 100644 --- a/app/Http/Controllers/ClientPortal/PaymentMethodController.php +++ b/app/Http/Controllers/ClientPortal/PaymentMethodController.php @@ -14,7 +14,7 @@ namespace App\Http\Controllers\ClientPortal; use App\Events\Payment\Methods\MethodDeleted; use App\Http\Controllers\Controller; -use App\Http\Requests\ClientPortal\CreatePaymentMethodRequest; +use App\Http\Requests\ClientPortal\PaymentMethod\CreatePaymentMethodRequest; use App\Http\Requests\Request; use App\Models\ClientGatewayToken; use App\Models\GatewayType; @@ -52,7 +52,7 @@ class PaymentMethodController extends Controller $data['gateway'] = $gateway; $data['client'] = auth()->user()->client; - + return $gateway ->driver(auth()->user()->client) ->setPaymentMethod($request->query('method')) @@ -93,7 +93,7 @@ class PaymentMethodController extends Controller public function verify(ClientGatewayToken $payment_method) { // $gateway = $this->getClientGateway(); - + return $payment_method->gateway ->driver(auth()->user()->client) ->setPaymentMethod(request()->query('method')) diff --git a/app/Http/Requests/ClientPortal/CreatePaymentMethodRequest.php b/app/Http/Requests/ClientPortal/CreatePaymentMethodRequest.php deleted file mode 100644 index 7997eb9efa..0000000000 --- a/app/Http/Requests/ClientPortal/CreatePaymentMethodRequest.php +++ /dev/null @@ -1,31 +0,0 @@ -user()->client->getCreditCardGateway() ? true : false; - } - - /** - * Get the validation rules that apply to the request. - * - * @return array - */ - public function rules() - { - return [ - // - ]; - } -} diff --git a/app/Http/Requests/ClientPortal/PaymentMethod/CreatePaymentMethodRequest.php b/app/Http/Requests/ClientPortal/PaymentMethod/CreatePaymentMethodRequest.php new file mode 100644 index 0000000000..d90438ac8c --- /dev/null +++ b/app/Http/Requests/ClientPortal/PaymentMethod/CreatePaymentMethodRequest.php @@ -0,0 +1,48 @@ +user()->client; + + $available_methods = []; + + collect($client->service()->getPaymentMethods(1)) + ->filter(function ($method) use (&$available_methods) { + $available_methods[] = $method['gateway_type_id']; + }); + + if (in_array($this->query('method'), $available_methods)) { + return true; + } + + return false; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules() + { + return [ + // + ]; + } +}