From 5fbe780ef580b527fe3be5ca2874f3c489a3a34f Mon Sep 17 00:00:00 2001 From: Djery-Tom Date: Sun, 9 Oct 2022 01:05:47 +0100 Subject: [PATCH] Add endpoint to get payment service payment methods --- .env.example | 18 +++--- .../Controllers/PaymentServiceController.php | 56 +++++++++++++++++++ app/Services/PaymentService.php | 46 +++++++++++++++ app/Traits/ConsumesExternalService.php | 4 +- config/services.php | 4 ++ routes/web.php | 7 +++ 6 files changed, 126 insertions(+), 9 deletions(-) create mode 100755 app/Http/Controllers/PaymentServiceController.php create mode 100755 app/Services/PaymentService.php diff --git a/.env.example b/.env.example index bff3c66..0ea9f68 100755 --- a/.env.example +++ b/.env.example @@ -18,18 +18,22 @@ DB_PASSWORD=vps@2017GA CACHE_DRIVER=file QUEUE_CONNECTION=sync -MOBILEBACKEND_BASE_URL =https://ilink-app.com +MOBILEBACKEND_BASE_URL=https://ilink-app.com MOBILEBACKENDTEST_BASE_URL=http://test.ilink-app.com:8080 -WALLET_SERVICE_BASE_URL =https://ilink-app.com -WALLET_SERVICE_NAME = walletService +WALLET_SERVICE_BASE_URL=https://ilink-app.com +WALLET_SERVICE_NAME=walletService WALLET_SERVICE_KEY=yhSTSSqIO1uSE1icu09edPOeSFGxIDjo -NOTIFICATION_SERVICE_NAME = notificationService -NOTIFICATION_SERVICE_BASE_URL= http://localhost:8083 +NOTIFICATION_SERVICE_NAME=notificationService +NOTIFICATION_SERVICE_BASE_URL=http://localhost:8083 NOTIFICATION_SERVICE_KEY=RfXvPQzQRgwpzQYPnLfWpZzgx4QseHlg -NANO_SANTE_SERVICE_NAME = nanoSanteService -NANO_SANTE_SERVICE_BASE_URL= http://localhost:8086 +NANO_SANTE_SERVICE_NAME=nanoSanteService +NANO_SANTE_SERVICE_BASE_URL=http://localhost:8086 NANO_SANTE_SERVICE_KEY=eStSQIoAfnTJ9nkCs0IJkJiKACxYVcQm +PAYMENT_SERVICE_NAME=paymentService +PAYMENT_SERVICE_BASE_URL=http://localhost:8087 +PAYMENT_SERVICE_KEY=U14YhuyFhweMeYpIYj8Ft2jm4cVgbMzD + GOOGLE_GEOCODING_API_KEY=AIzaSyAixFlmxSD_IM_X3jaRn0OyhfZK3xJSAAk diff --git a/app/Http/Controllers/PaymentServiceController.php b/app/Http/Controllers/PaymentServiceController.php new file mode 100755 index 0000000..cfb0133 --- /dev/null +++ b/app/Http/Controllers/PaymentServiceController.php @@ -0,0 +1,56 @@ +paymentService = $service; + } + + public function get(Request $request) + { + return $this->successResponse($this->paymentService->get( + substr($request->getRequestUri(),strlen(env('PAYMENT_SERVICE_NAME'))+1), $request->all(),$request->header() + )); + } + + public function post(Request $request) + { + return $this->successResponse($this->paymentService->post( + substr($request->getRequestUri(),strlen(env('PAYMENT_SERVICE_NAME'))+1), $request->all(),$request->header() + )); + } + + public function put(Request $request) + { + return $this->successResponse($this->paymentService->put( + substr($request->getRequestUri(),strlen(env('PAYMENT_SERVICE_NAME'))+1), $request->all(),$request->header() + )); + } + + public function delete(Request $request) + { + return $this->successResponse($this->paymentService->delete( + substr($request->getRequestUri(),strlen(env('PAYMENT_SERVICE_NAME'))+1), $request->all(),$request->header() + )); + } +} diff --git a/app/Services/PaymentService.php b/app/Services/PaymentService.php new file mode 100755 index 0000000..3016e68 --- /dev/null +++ b/app/Services/PaymentService.php @@ -0,0 +1,46 @@ +baseUri = config('services.payment_service.base_uri'); + $this->key = config('services.payment_service.key'); + } + + public function post($uri , $data, $headers) + { + return $this->perfomRequest('POST',$uri,$data,$headers); + } + + public function get($uri , $data, $headers) + { + return $this->perfomRequest('GET',$uri,$data,$headers); + } + + public function put($uri , $data, $headers) + { + return $this->perfomRequest('PUT',$uri,$data,$headers); + } + + public function delete($uri , $data, $headers) + { + return $this->perfomRequest('DELETE',$uri,$data,$headers); + } +} diff --git a/app/Traits/ConsumesExternalService.php b/app/Traits/ConsumesExternalService.php index 6bdb3cc..0c40017 100755 --- a/app/Traits/ConsumesExternalService.php +++ b/app/Traits/ConsumesExternalService.php @@ -61,10 +61,10 @@ trait ConsumesExternalService foreach ($body as $key => $value) { if(is_array($value)){ foreach ($value as $v){ - array_push($multipart, $this->convertToMultiFormArray($key.'[]',$v)); + $multipart[] = $this->convertToMultiFormArray($key . '[]', $v); } }else{ - array_push($multipart, $this->convertToMultiFormArray($key,$value)); + $multipart[] = $this->convertToMultiFormArray($key, $value); } } return $multipart; diff --git a/config/services.php b/config/services.php index 271d16b..261eca0 100755 --- a/config/services.php +++ b/config/services.php @@ -21,5 +21,9 @@ return [ 'name' => env('NANO_SANTE_SERVICE_NAME'), 'base_uri' => env('NANO_SANTE_SERVICE_BASE_URL'), 'key'=> env('NANO_SANTE_SERVICE_KEY') + ], + 'payment_service' => [ + 'base_uri' => env('PAYMENT_SERVICE_BASE_URL'), + 'key'=> env('PAYMENT_SERVICE_KEY') ] ]; diff --git a/routes/web.php b/routes/web.php index a9625eb..774cbc3 100755 --- a/routes/web.php +++ b/routes/web.php @@ -266,3 +266,10 @@ $router->get('/geocode', 'HelperController@getGoogleGeocoding'); $router->post('password-validation', 'NanoSanteServiceController@post'); }); }); + +/** + * Routes for Payment Service + */ +$router->group(['prefix' => '/'.env('PAYMENT_SERVICE_NAME')], function () use ($router){ + $router->get('methods', 'PaymentServiceController@get'); +});