+ Add "User - Envoi de wallet à banque" and "Agent - Envoi de cash à banque"

This commit is contained in:
Djery-Tom 2020-11-03 10:05:30 +01:00
parent f30e522c10
commit 29374c8cc4
6 changed files with 223 additions and 84 deletions

View File

@ -107,20 +107,20 @@ class TransmittingNetworksController extends Controller
$configTransmitter = ConfigWallet::where('id_network', $request->network_emetteur)->first(); $configTransmitter = ConfigWallet::where('id_network', $request->network_emetteur)->first();
if (!$configRecipient) if (!$configRecipient)
return $this->errorResponse("Ce reseau destinataire n'est pas configuré dans notre systeme"); return $this->errorResponse(trans('errors.recipient_network_not_configured'));
if ($configRecipient->type != 'ilink') if ($configRecipient->type != 'ilink')
return $this->errorResponse("Ce reseau destinataire n'est pas autorise à recevoir des transactions dans notre systeme"); return $this->errorResponse(trans('errors.recipient_network_not_authorized'));
if (!$configTransmitter) if (!$configTransmitter)
return $this->errorResponse("Ce reseau emetteur n'est pas configuré dans notre systeme"); return $this->errorResponse(trans('errors.transmitter_network_not_configured'));
if ($configTransmitter->type != 'autre') if ($configTransmitter->type != 'autre')
return $this->errorResponse("Ce reseau emetteur n'est pas autorise à recevoir des transactions dans notre systeme"); return $this->errorResponse(trans('errors.transmitter_network_not_authorized'));
$transmittingNetwork = TransmittingNetwork::where('id_network', $request->network_emetteur)->where('id_configWallet', $configRecipient->id)->first(); $transmittingNetwork = TransmittingNetwork::where('id_network', $request->network_emetteur)->where('id_configWallet', $configRecipient->id)->first();
if (!$transmittingNetwork) if (!$transmittingNetwork)
return $this->errorResponse("Ce reseau n'est pas reconnu comme etant un reseau emetteur du reseau destinataire"); return $this->errorResponse(trans('errors.transmitter_network_not_recognized'));
$transaction = new WalletIlinkTransaction(); $transaction = new WalletIlinkTransaction();

View File

