Fix GET /methods request
This commit is contained in:
parent
d0e69790b3
commit
6540a42d0d
|
@ -49,7 +49,7 @@ class CinetpayController extends Controller
|
|||
*/
|
||||
public function getMethods()
|
||||
{
|
||||
return $this->successResponse(['ALL', 'MOBILE_MONEY','CREDIT_CARD','WALLET']);
|
||||
return $this->successResponse(['ALL', 'MOBILE_MONEY','CREDIT_CARD']);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\PaymentAggregator;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
@ -10,19 +11,30 @@ class PaymentController extends Controller
|
|||
{
|
||||
public function getMethods(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'aggregator_id' => 'required|integer|exists:payment_aggregators,id',
|
||||
]);
|
||||
$aggregator = PaymentAggregator::where('status', 1)->first();
|
||||
if (!$aggregator) {
|
||||
return $this->errorResponse(trans('errors.model_not_found', ['model' => 'methods']));
|
||||
}
|
||||
|
||||
$aggregator = PaymentAggregator::findOrFail($request->input('aggregator_id'));
|
||||
Log::info($aggregator->name);
|
||||
|
||||
switch(strtolower($aggregator->name)){
|
||||
switch (strtolower($aggregator->name)) {
|
||||
case 'yoomee':
|
||||
return redirect()->route('yoomee.methods', $request->all());
|
||||
$client = new Client([
|
||||
'base_uri' => config('variables.yoomee_api_url'),
|
||||
'timeout' => 60,
|
||||
]);
|
||||
$response = $client->get('operators');
|
||||
return $this->successResponse(json_decode($response->getBody()->getContents()));
|
||||
case 'yoomeev2':
|
||||
return redirect()->route('yoomee.v2.methods', $request->all());
|
||||
$client = new Client([
|
||||
'base_uri' => config('variables.yoomee_api_v2_url'),
|
||||
'timeout' => 60,
|
||||
]);
|
||||
$response = $client->get('providers/v1');
|
||||
return $this->successResponse(json_decode($response->getBody()->getContents()));
|
||||
case 'cinetpay':
|
||||
return redirect()->route('cinetpay.methods', $request->all());
|
||||
return $this->successResponse(['ALL', 'MOBILE_MONEY', 'CREDIT_CARD']);
|
||||
default:
|
||||
return $this->errorResponse(__('errors.unexpected_error'));
|
||||
}
|
||||
|
@ -36,7 +48,7 @@ class PaymentController extends Controller
|
|||
|
||||
$aggregator = PaymentAggregator::findOrFail($request->input('aggregator_id'));
|
||||
|
||||
switch(strtolower($aggregator->name)){
|
||||
switch (strtolower($aggregator->name)) {
|
||||
case 'yoomee':
|
||||
return redirect()->route('yoomee.pay', $request->all());
|
||||
case 'yoomeev2':
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreatePaymentAggregatorsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('payment_aggregators', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email');
|
||||
$table->string('address');
|
||||
$table->string('phone');
|
||||
$table->boolean('status')->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('payment_aggregators');
|
||||
}
|
||||
}
|
|
@ -24,7 +24,7 @@ $router->group(['prefix' => '', 'middleware' => 'auth'], function () use ($route
|
|||
/**
|
||||
* Entry Endpoints
|
||||
*/
|
||||
$router->post('methods','PaymentController@getMethods');
|
||||
$router->get('methods','PaymentController@getMethods');
|
||||
$router->post('pay','PaymentController@pay');
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue