Add endpoint to get payment service payment methods

This commit is contained in:
Djery-Tom 2022-10-09 01:05:47 +01:00
parent f53efe4d34
commit 5fbe780ef5
6 changed files with 126 additions and 9 deletions

View File

@ -18,18 +18,22 @@ DB_PASSWORD=vps@2017GA
CACHE_DRIVER=file CACHE_DRIVER=file
QUEUE_CONNECTION=sync 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 MOBILEBACKENDTEST_BASE_URL=http://test.ilink-app.com:8080
WALLET_SERVICE_BASE_URL =https://ilink-app.com WALLET_SERVICE_BASE_URL=https://ilink-app.com
WALLET_SERVICE_NAME = walletService WALLET_SERVICE_NAME=walletService
WALLET_SERVICE_KEY=yhSTSSqIO1uSE1icu09edPOeSFGxIDjo WALLET_SERVICE_KEY=yhSTSSqIO1uSE1icu09edPOeSFGxIDjo
NOTIFICATION_SERVICE_NAME = notificationService NOTIFICATION_SERVICE_NAME=notificationService
NOTIFICATION_SERVICE_BASE_URL= http://localhost:8083 NOTIFICATION_SERVICE_BASE_URL=http://localhost:8083
NOTIFICATION_SERVICE_KEY=RfXvPQzQRgwpzQYPnLfWpZzgx4QseHlg NOTIFICATION_SERVICE_KEY=RfXvPQzQRgwpzQYPnLfWpZzgx4QseHlg
NANO_SANTE_SERVICE_NAME = nanoSanteService NANO_SANTE_SERVICE_NAME=nanoSanteService
NANO_SANTE_SERVICE_BASE_URL= http://localhost:8086 NANO_SANTE_SERVICE_BASE_URL=http://localhost:8086
NANO_SANTE_SERVICE_KEY=eStSQIoAfnTJ9nkCs0IJkJiKACxYVcQm 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 GOOGLE_GEOCODING_API_KEY=AIzaSyAixFlmxSD_IM_X3jaRn0OyhfZK3xJSAAk

View File

@ -0,0 +1,56 @@
<?php
namespace App\Http\Controllers;
use App\Services\NotificationService;
use App\Services\PaymentService;
use App\Traits\ApiResponser;
use Illuminate\Http\Request;
class PaymentServiceController extends Controller
{
use ApiResponser;
/**
* @var paymentService
*/
public $paymentService;
/**
* Create a new controller instance.
*
* @param PaymentService $service
*/
public function __construct(PaymentService $service)
{
$this->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()
));
}
}

46
app/Services/PaymentService.php Executable file
View File

@ -0,0 +1,46 @@
<?php
namespace App\Services;
use App\Traits\ConsumesExternalService;
class PaymentService
{
use ConsumesExternalService;
/**
* @var string
*/
public $baseUri ;
/**
* @var string
*/
public $key ;
public function __construct()
{
$this->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);
}
}

View File

@ -61,10 +61,10 @@ trait ConsumesExternalService
foreach ($body as $key => $value) { foreach ($body as $key => $value) {
if(is_array($value)){ if(is_array($value)){
foreach ($value as $v){ foreach ($value as $v){
array_push($multipart, $this->convertToMultiFormArray($key.'[]',$v)); $multipart[] = $this->convertToMultiFormArray($key . '[]', $v);
} }
}else{ }else{
array_push($multipart, $this->convertToMultiFormArray($key,$value)); $multipart[] = $this->convertToMultiFormArray($key, $value);
} }
} }
return $multipart; return $multipart;

View File

@ -21,5 +21,9 @@ return [
'name' => env('NANO_SANTE_SERVICE_NAME'), 'name' => env('NANO_SANTE_SERVICE_NAME'),
'base_uri' => env('NANO_SANTE_SERVICE_BASE_URL'), 'base_uri' => env('NANO_SANTE_SERVICE_BASE_URL'),
'key'=> env('NANO_SANTE_SERVICE_KEY') 'key'=> env('NANO_SANTE_SERVICE_KEY')
],
'payment_service' => [
'base_uri' => env('PAYMENT_SERVICE_BASE_URL'),
'key'=> env('PAYMENT_SERVICE_KEY')
] ]
]; ];

View File

@ -266,3 +266,10 @@ $router->get('/geocode', 'HelperController@getGoogleGeocoding');
$router->post('password-validation', 'NanoSanteServiceController@post'); $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');
});