Add endpoint to get payment service payment methods
This commit is contained in:
parent
f53efe4d34
commit
5fbe780ef5
|
@ -32,4 +32,8 @@ 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
|
||||
|
|
|
@ -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()
|
||||
));
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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')
|
||||
]
|
||||
];
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue