|
|
@ -129,17 +129,22 @@ class iLinkTransactionController extends Controller
|
|
|
|
$transaction->frais = $frais = ($init_country != $request->final_country) ? $this->calculateFees($plr_user_wallet_wallet, $request->montant) : $this->calculateFees($plr_user_wallet_wallet_national, $request->montant);
|
|
|
|
$transaction->frais = $frais = ($init_country != $request->final_country) ? $this->calculateFees($plr_user_wallet_wallet, $request->montant) : $this->calculateFees($plr_user_wallet_wallet_national, $request->montant);
|
|
|
|
$transaction->taxe = $taxe = ($init_country != $request->final_country) ? $this->calculateTax($taxesInternationales, $frais) : $this->calculateTax($taxesNationales, $frais);
|
|
|
|
$transaction->taxe = $taxe = ($init_country != $request->final_country) ? $this->calculateTax($taxesInternationales, $frais) : $this->calculateTax($taxesNationales, $frais);
|
|
|
|
$transaction->montant_net = $montantDepot = $transaction->montant - $frais - $taxe;
|
|
|
|
$transaction->montant_net = $montantDepot = $transaction->montant - $frais - $taxe;
|
|
|
|
|
|
|
|
$transaction->montant_net_final_country = $this->toMoneyAmount($montantDepot, $init_country, $request->final_country);
|
|
|
|
$configPayeur = ConfigWallet::where('id_network', $request->network_destinataire)->firstOrFail();
|
|
|
|
$configPayeur = ConfigWallet::where('id_network', $request->network_destinataire)->firstOrFail();
|
|
|
|
|
|
|
|
|
|
|
|
$reseauPayeur = PayingNetwork::where('id_network', $request->network_destinataire)->where('id_configWallet', $config->id)->firstOrFail();
|
|
|
|
$reseauPayeur = PayingNetwork::where('id_network', $request->network_destinataire)->where('id_configWallet', $config->id)->first();
|
|
|
|
|
|
|
|
if (isset($reseauPayeur)) {
|
|
|
|
$transaction->part_reseau_payeur = $frais * $reseauPayeur->taux_partage / 100;
|
|
|
|
$transaction->part_reseau_payeur = $frais * $reseauPayeur->taux_partage / 100;
|
|
|
|
$transaction->part_reseau_emetteur = $frais - $transaction->part_reseau_payeur;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$transaction->montant_net_final_country = $this->toMoneyAmount($montantDepot, $init_country, $request->final_country);
|
|
|
|
|
|
|
|
$transaction->commission_hyp = $transaction->part_reseau_emetteur;
|
|
|
|
|
|
|
|
$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);
|
|
|
|
if (isset($reseauPayeur))
|
|
|
|
$transaction->part_reseau_emetteur = $frais - $transaction->part_reseau_payeur;
|
|
|
|
$reseauPayeur->balance_com += $transaction->part_reseau_payeur_final_country;
|
|
|
|
$reseauPayeur->balance_com += $transaction->part_reseau_payeur_final_country;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$transaction->part_reseau_payeur = 0;
|
|
|
|
|
|
|
|
$transaction->part_reseau_payeur_final_country = 0;
|
|
|
|
|
|
|
|
$transaction->part_reseau_emetteur = $frais;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$transaction->commission_hyp = $transaction->part_reseau_emetteur;
|
|
|
|
if ($configPayeur->type == 'ilink') {
|
|
|
|
if ($configPayeur->type == 'ilink') {
|
|
|
|
$destinataire = User::where('user_code', $request->id_destinataire)->first();
|
|
|
|
$destinataire = User::where('user_code', $request->id_destinataire)->first();
|
|
|
|
if ($destinataire) { // Si c'est un wallet ilink
|
|
|
|
if ($destinataire) { // Si c'est un wallet ilink
|
|
|
@ -157,7 +162,6 @@ class iLinkTransactionController extends Controller
|
|
|
|
//Hyperviseur payeur
|
|
|
|
//Hyperviseur payeur
|
|
|
|
$hyperviseurPayeur = AgentPlus::where('category', 'hyper')->where('network_id', $request->network_destinataire)->firstOrFail();
|
|
|
|
$hyperviseurPayeur = AgentPlus::where('category', 'hyper')->where('network_id', $request->network_destinataire)->firstOrFail();
|
|
|
|
if ($hyperviseurPayeur->id == $hyperviseur->id) { //Si c'est le reseau payeur est aussi emetteur
|
|
|
|
if ($hyperviseurPayeur->id == $hyperviseur->id) { //Si c'est le reseau payeur est aussi emetteur
|
|
|
|
$walletHyperviseur->balance_com += $transaction->part_reseau_payeur;
|
|
|
|
|
|
|
|
$transaction->id_wallet_hyp_payeur = $walletHyperviseur->id;
|
|
|
|
$transaction->id_wallet_hyp_payeur = $walletHyperviseur->id;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$wallet_agent_hypPayeur = WalletAgent::where('agent_id', $hyperviseurPayeur->id)->firstOrFail();
|
|
|
|
$wallet_agent_hypPayeur = WalletAgent::where('agent_id', $hyperviseurPayeur->id)->firstOrFail();
|
|
|
@ -256,23 +260,28 @@ class iLinkTransactionController extends Controller
|
|
|
|
$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);
|
|
|
|
$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);
|
|
|
|
$transaction->taxe = $taxe = ($init_country != $request->final_country) ? $this->calculateTax($taxesInternationales, $frais) : $this->calculateTax($taxesNationales, $frais);
|
|
|
|
$transaction->taxe = $taxe = ($init_country != $request->final_country) ? $this->calculateTax($taxesInternationales, $frais) : $this->calculateTax($taxesNationales, $frais);
|
|
|
|
$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);
|
|
|
|
$configPayeur = ConfigWallet::where('id_network', $request->network_destinataire)->firstOrFail();
|
|
|
|
$configPayeur = ConfigWallet::where('id_network', $request->network_destinataire)->firstOrFail();
|
|
|
|
|
|
|
|
|
|
|
|
$reseauPayeur = PayingNetwork::where('id_network', $request->network_destinataire)->where('id_configWallet', $config->id)->firstOrFail();
|
|
|
|
$reseauPayeur = PayingNetwork::where('id_network', $request->network_destinataire)->where('id_configWallet', $config->id)->first();
|
|
|
|
|
|
|
|
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_emetteur = $frais - $transaction->part_reseau_payeur;
|
|
|
|
$transaction->part_reseau_emetteur = $frais - $transaction->part_reseau_payeur;
|
|
|
|
|
|
|
|
$reseauPayeur->balance_com += $transaction->part_reseau_payeur_final_country;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$transaction->part_reseau_payeur = 0;
|
|
|
|
|
|
|
|
$transaction->part_reseau_payeur_final_country = 0;
|
|
|
|
|
|
|
|
$transaction->part_reseau_emetteur = $frais;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$transaction->montant_net_final_country = $this->toMoneyAmount($montantRetrait, $init_country, $request->final_country);
|
|
|
|
|
|
|
|
$transaction->commission_hyp = $transaction->part_reseau_emetteur;
|
|
|
|
$transaction->commission_hyp = $transaction->part_reseau_emetteur;
|
|
|
|
$transaction->commission_hyp_final_country = $this->toMoneyAmount($transaction->commission_hyp, $init_country, $request->final_country);
|
|
|
|
$transaction->commission_hyp_final_country = $this->toMoneyAmount($transaction->commission_hyp, $init_country, $request->final_country);
|
|
|
|
$transaction->part_reseau_payeur_final_country = $this->toMoneyAmount($transaction->part_reseau_payeur, $init_country, $request->final_country);
|
|
|
|
|
|
|
|
if (isset($reseauPayeur))
|
|
|
|
|
|
|
|
$reseauPayeur->balance_com += $transaction->part_reseau_payeur_final_country;
|
|
|
|
|
|
|
|
if ($configPayeur->type == 'ilink') {
|
|
|
|
if ($configPayeur->type == 'ilink') {
|
|
|
|
//Hyperviseur payeur
|
|
|
|
//Hyperviseur payeur
|
|
|
|
$hyperviseurPayeur = AgentPlus::where('category', 'hyper')->where('network_id', $request->network_destinataire)->firstOrFail();
|
|
|
|
$hyperviseurPayeur = AgentPlus::where('category', 'hyper')->where('network_id', $request->network_destinataire)->firstOrFail();
|
|
|
|
if ($hyperviseurPayeur->id == $hyperviseur->id) { //Si c'est le reseau payeur est aussi emetteur
|
|
|
|
if ($hyperviseurPayeur->id == $hyperviseur->id) { //Si c'est le reseau payeur est aussi emetteur
|
|
|
|
$walletHyperviseur->balance_com += $transaction->part_reseau_payeur;
|
|
|
|
|
|
|
|
$transaction->id_wallet_hyp_payeur = $walletHyperviseur->id;
|
|
|
|
$transaction->id_wallet_hyp_payeur = $walletHyperviseur->id;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$wallet_agent_hypPayeur = WalletAgent::where('agent_id', $hyperviseurPayeur->id)->firstOrFail();
|
|
|
|
$wallet_agent_hypPayeur = WalletAgent::where('agent_id', $hyperviseurPayeur->id)->firstOrFail();
|
|
|
@ -428,6 +437,7 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
|
|
|
|
|
|
|
$transaction->expiration_date = $user->expiration_date;
|
|
|
|
$transaction->expiration_date = $user->expiration_date;
|
|
|
|
$transaction->numero_carte = $user->numero_carte;
|
|
|
|
$transaction->numero_carte = $user->numero_carte;
|
|
|
|
|
|
|
|
$transaction->final_country = $init_country;
|
|
|
|
|
|
|
|
|
|
|
|
$frais = $request->montant * $config->taux_com_user_carte_cash / 100;
|
|
|
|
$frais = $request->montant * $config->taux_com_user_carte_cash / 100;
|
|
|
|
$transaction->montant_net = $montantRetrait = $transaction->montant - $frais;
|
|
|
|
$transaction->montant_net = $montantRetrait = $transaction->montant - $frais;
|
|
|
@ -478,9 +488,14 @@ class iLinkTransactionController extends Controller
|
|
|
|
if ($this->checkPassword($request->password, $agent->encrypted_password, $agent->salt)) {
|
|
|
|
if ($this->checkPassword($request->password, $agent->encrypted_password, $agent->salt)) {
|
|
|
|
$transaction = WalletIlinkTransaction::where('id_transaction', $request->id_transaction)->first();
|
|
|
|
$transaction = WalletIlinkTransaction::where('id_transaction', $request->id_transaction)->first();
|
|
|
|
if ($transaction) {
|
|
|
|
if ($transaction) {
|
|
|
|
|
|
|
|
//Verifier que le reseau payeur est de type iLink
|
|
|
|
|
|
|
|
if (in_array($transaction->type, [3, 17])){
|
|
|
|
|
|
|
|
$configPayeur = ConfigWallet::where('id_network', $request->network_destinataire)->firstOrFail();
|
|
|
|
|
|
|
|
if($configPayeur->type != 'ilink')
|
|
|
|
|
|
|
|
return $this->errorResponse(trans('errors.withdrawal_network_unauthorized'));
|
|
|
|
|
|
|
|
}
|
|
|
|
if ($transaction->status_retrait == 0) {
|
|
|
|
if ($transaction->status_retrait == 0) {
|
|
|
|
//Verifier que le pays de destinatation correspond au pays de retrait
|
|
|
|
//Verifier que le pays de destinatation correspond au pays de retrait
|
|
|
|
if ($transaction->type != 11)
|
|
|
|
|
|
|
|
if ($init_country != $transaction->final_country)
|
|
|
|
if ($init_country != $transaction->final_country)
|
|
|
|
return $this->errorResponse(trans('errors.operation_cannot_performed_in_country'));
|
|
|
|
return $this->errorResponse(trans('errors.operation_cannot_performed_in_country'));
|
|
|
|
if ($this->checkPassword($request->code_retrait, $transaction->encrypted_code_retrait, $transaction->code_retrait_salt)) {
|
|
|
|
if ($this->checkPassword($request->code_retrait, $transaction->encrypted_code_retrait, $transaction->code_retrait_salt)) {
|
|
|
@ -647,7 +662,9 @@ class iLinkTransactionController extends Controller
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 15: // Agent - Envoi de cash vers autre wallet
|
|
|
|
case 15: // Agent - Envoi de cash vers autre wallet
|
|
|
|
$this->validate($request, $transaction->cash_cash_rules());
|
|
|
|
$this->validate($request, array_merge($transaction->cash_cash_rules(), [
|
|
|
|
|
|
|
|
'id_destinataire' => 'required'
|
|
|
|
|
|
|
|
]));
|
|
|
|
$agent = AgentPlus::findOrFail($network_agent->agent_id);
|
|
|
|
$agent = AgentPlus::findOrFail($network_agent->agent_id);
|
|
|
|
if ($this->checkPassword($request->password, $agent->encrypted_password, $agent->salt)) {
|
|
|
|
if ($this->checkPassword($request->password, $agent->encrypted_password, $agent->salt)) {
|
|
|
|
if ($request->montant > $walletAgent->balance_princ)
|
|
|
|
if ($request->montant > $walletAgent->balance_princ)
|
|
|
@ -780,20 +797,26 @@ class iLinkTransactionController extends Controller
|
|
|
|
|
|
|
|
|
|
|
|
$configPayeur = ConfigWallet::where('id_network', $request->network_destinataire)->firstOrFail();
|
|
|
|
$configPayeur = ConfigWallet::where('id_network', $request->network_destinataire)->firstOrFail();
|
|
|
|
|
|
|
|
|
|
|
|
$reseauPayeur = PayingNetwork::where('id_network', $request->network_destinataire)->where('id_configWallet', $config->id)->firstOrFail();
|
|
|
|
$reseauPayeur = PayingNetwork::where('id_network', $request->network_destinataire)->where('id_configWallet', $config->id)->first();
|
|
|
|
|
|
|
|
if (isset($reseauPayeur)) {
|
|
|
|
$transaction->part_reseau_payeur = $frais * $reseauPayeur->taux_partage / 100;
|
|
|
|
$transaction->part_reseau_payeur = $frais * $reseauPayeur->taux_partage / 100;
|
|
|
|
$transaction->part_reseau_emetteur = $frais - $transaction->part_reseau_payeur;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$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);
|
|
|
|
if (isset($reseauPayeur))
|
|
|
|
$transaction->part_reseau_emetteur = $frais - $transaction->part_reseau_payeur;
|
|
|
|
$reseauPayeur->balance_com += $transaction->part_reseau_payeur_final_country;
|
|
|
|
$reseauPayeur->balance_com += $transaction->part_reseau_payeur_final_country;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$transaction->part_reseau_payeur = 0;
|
|
|
|
|
|
|
|
$transaction->part_reseau_payeur_final_country = 0;
|
|
|
|
|
|
|
|
$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);
|
|
|
|
|
|
|
|
|
|
|
|
if ($configPayeur->type == 'ilink') {
|
|
|
|
if ($configPayeur->type == 'ilink') {
|
|
|
|
//Hyperviseur payeur
|
|
|
|
//Hyperviseur payeur
|
|
|
|
$hyperviseurPayeur = AgentPlus::where('category', 'hyper')->where('network_id', $request->network_destinataire)->firstOrFail();
|
|
|
|
$hyperviseurPayeur = AgentPlus::where('category', 'hyper')->where('network_id', $request->network_destinataire)->firstOrFail();
|
|
|
|
if ($hyperviseurPayeur->id == $hyperviseur->id) { //Si c'est le reseau payeur est aussi emetteur
|
|
|
|
if ($hyperviseurPayeur->id == $hyperviseur->id) { //Si c'est le reseau payeur est aussi emetteur
|
|
|
|
$walletHyperviseur->balance_com += $transaction->part_reseau_payeur;
|
|
|
|
|
|
|
|
$transaction->id_wallet_hyp_payeur = $walletHyperviseur->id;
|
|
|
|
$transaction->id_wallet_hyp_payeur = $walletHyperviseur->id;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$wallet_agent_hypPayeur = WalletAgent::where('agent_id', $hyperviseurPayeur->id)->firstOrFail();
|
|
|
|
$wallet_agent_hypPayeur = WalletAgent::where('agent_id', $hyperviseurPayeur->id)->firstOrFail();
|
|
|
@ -809,9 +832,6 @@ class iLinkTransactionController extends Controller
|
|
|
|
// $montantDepot;
|
|
|
|
// $montantDepot;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$walletAgent->balance_com += $commisionAgent;
|
|
|
|
$walletAgent->balance_com += $commisionAgent;
|
|
|
|
$transaction->commission_ag = $commisionAgent;
|
|
|
|
$transaction->commission_ag = $commisionAgent;
|
|
|
@ -1057,17 +1077,22 @@ class iLinkTransactionController extends Controller
|
|
|
|
if (!$transaction)
|
|
|
|
if (!$transaction)
|
|
|
|
return $this->errorResponse(trans('errors.transaction_not_exist'), Response::HTTP_NOT_FOUND);
|
|
|
|
return $this->errorResponse(trans('errors.transaction_not_exist'), Response::HTTP_NOT_FOUND);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Verifier que le reseau payeur est de type iLink
|
|
|
|
|
|
|
|
if (in_array($transaction->type, [3, 17])){
|
|
|
|
|
|
|
|
$configPayeur = ConfigWallet::where('id_network', $request->network_destinataire)->firstOrFail();
|
|
|
|
|
|
|
|
if($configPayeur->type != 'ilink')
|
|
|
|
|
|
|
|
return $this->errorResponse(trans('errors.withdrawal_network_unauthorized'));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($transaction->status_retrait != 0)
|
|
|
|
if ($transaction->status_retrait != 0)
|
|
|
|
return $this->errorResponse(trans('errors.withdrawal_already_made'));
|
|
|
|
return $this->errorResponse(trans('errors.withdrawal_already_made'));
|
|
|
|
|
|
|
|
|
|
|
|
$walletAgent = Wallet::findOrFail($request->get('id_wallet_agent'));
|
|
|
|
$walletAgent = Wallet::findOrFail($request->get('id_wallet_agent'));
|
|
|
|
$network_agent = NetworksAgent::findOrFail($walletAgent->id_networkAgent);
|
|
|
|
$network_agent = NetworksAgent::findOrFail($walletAgent->id_networkAgent);
|
|
|
|
$agent_country = $network_agent->network->country->id;
|
|
|
|
$agent_country = $network_agent->network->country->id;
|
|
|
|
if ($transaction->type != 11)
|
|
|
|
|
|
|
|
if ($agent_country != $transaction->final_country)
|
|
|
|
if ($agent_country != $transaction->final_country)
|
|
|
|
return $this->errorResponse(trans('errors.operation_cannot_performed_in_country'));
|
|
|
|
return $this->errorResponse(trans('errors.operation_cannot_performed_in_country'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$data = $transaction->replicate();
|
|
|
|
$data = $transaction->replicate();
|
|
|
|
if (in_array($transaction->type, [9, 11])) {
|
|
|
|
if (in_array($transaction->type, [9, 11])) {
|
|
|
|
$data->nom_destinataire = $transaction->wallet_user->user->lastname;
|
|
|
|
$data->nom_destinataire = $transaction->wallet_user->user->lastname;
|
|
|
|