Improve aggregator methods and Yoomee capture result
This commit is contained in:
parent
3bcdcc5c61
commit
21a8b3464d
|
@ -6,6 +6,7 @@ use App\Enums\PaymentTransactionState;
|
||||||
use App\Models\PaymentTransaction;
|
use App\Models\PaymentTransaction;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Lang;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
|
@ -49,7 +50,20 @@ class CinetpayController extends Controller
|
||||||
*/
|
*/
|
||||||
public function getMethods()
|
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,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -6,6 +6,7 @@ use App\Enums\PaymentTransactionState;
|
||||||
use App\Models\PaymentTransaction;
|
use App\Models\PaymentTransaction;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Lang;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class YoomeeController extends Controller
|
class YoomeeController extends Controller
|
||||||
|
@ -49,7 +50,17 @@ class YoomeeController extends Controller
|
||||||
public function getMethods()
|
public function getMethods()
|
||||||
{
|
{
|
||||||
$response = $this->client->get('operators');
|
$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
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ use App\Models\PaymentTransaction;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Lang;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
@ -55,7 +56,17 @@ class YoomeeV2Controller extends Controller
|
||||||
public function getMethods()
|
public function getMethods()
|
||||||
{
|
{
|
||||||
$response = $this->client->get('providers/v1');
|
$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) {
|
if ($transaction->state == PaymentTransactionState::ACCEPTED) {
|
||||||
return $this->successResponse([
|
return redirect()->route('paymentResult',[
|
||||||
'transaction_id' => $transaction->transaction_id,
|
'transaction_id' => $transaction->transaction_id,
|
||||||
'token' => $transaction->payment_token
|
'token' => $transaction->payment_token,
|
||||||
|
'status' => 1
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
return $this->errorResponse("Payment failed");
|
return redirect()->route('paymentResult',[
|
||||||
|
'message' => "Payment failed",
|
||||||
|
'status' => 0
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ return new class extends Migration
|
||||||
$table->string('payment_url')->nullable();
|
$table->string('payment_url')->nullable();
|
||||||
$table->string('payment_token')->nullable();
|
$table->string('payment_token')->nullable();
|
||||||
$table->string('payment_date')->nullable();
|
$table->string('payment_date')->nullable();
|
||||||
$table->string('reason');
|
$table->text('reason');
|
||||||
$table->string('state');
|
$table->string('state');
|
||||||
$table->text('metadata')->nullable();
|
$table->text('metadata')->nullable();
|
||||||
$table->integer('customer_id');
|
$table->integer('customer_id');
|
||||||
|
|
|
@ -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'
|
||||||
|
];
|
|
@ -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'
|
||||||
|
];
|
Loading…
Reference in New Issue