@ -23,6 +23,7 @@ use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class iLinkTransactionController extends Controller class iLinkTransactionController extends Controller
{ {
@ -214,7 +215,7 @@ class iLinkTransactionController extends Controller
['id_transaction' => $transaction->id_transaction, 'amount' => $this->toMoney($transaction->montant, $init_country), 'net_init' => $this->toMoney($montantDepot, $init_country), ['id_transaction' => $transaction->id_transaction, 'amount' => $this->toMoney($transaction->montant, $init_country), 'net_init' => $this->toMoney($montantDepot, $init_country),
'net_final' => $this->toMoneyWithCurrency($montantDepot, $init_country, $request->final_country), 'fees' => $this->toMoney($frais + $taxe, $init_country), 'net_final' => $this->toMoneyWithCurrency($montantDepot, $init_country, $request->final_country), 'fees' => $this->toMoney($frais + $taxe, $init_country),
'init_country' => $this->getCountryName($init_country), 'final_country' => $this->getCountryName($request->final_country), 'init_country' => $this->getCountryName($init_country), 'final_country' => $this->getCountryName($request->final_country),
'sender_code' => $user->user_code, 'receiver_code' => $transaction->id_destinataire,'network'=> $this->getNetworkName($transaction->network_destinataire)]); 'sender_code' => $user->user_code, 'receiver_code' => $transaction->id_destinataire, 'network' => $this->getNetworkName($transaction->network_destinataire)]);
$this->sendMail($user->email, trans('messages.successful_transaction'), $message); $this->sendMail($user->email, trans('messages.successful_transaction'), $message);
return $this->successResponse($message . trans('messages.sent_by_mail')); return $this->successResponse($message . trans('messages.sent_by_mail'));
} }
@ -368,7 +369,7 @@ class iLinkTransactionController extends Controller
'net_final' => $this->toMoneyWithCurrency($montantRetrait, $init_country, $request->final_country), 'fees' => $this->toMoney($frais + $taxe, $init_country), 'net_final' => $this->toMoneyWithCurrency($montantRetrait, $init_country, $request->final_country), 'fees' => $this->toMoney($frais + $taxe, $init_country),
'init_country' => $this->getCountryName($init_country), 'final_country' => $this->getCountryName($request->final_country), 'code' => wordwrap($code_retrait, 4, ' ', true), 'init_country' => $this->getCountryName($init_country), 'final_country' => $this->getCountryName($request->final_country), 'code' => wordwrap($code_retrait, 4, ' ', true),
'sender_code' => $user->user_code, 'receiver_code' => $transaction->id_destinataire, 'receiver_name' => $request->prenom_destinataire . ' ' . $request->nom_destinataire, 'sender_code' => $user->user_code, 'receiver_code' => $transaction->id_destinataire, 'receiver_name' => $request->prenom_destinataire . ' ' . $request->nom_destinataire,
'sender_name'=> $user->lastname.' '.$user->firstname,'network'=> $this->getNetworkName($transaction->network_destinataire)]); 'sender_name' => $user->lastname . ' ' . $user->firstname, 'network' => $this->getNetworkName($transaction->network_destinataire)]);
$this->sendMail($user->email, trans('messages.successful_transaction'), $message); $this->sendMail($user->email, trans('messages.successful_transaction'), $message);
return $this->successResponse($message . trans('messages.sent_by_mail')); return $this->successResponse($message . trans('messages.sent_by_mail'));
} }
@ -377,8 +378,57 @@ class iLinkTransactionController extends Controller
} }
break; break;
case 4: //User - Envoi de wallet à banque case 4: //User - Envoi de wallet à banque
// Non disponible
//Pas de taxes $this->validate($request, [
'iban' => 'required',
'id_wallet_network' => 'required|integer|min:0|not_in:0',
'id_bank' => 'required|integer|min:0|not_in:0',
]);
$user = $walletUser->user;
if (!$this->checkPassword($request->password, $user->encrypted_password, $user->salt))
return $this->errorResponse(trans('messages.incorrect_user_password'));
if ($request->montant > $walletUser->balance)
return $this->errorResponse(trans('errors.insufficient_balance'));
// $rep = $this->checkUserIdentification($user->id);
// if ($rep instanceof JsonResponse)
// return $rep;
//Verifier si la banque est associée au reseau
$result = DB::select("SELECT * FROM networks_banks nb INNER JOIN banks_countries bc ON bc.id = nb.id_bank_country
WHERE nb.id_network = :id_network AND bc.id_bank = :id_bank;", ["id_network" => $request->id_wallet_network, 'id_bank' => $request->id_bank]);
if (sizeof($result) == 0)
return $this->errorResponse(trans('errors.bank_not_associated_with_network'));
$transaction->frais = $frais = 0;
$transaction->taxe = $taxe = 0;
// $walletUser->balance -= $transaction->montant;
//Emettre une trame SSL pour recharger le compte bancaire du montant de la transaction
$transaction->commission_banque = 0;
$transaction->commission_hyp = 0;
$transaction->id_wallet_hyp = $walletHyperviseur->id;
$transaction->frais = $frais;
$transaction->date = new \DateTime();
$transaction->id_bank = $request->id_bank;
$transaction->iban = $request->iban;
// $walletUser->save();
$transaction->id_transaction = $this->getTransactionID();
// $transaction->save();
Log::info('-------------------------- User - Envoi de wallet à banque ------------------------------------');
Log::info($transaction->toArray());
Log::info('------------------------------------------------------------------------------------------------');
$message = trans('messages.successful_user_send_to_bank',
['id_transaction' => $transaction->id_transaction, 'amount' => $this->toMoney($transaction->montant, $init_country),
'net' => $this->toMoney($transaction->montant, $init_country), 'iban' => $request->iban, 'fees' => $this->toMoney($frais, $init_country),
'sender_code' => $user->user_code]);
// $this->sendMail($user->email, trans('messages.successful_transaction'), $message);
return $this->successResponse($message . trans('messages.sent_by_mail'));
break; break;
// case 5: //User - Envoi de carte à wallet // case 5: //User - Envoi de carte à wallet
// $frais =$montant * $config->taux_com_user_carte_wallet / 100; // $frais =$montant * $config->taux_com_user_carte_wallet / 100;
@ -568,14 +618,14 @@ class iLinkTransactionController extends Controller
$transaction = WalletIlinkTransaction::where('id_transaction', $request->id_transaction)->first(); $transaction = WalletIlinkTransaction::where('id_transaction', $request->id_transaction)->first();
if ($transaction) { if ($transaction) {
//Verifier si l'agent qui a effectué l'envoi de cash à cash ne puisse pas retirer l'argent //Verifier si l'agent qui a effectué l'envoi de cash à cash ne puisse pas retirer l'argent
if($transaction->type == 17) if ($transaction->type == 17)
if($transaction->id_wallet_ag == $walletAgent->id) if ($transaction->id_wallet_ag == $walletAgent->id)
return $this->errorResponse(trans('errors.agent_unauthorized')); return $this->errorResponse(trans('errors.agent_unauthorized'));
//Verifier que le reseau payeur est de type iLink //Verifier que le reseau payeur est de type iLink
if (in_array($transaction->type, [3, 17])) { if (in_array($transaction->type, [3, 17])) {
$configPayeur = ConfigWallet::where('id_network', $transaction->network_destinataire)->firstOrFail(); $configPayeur = ConfigWallet::where('id_network', $transaction->network_destinataire)->firstOrFail();
if ($configPayeur->type != 'ilink') if ($configPayeur->type != 'ilink')
return $this->errorResponse(trans('errors.withdrawal_network_unauthorized',['network'=> $this->getNetworkName($transaction->network_destinataire), return $this->errorResponse(trans('errors.withdrawal_network_unauthorized', ['network' => $this->getNetworkName($transaction->network_destinataire),
'country' => $this->getCountryName($transaction->final_country)])); 'country' => $this->getCountryName($transaction->final_country)]));
} }
if ($transaction->status_retrait == 0) { if ($transaction->status_retrait == 0) {
@ -597,8 +647,8 @@ class iLinkTransactionController extends Controller
$transactionRetrait->id_transaction = $this->getTransactionID(); $transactionRetrait->id_transaction = $this->getTransactionID();
$transactionRetrait->montant = $montantNet; $transactionRetrait->montant = $montantNet;
$emailEmetteur = $transaction->wallet_user ? $transaction->wallet_user->user->email : $transaction->email_emetteur; $emailEmetteur = $transaction->wallet_user ? $transaction->wallet_user->user->email : $transaction->email_emetteur;
$emetteur = $transaction->wallet_user ? $transaction->wallet_user->user->lastname.' '.$transaction->wallet_user->user->firstname : $transaction->prenom_emetteur . ' ' . $transaction->nom_emetteur; $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; $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_ag = floatval($commissionHyp * $config->taux_com_ag_retrait_cash / 100);
$transactionRetrait->commission_sup = floatval($commissionHyp * $config->taux_com_sup_retrait_cash / 100); $transactionRetrait->commission_sup = floatval($commissionHyp * $config->taux_com_sup_retrait_cash / 100);
@ -830,7 +880,7 @@ class iLinkTransactionController extends Controller
$message = trans('messages.successful_agent_deposit_other_wallet', $message = trans('messages.successful_agent_deposit_other_wallet',
['id_transaction' => $transaction->id_transaction, 'amount' => $this->toMoney($transaction->montant, $init_country), 'net_init' => $this->toMoney($montantDepot, $init_country), ['id_transaction' => $transaction->id_transaction, 'amount' => $this->toMoney($transaction->montant, $init_country), 'net_init' => $this->toMoney($montantDepot, $init_country),
'net_final' => $this->toMoneyWithCurrency($montantDepot, $init_country, $request->final_country), 'fees' => $this->toMoney($frais + $taxe, $init_country), 'init_country' => $this->getCountryName($init_country), 'net_final' => $this->toMoneyWithCurrency($montantDepot, $init_country, $request->final_country), 'fees' => $this->toMoney($frais + $taxe, $init_country), 'init_country' => $this->getCountryName($init_country),
'final_country' => $this->getCountryName($request->final_country), 'receiver_code' => $request->id_destinataire,'network'=> $this->getNetworkName($transaction->network_destinataire), 'final_country' => $this->getCountryName($request->final_country), 'receiver_code' => $request->id_destinataire, 'network' => $this->getNetworkName($transaction->network_destinataire),
'sender_name' => $request->prenom_emetteur . ' ' . $request->nom_emetteur, 'receiver_name' => $request->prenom_destinataire . ' ' . $request->nom_destinataire,]); 'sender_name' => $request->prenom_emetteur . ' ' . $request->nom_emetteur, 'receiver_name' => $request->prenom_destinataire . ' ' . $request->nom_destinataire,]);
$this->sendMail($request->email_emetteur, trans('messages.successful_transaction'), $message); $this->sendMail($request->email_emetteur, trans('messages.successful_transaction'), $message);
return $this->successResponse($message . trans('messages.sent_by_mail')); return $this->successResponse($message . trans('messages.sent_by_mail'));
@ -1005,7 +1055,7 @@ class iLinkTransactionController extends Controller
'id_transaction' => $transaction->id_transaction, 'amount' => $this->toMoney($transaction->montant, $init_country), 'net_init' => $this->toMoney($montantRetrait, $init_country), 'id_transaction' => $transaction->id_transaction, 'amount' => $this->toMoney($transaction->montant, $init_country), 'net_init' => $this->toMoney($montantRetrait, $init_country),
'net_final' => $this->toMoneyWithCurrency($montantRetrait, $init_country, $request->final_country), 'fees' => $this->toMoney($frais + $taxe, $init_country), 'init_country' => $this->getCountryName($init_country), 'net_final' => $this->toMoneyWithCurrency($montantRetrait, $init_country, $request->final_country), 'fees' => $this->toMoney($frais + $taxe, $init_country), 'init_country' => $this->getCountryName($init_country),
'final_country' => $this->getCountryName($request->final_country), 'code' => wordwrap($code_retrait, 4, ' ', true), 'final_country' => $this->getCountryName($request->final_country), 'code' => wordwrap($code_retrait, 4, ' ', true),
'network'=> $this->getNetworkName($transaction->network_destinataire)]); 'network' => $this->getNetworkName($transaction->network_destinataire)]);
$this->sendMail($request->email_emetteur, trans('messages.successful_transaction'), $message); $this->sendMail($request->email_emetteur, trans('messages.successful_transaction'), $message);
return $this->successResponse($message . trans('messages.sent_by_mail')); return $this->successResponse($message . trans('messages.sent_by_mail'));
} else { } else {
@ -1013,34 +1063,81 @@ class iLinkTransactionController extends Controller
} }
break; break;
case 18: // Agent - Envoi de cash vers banque case 18: // Agent - Envoi de cash vers banque
// Indisponible $this->validate($request, [
break; 'iban' => 'required',
'id_wallet_network' => 'required|integer|min:0|not_in:0',
'id_bank' => 'required|integer|min:0|not_in:0',
]);
$agent = AgentPlus::findOrFail($network_agent->agent_id);
if (!$this->checkPassword($request->password, $agent->encrypted_password, $agent->salt))
return $this->errorResponse(trans('messages.incorrect_user_password'));
if ($request->montant > $walletAgent->balance_princ)
return $this->errorResponse(trans('errors.insufficient_balance'));
//Verifier si la banque est associée au reseau
$result = DB::select("SELECT * FROM networks_banks nb INNER JOIN banks_countries bc ON bc.id = nb.id_bank_country
WHERE nb.id_network = :id_network AND bc.id_bank = :id_bank;", ["id_network" => $request->id_wallet_network, 'id_bank' => $request->id_bank]);
if (sizeof($result) == 0)
return $this->errorResponse(trans('errors.bank_not_associated_with_network'));
$transaction->frais = $frais = 0;
$transaction->taxe = $taxe = 0;
// $walletUser->balance -= $transaction->montant;
//Emettre une trame SSL pour recharger le compte bancaire du montant de la transaction
$transaction->commission_banque = 0;
$transaction->commission_hyp = 0;
$transaction->id_wallet_hyp = $walletHyperviseur->id;
$transaction->id_wallet_ag = $walletAgent->id;
$transaction->id_wallet_sup = $walletSuperviseur->id;
$transaction->frais = $frais;
$transaction->date = new \DateTime();
$transaction->id_bank = $request->id_bank;
$transaction->iban = $request->iban;
// $walletUser->save();
$transaction->id_transaction = $this->getTransactionID();
// $transaction->save();
Log::info('-------------------------- Agent - Envoi de cash vers banque ------------------------------------');
Log::info($transaction->toArray());
Log::info('------------------------------------------------------------------------------------------------');
$message = trans('messages.successful_user_send_to_bank',
['id_transaction' => $transaction->id_transaction, 'amount' => $this->toMoney($transaction->montant, $init_country),
'net' => $this->toMoney($transaction->montant, $init_country), 'iban' => $request->iban, 'fees' => $this->toMoney($frais, $init_country),
'sender_code' => $codeGenerer->code_membre]);
// $this->sendMail($user->email, trans('messages.successful_transaction'), $message);
return $this->successResponse($message . trans('messages.sent_by_mail'));
} }
} }
public function lastUserTransactions($id_user) public
function lastUserTransactions($id_user)
{ {
$user = User::findOrFail($id_user); $user = User::findOrFail($id_user);
$wallet_user = WalletsUser::where('idUser',$user->id)->firstOrFail(); $wallet_user = WalletsUser::where('idUser', $user->id)->firstOrFail();
$transactions = DB::select('SELECT id_wallet_user , operation_fr , operation_en, id_transaction ,network_destinataire, init_country , final_country, date , id , montant , frais , taxe , pays_init , pays_final, $transactions = DB::select('SELECT id_wallet_user , operation_fr , operation_en, id_transaction ,network_destinataire, init_country , final_country, date , id , montant , frais , taxe , pays_init , pays_final,
destinataire_phone , destinataire_name , nom_destinataire, prenom_destinataire, montant_net ,montant_net_final_country FROM infos_ilink_transaction WHERE id_wallet_user = :id_wallet AND type <> 12 AND type <> 14 destinataire_phone , destinataire_name , nom_destinataire, prenom_destinataire, montant_net ,montant_net_final_country FROM infos_ilink_transaction WHERE id_wallet_user = :id_wallet AND type <> 12 AND type <> 14
ORDER BY date DESC LIMIT 10;', ['id_wallet' => $wallet_user->id]); ORDER BY date DESC LIMIT 10;', ['id_wallet' => $wallet_user->id]);
foreach ($transactions as $data){ foreach ($transactions as $data) {
$data->operation = app()->isLocale('en') ? $data->operation_en : $data->operation_fr; $data->operation = app()->isLocale('en') ? $data->operation_en : $data->operation_fr;
$date = $data->date; $date = $data->date;
unset($data->date); unset($data->date);
$user_destinataire = isset($data->id_destinataire) ? User::where('user_code',$data->id_destinataire)->first() : null ; $user_destinataire = isset($data->id_destinataire) ? User::where('user_code', $data->id_destinataire)->first() : null;
// $emetteur = $wallet_user ? $wallet_user->user->lastname.' '.$wallet_user->user->firstname : $data->prenom_emetteur . ' ' . $data->nom_emetteur; // $emetteur = $wallet_user ? $wallet_user->user->lastname.' '.$wallet_user->user->firstname : $data->prenom_emetteur . ' ' . $data->nom_emetteur;
$emetteur = 'Moi'; $emetteur = 'Moi';
if($data->destinataire_phone){ if ($data->destinataire_phone) {
$destinataire = $data->destinataire_name; $destinataire = $data->destinataire_name;
}else{ } else {
$destinataire = $data->prenom_destinataire ? $data->prenom_destinataire . ' ' . $data->nom_destinataire : $emetteur; $destinataire = $data->prenom_destinataire ? $data->prenom_destinataire . ' ' . $data->nom_destinataire : $emetteur;
} }
// $destinataire = in_array($data->type,[12,16]) ? $emetteur : ( $user_destinataire ? $user_destinataire->lastname.' '.$user_destinataire->firstname : // $destinataire = in_array($data->type,[12,16]) ? $emetteur : ( $user_destinataire ? $user_destinataire->lastname.' '.$user_destinataire->firstname :
// $data->prenom_destinataire . ' ' . $data->nom_destinataire); // $data->prenom_destinataire . ' ' . $data->nom_destinataire);
@ -1048,11 +1145,11 @@ class iLinkTransactionController extends Controller
$data->destinataire = $destinataire; $data->destinataire = $destinataire;
$data->frais = $this->toMoney($data->frais + $data->taxe, $data->init_country); $data->frais = $this->toMoney($data->frais + $data->taxe, $data->init_country);
$data->montant_net_init = $this->toMoney($data->montant_net, $data->init_country); $data->montant_net_init = $this->toMoney($data->montant_net, $data->init_country);
$data->montant_net_final = $data->montant_net_final_country ? $this->toMoney($data->montant_net_final_country, $data->final_country) : $data->montant_net_init ; $data->montant_net_final = $data->montant_net_final_country ? $this->toMoney($data->montant_net_final_country, $data->final_country) : $data->montant_net_init;
$data->montant = $this->toMoney($data->montant, $data->init_country); $data->montant = $this->toMoney($data->montant, $data->init_country);
$data->init_country = $data->pays_init; $data->init_country = $data->pays_init;
$data->final_country = $data->pays_final; $data->final_country = $data->pays_final;
$data->reseau_payeur = isset($data->network_destinataire) ? $this->getNetworkName($data->network_destinataire).' '.$data->final_country : null; $data->reseau_payeur = isset($data->network_destinataire) ? $this->getNetworkName($data->network_destinataire) . ' ' . $data->final_country : null;
$data->date = $date; $data->date = $date;
unset($data->type, $data->destinataire_name, $data->id_wallet_user, $data->network_destinataire, $data->nom_destinataire, $data->prenom_destinataire, $data->taxe, $data->numero_carte, unset($data->type, $data->destinataire_name, $data->id_wallet_user, $data->network_destinataire, $data->nom_destinataire, $data->prenom_destinataire, $data->taxe, $data->numero_carte,
$data->montant_net_final_country, $data->montant_net, $data->pays_init, $data->pays_final, $data->id_destinataire, $data->destinataire_phone, $data->operation_fr, $data->operation_en); $data->montant_net_final_country, $data->montant_net, $data->pays_init, $data->pays_final, $data->id_destinataire, $data->destinataire_phone, $data->operation_fr, $data->operation_en);
@ -1060,7 +1157,8 @@ class iLinkTransactionController extends Controller
return $this->successResponse($transactions); return $this->successResponse($transactions);
} }
public function lastAgentTransactions($id_wallet_agent) public
function lastAgentTransactions($id_wallet_agent)
{ {
$transactions = DB::select('SELECT wit.id_transaction, tit.nom as operation_fr , tit.name as operation_en, wit.montant ,wit.nom_emetteur, wit.prenom_emetteur, wit.id_wallet_user,wit.frais,wit.taxe,wit.id_destinataire, $transactions = DB::select('SELECT wit.id_transaction, tit.nom as operation_fr , tit.name as operation_en, wit.montant ,wit.nom_emetteur, wit.prenom_emetteur, wit.id_wallet_user,wit.frais,wit.taxe,wit.id_destinataire,
wit.nom_destinataire, wit.prenom_destinataire, wit.type , wit.id_wallet_user, wit.init_country, wit.final_country , wit.network_destinataire , wit.montant_net_final_country , wit.nom_destinataire, wit.prenom_destinataire, wit.type , wit.id_wallet_user, wit.init_country, wit.final_country , wit.network_destinataire , wit.montant_net_final_country ,
@ -1068,22 +1166,22 @@ class iLinkTransactionController extends Controller
INNER JOIN type_ilink_transaction tit ON wit.type = tit.id WHERE wit.id_wallet_ag = :id_wallet INNER JOIN type_ilink_transaction tit ON wit.type = tit.id WHERE wit.id_wallet_ag = :id_wallet
ORDER BY wit.date DESC LIMIT 10;', ['id_wallet' => $id_wallet_agent]); ORDER BY wit.date DESC LIMIT 10;', ['id_wallet' => $id_wallet_agent]);
foreach ($transactions as $data){ foreach ($transactions as $data) {
$data->operation = app()->isLocale('en') ? $data->operation_en : $data->operation_fr; $data->operation = app()->isLocale('en') ? $data->operation_en : $data->operation_fr;
$date = $data->date; $date = $data->date;
unset($data->date); unset($data->date);
$wallet_user = isset($data->id_wallet_user) ? WalletsUser::findOrFail($data->id_wallet_user) : null ; $wallet_user = isset($data->id_wallet_user) ? WalletsUser::findOrFail($data->id_wallet_user) : null;
$user_destinataire = isset($data->id_destinataire) ? User::where('user_code',$data->id_destinataire)->first() : null ; $user_destinataire = isset($data->id_destinataire) ? User::where('user_code', $data->id_destinataire)->first() : null;
$emetteur = $wallet_user ? $wallet_user->user->lastname.' '.$wallet_user->user->firstname : $data->prenom_emetteur . ' ' . $data->nom_emetteur; $emetteur = $wallet_user ? $wallet_user->user->lastname . ' ' . $wallet_user->user->firstname : $data->prenom_emetteur . ' ' . $data->nom_emetteur;
if(!$wallet_user && !$data->nom_emetteur) if (!$wallet_user && !$data->nom_emetteur)
$emetteur = $data->numero_carte; $emetteur = $data->numero_carte;
$destinataire = in_array($data->type,[12,16]) ? $emetteur : ( $user_destinataire ? $user_destinataire->lastname.' '.$user_destinataire->firstname : $destinataire = in_array($data->type, [12, 16]) ? $emetteur : ($user_destinataire ? $user_destinataire->lastname . ' ' . $user_destinataire->firstname :
$data->prenom_destinataire . ' ' . $data->nom_destinataire); $data->prenom_destinataire . ' ' . $data->nom_destinataire);
$data->emetteur = $emetteur; $data->emetteur = $emetteur;
$data->destinataire = $destinataire; $data->destinataire = $destinataire;
$data->frais = $this->toMoney($data->frais + $data->taxe, $data->init_country); $data->frais = $this->toMoney($data->frais + $data->taxe, $data->init_country);
$data->montant_net_init = $this->toMoney($data->montant_net, $data->init_country); $data->montant_net_init = $this->toMoney($data->montant_net, $data->init_country);
$data->montant_net_final = $data->montant_net_final_country ? $this->toMoney($data->montant_net_final_country, $data->final_country) : $data->montant_net_init ; $data->montant_net_final = $data->montant_net_final_country ? $this->toMoney($data->montant_net_final_country, $data->final_country) : $data->montant_net_init;
$data->montant = $this->toMoney($data->montant, $data->init_country); $data->montant = $this->toMoney($data->montant, $data->init_country);
$data->init_country = $this->getCountryName($data->init_country); $data->init_country = $this->getCountryName($data->init_country);
$data->final_country = $data->montant_net_final_country ? $this->getCountryName($data->final_country) : ''; $data->final_country = $data->montant_net_final_country ? $this->getCountryName($data->final_country) : '';
@ -1095,7 +1193,8 @@ class iLinkTransactionController extends Controller
return $this->successResponse($transactions); return $this->successResponse($transactions);
} }
public function calculateCommission(Request $request) public
function calculateCommission(Request $request)
{ {
$rules = [ $rules = [
'type' => 'required|integer|min:0|not_in:0', 'type' => 'required|integer|min:0|not_in:0',
@ -1156,14 +1255,14 @@ class iLinkTransactionController extends Controller
$destinataire = User::where('user_code', $request->id_destinataire)->first(); $destinataire = User::where('user_code', $request->id_destinataire)->first();
//Verifier si c'est pas un reseau ilink //Verifier si c'est pas un reseau ilink
$data['destinataire'] = $destinataire ? $destinataire->lastname . ' ' . $destinataire->firstname : $request->id_destinataire; $data['destinataire'] = $destinataire ? $destinataire->lastname . ' ' . $destinataire->firstname : $request->id_destinataire;
$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);
$data['montant_net_final'] = $this->toMoneyWithCurrency($data['montant_net_init'], $init_country, $request->final_country); $data['montant_net_final'] = $this->toMoneyWithCurrency($data['montant_net_init'], $init_country, $request->final_country);
break; break;
case 2: //User - Envoi de wallet à carte case 2: //User - Envoi de wallet à carte
$frais = $request->montant * $config->taux_com_user_wallet_carte / 100; $frais = $request->montant * $config->taux_com_user_wallet_carte / 100;
$data['frais'] = round($frais,2); $data['frais'] = round($frais, 2);
$data['montant_net'] = round($request->montant - $data['frais'],2); $data['montant_net'] = round($request->montant - $data['frais'], 2);
break; break;
case 3: // User - Envoi wallet à cash case 3: // User - Envoi wallet à cash
$this->validate($request, [ $this->validate($request, [
@ -1171,14 +1270,14 @@ class iLinkTransactionController extends Controller
]); ]);
$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);
$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);
$data['montant_net_final'] = $this->toMoneyWithCurrency($data['montant_net_init'], $init_country, $request->final_country); $data['montant_net_final'] = $this->toMoneyWithCurrency($data['montant_net_init'], $init_country, $request->final_country);
break; break;
case 9: // User - Retrait de wallet en cash case 9: // User - Retrait de wallet en cash
$frais = $this->calculateFees($plr_user_wallet_cash_national, $request->montant); $frais = $this->calculateFees($plr_user_wallet_cash_national, $request->montant);
$taxe = $this->calculateTax($taxesNationales, $frais); $taxe = $this->calculateTax($taxesNationales, $frais);
$data['frais'] = round($frais + $taxe,2); $data['frais'] = round($frais + $taxe, 2);
$data['montant_net'] = round($request->montant - $data['frais'], 2); $data['montant_net'] = round($request->montant - $data['frais'], 2);
break; break;
case 10: //User - Retrait de carte vers wallet case 10: //User - Retrait de carte vers wallet
@ -1206,8 +1305,8 @@ class iLinkTransactionController extends Controller
$final_country = $user->network->country->id; $final_country = $user->network->country->id;
$frais = ($init_country != $final_country) ? $this->calculateFees($plr_agent_depot_wallet_ilink, $request->montant) : $this->calculateFees($plr_agent_depot_wallet_ilink_national, $request->montant); $frais = ($init_country != $final_country) ? $this->calculateFees($plr_agent_depot_wallet_ilink, $request->montant) : $this->calculateFees($plr_agent_depot_wallet_ilink_national, $request->montant);
$taxe = ($init_country != $final_country) ? $this->calculateTax($taxesInternationales, $frais) : $this->calculateTax($taxesNationales, $frais); $taxe = ($init_country != $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);
$data['montant_net_final'] = $this->toMoneyWithCurrency($data['montant_net_init'], $init_country, $final_country); $data['montant_net_final'] = $this->toMoneyWithCurrency($data['montant_net_init'], $init_country, $final_country);
break; break;
case 15: // Agent - Envoi de cash vers autre wallet case 15: // Agent - Envoi de cash vers autre wallet
@ -1216,14 +1315,14 @@ class iLinkTransactionController extends Controller
]); ]);
$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); $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); $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);
$data['montant_net_final'] = $this->toMoneyWithCurrency($data['montant_net_init'], $init_country, $request->final_country); $data['montant_net_final'] = $this->toMoneyWithCurrency($data['montant_net_init'], $init_country, $request->final_country);
break; break;
case 16: // Agent - Envoi de cash vers une carte visa case 16: // Agent - Envoi de cash vers une carte visa
$frais = $request->montant * $config->taux_com_wallet_ag_envoi_cash_carte / 100; $frais = $request->montant * $config->taux_com_wallet_ag_envoi_cash_carte / 100;
$data['frais'] = round($frais,2); $data['frais'] = round($frais, 2);
$data['montant_net'] = round($request->montant - $data['frais'],2); $data['montant_net'] = round($request->montant - $data['frais'], 2);
break; break;
case 17: // Agent - Envoi de cash vers cash case 17: // Agent - Envoi de cash vers cash
$this->validate($request, [ $this->validate($request, [
@ -1231,19 +1330,20 @@ class iLinkTransactionController extends Controller
]); ]);
$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);
$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);
$data['montant_net_final'] = $this->toMoneyWithCurrency($data['montant_net_init'], $init_country, $request->final_country); $data['montant_net_final'] = $this->toMoneyWithCurrency($data['montant_net_init'], $init_country, $request->final_country);
break; break;
} }
$net = isset($data['montant_net']) ? $data['montant_net'] : $data['montant_net_init']; $net = isset($data['montant_net']) ? $data['montant_net'] : $data['montant_net_init'];
if(isset($net)) if (isset($net))
if($net < 0) if ($net < 0)
return $this->errorResponse(trans('errors.incorrect_net_amount')); return $this->errorResponse(trans('errors.incorrect_net_amount'));
return $this->successResponse($data); return $this->successResponse($data);
} }
public function getTransactionRetrait(Request $request) public
function getTransactionRetrait(Request $request)
{ {
$this->validate($request, [ $this->validate($request, [
'id_transaction' => 'required', 'id_transaction' => 'required',
@ -1251,13 +1351,13 @@ class iLinkTransactionController extends Controller
'code_retrait' => 'required', 'code_retrait' => 'required',
]); ]);
$transaction = WalletIlinkTransaction::select('nom_destinataire', 'prenom_destinataire', 'type_document_destinataire', 'id_document_destinataire', 'type','encrypted_code_retrait','code_retrait_salt', $transaction = WalletIlinkTransaction::select('nom_destinataire', 'prenom_destinataire', 'type_document_destinataire', 'id_document_destinataire', 'type', 'encrypted_code_retrait', 'code_retrait_salt',
'id_wallet_user', 'init_country', 'final_country', 'network_destinataire' ,'id_transaction', 'montant_net_final_country', 'montant_net')->where('id_transaction', $request->id_transaction)->first(); 'id_wallet_user', 'init_country', 'final_country', 'network_destinataire', 'id_transaction', 'montant_net_final_country', 'montant_net')->where('id_transaction', $request->id_transaction)->first();
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);
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))
return $this->errorResponse(trans('errors.invalid_withdrawal_code')); return $this->errorResponse(trans('errors.invalid_withdrawal_code'));
@ -1292,14 +1392,15 @@ class iLinkTransactionController extends Controller
// $data->user_code = $transaction->wallet_user->user->user_code; // $data->user_code = $transaction->wallet_user->user->user_code;
} }
$data->montant = $transaction->type == 11 ? $transaction->montant_net : $transaction->montant_net_final_country; $data->montant = $transaction->type == 11 ? $transaction->montant_net : $transaction->montant_net_final_country;
unset($data->type, $data->init_country, $data->final_country, $data->id_wallet_user, $data->network_destinataire,$data->code_retrait_salt, unset($data->type, $data->init_country, $data->final_country, $data->id_wallet_user, $data->network_destinataire, $data->code_retrait_salt,
$data->encrypted_code_retrait,$data->montant_net_final_country, $data->montant_net); $data->encrypted_code_retrait, $data->montant_net_final_country, $data->montant_net);
return $this->successResponse($data); return $this->successResponse($data);
} }
private function getPaliers(array $paliers, $type) private
function getPaliers(array $paliers, $type)
{ {
return array_values(array_filter($paliers, function ($palier) use ($type) { return array_values(array_filter($paliers, function ($palier) use ($type) {
return $palier->type == $type; return $palier->type == $type;
@ -1307,7 +1408,8 @@ class iLinkTransactionController extends Controller
} }
//Calcul des frais internationaux //Calcul des frais internationaux
private function calculateFees(array $paliers, $montant) private
function calculateFees(array $paliers, $montant)
{ {
$size = sizeof($paliers); $size = sizeof($paliers);
if ($size > 0) { if ($size > 0) {
@ -1334,7 +1436,8 @@ class iLinkTransactionController extends Controller
} }
private function random_string() private
function random_string()
{ {
$character_set_array = array(); $character_set_array = array();
$character_set_array[] = array('count' => 12, 'characters' => 'ABCDEFGHJKMNPQRSTUVWXYZ'); $character_set_array[] = array('count' => 12, 'characters' => 'ABCDEFGHJKMNPQRSTUVWXYZ');
@ -1349,25 +1452,30 @@ class iLinkTransactionController extends Controller
return implode('', $temp_array); return implode('', $temp_array);
} }
private function getTransactionID(){ private
do{ function getTransactionID()
$code=$this->generateTransactionCode(); {
$result = collect(DB::select('SELECT * FROM wallet_ilink_transaction WHERE id_transaction = :code',['code'=>$code])); do {
$codeCorrect=sizeof($result)<0; $code = $this->generateTransactionCode();
}while($codeCorrect); $result = collect(DB::select('SELECT * FROM wallet_ilink_transaction WHERE id_transaction = :code', ['code' => $code]));
$codeCorrect = sizeof($result) < 0;
} while ($codeCorrect);
return $code; return $code;
} }
private function checkUserIdentification($id_user){ private
function checkUserIdentification($id_user)
{
$identification = Identification::where('id_user', $id_user)->first(); $identification = Identification::where('id_user', $id_user)->first();
if(isset($identification)) { if (isset($identification)) {
if ($identification->status == 0) if ($identification->status == 0)
return $this->errorResponse(trans('errors.validation_user_identification_required')); return $this->errorResponse(trans('errors.validation_user_identification_required'));
}else { } else {
return $this->errorResponse(trans('errors.user_identification_required')); return $this->errorResponse(trans('errors.user_identification_required'));
} }
} }
// public function index(Request $request){ // public function index(Request $request){
// //
// $notices = DB::select('select notices.id,notices.title,notices.body,notices.created_at,notices.updated_at, // $notices = DB::select('select notices.id,notices.title,notices.body,notices.created_at,notices.updated_at,
@ -1383,20 +1491,21 @@ class iLinkTransactionController extends Controller
// //
// } // }
public function cancel($id_transaction) public
function cancel($id_transaction)
{ {
$transaction = WalletIlinkTransaction::where('id_transaction',$id_transaction)->firstOrFail(); $transaction = WalletIlinkTransaction::where('id_transaction', $id_transaction)->firstOrFail();
$transactionInverse = $transaction->replicate(); $transactionInverse = $transaction->replicate();
$transactionInverse->date = new \DateTime(); $transactionInverse->date = new \DateTime();
$transactionInverse->montant = -$transaction->montant; $transactionInverse->montant = -$transaction->montant;
$transactionInverse->montant_net = -$transaction->montant_net; $transactionInverse->montant_net = -$transaction->montant_net;
$transactionInverse->montant_net_final_country = -$transaction->montant_net_final_country; $transactionInverse->montant_net_final_country = -$transaction->montant_net_final_country;
$transactionInverse->taxe = -$transaction->taxe; $transactionInverse->taxe = -$transaction->taxe;
$transactionInverse->frais = -$transaction->frais; $transactionInverse->frais = -$transaction->frais;
$transactionInverse->commission_ag = -$transaction->commission_ag; $transactionInverse->commission_ag = -$transaction->commission_ag;
$transactionInverse->commission_sup = -$transaction->commission_sup; $transactionInverse->commission_sup = -$transaction->commission_sup;
$transactionInverse->commission_hyp = -$transaction->commission_hyp; $transactionInverse->commission_hyp = -$transaction->commission_hyp;
$transactionInverse->commission_hyp_final_country = -$transaction->commission_hyp_final_country; $transactionInverse->commission_hyp_final_country = -$transaction->commission_hyp_final_country;
$transactionInverse->commission_banque = -$transaction->commission_banque; $transactionInverse->commission_banque = -$transaction->commission_banque;
$transactionInverse->id = null; $transactionInverse->id = null;
$transactionInverse->id_transaction = $this->getTransactionID(); $transactionInverse->id_transaction = $this->getTransactionID();
@ -1427,7 +1536,8 @@ class iLinkTransactionController extends Controller
} }
//Verfier les limites reglementaires //Verfier les limites reglementaires
public function checkReguationsLimits($identifiant, $init_country, $final_country, $montant_transaction, $is_id_document_emetteur = false) public
function checkReguationsLimits($identifiant, $init_country, $final_country, $montant_transaction, $is_id_document_emetteur = false)
{ {
$regulation = Regulation::where('id_country', $init_country)->first(); $regulation = Regulation::where('id_country', $init_country)->first();
@ -1472,7 +1582,8 @@ class iLinkTransactionController extends Controller
} }
// Recevoir le traitement d'une transaction venant d'un reseau payeur // Recevoir le traitement d'une transaction venant d'un reseau payeur
public function receiveRequestProcessingResult(Request $request) public
function receiveRequestProcessingResult(Request $request)
{ {
$this->validate($request, [ $this->validate($request, [
'id_transaction' => 'required', 'id_transaction' => 'required',

View File

@ -69,4 +69,10 @@ Paying network : :network :country',
"international_monthly_regulations_limits_reached" => "You have reached your international monthly limit.", "international_monthly_regulations_limits_reached" => "You have reached your international monthly limit.",
"forbidden" => 'Forbidden', "forbidden" => 'Forbidden',
"request_already_processed" => "This request has already been processed", "request_already_processed" => "This request has already been processed",
"recipient_network_not_configured" => "This recipient network is not configured in our system",
"recipient_network_not_authorized" => "This recipient network is not authorized to receive transactions in our system",
"bank_not_associated_with_network" => "This bank is not associated with your network",
"transmitter_network_not_configured" => "This transmitter network is not configured in our system",
"transmitter_network_not_authorized" => "This sender network is not authorized to receive transactions in our system",
"transmitter_network_not_recognized" => 'This network is not recognized as being a sender network of the recipient network',
]; ];

View File

@ -270,4 +270,12 @@ Transaction Information:
- Country of destination: :final_country - Country of destination: :final_country
- Recipient's names: :receiver_name - Recipient's names: :receiver_name
- Collection code: :code", - Collection code: :code",
'successful_user_send_to_bank' => 'Sending money from your account to the bank
Transaction Information:
- Number: :id_transaction
- Amount of the transaction: :amount
- Fees: :fees
- Net shipping amount:: net
- Issuer account: :sender_code
- IBAN: :iban',
]; ];

View File

@ -69,4 +69,10 @@ Réseau payeur : :network :country',
"international_monthly_regulations_limits_reached" => "Vous avez atteint votre limite mensuelle internationale.", "international_monthly_regulations_limits_reached" => "Vous avez atteint votre limite mensuelle internationale.",
"forbidden" => "Interdit d'access", "forbidden" => "Interdit d'access",
"request_already_processed" => "Cette requete a déja ete traitée", "request_already_processed" => "Cette requete a déja ete traitée",
"recipient_network_not_configured" => "Ce reseau destinataire n'est pas configuré dans notre systeme",
"recipient_network_not_authorized" => "Ce reseau destinataire n'est pas autorise à recevoir des transactions dans notre systeme",
"bank_not_associated_with_network" => "Cette banque n'est pas associée à votre réseau",
"transmitter_network_not_configured" => "Ce reseau emetteur n'est pas configuré dans notre systeme",
"transmitter_network_not_authorized" => "Ce reseau emetteur n'est pas autorisé à recevoir des transactions dans notre systeme",
"transmitter_network_not_recognized" => "Ce réseau n'est pas reconnu comme etant un réseau emetteur du reseau destinataire",
]; ];

View File

@ -271,4 +271,12 @@ Informations de la transaction :
- Pays de destination : :final_country - Pays de destination : :final_country
- Noms du destinataire : :receiver_name - Noms du destinataire : :receiver_name
- Code de retrait : :code", - Code de retrait : :code",
'successful_user_send_to_bank' => 'Envoi d\'argent de votre compte vers la banque
Informations de la transaction :
- Numéro : :id_transaction
- Montant de la transaction : :amount
- Frais : :fees
- Montant net d\'envoi: :net
- Compte émetteur : :sender_code
- IBAN : :iban',
]; ];