|
|
|
@ -175,8 +175,7 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
$wallet_agent_sup = WalletAgent::where('agent_id', $superviseur->id)->firstOrFail();
|
|
|
|
|
$wallet_agent_hyp = WalletAgent::where('agent_id', $hyperviseur->id)->firstOrFail();
|
|
|
|
|
$walletSuperviseur = Wallet::findOrFail($wallet_agent_sup->wallet_id);
|
|
|
|
|
$walletHyperviseur = Wallet::findOrFail($wallet_agent_hyp->wallet_id);
|
|
|
|
|
} elseif (isset($id_wallet_user)) {
|
|
|
|
|
} else {
|
|
|
|
|
$walletUser = WalletsUser::findOrFail($id_wallet_user);
|
|
|
|
|
$transaction->init_country = $init_country = $walletUser->user->network->country->id;
|
|
|
|
|
$result = ConfigWallet::join('networks', 'networks.id', '=', 'configWallet.id_network')
|
|
|
|
@ -190,8 +189,8 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
|
|
|
|
|
$hyperviseur = AgentPlus::where('category', 'hyper')->where('network_id', $config->id_network)->firstOrFail();
|
|
|
|
|
$wallet_agent_hyp = WalletAgent::where('agent_id', $hyperviseur->id)->firstOrFail();
|
|
|
|
|
$walletHyperviseur = Wallet::findOrFail($wallet_agent_hyp->wallet_id);
|
|
|
|
|
}
|
|
|
|
|
$walletHyperviseur = Wallet::findOrFail($wallet_agent_hyp->wallet_id);
|
|
|
|
|
$transaction->network_emetteur = $config->id_network;
|
|
|
|
|
|
|
|
|
|
$taxesNationales = array_values(array_filter($config->taxes->all(), function ($tax) {
|
|
|
|
@ -341,7 +340,17 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
$transaction->expiration_date = $user->expiration_date;
|
|
|
|
|
$transaction->numero_carte = $user->numero_carte;
|
|
|
|
|
|
|
|
|
|
$frais = $request->montant * $config->taux_com_user_wallet_carte / 100;
|
|
|
|
|
$final_country = $request->input('final_country');
|
|
|
|
|
$transaction->final_country = $final_country;
|
|
|
|
|
$plr_user_wallet_cart_national = $this->getPaliers($paliers_commission_wallets, 'user_wallet_cart_national');
|
|
|
|
|
$plr_user_wallet_cart_international = $this->getPaliers($paliers_commission_wallets, 'user_wallet_cart_international');
|
|
|
|
|
$plr_hyp_user_wallet_cart_national = $this->getPaliers($paliers_commission_wallets, 'hyp_user_wallet_cart_national');
|
|
|
|
|
$plr_hyp_user_wallet_cart_international = $this->getPaliers($paliers_commission_wallets, 'hyp_user_wallet_cart_international');
|
|
|
|
|
$plr_bank_user_wallet_cart_national = $this->getPaliers($paliers_commission_wallets, 'bank_user_wallet_cart_national');
|
|
|
|
|
$plr_bank_user_wallet_cart_international = $this->getPaliers($paliers_commission_wallets, 'bank_user_wallet_cart_international');
|
|
|
|
|
|
|
|
|
|
$frais = ($init_country != $final_country) ? $this->calculateFees($plr_user_wallet_cart_international, $request->montant) : $this->calculateFees($plr_user_wallet_cart_national, $request->montant);
|
|
|
|
|
|
|
|
|
|
$transaction->montant_net = $montantDepot = $transaction->montant - $frais;
|
|
|
|
|
// $body['amount'] = $this->toUSDAmount($montantDepot, $init_country);
|
|
|
|
|
$body['card_number'] = $user->numero_carte;
|
|
|
|
@ -364,9 +373,9 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
|
|
|
|
|
$walletUser->balance -= $transaction->montant;
|
|
|
|
|
//Emettre une trame SSL pour recharger le compte de la banque partenaire du montant de sa commission
|
|
|
|
|
$transaction->commission_banque = $frais * $config->taux_com_banque_envoi_wallet_carte_ilink / 100;
|
|
|
|
|
$transaction->commission_banque = ($init_country != $final_country) ? $this->calculateFees($plr_bank_user_wallet_cart_national, $request->montant, $frais) : $this->calculateFees($plr_bank_user_wallet_cart_international, $request->montant, $frais);
|
|
|
|
|
$transaction->commission_hyp = ($init_country != $final_country) ? $this->calculateFees($plr_hyp_user_wallet_cart_national, $request->montant, $frais) : $this->calculateFees($plr_hyp_user_wallet_cart_international, $request->montant, $frais);
|
|
|
|
|
|
|
|
|
|
$transaction->commission_hyp = $frais * $config->taux_com_hyp_envoi_wallet_carte_ilink / 100;
|
|
|
|
|
$walletHyperviseur->balance_com += $transaction->commission_hyp;
|
|
|
|
|
$transaction->id_wallet_hyp = $walletHyperviseur->id;
|
|
|
|
|
$transaction->frais = $frais;
|
|
|
|
@ -631,7 +640,16 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
$transaction->expiration_date = $user->expiration_date;
|
|
|
|
|
$transaction->numero_carte = $user->numero_carte;
|
|
|
|
|
|
|
|
|
|
$frais = $request->montant * $config->taux_com_user_carte_wallet / 100;
|
|
|
|
|
$final_country = $request->input('final_country');
|
|
|
|
|
$transaction->final_country = $final_country;
|
|
|
|
|
$plr_user_cart_wallet_national = $this->getPaliers($paliers_commission_wallets, 'user_cart_wallet_national');
|
|
|
|
|
$plr_user_cart_wallet_international = $this->getPaliers($paliers_commission_wallets, 'user_cart_wallet_international');
|
|
|
|
|
$plr_hyp_user_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'hyp_user_cart_cash_national');
|
|
|
|
|
$plr_hyp_user_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'hyp_user_cart_cash_international');
|
|
|
|
|
$plr_bank_user_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'bank_user_cart_cash_national');
|
|
|
|
|
$plr_bank_user_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'bank_user_cart_cash_international');
|
|
|
|
|
|
|
|
|
|
$frais = ($init_country != $final_country) ? $this->calculateFees($plr_user_cart_wallet_international, $request->montant) : $this->calculateFees($plr_user_cart_wallet_national, $request->montant);
|
|
|
|
|
|
|
|
|
|
$transaction->montant_net = $montantRetrait = $transaction->montant + $frais;
|
|
|
|
|
// $body['amount'] = $this->toUSDAmount($montantRetrait, $init_country);
|
|
|
|
@ -653,11 +671,11 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
$response = json_decode($response->getBody()->getContents(), true)["response"];
|
|
|
|
|
$transaction->pspReference = $response["pspReference"];
|
|
|
|
|
|
|
|
|
|
$transaction->commission_banque = $commissionBanque = $frais * $config->taux_com_banque_retrait_carte_cash_ilink / 100;
|
|
|
|
|
$transaction->commission_banque = ($init_country != $final_country) ? $this->calculateFees($plr_bank_user_cart_cash_international, $request->montant, $frais) : $this->calculateFees($plr_bank_user_cart_cash_national, $request->montant, $frais);
|
|
|
|
|
//Emettre une trame SSL pour recharger le compte de la banque partenaire du montant de sa commission
|
|
|
|
|
|
|
|
|
|
$walletUser->balance += $transaction->montant;
|
|
|
|
|
$transaction->commission_hyp = $frais * $config->taux_com_hyp_retrait_carte_cash_ilink / 100;
|
|
|
|
|
$transaction->commission_hyp = ($init_country != $final_country) ? $this->calculateFees($plr_hyp_user_cart_cash_national, $request->montant, $frais) : $this->calculateFees($plr_hyp_user_cart_cash_international, $request->montant, $frais);
|
|
|
|
|
$walletHyperviseur->balance_com += $transaction->commission_hyp;
|
|
|
|
|
$transaction->id_wallet_hyp = $walletHyperviseur->id;
|
|
|
|
|
$transaction->frais = $frais;
|
|
|
|
@ -688,9 +706,18 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
|
|
|
|
|
$transaction->expiration_date = $user->expiration_date;
|
|
|
|
|
$transaction->numero_carte = $user->numero_carte;
|
|
|
|
|
$transaction->final_country = $init_country;
|
|
|
|
|
// $transaction->final_country = $init_country;
|
|
|
|
|
$final_country = $request->input('final_country');
|
|
|
|
|
$transaction->final_country = $final_country;
|
|
|
|
|
$plr_user_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'user_cart_cash_national');
|
|
|
|
|
$plr_user_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'user_cart_cash_international');
|
|
|
|
|
$plr_hyp_user_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'hyp_user_cart_cash_national');
|
|
|
|
|
$plr_hyp_user_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'hyp_user_cart_cash_international');
|
|
|
|
|
$plr_bank_user_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'bank_user_cart_cash_national');
|
|
|
|
|
$plr_bank_user_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'bank_user_cart_cash_international');
|
|
|
|
|
|
|
|
|
|
$frais = ($init_country != $final_country) ? $this->calculateFees($plr_user_cart_cash_international, $request->montant) : $this->calculateFees($plr_user_cart_cash_national, $request->montant);
|
|
|
|
|
|
|
|
|
|
$frais = $request->montant * $config->taux_com_user_carte_cash / 100;
|
|
|
|
|
$transaction->montant_net = $montantRetrait = $transaction->montant + $frais;
|
|
|
|
|
$transaction->montant_net_final_country = $transaction->montant;
|
|
|
|
|
// $body['amount'] = $this->toUSDAmount($montantRetrait, $init_country);
|
|
|
|
@ -711,7 +738,7 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
$response = json_decode($response->getBody()->getContents(), true)["response"];
|
|
|
|
|
$transaction->pspReference = $response["pspReference"];
|
|
|
|
|
|
|
|
|
|
$transaction->commission_banque = $commissionBanque = $frais * $config->taux_com_banque_retrait_carte_cash_ilink / 100;
|
|
|
|
|
$transaction->commission_banque = ($init_country != $final_country) ? $this->calculateFees($plr_bank_user_cart_cash_international, $request->montant, $frais) : $this->calculateFees($plr_bank_user_cart_cash_national, $request->montant, $frais);
|
|
|
|
|
//Emettre une trame SSL pour recharger le compte de la banque partenaire du montant de sa commission
|
|
|
|
|
|
|
|
|
|
$code_retrait = $this->random_string();
|
|
|
|
@ -719,7 +746,7 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
$transaction->encrypted_code_retrait = $hash['encrypted'];
|
|
|
|
|
$transaction->code_retrait_salt = $hash['salt'];
|
|
|
|
|
|
|
|
|
|
$transaction->commission_hyp = $frais * $config->taux_com_hyp_retrait_carte_cash_ilink / 100;
|
|
|
|
|
$transaction->commission_hyp = ($init_country != $final_country) ? $this->calculateFees($plr_hyp_user_cart_cash_national, $request->montant, $frais) : $this->calculateFees($plr_hyp_user_cart_cash_international, $request->montant, $frais);
|
|
|
|
|
$walletHyperviseur->balance_com += $transaction->commission_hyp;
|
|
|
|
|
$transaction->id_wallet_hyp = $walletHyperviseur->id;
|
|
|
|
|
$transaction->frais = $frais;
|
|
|
|
@ -779,9 +806,26 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
$emetteur = $transaction->wallet_user ? $transaction->wallet_user->user->lastname . ' ' . $transaction->wallet_user->user->firstname : $transaction->prenom_emetteur . ' ' . $transaction->nom_emetteur;
|
|
|
|
|
$destinataire = in_array($transaction->type, [9, 11]) ? $emetteur : $transaction->prenom_destinataire . ' ' . $transaction->nom_destinataire;
|
|
|
|
|
|
|
|
|
|
$transactionRetrait->commission_ag = floatval($commissionHyp * $config->taux_com_ag_retrait_cash / 100);
|
|
|
|
|
$transactionRetrait->commission_sup = floatval($commissionHyp * $config->taux_com_sup_retrait_cash / 100);
|
|
|
|
|
$transactionRetrait->commission_hyp = $commissionHyp - $transactionRetrait->commission_ag - $transactionRetrait->commission_sup;
|
|
|
|
|
// $transactionRetrait->commission_ag = floatval($commissionHyp * $config->taux_com_ag_retrait_cash / 100);
|
|
|
|
|
// $transactionRetrait->commission_sup = floatval($commissionHyp * $config->taux_com_sup_retrait_cash / 100);
|
|
|
|
|
// $transactionRetrait->commission_hyp = $commissionHyp - $transactionRetrait->commission_ag - $transactionRetrait->commission_sup;
|
|
|
|
|
|
|
|
|
|
// Commissions
|
|
|
|
|
$final_country = $transaction->final_country;
|
|
|
|
|
$plr_agent_wallet_cash_national = $this->getPaliers($paliers_commission_wallets, 'agent_wallet_cash_national');
|
|
|
|
|
$plr_agent_wallet_cash_international = $this->getPaliers($paliers_commission_wallets, 'agent_wallet_cash_international');
|
|
|
|
|
$plr_sup_wallet_cash_national = $this->getPaliers($paliers_commission_wallets, 'sup_wallet_cash_national');
|
|
|
|
|
$plr_sup_wallet_cash_international = $this->getPaliers($paliers_commission_wallets, 'sup_wallet_cash_international');
|
|
|
|
|
$plr_customer_wallet_cash_national = $this->getPaliers($paliers_commission_wallets, 'customer_wallet_cash_national');
|
|
|
|
|
$plr_customer_wallet_cash_international = $this->getPaliers($paliers_commission_wallets, 'customer_wallet_cash_international');
|
|
|
|
|
|
|
|
|
|
//TODO commission client
|
|
|
|
|
$commission_customer = ($init_country != $final_country) ? $this->calculateFees($plr_customer_wallet_cash_international, $request->montant) : $this->calculateFees($plr_customer_wallet_cash_national, $request->montant);
|
|
|
|
|
$transactionRetrait->commission_ag = ($init_country != $final_country) ? $this->calculateFees($plr_agent_wallet_cash_international, $request->montant) : $this->calculateFees($plr_agent_wallet_cash_national, $request->montant);
|
|
|
|
|
$transactionRetrait->commission_sup = ($init_country != $final_country) ? $this->calculateFees($plr_sup_wallet_cash_international, $request->montant, $transactionRetrait->commission_ag) : $this->calculateFees($plr_sup_wallet_cash_national, $request->montant, $transactionRetrait->commission_ag);
|
|
|
|
|
$transactionRetrait->commission_hyp = $commission_customer - $transactionRetrait->commission_ag - $transactionRetrait->commission_sup;
|
|
|
|
|
$montantNet -= $commission_customer;
|
|
|
|
|
|
|
|
|
|
$walletAgent->balance_princ += $montantNet;
|
|
|
|
|
$walletAgent->balance_com += $transactionRetrait->commission_ag;
|
|
|
|
|
$walletSuperviseur->balance_com += $transactionRetrait->commission_sup;
|
|
|
|
@ -831,9 +875,21 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
if (!$expiration_date)
|
|
|
|
|
$expiration_date = new DateTime();
|
|
|
|
|
$transaction->expiration_date = $expiration_date;
|
|
|
|
|
$transaction->final_country = $init_country;
|
|
|
|
|
$transaction->final_country = $request->final_country;
|
|
|
|
|
|
|
|
|
|
$frais = floatval($request->montant * $config->taux_com_wallet_ag_carte_cash / 100);
|
|
|
|
|
$final_country = $request->final_country;
|
|
|
|
|
$plr_customer_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'customer_cart_cash_national');
|
|
|
|
|
$plr_customer_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'customer_cart_cash_international');
|
|
|
|
|
$plr_agent_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'agent_cart_cash_national');
|
|
|
|
|
$plr_agent_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'agent_cart_cash_international');
|
|
|
|
|
$plr_sup_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'sup_cart_cash_national');
|
|
|
|
|
$plr_sup_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'sup_cart_cash_international');
|
|
|
|
|
$plr_hyp_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'hyp_cart_cash_national');
|
|
|
|
|
$plr_hyp_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'hyp_cart_cash_international');
|
|
|
|
|
$plr_bank_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'bank_cart_cash_national');
|
|
|
|
|
$plr_bank_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'bank_cart_cash_international');
|
|
|
|
|
|
|
|
|
|
$frais = ($init_country != $final_country) ? $this->calculateFees($plr_customer_cart_cash_international, $request->montant) : $this->calculateFees($plr_customer_cart_cash_national, $request->montant);
|
|
|
|
|
$montantRetrait = $transaction->montant + $frais;
|
|
|
|
|
$transaction->montant_net = $montantRetrait;
|
|
|
|
|
// $body['amount'] = $this->toUSDAmount($montantRetrait, $init_country);
|
|
|
|
@ -853,7 +909,7 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
$response = json_decode($response->getBody()->getContents(), true)["response"];
|
|
|
|
|
$transaction->pspReference = $response["pspReference"];
|
|
|
|
|
|
|
|
|
|
$banqueCommission = floatval($frais * $config->taux_com_banque_retrait_carte_cash / 100);
|
|
|
|
|
$banqueCommission = ($init_country != $final_country) ? $this->calculateFees($plr_bank_cart_cash_international, $request->montant, $frais) : $this->calculateFees($plr_bank_cart_cash_national, $request->montant, $frais);
|
|
|
|
|
$transaction->commission_banque = $banqueCommission;
|
|
|
|
|
// 2---> Emmètre via API sécurisé SSL une requête de débit de notre
|
|
|
|
|
//compte marchand du (Part de la banque partenaire en %
|
|
|
|
@ -863,9 +919,9 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
|
|
|
|
|
$walletAgent->balance_princ += $transaction->montant;
|
|
|
|
|
|
|
|
|
|
$agentCommission = floatval($frais * $config->taux_com_ag_retrait_carte_cash / 100);
|
|
|
|
|
$superviseurCommission = floatval($frais * $config->taux_com_sup_retrait_carte_cash / 100);
|
|
|
|
|
$hyperviseurCommission = floatval($frais * $config->taux_com_hyp_retrait_carte_cash / 100);
|
|
|
|
|
$agentCommission = ($init_country != $final_country) ? $this->calculateFees($plr_agent_cart_cash_international, $request->montant, $frais) : $this->calculateFees($plr_agent_cart_cash_national, $request->montant, $frais);
|
|
|
|
|
$superviseurCommission = ($init_country != $final_country) ? $this->calculateFees($plr_sup_cart_cash_international, $request->montant, $frais) : $this->calculateFees($plr_sup_cart_cash_national, $request->montant, $frais);
|
|
|
|
|
$hyperviseurCommission = ($init_country != $final_country) ? $this->calculateFees($plr_hyp_cart_cash_international, $request->montant, $frais) : $this->calculateFees($plr_hyp_cart_cash_national, $request->montant, $frais);
|
|
|
|
|
|
|
|
|
|
$walletAgent->balance_com += $agentCommission;
|
|
|
|
|
$transaction->commission_ag = $agentCommission;
|
|
|
|
@ -913,9 +969,15 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
$transaction->montant_net = $montantDepot;
|
|
|
|
|
$transaction->montant_net_final_country = $this->toMoneyAmount($montantDepot, $init_country, $final_country);
|
|
|
|
|
$walletUser->balance += $transaction->montant_net_final_country;
|
|
|
|
|
$commisionAgent = floatval($frais * $config->taux_com_ag_envoi_cash / 100);
|
|
|
|
|
$commisionSuper = floatval($frais * $config->taux_com_sup_envoi_cash / 100);
|
|
|
|
|
$commisionHyper = floatval($frais * $config->taux_com_hyp_envoi_cash / 100);
|
|
|
|
|
|
|
|
|
|
$plr_agent_cash_wallet_or_cash_national = $this->getPaliers($paliers_commission_wallets, 'agent_cash_wallet_or_cash_national');
|
|
|
|
|
$plr_agent_cash_wallet_or_cash_international = $this->getPaliers($paliers_commission_wallets, 'agent_cash_wallet_or_cash_international');
|
|
|
|
|
$plr_sup_cash_wallet_or_cash_national = $this->getPaliers($paliers_commission_wallets, 'sup_cash_wallet_or_cash_national');
|
|
|
|
|
$plr_sup_cash_wallet_or_cash_international = $this->getPaliers($paliers_commission_wallets, 'sup_cash_wallet_or_cash_international');
|
|
|
|
|
|
|
|
|
|
$commisionAgent = ($init_country != $final_country) ? $this->calculateFees($plr_agent_cash_wallet_or_cash_international, $request->montant) : $this->calculateFees($plr_agent_cash_wallet_or_cash_national, $request->montant);
|
|
|
|
|
$commisionSuper = ($init_country != $final_country) ? $this->calculateFees($plr_sup_cash_wallet_or_cash_international, $request->montant, $commisionAgent) : $this->calculateFees($plr_sup_cash_wallet_or_cash_national, $request->montant, $commisionAgent);
|
|
|
|
|
$commisionHyper = $frais - $commisionAgent - $commisionSuper;
|
|
|
|
|
|
|
|
|
|
$walletAgent->balance_princ -= $transaction->montant;
|
|
|
|
|
$walletAgent->balance_com += $commisionAgent;
|
|
|
|
@ -973,9 +1035,17 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
//Emettre une trame securise pour crediter le wallet utilisateur
|
|
|
|
|
// $walletUser->balance += $transaction->montant_net_final_country;
|
|
|
|
|
// $transaction->id_destinataire = r
|
|
|
|
|
$commisionAgent = floatval($transaction->part_reseau_emetteur * $config->taux_com_ag_envoi_cash / 100);
|
|
|
|
|
$commisionSuper = floatval($transaction->part_reseau_emetteur * $config->taux_com_sup_envoi_cash / 100);
|
|
|
|
|
$commisionHyper = floatval($transaction->part_reseau_emetteur * $config->taux_com_hyp_envoi_cash / 100);
|
|
|
|
|
|
|
|
|
|
$final_country = $request->final_country;
|
|
|
|
|
$plr_agent_cash_wallet_or_cash_national = $this->getPaliers($paliers_commission_wallets, 'agent_cash_wallet_or_cash_national');
|
|
|
|
|
$plr_agent_cash_wallet_or_cash_international = $this->getPaliers($paliers_commission_wallets, 'agent_cash_wallet_or_cash_international');
|
|
|
|
|
$plr_sup_cash_wallet_or_cash_national = $this->getPaliers($paliers_commission_wallets, 'sup_cash_wallet_or_cash_national');
|
|
|
|
|
$plr_sup_cash_wallet_or_cash_international = $this->getPaliers($paliers_commission_wallets, 'sup_cash_wallet_or_cash_international');
|
|
|
|
|
|
|
|
|
|
$commisionAgent = ($init_country != $final_country) ? $this->calculateFees($plr_agent_cash_wallet_or_cash_international, $request->montant) : $this->calculateFees($plr_agent_cash_wallet_or_cash_national, $request->montant);
|
|
|
|
|
$commisionSuper = ($init_country != $final_country) ? $this->calculateFees($plr_sup_cash_wallet_or_cash_international, $request->montant, $commisionAgent) : $this->calculateFees($plr_sup_cash_wallet_or_cash_national, $request->montant, $commisionAgent);
|
|
|
|
|
$commisionHyper = $transaction->part_reseau_emetteur - $commisionAgent - $commisionSuper;
|
|
|
|
|
|
|
|
|
|
$walletAgent->balance_princ -= $transaction->montant;
|
|
|
|
|
$walletAgent->balance_com += $commisionAgent;
|
|
|
|
|
$transaction->commission_ag = $commisionAgent;
|
|
|
|
@ -1015,9 +1085,22 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
if (!$expiration_date)
|
|
|
|
|
$expiration_date = new DateTime();
|
|
|
|
|
$transaction->expiration_date = $expiration_date;
|
|
|
|
|
$transaction->final_country = $init_country;
|
|
|
|
|
$transaction->final_country = $request->final_country;
|
|
|
|
|
|
|
|
|
|
$final_country = $request->final_country;
|
|
|
|
|
$plr_customer_cash_cart_national = $this->getPaliers($paliers_commission_wallets, 'customer_cash_cart_national');
|
|
|
|
|
$plr_customer_cash_cart_international = $this->getPaliers($paliers_commission_wallets, 'customer_cash_cart_international');
|
|
|
|
|
$plr_agent_cash_cart_national = $this->getPaliers($paliers_commission_wallets, 'agent_cash_cart_national');
|
|
|
|
|
$plr_agent_cash_cart_international = $this->getPaliers($paliers_commission_wallets, 'agent_cash_cart_international');
|
|
|
|
|
$plr_sup_cash_cart_national = $this->getPaliers($paliers_commission_wallets, 'sup_cash_cart_national');
|
|
|
|
|
$plr_sup_cash_cart_international = $this->getPaliers($paliers_commission_wallets, 'sup_cash_cart_international');
|
|
|
|
|
$plr_hyp_cash_cart_national = $this->getPaliers($paliers_commission_wallets, 'hyp_cash_cart_national');
|
|
|
|
|
$plr_hyp_cash_cart_international = $this->getPaliers($paliers_commission_wallets, 'hyp_cash_cart_international');
|
|
|
|
|
$plr_bank_cash_cart_national = $this->getPaliers($paliers_commission_wallets, 'bank_cash_cart_national');
|
|
|
|
|
$plr_bank_cash_cart_international = $this->getPaliers($paliers_commission_wallets, 'bank_cash_cart_international');
|
|
|
|
|
|
|
|
|
|
$frais = ($init_country != $final_country) ? $this->calculateFees($plr_customer_cash_cart_international, $request->montant) : $this->calculateFees($plr_customer_cash_cart_national, $request->montant);
|
|
|
|
|
|
|
|
|
|
$frais = $request->montant * $config->taux_com_wallet_ag_envoi_cash_carte / 100;
|
|
|
|
|
$montantDepot = $transaction->montant - $frais;
|
|
|
|
|
$transaction->montant_net = $montantDepot;
|
|
|
|
|
// $body['amount'] = $this->toUSDAmount($montantDepot, $init_country);;
|
|
|
|
@ -1038,7 +1121,7 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
$response = json_decode($response->getBody()->getContents(), true)["response"];
|
|
|
|
|
$transaction->pspReference = $response["pspReference"];
|
|
|
|
|
|
|
|
|
|
$banqueCommission = floatval($frais * $config->taux_com_banque_depot_cash_carte / 100);
|
|
|
|
|
$banqueCommission = ($init_country != $final_country) ? $this->calculateFees($plr_bank_cash_cart_international, $request->montant, $frais) : $this->calculateFees($plr_bank_cash_cart_national, $request->montant, $frais);
|
|
|
|
|
$transaction->commission_banque = $banqueCommission;
|
|
|
|
|
// 2---> Emmètre via API sécurisé SSL une requête de débit de notre
|
|
|
|
|
//compte marchand du (Part de la banque partenaire en %
|
|
|
|
@ -1048,9 +1131,9 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
|
|
|
|
|
$walletAgent->balance_princ -= $transaction->montant;
|
|
|
|
|
|
|
|
|
|
$agentCommission = floatval($frais * $config->taux_com_ag_depot_cash_carte / 100);
|
|
|
|
|
$superviseurCommission = floatval($frais * $config->taux_com_sup_depot_cash_carte / 100);
|
|
|
|
|
$hyperviseurCommission = floatval($frais * $config->taux_com_hyp_depot_cash_carte / 100);
|
|
|
|
|
$agentCommission = ($init_country != $final_country) ? $this->calculateFees($plr_agent_cash_cart_international, $request->montant, $frais) : $this->calculateFees($plr_agent_cash_cart_national, $request->montant, $frais);
|
|
|
|
|
$superviseurCommission = ($init_country != $final_country) ? $this->calculateFees($plr_sup_cash_cart_international, $request->montant, $frais) : $this->calculateFees($plr_sup_cash_cart_national, $request->montant, $frais);
|
|
|
|
|
$hyperviseurCommission = ($init_country != $final_country) ? $this->calculateFees($plr_hyp_cash_cart_international, $request->montant, $frais) : $this->calculateFees($plr_hyp_cash_cart_national, $request->montant, $frais);
|
|
|
|
|
|
|
|
|
|
$walletAgent->balance_com += $agentCommission;
|
|
|
|
|
$transaction->commission_ag = $agentCommission;
|
|
|
|
@ -1103,9 +1186,15 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
$transaction->part_reseau_emetteur = $frais;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$commisionAgent = floatval($transaction->part_reseau_emetteur * $config->taux_com_ag_envoi_cash / 100);
|
|
|
|
|
$commisionSuper = floatval($transaction->part_reseau_emetteur * $config->taux_com_sup_envoi_cash / 100);
|
|
|
|
|
$commisionHyper = floatval($transaction->part_reseau_emetteur * $config->taux_com_hyp_envoi_cash / 100);
|
|
|
|
|
$final_country = $request->final_country;
|
|
|
|
|
$plr_agent_cash_wallet_or_cash_national = $this->getPaliers($paliers_commission_wallets, 'agent_cash_wallet_or_cash_national');
|
|
|
|
|
$plr_agent_cash_wallet_or_cash_international = $this->getPaliers($paliers_commission_wallets, 'agent_cash_wallet_or_cash_international');
|
|
|
|
|
$plr_sup_cash_wallet_or_cash_national = $this->getPaliers($paliers_commission_wallets, 'sup_cash_wallet_or_cash_national');
|
|
|
|
|
$plr_sup_cash_wallet_or_cash_international = $this->getPaliers($paliers_commission_wallets, 'sup_cash_wallet_or_cash_international');
|
|
|
|
|
|
|
|
|
|
$commisionAgent = ($init_country != $final_country) ? $this->calculateFees($plr_agent_cash_wallet_or_cash_international, $request->montant) : $this->calculateFees($plr_agent_cash_wallet_or_cash_national, $request->montant);
|
|
|
|
|
$commisionSuper = ($init_country != $final_country) ? $this->calculateFees($plr_sup_cash_wallet_or_cash_international, $request->montant, $commisionAgent) : $this->calculateFees($plr_sup_cash_wallet_or_cash_national, $request->montant, $commisionAgent);
|
|
|
|
|
$commisionHyper = $transaction->part_reseau_emetteur - $commisionAgent - $commisionSuper;
|
|
|
|
|
|
|
|
|
|
$transaction->id_transaction = $this->getTransactionID();
|
|
|
|
|
if ($configPayeur->type == 'ilink') {
|
|
|
|
@ -1643,22 +1732,24 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
return $tax->destination == 'international' && $tax->categorie == 'wallet';
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
$paliers_config_wallets = $config->paliers_config_wallets->all();
|
|
|
|
|
$paliers_commission_wallets = $config->paliers_commissions_wallets->all();
|
|
|
|
|
|
|
|
|
|
$plr_user_wallet_wallet = $this->getPaliers($config->paliers_config_wallets->all(), "user_wallet_wallet_international");
|
|
|
|
|
$plr_user_wallet_cash = $this->getPaliers($config->paliers_config_wallets->all(), "user_wallet_cash_international");
|
|
|
|
|
$plr_agent_depot_wallet_ilink = $this->getPaliers($config->paliers_config_wallets->all(), "agent_depot_wallet_ilink_international");
|
|
|
|
|
$plr_agent_depot_autre_wallet = $this->getPaliers($config->paliers_config_wallets->all(), "agent_depot_autre_wallet_international");
|
|
|
|
|
$plr_agent_cash_cash = $this->getPaliers($config->paliers_config_wallets->all(), "agent_cash_cash_international");
|
|
|
|
|
$plr_user_wallet_wallet = $this->getPaliers($paliers_config_wallets, "user_wallet_wallet_international");
|
|
|
|
|
$plr_user_wallet_cash = $this->getPaliers($paliers_config_wallets, "user_wallet_cash_international");
|
|
|
|
|
$plr_agent_depot_wallet_ilink = $this->getPaliers($paliers_config_wallets, "agent_depot_wallet_ilink_international");
|
|
|
|
|
$plr_agent_depot_autre_wallet = $this->getPaliers($paliers_config_wallets, "agent_depot_autre_wallet_international");
|
|
|
|
|
$plr_agent_cash_cash = $this->getPaliers($paliers_config_wallets, "agent_cash_cash_international");
|
|
|
|
|
|
|
|
|
|
$plr_user_wallet_wallet_national = $this->getPaliers($config->paliers_config_wallets->all(), "user_wallet_wallet_national");
|
|
|
|
|
$plr_user_wallet_cash_national = $this->getPaliers($config->paliers_config_wallets->all(), "user_wallet_cash_national");
|
|
|
|
|
$plr_agent_depot_wallet_ilink_national = $this->getPaliers($config->paliers_config_wallets->all(), "agent_depot_wallet_ilink_national");
|
|
|
|
|
$plr_agent_depot_autre_wallet_national = $this->getPaliers($config->paliers_config_wallets->all(), "agent_depot_autre_wallet_national");
|
|
|
|
|
$plr_agent_cash_cash_national = $this->getPaliers($config->paliers_config_wallets->all(), "agent_cash_cash_national");
|
|
|
|
|
$plr_user_wallet_wallet_national = $this->getPaliers($paliers_config_wallets, "user_wallet_wallet_national");
|
|
|
|
|
$plr_user_wallet_cash_national = $this->getPaliers($paliers_config_wallets, "user_wallet_cash_national");
|
|
|
|
|
$plr_agent_depot_wallet_ilink_national = $this->getPaliers($paliers_config_wallets, "agent_depot_wallet_ilink_national");
|
|
|
|
|
$plr_agent_depot_autre_wallet_national = $this->getPaliers($paliers_config_wallets, "agent_depot_autre_wallet_national");
|
|
|
|
|
$plr_agent_cash_cash_national = $this->getPaliers($paliers_config_wallets, "agent_cash_cash_national");
|
|
|
|
|
switch ($request->type) {
|
|
|
|
|
case 1: //User - Envoi wallet à wallet
|
|
|
|
|
$this->validate($request, [
|
|
|
|
|
'final_country' => 'required|integer|min:0|not_in:0',
|
|
|
|
|
'final_country' => 'required|integer|exists:countries,id',
|
|
|
|
|
'id_destinataire' => 'required_without:phone_destinataire',
|
|
|
|
|
'network_destinataire' => 'required|integer|min:0|not_in:0',
|
|
|
|
|
]);
|
|
|
|
@ -1677,7 +1768,13 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
$data['montant_net_final'] = $this->toMoneyWithCurrency($data['montant_net_init'], $init_country, $request->final_country);
|
|
|
|
|
break;
|
|
|
|
|
case 2: //User - Envoi de wallet à carte
|
|
|
|
|
$frais = $request->montant * $config->taux_com_user_wallet_carte / 100;
|
|
|
|
|
$this->validate($request, [
|
|
|
|
|
'final_country' => 'required|integer|exists:countries,id'
|
|
|
|
|
]);
|
|
|
|
|
$final_country = $request->input('final_country');
|
|
|
|
|
$plr_user_wallet_cart_national = $this->getPaliers($paliers_commission_wallets, 'user_wallet_cart_national');
|
|
|
|
|
$plr_user_wallet_cart_international = $this->getPaliers($paliers_commission_wallets, 'user_wallet_cart_international');
|
|
|
|
|
$frais = ($init_country != $final_country) ? $this->calculateFees($plr_user_wallet_cart_international, $request->montant) : $this->calculateFees($plr_user_wallet_cart_national, $request->montant);
|
|
|
|
|
$data['frais'] = round($frais, 2);
|
|
|
|
|
$data['montant_net'] = round($request->montant - $data['frais'], 2);
|
|
|
|
|
break;
|
|
|
|
@ -1698,17 +1795,35 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
$data['montant_net'] = round($request->montant - $data['frais'], 2);
|
|
|
|
|
break;
|
|
|
|
|
case 10: //User - Retrait de carte vers wallet
|
|
|
|
|
$frais = $request->montant * $config->taux_com_user_carte_wallet / 100;;
|
|
|
|
|
$this->validate($request, [
|
|
|
|
|
'final_country' => 'required|integer|exists:countries,id'
|
|
|
|
|
]);
|
|
|
|
|
$final_country = $request->input('final_country');
|
|
|
|
|
$plr_user_cart_wallet_national = $this->getPaliers($paliers_commission_wallets, 'user_cart_wallet_national');
|
|
|
|
|
$plr_user_cart_wallet_international = $this->getPaliers($paliers_commission_wallets, 'user_cart_wallet_international');
|
|
|
|
|
$frais = ($init_country != $final_country) ? $this->calculateFees($plr_user_cart_wallet_international, $request->montant) : $this->calculateFees($plr_user_cart_wallet_national, $request->montant);
|
|
|
|
|
$data['frais'] = round($frais, 2);
|
|
|
|
|
$data['montant_net'] = round($request->montant + $data['frais'], 2);
|
|
|
|
|
break;
|
|
|
|
|
case 11: // User - Retrait de carte vers cash
|
|
|
|
|
$frais = $request->montant * $config->taux_com_user_carte_cash / 100;
|
|
|
|
|
$this->validate($request, [
|
|
|
|
|
'final_country' => 'required|integer|exists:countries,id'
|
|
|
|
|
]);
|
|
|
|
|
$final_country = $request->input('final_country');
|
|
|
|
|
$plr_user_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'user_cart_cash_national');
|
|
|
|
|
$plr_user_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'user_cart_cash_international');
|
|
|
|
|
$frais = ($init_country != $final_country) ? $this->calculateFees($plr_user_cart_cash_international, $request->montant) : $this->calculateFees($plr_user_cart_cash_national, $request->montant);
|
|
|
|
|
$data['frais'] = round($frais, 2);
|
|
|
|
|
$data['montant_net'] = round($request->montant + $data['frais'], 2);
|
|
|
|
|
break;
|
|
|
|
|
case 13: // Agent - Retrait de la carte vers cash
|
|
|
|
|
$frais = $request->montant * $config->taux_com_wallet_ag_carte_cash / 100;
|
|
|
|
|
$this->validate($request, [
|
|
|
|
|
'final_country' => 'required|integer|exists:countries,id',
|
|
|
|
|
]);
|
|
|
|
|
$final_country = $request->input('final_country');
|
|
|
|
|
$plr_customer_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'customer_cart_cash_national');
|
|
|
|
|
$plr_customer_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'customer_cart_cash_international');
|
|
|
|
|
$frais = ($init_country != $final_country) ? $this->calculateFees($plr_customer_cart_cash_international, $request->montant) : $this->calculateFees($plr_customer_cart_cash_national, $request->montant);
|
|
|
|
|
$data['frais'] = round($frais, 2);
|
|
|
|
|
$data['montant_net'] = round($request->montant + $data['frais'], 2);
|
|
|
|
|
break;
|
|
|
|
@ -1728,7 +1843,7 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
break;
|
|
|
|
|
case 15: // Agent - Envoi de cash vers autre wallet
|
|
|
|
|
$this->validate($request, [
|
|
|
|
|
'final_country' => 'required|integer|min:0|not_in:0',
|
|
|
|
|
'final_country' => 'required|integer|exists:countries,id',
|
|
|
|
|
]);
|
|
|
|
|
$frais = ($init_country != $request->final_country) ? $this->calculateFees($plr_agent_depot_autre_wallet, $request->montant) : $this->calculateFees($plr_agent_depot_autre_wallet_national, $request->montant);
|
|
|
|
|
$taxe = ($init_country != $request->final_country) ? $this->calculateTax($taxesInternationales, $frais) : $this->calculateTax($taxesNationales, $frais);
|
|
|
|
@ -1737,13 +1852,19 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
$data['montant_net_final'] = $this->toMoneyWithCurrency($data['montant_net_init'], $init_country, $request->final_country);
|
|
|
|
|
break;
|
|
|
|
|
case 16: // Agent - Envoi de cash vers une carte visa
|
|
|
|
|
$frais = $request->montant * $config->taux_com_wallet_ag_envoi_cash_carte / 100;
|
|
|
|
|
$this->validate($request, [
|
|
|
|
|
'final_country' => 'required|integer|exists:countries,id'
|
|
|
|
|
]);
|
|
|
|
|
$final_country = $request->input('final_country');
|
|
|
|
|
$plr_customer_cash_cart_national = $this->getPaliers($paliers_commission_wallets, 'customer_cash_cart_national');
|
|
|
|
|
$plr_customer_cash_cart_international = $this->getPaliers($paliers_commission_wallets, 'customer_cash_cart_international');
|
|
|
|
|
$frais = ($init_country != $final_country) ? $this->calculateFees($plr_customer_cash_cart_international, $request->montant) : $this->calculateFees($plr_customer_cash_cart_national, $request->montant);
|
|
|
|
|
$data['frais'] = round($frais, 2);
|
|
|
|
|
$data['montant_net'] = round($request->montant - $data['frais'], 2);
|
|
|
|
|
break;
|
|
|
|
|
case 17: // Agent - Envoi de cash vers cash
|
|
|
|
|
$this->validate($request, [
|
|
|
|
|
'final_country' => 'required|integer|min:0|not_in:0',
|
|
|
|
|
'final_country' => 'required|integer|exists:countries,id',
|
|
|
|
|
]);
|
|
|
|
|
$frais = ($init_country != $request->final_country) ? $this->calculateFees($plr_agent_cash_cash, $request->montant) : $this->calculateFees($plr_agent_cash_cash_national, $request->montant);
|
|
|
|
|
$taxe = ($init_country != $request->final_country) ? $this->calculateTax($taxesInternationales, $frais) : $this->calculateTax($taxesNationales, $frais);
|
|
|
|
@ -1752,7 +1873,7 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
$data['montant_net_final'] = $this->toMoneyWithCurrency($data['montant_net_init'], $init_country, $request->final_country);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
$net = isset($data['montant_net']) ? $data['montant_net'] : $data['montant_net_init'];
|
|
|
|
|
$net = $data['montant_net'] ?? $data['montant_net_init'];
|
|
|
|
|
if (isset($net))
|
|
|
|
|
if ($net < 0)
|
|
|
|
|
return $this->errorResponse(trans('errors.incorrect_net_amount'));
|
|
|
|
@ -1828,7 +1949,7 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
/**
|
|
|
|
|
* @throws AppException
|
|
|
|
|
*/
|
|
|
|
|
private function calculateFees(array $paliers, $montant)
|
|
|
|
|
private function calculateFees(array $paliers, $montant, $frais = null)
|
|
|
|
|
{
|
|
|
|
|
$size = sizeof($paliers);
|
|
|
|
|
$fees = 0;
|
|
|
|
@ -1844,7 +1965,11 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($palier) {
|
|
|
|
|
$fees = ($montant * $palier->taux / 100);
|
|
|
|
|
if (isset($frais)) {
|
|
|
|
|
// Pour le calcul par paliers des commissions uniquement
|
|
|
|
|
$montant = $frais;
|
|
|
|
|
}
|
|
|
|
|
$fees = round(($montant * $palier->taux / 100), 2);
|
|
|
|
|
} else {
|
|
|
|
|
throw new AppException(trans('errors.amount_not_allowed', ['min' => floatval($min), 'max' => floatval($max)]));
|
|
|
|
|
}
|
|
|
|
|