Improve ilink wallet fees calculation
This commit is contained in:
parent
765ca8d963
commit
a8da94529d
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
class AppException extends Exception
|
||||
{
|
||||
// Redéfinissez l'exception ainsi le message n'est pas facultatif
|
||||
public function __construct($message, $code = 400, Throwable $previous = null)
|
||||
{
|
||||
// traitement personnalisé que vous voulez réaliser ...
|
||||
|
||||
// assurez-vous que tout a été assigné proprement
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
|
||||
// chaîne personnalisée représentant l'objet
|
||||
public function __toString()
|
||||
{
|
||||
return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
|
||||
}
|
||||
|
||||
}
|
|
@ -132,6 +132,10 @@ class Handler extends ExceptionHandler
|
|||
return $this->errorResponse($message, $code);
|
||||
}
|
||||
|
||||
if ($exception instanceof AppException) {
|
||||
return $this->errorResponse($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
if (env('APP_DEBUG', false)) {
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Exceptions\AppException;
|
||||
use App\Models\AgentPlus;
|
||||
use App\Models\CodeGenerer;
|
||||
use App\Models\ConfigWallet;
|
||||
|
@ -1861,6 +1862,10 @@ class iLinkTransactionController extends Controller
|
|||
}
|
||||
|
||||
//Calcul des frais internationaux
|
||||
|
||||
/**
|
||||
* @throws AppException
|
||||
*/
|
||||
private function calculateFees(array $paliers, $montant)
|
||||
{
|
||||
$size = sizeof($paliers);
|
||||
|
@ -1877,15 +1882,9 @@ class iLinkTransactionController extends Controller
|
|||
}
|
||||
|
||||
if ($palier) {
|
||||
$fees = (($palier->min + $palier->max) / 2 * $palier->taux / 100);
|
||||
$fees = ($montant * $palier->taux / 100);
|
||||
} else {
|
||||
if ($montant < $min) {
|
||||
$palier = $paliers[0];
|
||||
$fees = $min * $palier->taux / 100;
|
||||
} else if ($montant > $max) {
|
||||
$palier = $paliers[$size - 1];
|
||||
$fees = $max * $palier->taux / 100;
|
||||
}
|
||||
throw new AppException(trans('errors.amount_not_allowed', ['min' => floatval($min), 'max' => floatval($max)]));
|
||||
}
|
||||
|
||||
if (!empty($palier->plafond) && ($fees > $palier->plafond)) {
|
||||
|
|
|
@ -85,4 +85,5 @@ Paying network : :network :country',
|
|||
"update_banking_information" => "Update your banking information",
|
||||
"wallet_already_linked_to_bank_account" => "Your wallet is already linked to your bank account",
|
||||
"users_group_not_found" => "This group code does not exist",
|
||||
"amount_not_allowed" => "Ce montant n'est pas autorisé. Il doit être compris entre :min et :max"
|
||||
];
|
||||
|
|
|
@ -85,4 +85,5 @@ Réseau payeur : :network :country',
|
|||
"update_banking_information" => "Mettez à jour vos informations bancaires",
|
||||
"wallet_already_linked_to_bank_account" => "Votre wallet est déjà rattaché à votre compte bancaire",
|
||||
"users_group_not_found" => "Ce code de groupe n'existe pas",
|
||||
"amount_not_allowed" => "Ce montant n'est pas autorisé. Il doit être compris entre :min et :max"
|
||||
];
|
||||
|
|
Loading…
Reference in New Issue