diff --git a/app/Http/Requests/CreatePaymentAPIRequest.php b/app/Http/Requests/CreatePaymentAPIRequest.php index 5c58050e3e38..4a43bf368b2b 100644 --- a/app/Http/Requests/CreatePaymentAPIRequest.php +++ b/app/Http/Requests/CreatePaymentAPIRequest.php @@ -1,9 +1,7 @@ req = $req; - } + public function authorize() { @@ -60,22 +55,5 @@ class CreatePaymentAPIRequest extends PaymentRequest } - public function response(array $errors) - { - /* If the user is not validating from a mobile app - pass through parent::response */ - if(!isset($this->req->api_secret)) - return parent::response($errors); - /* If the user is validating from a mobile app - pass through first error string and return error */ - foreach($errors as $error) { - foreach ($error as $key => $value) { - - $message['error'] = ['message'=>$value]; - $message = json_encode($message, JSON_PRETTY_PRINT); - $headers = Utils::getApiHeaders(); - - return Response::make($message, 400, $headers); - } - } - } } diff --git a/app/Http/Requests/Request.php b/app/Http/Requests/Request.php index 9874a8f50384..7825ca586e68 100644 --- a/app/Http/Requests/Request.php +++ b/app/Http/Requests/Request.php @@ -1,6 +1,9 @@ req = $req; + } + /** * Validate the input. * @@ -48,4 +56,23 @@ abstract class Request extends FormRequest { return $this->all(); } + + public function response(array $errors) + { + /* If the user is not validating from a mobile app - pass through parent::response */ + if(!isset($this->req->api_secret)) + return parent::response($errors); + + /* If the user is validating from a mobile app - pass through first error string and return error */ + foreach($errors as $error) { + foreach ($error as $key => $value) { + + $message['error'] = ['message'=>$value]; + $message = json_encode($message, JSON_PRETTY_PRINT); + $headers = Utils::getApiHeaders(); + + return Response::make($message, 400, $headers); + } + } + } }