Improve aggregator methods and Yoomee capture result

This commit is contained in:
Djery-Tom 2022-11-19 19:16:55 +01:00
parent 3bcdcc5c61
commit 21a8b3464d
6 changed files with 65 additions and 7 deletions

View File

@ -6,6 +6,7 @@ use App\Enums\PaymentTransactionState;
use App\Models\PaymentTransaction;
use GuzzleHttp\Client;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Lang;
use Illuminate\Support\Facades\Log;
use Throwable;
@ -49,7 +50,20 @@ class CinetpayController extends Controller
*/
public function getMethods()
{
return $this->successResponse(['ALL', 'MOBILE_MONEY','CREDIT_CARD']);
$providers = [
// 'ALL',
'MOBILE_MONEY',
'CREDIT_CARD',
];
$methods = [];
foreach ($providers as $provider) {
$key = 'providers.' . $provider;
$methods[$provider] = Lang::has($key) ? __($key) : $provider;
}
return $this->successResponse([
'hasWebview' => true,
'methods' => $methods,
]);
}
//

View File

@ -6,6 +6,7 @@ use App\Enums\PaymentTransactionState;
use App\Models\PaymentTransaction;
use GuzzleHttp\Client;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Lang;
use Illuminate\Support\Str;
class YoomeeController extends Controller
@ -49,7 +50,17 @@ class YoomeeController extends Controller
public function getMethods()
{
$response = $this->client->get('operators');
return $this->successResponse(json_decode($response->getBody()->getContents()));
$providers = json_decode($response->getBody()->getContents());
$methods = [];
foreach ($providers as $provider){
$key = 'providers.'.$provider;
$methods[$provider] = Lang::has($key) ? __($key) : $provider;
}
return $this->successResponse([
'hasWebview' => false,
'methods' => $methods
]
);
}

View File

@ -7,6 +7,7 @@ use App\Models\PaymentTransaction;
use GuzzleHttp\Client;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Lang;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
use Throwable;
@ -55,7 +56,17 @@ class YoomeeV2Controller extends Controller
public function getMethods()
{
$response = $this->client->get('providers/v1');
return $this->successResponse(json_decode($response->getBody()->getContents()));
$providers = json_decode($response->getBody()->getContents());
$methods = [];
foreach ($providers as $provider){
$key = 'providers.'.$provider;
$methods[$provider] = Lang::has($key) ? __($key) : $provider;
}
return $this->successResponse([
'hasWebview' => false,
'methods' => $methods
]
);
}
@ -196,12 +207,16 @@ class YoomeeV2Controller extends Controller
}
if ($transaction->state == PaymentTransactionState::ACCEPTED) {
return $this->successResponse([
return redirect()->route('paymentResult',[
'transaction_id' => $transaction->transaction_id,
'token' => $transaction->payment_token
'token' => $transaction->payment_token,
'status' => 1
]);
} else {
return $this->errorResponse("Payment failed");
return redirect()->route('paymentResult',[
'message' => "Payment failed",
'status' => 0
]);
}
}

View File

@ -25,7 +25,7 @@ return new class extends Migration
$table->string('payment_url')->nullable();
$table->string('payment_token')->nullable();
$table->string('payment_date')->nullable();
$table->string('reason');
$table->text('reason');
$table->string('state');
$table->text('metadata')->nullable();
$table->integer('customer_id');

View File

@ -0,0 +1,9 @@
<?php
return [
'EU' => 'Express Union',
'Orange' => 'Orange Money',
'MTN' => 'MTN MoMo',
'Yoomee' => 'Yoomee Money',
'MOBILE_MONEY' => 'Mobile Money',
'CREDIT_CARD' => 'Carte de crédit'
];

View File

@ -0,0 +1,9 @@
<?php
return [
'EU' => 'Express Union',
'Orange' => 'Orange Money',
'MTN' => 'MTN MoMo',
'Yoomee' => 'Yoomee Money',
'MOBILE_MONEY' => 'Mobile Money',
'CREDIT_CARD' => 'Carte de crédit'
];