diff --git a/app/Http/Controllers/TransmittingNetworksController.php b/app/Http/Controllers/TransmittingNetworksController.php index f62a06f..dc8d8ca 100755 --- a/app/Http/Controllers/TransmittingNetworksController.php +++ b/app/Http/Controllers/TransmittingNetworksController.php @@ -107,20 +107,20 @@ class TransmittingNetworksController extends Controller $configTransmitter = ConfigWallet::where('id_network', $request->network_emetteur)->first(); 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') - 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) - 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') - 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(); 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(); diff --git a/app/Http/Controllers/iLinkTransactionController.php b/app/Http/Controllers/iLinkTransactionController.php index de5fd85..e3fb066 100755 --- a/app/Http/Controllers/iLinkTransactionController.php +++ b/app/Http/Controllers/iLinkTransactionController.php @@ -23,6 +23,7 @@ use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Http\Response; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Log; 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), '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), - '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); 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), '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_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); return $this->successResponse($message . trans('messages.sent_by_mail')); } @@ -377,8 +378,57 @@ class iLinkTransactionController extends Controller } break; 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; // case 5: //User - Envoi de carte à wallet // $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(); if ($transaction) { //Verifier si l'agent qui a effectué l'envoi de cash à cash ne puisse pas retirer l'argent - if($transaction->type == 17) - if($transaction->id_wallet_ag == $walletAgent->id) + if ($transaction->type == 17) + if ($transaction->id_wallet_ag == $walletAgent->id) return $this->errorResponse(trans('errors.agent_unauthorized')); //Verifier que le reseau payeur est de type iLink if (in_array($transaction->type, [3, 17])) { $configPayeur = ConfigWallet::where('id_network', $transaction->network_destinataire)->firstOrFail(); 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)])); } if ($transaction->status_retrait == 0) { @@ -597,8 +647,8 @@ class iLinkTransactionController extends Controller $transactionRetrait->id_transaction = $this->getTransactionID(); $transactionRetrait->montant = $montantNet; $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; - $destinataire = in_array($transaction->type, [9, 11]) ? $emetteur : $transaction->prenom_destinataire . ' ' . $transaction->nom_destinataire; + $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); @@ -830,7 +880,7 @@ class iLinkTransactionController extends Controller $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), '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,]); $this->sendMail($request->email_emetteur, trans('messages.successful_transaction'), $message); 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), '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), - 'network'=> $this->getNetworkName($transaction->network_destinataire)]); + 'network' => $this->getNetworkName($transaction->network_destinataire)]); $this->sendMail($request->email_emetteur, trans('messages.successful_transaction'), $message); return $this->successResponse($message . trans('messages.sent_by_mail')); } else { @@ -1013,34 +1063,81 @@ class iLinkTransactionController extends Controller } break; case 18: // Agent - Envoi de cash vers banque - // Indisponible - break; + $this->validate($request, [ + '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); - $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, 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]); - foreach ($transactions as $data){ + foreach ($transactions as $data) { $data->operation = app()->isLocale('en') ? $data->operation_en : $data->operation_fr; $date = $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 = 'Moi'; - if($data->destinataire_phone){ + if ($data->destinataire_phone) { $destinataire = $data->destinataire_name; - }else{ - $destinataire = $data->prenom_destinataire ? $data->prenom_destinataire . ' ' . $data->nom_destinataire : $emetteur; + } else { + $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 : // $data->prenom_destinataire . ' ' . $data->nom_destinataire); @@ -1048,11 +1145,11 @@ class iLinkTransactionController extends Controller $data->destinataire = $destinataire; $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_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->init_country = $data->pays_init; $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; 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); @@ -1060,7 +1157,8 @@ class iLinkTransactionController extends Controller 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, 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 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; $date = $data->date; unset($data->date); - $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 ; - $emetteur = $wallet_user ? $wallet_user->user->lastname.' '.$wallet_user->user->firstname : $data->prenom_emetteur . ' ' . $data->nom_emetteur; - if(!$wallet_user && !$data->nom_emetteur) + $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; + $emetteur = $wallet_user ? $wallet_user->user->lastname . ' ' . $wallet_user->user->firstname : $data->prenom_emetteur . ' ' . $data->nom_emetteur; + if (!$wallet_user && !$data->nom_emetteur) $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->emetteur = $emetteur; $data->destinataire = $destinataire; $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_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->init_country = $this->getCountryName($data->init_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); } - public function calculateCommission(Request $request) + public + function calculateCommission(Request $request) { $rules = [ '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(); //Verifier si c'est pas un reseau ilink $data['destinataire'] = $destinataire ? $destinataire->lastname . ' ' . $destinataire->firstname : $request->id_destinataire; - $data['frais'] = round($frais + $taxe,2); - $data['montant_net_init'] = round($request->montant - $data['frais'] , 2); + $data['frais'] = round($frais + $taxe, 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); break; case 2: //User - Envoi de wallet à carte $frais = $request->montant * $config->taux_com_user_wallet_carte / 100; - $data['frais'] = round($frais,2); - $data['montant_net'] = round($request->montant - $data['frais'],2); + $data['frais'] = round($frais, 2); + $data['montant_net'] = round($request->montant - $data['frais'], 2); break; case 3: // User - Envoi wallet à cash $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); $taxe = ($init_country != $request->final_country) ? $this->calculateTax($taxesInternationales, $frais) : $this->calculateTax($taxesNationales, $frais); - $data['frais'] = round($frais + $taxe,2); - $data['montant_net_init'] = round($request->montant - $data['frais'],2); + $data['frais'] = round($frais + $taxe, 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); break; case 9: // User - Retrait de wallet en cash $frais = $this->calculateFees($plr_user_wallet_cash_national, $request->montant); $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); break; case 10: //User - Retrait de carte vers wallet @@ -1206,8 +1305,8 @@ class iLinkTransactionController extends Controller $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); $taxe = ($init_country != $final_country) ? $this->calculateTax($taxesInternationales, $frais) : $this->calculateTax($taxesNationales, $frais); - $data['frais'] = round($frais + $taxe,2); - $data['montant_net_init'] = round($request->montant - $data['frais'],2); + $data['frais'] = round($frais + $taxe, 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); break; 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); $taxe = ($init_country != $request->final_country) ? $this->calculateTax($taxesInternationales, $frais) : $this->calculateTax($taxesNationales, $frais); - $data['frais'] = round($frais + $taxe,2); - $data['montant_net_init'] = round($request->montant - $data['frais'],2); + $data['frais'] = round($frais + $taxe, 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); break; case 16: // Agent - Envoi de cash vers une carte visa $frais = $request->montant * $config->taux_com_wallet_ag_envoi_cash_carte / 100; - $data['frais'] = round($frais,2); - $data['montant_net'] = round($request->montant - $data['frais'],2); + $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, [ @@ -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); $taxe = ($init_country != $request->final_country) ? $this->calculateTax($taxesInternationales, $frais) : $this->calculateTax($taxesNationales, $frais); - $data['frais'] = round($frais + $taxe,2); - $data['montant_net_init'] = round($request->montant - $data['frais'],2); + $data['frais'] = round($frais + $taxe, 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); break; } $net = isset($data['montant_net']) ? $data['montant_net'] : $data['montant_net_init']; - if(isset($net)) - if($net < 0) + if (isset($net)) + if ($net < 0) return $this->errorResponse(trans('errors.incorrect_net_amount')); return $this->successResponse($data); } - public function getTransactionRetrait(Request $request) + public + function getTransactionRetrait(Request $request) { $this->validate($request, [ 'id_transaction' => 'required', @@ -1251,13 +1351,13 @@ class iLinkTransactionController extends Controller 'code_retrait' => 'required', ]); - $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(); + $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(); if (!$transaction) 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')); @@ -1292,14 +1392,15 @@ class iLinkTransactionController extends Controller // $data->user_code = $transaction->wallet_user->user->user_code; } $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, - $data->encrypted_code_retrait,$data->montant_net_final_country, $data->montant_net); + 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); 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 $palier->type == $type; @@ -1307,7 +1408,8 @@ class iLinkTransactionController extends Controller } //Calcul des frais internationaux - private function calculateFees(array $paliers, $montant) + private + function calculateFees(array $paliers, $montant) { $size = sizeof($paliers); 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('count' => 12, 'characters' => 'ABCDEFGHJKMNPQRSTUVWXYZ'); @@ -1349,25 +1452,30 @@ class iLinkTransactionController extends Controller return implode('', $temp_array); } - private function getTransactionID(){ - do{ - $code=$this->generateTransactionCode(); - $result = collect(DB::select('SELECT * FROM wallet_ilink_transaction WHERE id_transaction = :code',['code'=>$code])); - $codeCorrect=sizeof($result)<0; - }while($codeCorrect); + private + function getTransactionID() + { + do { + $code = $this->generateTransactionCode(); + $result = collect(DB::select('SELECT * FROM wallet_ilink_transaction WHERE id_transaction = :code', ['code' => $code])); + $codeCorrect = sizeof($result) < 0; + } while ($codeCorrect); return $code; } - private function checkUserIdentification($id_user){ + private + function checkUserIdentification($id_user) + { $identification = Identification::where('id_user', $id_user)->first(); - if(isset($identification)) { + if (isset($identification)) { if ($identification->status == 0) return $this->errorResponse(trans('errors.validation_user_identification_required')); - }else { + } else { return $this->errorResponse(trans('errors.user_identification_required')); } } + // public function index(Request $request){ // // $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->date = new \DateTime(); - $transactionInverse->montant = -$transaction->montant; - $transactionInverse->montant_net = -$transaction->montant_net; - $transactionInverse->montant_net_final_country = -$transaction->montant_net_final_country; - $transactionInverse->taxe = -$transaction->taxe; - $transactionInverse->frais = -$transaction->frais; - $transactionInverse->commission_ag = -$transaction->commission_ag; - $transactionInverse->commission_sup = -$transaction->commission_sup; - $transactionInverse->commission_hyp = -$transaction->commission_hyp; - $transactionInverse->commission_hyp_final_country = -$transaction->commission_hyp_final_country; + $transactionInverse->montant = -$transaction->montant; + $transactionInverse->montant_net = -$transaction->montant_net; + $transactionInverse->montant_net_final_country = -$transaction->montant_net_final_country; + $transactionInverse->taxe = -$transaction->taxe; + $transactionInverse->frais = -$transaction->frais; + $transactionInverse->commission_ag = -$transaction->commission_ag; + $transactionInverse->commission_sup = -$transaction->commission_sup; + $transactionInverse->commission_hyp = -$transaction->commission_hyp; + $transactionInverse->commission_hyp_final_country = -$transaction->commission_hyp_final_country; $transactionInverse->commission_banque = -$transaction->commission_banque; $transactionInverse->id = null; $transactionInverse->id_transaction = $this->getTransactionID(); @@ -1427,7 +1536,8 @@ class iLinkTransactionController extends Controller } //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(); @@ -1472,7 +1582,8 @@ class iLinkTransactionController extends Controller } // Recevoir le traitement d'une transaction venant d'un reseau payeur - public function receiveRequestProcessingResult(Request $request) + public + function receiveRequestProcessingResult(Request $request) { $this->validate($request, [ 'id_transaction' => 'required', diff --git a/resources/lang/en/errors.php b/resources/lang/en/errors.php index 87b3938..c176a15 100755 --- a/resources/lang/en/errors.php +++ b/resources/lang/en/errors.php @@ -69,4 +69,10 @@ Paying network : :network :country', "international_monthly_regulations_limits_reached" => "You have reached your international monthly limit.", "forbidden" => 'Forbidden', "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', ]; diff --git a/resources/lang/en/messages.php b/resources/lang/en/messages.php index a1646ae..12915d0 100755 --- a/resources/lang/en/messages.php +++ b/resources/lang/en/messages.php @@ -270,4 +270,12 @@ Transaction Information: - Country of destination: :final_country - Recipient's names: :receiver_name - 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', ]; diff --git a/resources/lang/fr/errors.php b/resources/lang/fr/errors.php index 7be31c3..255ba92 100755 --- a/resources/lang/fr/errors.php +++ b/resources/lang/fr/errors.php @@ -69,4 +69,10 @@ Réseau payeur : :network :country', "international_monthly_regulations_limits_reached" => "Vous avez atteint votre limite mensuelle internationale.", "forbidden" => "Interdit d'access", "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", ]; diff --git a/resources/lang/fr/messages.php b/resources/lang/fr/messages.php index 9bab621..188ba63 100755 --- a/resources/lang/fr/messages.php +++ b/resources/lang/fr/messages.php @@ -271,4 +271,12 @@ Informations de la transaction : - Pays de destination : :final_country - Noms du destinataire : :receiver_name - 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', ];