fix(ilink transaction): missing additional fees for transaction ids 3, 17 and 21
This commit is contained in:
parent
be684d7f4e
commit
c5bfe33cad
|
@ -35,8 +35,6 @@ use Throwable;
|
||||||
|
|
||||||
class iLinkTransactionController extends Controller
|
class iLinkTransactionController extends Controller
|
||||||
{
|
{
|
||||||
private $REFUND_URL = "/adyen-api/v1/transaction/refund";
|
|
||||||
private $PAYING_NETWORK_SIMULATOR_SEND_FRAME_URL = 'http://localhost:8084/receive_payment';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new controller instance.
|
* Create a new controller instance.
|
||||||
|
@ -223,13 +221,6 @@ class iLinkTransactionController extends Controller
|
||||||
return $this->errorResponse('errors.invalid_cvv');
|
return $this->errorResponse('errors.invalid_cvv');
|
||||||
|
|
||||||
$transaction->fill($data);
|
$transaction->fill($data);
|
||||||
// Pay through payment service
|
|
||||||
$client = new Client([
|
|
||||||
'base_uri' => config('services.payment_service.base_uri'),
|
|
||||||
'headers' => [
|
|
||||||
'Authorization' => config('services.payment_service.key'),
|
|
||||||
]
|
|
||||||
]);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
|
@ -450,13 +441,28 @@ class iLinkTransactionController extends Controller
|
||||||
//Verification des limites reglementaires
|
//Verification des limites reglementaires
|
||||||
$this->checkReguationsLimits($walletUser->id, $init_country, $request->final_country, $transaction->montant);
|
$this->checkReguationsLimits($walletUser->id, $init_country, $request->final_country, $transaction->montant);
|
||||||
|
|
||||||
$transaction->frais = $frais = ($init_country != $request->final_country) ? $this->calculateFees($plr_user_wallet_cash, $request->montant) : $this->calculateFees($plr_user_wallet_cash_national, $request->montant);
|
$frais = ($init_country != $request->final_country) ? $this->calculateFees($plr_user_wallet_cash, $request->montant) : $this->calculateFees($plr_user_wallet_cash_national, $request->montant);
|
||||||
$transaction->taxe = $taxe = ($init_country != $request->final_country) ? $this->calculateTax($taxesInternationales, $frais) : $this->calculateTax($taxesNationales, $frais);
|
$configPayeur = ConfigWallet::where('id_network', $request->network_destinataire)->firstOrFail();
|
||||||
|
$reseauPayeur = PayingNetwork::where('id_network', $request->network_destinataire)->where('id_configWallet', $config->id)->first();
|
||||||
|
|
||||||
|
$fees = 0;
|
||||||
|
if ($configPayeur->type != 'ilink') {
|
||||||
|
$fees = $this->getBasicTransactionFees([
|
||||||
|
'amount' => $request->montant,
|
||||||
|
'country_id' => $init_country,
|
||||||
|
'payment_type' => PaymentType::CASH_IN,
|
||||||
|
'payment_method' => PaymentMethod::WALLET
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$frais += $fees;
|
||||||
|
|
||||||
|
$taxe = ($init_country != $request->final_country) ? $this->calculateTax($taxesInternationales, $frais) : $this->calculateTax($taxesNationales, $frais);
|
||||||
|
$transaction->frais = $frais;
|
||||||
|
$transaction->taxe = $taxe;
|
||||||
$transaction->montant_net = $montantRetrait = $transaction->montant - $frais - $taxe;
|
$transaction->montant_net = $montantRetrait = $transaction->montant - $frais - $taxe;
|
||||||
$transaction->montant_net_final_country = $this->toMoneyAmount($montantRetrait, $init_country, $request->final_country);
|
$transaction->montant_net_final_country = $this->toMoneyAmount($montantRetrait, $init_country, $request->final_country);
|
||||||
$configPayeur = ConfigWallet::where('id_network', $request->network_destinataire)->firstOrFail();
|
|
||||||
|
|
||||||
$reseauPayeur = PayingNetwork::where('id_network', $request->network_destinataire)->where('id_configWallet', $config->id)->first();
|
|
||||||
if (isset($reseauPayeur)) {
|
if (isset($reseauPayeur)) {
|
||||||
$transaction->part_reseau_payeur = $frais * $reseauPayeur->taux_partage / 100;
|
$transaction->part_reseau_payeur = $frais * $reseauPayeur->taux_partage / 100;
|
||||||
$transaction->part_reseau_payeur_final_country = $this->toMoneyAmount($transaction->part_reseau_payeur, $init_country, $request->final_country);
|
$transaction->part_reseau_payeur_final_country = $this->toMoneyAmount($transaction->part_reseau_payeur, $init_country, $request->final_country);
|
||||||
|
@ -1286,15 +1292,28 @@ class iLinkTransactionController extends Controller
|
||||||
//Verification des limites reglementaires
|
//Verification des limites reglementaires
|
||||||
$this->checkReguationsLimits($request->id_document_emetteur, $init_country, $request->final_country, $transaction->montant, true);
|
$this->checkReguationsLimits($request->id_document_emetteur, $init_country, $request->final_country, $transaction->montant, true);
|
||||||
|
|
||||||
|
$configPayeur = ConfigWallet::where('id_network', $request->network_destinataire)->firstOrFail();
|
||||||
|
$reseauPayeur = PayingNetwork::where('id_network', $request->network_destinataire)->where('id_configWallet', $config->id)->first();
|
||||||
|
|
||||||
$frais = ($init_country != $request->final_country) ? $this->calculateFees($plr_agent_cash_cash, $request->montant) : $this->calculateFees($plr_agent_cash_cash_national, $request->montant);
|
$frais = ($init_country != $request->final_country) ? $this->calculateFees($plr_agent_cash_cash, $request->montant) : $this->calculateFees($plr_agent_cash_cash_national, $request->montant);
|
||||||
|
$fees = 0;
|
||||||
|
if ($configPayeur->type != 'ilink') {
|
||||||
|
$fees = $this->getBasicTransactionFees([
|
||||||
|
'amount' => $request->montant,
|
||||||
|
'country_id' => $init_country,
|
||||||
|
'payment_type' => PaymentType::CASH_IN,
|
||||||
|
'payment_method' => PaymentMethod::WALLET
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$frais += $fees;
|
||||||
$taxe = ($init_country != $request->final_country) ? $this->calculateTax($taxesInternationales, $frais) : $this->calculateTax($taxesNationales, $frais);
|
$taxe = ($init_country != $request->final_country) ? $this->calculateTax($taxesInternationales, $frais) : $this->calculateTax($taxesNationales, $frais);
|
||||||
$montantRetrait = $request->montant - $frais - $taxe;
|
$montantRetrait = $request->montant - $frais - $taxe;
|
||||||
|
$transaction->frais = $frais;
|
||||||
|
$transaction->taxe = $taxe;
|
||||||
$transaction->montant_net = $montantRetrait;
|
$transaction->montant_net = $montantRetrait;
|
||||||
$transaction->montant_net_final_country = $this->toMoneyAmount($transaction->montant_net, $init_country, $request->final_country);
|
$transaction->montant_net_final_country = $this->toMoneyAmount($transaction->montant_net, $init_country, $request->final_country);
|
||||||
|
|
||||||
$configPayeur = ConfigWallet::where('id_network', $request->network_destinataire)->firstOrFail();
|
|
||||||
|
|
||||||
$reseauPayeur = PayingNetwork::where('id_network', $request->network_destinataire)->where('id_configWallet', $config->id)->first();
|
|
||||||
if (isset($reseauPayeur)) {
|
if (isset($reseauPayeur)) {
|
||||||
$transaction->part_reseau_payeur = $frais * $reseauPayeur->taux_partage / 100;
|
$transaction->part_reseau_payeur = $frais * $reseauPayeur->taux_partage / 100;
|
||||||
$transaction->part_reseau_payeur_final_country = $this->toMoneyAmount($transaction->part_reseau_payeur, $init_country, $request->final_country);
|
$transaction->part_reseau_payeur_final_country = $this->toMoneyAmount($transaction->part_reseau_payeur, $init_country, $request->final_country);
|
||||||
|
@ -1774,28 +1793,34 @@ class iLinkTransactionController extends Controller
|
||||||
|
|
||||||
//Verification des limites reglementaires
|
//Verification des limites reglementaires
|
||||||
$this->checkReguationsLimits($walletUser->id, $init_country, $request->final_country, $transaction->montant);
|
$this->checkReguationsLimits($walletUser->id, $init_country, $request->final_country, $transaction->montant);
|
||||||
|
|
||||||
|
$configPayeur = ConfigWallet::where('id_network', $request->network_destinataire)->firstOrFail();
|
||||||
|
$reseauPayeur = PayingNetwork::where('id_network', $request->network_destinataire)->where('id_configWallet', $config->id)->first();
|
||||||
|
|
||||||
$frais = $this->calculateFees($init_country != $request->final_country ? $plr_user_cart_autre_wallet_international : $plr_user_cart_autre_wallet_national, $request->montant);
|
$frais = $this->calculateFees($init_country != $request->final_country ? $plr_user_cart_autre_wallet_international : $plr_user_cart_autre_wallet_national, $request->montant);
|
||||||
$fees = $this->getBasicTransactionFees([
|
$fees = $this->getBasicTransactionFees([
|
||||||
'amount' => $request->montant,
|
'amount' => $request->montant,
|
||||||
'country_id' => $init_country,
|
'country_id' => $init_country,
|
||||||
'payment_type' => PaymentType::CASH_OUT,
|
'payment_type' => PaymentType::CASH_OUT,
|
||||||
'payment_method' => PaymentMethod::CARD
|
'payment_method' => PaymentMethod::CARD
|
||||||
]) + $this->getBasicTransactionFees([
|
]);
|
||||||
|
|
||||||
|
if ($configPayeur->type != 'ilink') {
|
||||||
|
$fees += $this->getBasicTransactionFees([
|
||||||
'amount' => $request->montant,
|
'amount' => $request->montant,
|
||||||
'country_id' => $init_country,
|
'country_id' => $init_country,
|
||||||
'payment_type' => PaymentType::CASH_IN,
|
'payment_type' => PaymentType::CASH_IN,
|
||||||
'payment_method' => PaymentMethod::WALLET
|
'payment_method' => PaymentMethod::WALLET
|
||||||
]);
|
]);
|
||||||
$frais += $fees;
|
}
|
||||||
|
|
||||||
|
$frais += $fees;
|
||||||
$taxe = $this->calculateTax($init_country != $request->final_country ? $taxesInternationales : $taxesNationales, $frais);
|
$taxe = $this->calculateTax($init_country != $request->final_country ? $taxesInternationales : $taxesNationales, $frais);
|
||||||
$transaction->frais = $frais;
|
$transaction->frais = $frais;
|
||||||
$transaction->taxe = $taxe;
|
$transaction->taxe = $taxe;
|
||||||
$transaction->montant_net = $montantRetrait = $transaction->montant + $frais + $taxe;
|
$transaction->montant_net = $montantRetrait = $transaction->montant + $frais + $taxe;
|
||||||
$transaction->montant_net_final_country = $this->toMoneyAmount($transaction->montant, $init_country, $request->final_country);
|
$transaction->montant_net_final_country = $this->toMoneyAmount($transaction->montant, $init_country, $request->final_country);
|
||||||
$configPayeur = ConfigWallet::where('id_network', $request->network_destinataire)->firstOrFail();
|
|
||||||
|
|
||||||
$reseauPayeur = PayingNetwork::where('id_network', $request->network_destinataire)->where('id_configWallet', $config->id)->first();
|
|
||||||
if (isset($reseauPayeur)) {
|
if (isset($reseauPayeur)) {
|
||||||
$transaction->part_reseau_payeur = $frais * $reseauPayeur->taux_partage / 100;
|
$transaction->part_reseau_payeur = $frais * $reseauPayeur->taux_partage / 100;
|
||||||
$transaction->part_reseau_payeur_final_country = $this->toMoneyAmount($transaction->part_reseau_payeur, $init_country, $request->final_country);
|
$transaction->part_reseau_payeur_final_country = $this->toMoneyAmount($transaction->part_reseau_payeur, $init_country, $request->final_country);
|
||||||
|
@ -1906,7 +1931,8 @@ class iLinkTransactionController extends Controller
|
||||||
$response_message = ($message . trans('messages.sent_by_mail'));
|
$response_message = ($message . trans('messages.sent_by_mail'));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$response_message = "Default response message";
|
DB::rollBack();
|
||||||
|
return $this->errorResponse(trans('errors.transaction_not_supported'));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2188,8 +2214,20 @@ class iLinkTransactionController extends Controller
|
||||||
case 3: // User - Envoi wallet à cash
|
case 3: // User - Envoi wallet à cash
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'final_country' => 'required|integer|min:0|not_in:0',
|
'final_country' => 'required|integer|min:0|not_in:0',
|
||||||
|
// 'id_destinataire' => 'required_without:phone_destinataire',
|
||||||
|
'network_destinataire' => 'required|integer|min:0|not_in:0',
|
||||||
]);
|
]);
|
||||||
|
$configNetworkDestinataire = ConfigWallet::where('id_network', $request->network_destinataire)->firstOrFail();
|
||||||
$frais = ($init_country != $request->final_country) ? $this->calculateFees($plr_user_wallet_cash, $request->montant) : $this->calculateFees($plr_user_wallet_cash_national, $request->montant);
|
$frais = ($init_country != $request->final_country) ? $this->calculateFees($plr_user_wallet_cash, $request->montant) : $this->calculateFees($plr_user_wallet_cash_national, $request->montant);
|
||||||
|
if ($configNetworkDestinataire->type != 'ilink') {
|
||||||
|
$fees = $this->getBasicTransactionFees([
|
||||||
|
'amount' => $request->montant,
|
||||||
|
'country_id' => $init_country,
|
||||||
|
'payment_type' => PaymentType::CASH_IN,
|
||||||
|
'payment_method' => PaymentMethod::WALLET
|
||||||
|
]);
|
||||||
|
$frais += $fees;
|
||||||
|
}
|
||||||
$taxe = ($init_country != $request->final_country) ? $this->calculateTax($taxesInternationales, $frais) : $this->calculateTax($taxesNationales, $frais);
|
$taxe = ($init_country != $request->final_country) ? $this->calculateTax($taxesInternationales, $frais) : $this->calculateTax($taxesNationales, $frais);
|
||||||
$data['frais'] = round($frais + $taxe, 2);
|
$data['frais'] = round($frais + $taxe, 2);
|
||||||
$data['montant_net_init'] = round($request->montant - $data['frais'], 2);
|
$data['montant_net_init'] = round($request->montant - $data['frais'], 2);
|
||||||
|
@ -2298,8 +2336,20 @@ class iLinkTransactionController extends Controller
|
||||||
case 17: // Agent - Envoi de cash vers cash
|
case 17: // Agent - Envoi de cash vers cash
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'final_country' => 'required|integer|exists:countries,id',
|
'final_country' => 'required|integer|exists:countries,id',
|
||||||
|
// 'id_destinataire' => 'required_without:phone_destinataire',
|
||||||
|
'network_destinataire' => 'required|integer|min:0|not_in:0',
|
||||||
]);
|
]);
|
||||||
|
$configNetworkDestinataire = ConfigWallet::where('id_network', $request->network_destinataire)->firstOrFail();
|
||||||
$frais = ($init_country != $request->final_country) ? $this->calculateFees($plr_agent_cash_cash, $request->montant) : $this->calculateFees($plr_agent_cash_cash_national, $request->montant);
|
$frais = ($init_country != $request->final_country) ? $this->calculateFees($plr_agent_cash_cash, $request->montant) : $this->calculateFees($plr_agent_cash_cash_national, $request->montant);
|
||||||
|
if ($configNetworkDestinataire->type != 'ilink') {
|
||||||
|
$fees = $this->getBasicTransactionFees([
|
||||||
|
'amount' => $request->montant,
|
||||||
|
'country_id' => $init_country,
|
||||||
|
'payment_type' => PaymentType::CASH_IN,
|
||||||
|
'payment_method' => PaymentMethod::WALLET
|
||||||
|
]);
|
||||||
|
$frais += $fees;
|
||||||
|
}
|
||||||
$taxe = ($init_country != $request->final_country) ? $this->calculateTax($taxesInternationales, $frais) : $this->calculateTax($taxesNationales, $frais);
|
$taxe = ($init_country != $request->final_country) ? $this->calculateTax($taxesInternationales, $frais) : $this->calculateTax($taxesNationales, $frais);
|
||||||
$data['frais'] = round($frais + $taxe, 2);
|
$data['frais'] = round($frais + $taxe, 2);
|
||||||
$data['exchange_rate'] = $this->getExchangeRate($init_country, $request->final_country);
|
$data['exchange_rate'] = $this->getExchangeRate($init_country, $request->final_country);
|
||||||
|
@ -2309,6 +2359,8 @@ class iLinkTransactionController extends Controller
|
||||||
case 21: //User - Retrait de carte vers autre wallet
|
case 21: //User - Retrait de carte vers autre wallet
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'final_country' => 'required|integer|exists:countries,id',
|
'final_country' => 'required|integer|exists:countries,id',
|
||||||
|
'id_destinataire' => 'required_without:phone_destinataire',
|
||||||
|
'network_destinataire' => 'required|integer|min:0|not_in:0',
|
||||||
]);
|
]);
|
||||||
$plr_user_cart_autre_wallet_national = $this->getPaliers($paliers_commission_wallets, 'user_cart_autre_wallet_national');
|
$plr_user_cart_autre_wallet_national = $this->getPaliers($paliers_commission_wallets, 'user_cart_autre_wallet_national');
|
||||||
$plr_user_cart_autre_wallet_international = $this->getPaliers($paliers_commission_wallets, 'user_cart_autre_wallet_international');
|
$plr_user_cart_autre_wallet_international = $this->getPaliers($paliers_commission_wallets, 'user_cart_autre_wallet_international');
|
||||||
|
@ -2318,12 +2370,22 @@ class iLinkTransactionController extends Controller
|
||||||
'country_id' => $init_country,
|
'country_id' => $init_country,
|
||||||
'payment_type' => PaymentType::CASH_OUT,
|
'payment_type' => PaymentType::CASH_OUT,
|
||||||
'payment_method' => PaymentMethod::CARD
|
'payment_method' => PaymentMethod::CARD
|
||||||
]) + $this->getBasicTransactionFees([
|
]);
|
||||||
|
$configNetworkDestinataire = ConfigWallet::where('id_network', $request->network_destinataire)->firstOrFail();
|
||||||
|
//Verifier si c'est pas un reseau ilink
|
||||||
|
if ($configNetworkDestinataire->type != 'ilink') {
|
||||||
|
$data['destinataire'] = $request->id_destinataire;
|
||||||
|
$fees += $this->getBasicTransactionFees([
|
||||||
'amount' => $request->montant,
|
'amount' => $request->montant,
|
||||||
'country_id' => $init_country,
|
'country_id' => $init_country,
|
||||||
'payment_type' => PaymentType::CASH_IN,
|
'payment_type' => PaymentType::CASH_IN,
|
||||||
'payment_method' => PaymentMethod::WALLET
|
'payment_method' => PaymentMethod::WALLET
|
||||||
]);
|
]);
|
||||||
|
} else {
|
||||||
|
$destinataire = User::where('user_code', $request->id_destinataire)->orWhere('phone', $request->id_destinataire)->first();
|
||||||
|
$data['destinataire'] = $destinataire ? $destinataire->lastname . ' ' . $destinataire->firstname : $request->id_destinataire;
|
||||||
|
}
|
||||||
|
|
||||||
$frais += $fees;
|
$frais += $fees;
|
||||||
$taxe = $this->calculateTax($init_country != $request->final_country ? $taxesInternationales : $taxesNationales, $frais);
|
$taxe = $this->calculateTax($init_country != $request->final_country ? $taxesInternationales : $taxesNationales, $frais);
|
||||||
$data['frais'] = round($frais + $taxe, 2);
|
$data['frais'] = round($frais + $taxe, 2);
|
||||||
|
@ -2331,6 +2393,8 @@ class iLinkTransactionController extends Controller
|
||||||
$data['montant_net'] = round($request->montant + $data['frais'], 2);
|
$data['montant_net'] = round($request->montant + $data['frais'], 2);
|
||||||
$data['montant_net_final'] = $this->toMoneyWithCurrency($request->montant, $init_country, $request->final_country);
|
$data['montant_net_final'] = $this->toMoneyWithCurrency($request->montant, $init_country, $request->final_country);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
return $this->errorResponse(trans('errors.transaction_not_supported'));
|
||||||
}
|
}
|
||||||
$net = $data['montant_net'] ?? $data['montant_net_init'];
|
$net = $data['montant_net'] ?? $data['montant_net_init'];
|
||||||
if (isset($net))
|
if (isset($net))
|
||||||
|
|
|
@ -88,4 +88,5 @@ Paying network : :network :country',
|
||||||
"amount_not_allowed" => "This amount is not allowed. It must be between :min and :max",
|
"amount_not_allowed" => "This amount is not allowed. It must be between :min and :max",
|
||||||
"transaction_already_completed" => "This transaction has already been completed",
|
"transaction_already_completed" => "This transaction has already been completed",
|
||||||
'paying_network_api_failed' => "Request to API paying network failed",
|
'paying_network_api_failed' => "Request to API paying network failed",
|
||||||
|
'transaction_not_supported' => "This transaction is not supported"
|
||||||
];
|
];
|
||||||
|
|
|
@ -88,4 +88,5 @@ Réseau payeur : :network :country',
|
||||||
"amount_not_allowed" => "Ce montant n'est pas autorisé. Il doit être compris entre :min et :max",
|
"amount_not_allowed" => "Ce montant n'est pas autorisé. Il doit être compris entre :min et :max",
|
||||||
"transaction_already_completed" => "Cette transaction a déjà été éffectuée",
|
"transaction_already_completed" => "Cette transaction a déjà été éffectuée",
|
||||||
'paying_network_api_failed' => "La requête vers l'API du réseau payeur a échouée",
|
'paying_network_api_failed' => "La requête vers l'API du réseau payeur a échouée",
|
||||||
|
'transaction_not_supported' => "Cette transaction n'est pas supportée"
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in New Issue