diff --git a/app/Http/Controllers/iLinkTransactionController.php b/app/Http/Controllers/iLinkTransactionController.php index 6f1f80b..b16fcae 100755 --- a/app/Http/Controllers/iLinkTransactionController.php +++ b/app/Http/Controllers/iLinkTransactionController.php @@ -340,16 +340,15 @@ class iLinkTransactionController extends Controller $transaction->expiration_date = $user->expiration_date; $transaction->numero_carte = $user->numero_carte; - $final_country = $request->input('final_country'); - $transaction->final_country = $final_country; +// $final_country = $request->input('final_country'); $plr_user_wallet_cart_national = $this->getPaliers($paliers_commission_wallets, 'user_wallet_cart_national'); - $plr_user_wallet_cart_international = $this->getPaliers($paliers_commission_wallets, 'user_wallet_cart_international'); +// $plr_user_wallet_cart_international = $this->getPaliers($paliers_commission_wallets, 'user_wallet_cart_international'); $plr_hyp_user_wallet_cart_national = $this->getPaliers($paliers_commission_wallets, 'hyp_user_wallet_cart_national'); - $plr_hyp_user_wallet_cart_international = $this->getPaliers($paliers_commission_wallets, 'hyp_user_wallet_cart_international'); +// $plr_hyp_user_wallet_cart_international = $this->getPaliers($paliers_commission_wallets, 'hyp_user_wallet_cart_international'); $plr_bank_user_wallet_cart_national = $this->getPaliers($paliers_commission_wallets, 'bank_user_wallet_cart_national'); - $plr_bank_user_wallet_cart_international = $this->getPaliers($paliers_commission_wallets, 'bank_user_wallet_cart_international'); +// $plr_bank_user_wallet_cart_international = $this->getPaliers($paliers_commission_wallets, 'bank_user_wallet_cart_international'); - $frais = ($init_country != $final_country) ? $this->calculateFees($plr_user_wallet_cart_international, $request->montant) : $this->calculateFees($plr_user_wallet_cart_national, $request->montant); + $frais = $this->calculateFees($plr_user_wallet_cart_national, $request->montant); $transaction->montant_net = $montantDepot = $transaction->montant - $frais; // $body['amount'] = $this->toUSDAmount($montantDepot, $init_country); @@ -373,8 +372,8 @@ class iLinkTransactionController extends Controller $walletUser->balance -= $transaction->montant; //Emettre une trame SSL pour recharger le compte de la banque partenaire du montant de sa commission - $transaction->commission_banque = ($init_country != $final_country) ? $this->calculateFees($plr_bank_user_wallet_cart_national, $request->montant, $frais) : $this->calculateFees($plr_bank_user_wallet_cart_international, $request->montant, $frais); - $transaction->commission_hyp = ($init_country != $final_country) ? $this->calculateFees($plr_hyp_user_wallet_cart_national, $request->montant, $frais) : $this->calculateFees($plr_hyp_user_wallet_cart_international, $request->montant, $frais); + $transaction->commission_banque = $this->calculateFees($plr_bank_user_wallet_cart_national, $request->montant, $frais); + $transaction->commission_hyp = $this->calculateFees($plr_hyp_user_wallet_cart_national, $request->montant, $frais); $walletHyperviseur->balance_com += $transaction->commission_hyp; $transaction->id_wallet_hyp = $walletHyperviseur->id; @@ -640,16 +639,16 @@ class iLinkTransactionController extends Controller $transaction->expiration_date = $user->expiration_date; $transaction->numero_carte = $user->numero_carte; - $final_country = $request->input('final_country'); - $transaction->final_country = $final_country; +// $final_country = $request->input('final_country'); +// $transaction->final_country = $final_country; $plr_user_cart_wallet_national = $this->getPaliers($paliers_commission_wallets, 'user_cart_wallet_national'); - $plr_user_cart_wallet_international = $this->getPaliers($paliers_commission_wallets, 'user_cart_wallet_international'); +// $plr_user_cart_wallet_international = $this->getPaliers($paliers_commission_wallets, 'user_cart_wallet_international'); $plr_hyp_user_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'hyp_user_cart_cash_national'); - $plr_hyp_user_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'hyp_user_cart_cash_international'); +// $plr_hyp_user_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'hyp_user_cart_cash_international'); $plr_bank_user_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'bank_user_cart_cash_national'); - $plr_bank_user_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'bank_user_cart_cash_international'); +// $plr_bank_user_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'bank_user_cart_cash_international'); - $frais = ($init_country != $final_country) ? $this->calculateFees($plr_user_cart_wallet_international, $request->montant) : $this->calculateFees($plr_user_cart_wallet_national, $request->montant); + $frais = $this->calculateFees($plr_user_cart_wallet_national, $request->montant); $transaction->montant_net = $montantRetrait = $transaction->montant + $frais; // $body['amount'] = $this->toUSDAmount($montantRetrait, $init_country); @@ -671,11 +670,11 @@ class iLinkTransactionController extends Controller $response = json_decode($response->getBody()->getContents(), true)["response"]; $transaction->pspReference = $response["pspReference"]; - $transaction->commission_banque = ($init_country != $final_country) ? $this->calculateFees($plr_bank_user_cart_cash_international, $request->montant, $frais) : $this->calculateFees($plr_bank_user_cart_cash_national, $request->montant, $frais); + $transaction->commission_banque = $this->calculateFees($plr_bank_user_cart_cash_national, $request->montant, $frais); //Emettre une trame SSL pour recharger le compte de la banque partenaire du montant de sa commission $walletUser->balance += $transaction->montant; - $transaction->commission_hyp = ($init_country != $final_country) ? $this->calculateFees($plr_hyp_user_cart_cash_national, $request->montant, $frais) : $this->calculateFees($plr_hyp_user_cart_cash_international, $request->montant, $frais); + $transaction->commission_hyp = $this->calculateFees($plr_hyp_user_cart_cash_national, $request->montant, $frais); $walletHyperviseur->balance_com += $transaction->commission_hyp; $transaction->id_wallet_hyp = $walletHyperviseur->id; $transaction->frais = $frais; @@ -706,17 +705,17 @@ class iLinkTransactionController extends Controller $transaction->expiration_date = $user->expiration_date; $transaction->numero_carte = $user->numero_carte; -// $transaction->final_country = $init_country; - $final_country = $request->input('final_country'); - $transaction->final_country = $final_country; + $transaction->final_country = $init_country; +// $final_country = $request->input('final_country'); +// $transaction->final_country = $final_country; $plr_user_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'user_cart_cash_national'); - $plr_user_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'user_cart_cash_international'); +// $plr_user_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'user_cart_cash_international'); $plr_hyp_user_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'hyp_user_cart_cash_national'); - $plr_hyp_user_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'hyp_user_cart_cash_international'); +// $plr_hyp_user_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'hyp_user_cart_cash_international'); $plr_bank_user_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'bank_user_cart_cash_national'); - $plr_bank_user_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'bank_user_cart_cash_international'); +// $plr_bank_user_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'bank_user_cart_cash_international'); - $frais = ($init_country != $final_country) ? $this->calculateFees($plr_user_cart_cash_international, $request->montant) : $this->calculateFees($plr_user_cart_cash_national, $request->montant); + $frais = $this->calculateFees($plr_user_cart_cash_national, $request->montant); $transaction->montant_net = $montantRetrait = $transaction->montant + $frais; $transaction->montant_net_final_country = $transaction->montant; @@ -738,7 +737,7 @@ class iLinkTransactionController extends Controller $response = json_decode($response->getBody()->getContents(), true)["response"]; $transaction->pspReference = $response["pspReference"]; - $transaction->commission_banque = ($init_country != $final_country) ? $this->calculateFees($plr_bank_user_cart_cash_international, $request->montant, $frais) : $this->calculateFees($plr_bank_user_cart_cash_national, $request->montant, $frais); + $transaction->commission_banque = $this->calculateFees($plr_bank_user_cart_cash_national, $request->montant, $frais); //Emettre une trame SSL pour recharger le compte de la banque partenaire du montant de sa commission $code_retrait = $this->random_string(); @@ -746,7 +745,7 @@ class iLinkTransactionController extends Controller $transaction->encrypted_code_retrait = $hash['encrypted']; $transaction->code_retrait_salt = $hash['salt']; - $transaction->commission_hyp = ($init_country != $final_country) ? $this->calculateFees($plr_hyp_user_cart_cash_national, $request->montant, $frais) : $this->calculateFees($plr_hyp_user_cart_cash_international, $request->montant, $frais); + $transaction->commission_hyp = $this->calculateFees($plr_hyp_user_cart_cash_national, $request->montant, $frais); $walletHyperviseur->balance_com += $transaction->commission_hyp; $transaction->id_wallet_hyp = $walletHyperviseur->id; $transaction->frais = $frais; @@ -875,21 +874,21 @@ class iLinkTransactionController extends Controller if (!$expiration_date) $expiration_date = new DateTime(); $transaction->expiration_date = $expiration_date; - $transaction->final_country = $request->final_country; + $transaction->final_country = $init_country; - $final_country = $request->final_country; +// $final_country = $request->final_country; $plr_customer_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'customer_cart_cash_national'); - $plr_customer_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'customer_cart_cash_international'); +// $plr_customer_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'customer_cart_cash_international'); $plr_agent_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'agent_cart_cash_national'); - $plr_agent_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'agent_cart_cash_international'); +// $plr_agent_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'agent_cart_cash_international'); $plr_sup_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'sup_cart_cash_national'); - $plr_sup_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'sup_cart_cash_international'); +// $plr_sup_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'sup_cart_cash_international'); $plr_hyp_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'hyp_cart_cash_national'); - $plr_hyp_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'hyp_cart_cash_international'); +// $plr_hyp_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'hyp_cart_cash_international'); $plr_bank_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'bank_cart_cash_national'); - $plr_bank_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'bank_cart_cash_international'); +// $plr_bank_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'bank_cart_cash_international'); - $frais = ($init_country != $final_country) ? $this->calculateFees($plr_customer_cart_cash_international, $request->montant) : $this->calculateFees($plr_customer_cart_cash_national, $request->montant); + $frais = $this->calculateFees($plr_customer_cart_cash_national, $request->montant); $montantRetrait = $transaction->montant + $frais; $transaction->montant_net = $montantRetrait; // $body['amount'] = $this->toUSDAmount($montantRetrait, $init_country); @@ -909,7 +908,7 @@ class iLinkTransactionController extends Controller $response = json_decode($response->getBody()->getContents(), true)["response"]; $transaction->pspReference = $response["pspReference"]; - $banqueCommission = ($init_country != $final_country) ? $this->calculateFees($plr_bank_cart_cash_international, $request->montant, $frais) : $this->calculateFees($plr_bank_cart_cash_national, $request->montant, $frais); + $banqueCommission = $this->calculateFees($plr_bank_cart_cash_national, $request->montant, $frais); $transaction->commission_banque = $banqueCommission; // 2---> Emmètre via API sécurisé SSL une requête de débit de notre //compte marchand du (Part de la banque partenaire en % @@ -919,9 +918,9 @@ class iLinkTransactionController extends Controller $walletAgent->balance_princ += $transaction->montant; - $agentCommission = ($init_country != $final_country) ? $this->calculateFees($plr_agent_cart_cash_international, $request->montant, $frais) : $this->calculateFees($plr_agent_cart_cash_national, $request->montant, $frais); - $superviseurCommission = ($init_country != $final_country) ? $this->calculateFees($plr_sup_cart_cash_international, $request->montant, $frais) : $this->calculateFees($plr_sup_cart_cash_national, $request->montant, $frais); - $hyperviseurCommission = ($init_country != $final_country) ? $this->calculateFees($plr_hyp_cart_cash_international, $request->montant, $frais) : $this->calculateFees($plr_hyp_cart_cash_national, $request->montant, $frais); + $agentCommission = $this->calculateFees($plr_agent_cart_cash_national, $request->montant, $frais); + $superviseurCommission = $this->calculateFees($plr_sup_cart_cash_national, $request->montant, $frais); + $hyperviseurCommission = $this->calculateFees($plr_hyp_cart_cash_national, $request->montant, $frais); $walletAgent->balance_com += $agentCommission; $transaction->commission_ag = $agentCommission; @@ -1085,21 +1084,21 @@ class iLinkTransactionController extends Controller if (!$expiration_date) $expiration_date = new DateTime(); $transaction->expiration_date = $expiration_date; - $transaction->final_country = $request->final_country; + $transaction->final_country = $init_country; - $final_country = $request->final_country; +// $final_country = $request->final_country; $plr_customer_cash_cart_national = $this->getPaliers($paliers_commission_wallets, 'customer_cash_cart_national'); - $plr_customer_cash_cart_international = $this->getPaliers($paliers_commission_wallets, 'customer_cash_cart_international'); +// $plr_customer_cash_cart_international = $this->getPaliers($paliers_commission_wallets, 'customer_cash_cart_international'); $plr_agent_cash_cart_national = $this->getPaliers($paliers_commission_wallets, 'agent_cash_cart_national'); - $plr_agent_cash_cart_international = $this->getPaliers($paliers_commission_wallets, 'agent_cash_cart_international'); +// $plr_agent_cash_cart_international = $this->getPaliers($paliers_commission_wallets, 'agent_cash_cart_international'); $plr_sup_cash_cart_national = $this->getPaliers($paliers_commission_wallets, 'sup_cash_cart_national'); - $plr_sup_cash_cart_international = $this->getPaliers($paliers_commission_wallets, 'sup_cash_cart_international'); +// $plr_sup_cash_cart_international = $this->getPaliers($paliers_commission_wallets, 'sup_cash_cart_international'); $plr_hyp_cash_cart_national = $this->getPaliers($paliers_commission_wallets, 'hyp_cash_cart_national'); - $plr_hyp_cash_cart_international = $this->getPaliers($paliers_commission_wallets, 'hyp_cash_cart_international'); +// $plr_hyp_cash_cart_international = $this->getPaliers($paliers_commission_wallets, 'hyp_cash_cart_international'); $plr_bank_cash_cart_national = $this->getPaliers($paliers_commission_wallets, 'bank_cash_cart_national'); - $plr_bank_cash_cart_international = $this->getPaliers($paliers_commission_wallets, 'bank_cash_cart_international'); +// $plr_bank_cash_cart_international = $this->getPaliers($paliers_commission_wallets, 'bank_cash_cart_international'); - $frais = ($init_country != $final_country) ? $this->calculateFees($plr_customer_cash_cart_international, $request->montant) : $this->calculateFees($plr_customer_cash_cart_national, $request->montant); + $frais = $this->calculateFees($plr_customer_cash_cart_national, $request->montant); $montantDepot = $transaction->montant - $frais; $transaction->montant_net = $montantDepot; @@ -1121,7 +1120,7 @@ class iLinkTransactionController extends Controller $response = json_decode($response->getBody()->getContents(), true)["response"]; $transaction->pspReference = $response["pspReference"]; - $banqueCommission = ($init_country != $final_country) ? $this->calculateFees($plr_bank_cash_cart_international, $request->montant, $frais) : $this->calculateFees($plr_bank_cash_cart_national, $request->montant, $frais); + $banqueCommission = $this->calculateFees($plr_bank_cash_cart_national, $request->montant, $frais); $transaction->commission_banque = $banqueCommission; // 2---> Emmètre via API sécurisé SSL une requête de débit de notre //compte marchand du (Part de la banque partenaire en % @@ -1131,9 +1130,9 @@ class iLinkTransactionController extends Controller $walletAgent->balance_princ -= $transaction->montant; - $agentCommission = ($init_country != $final_country) ? $this->calculateFees($plr_agent_cash_cart_international, $request->montant, $frais) : $this->calculateFees($plr_agent_cash_cart_national, $request->montant, $frais); - $superviseurCommission = ($init_country != $final_country) ? $this->calculateFees($plr_sup_cash_cart_international, $request->montant, $frais) : $this->calculateFees($plr_sup_cash_cart_national, $request->montant, $frais); - $hyperviseurCommission = ($init_country != $final_country) ? $this->calculateFees($plr_hyp_cash_cart_international, $request->montant, $frais) : $this->calculateFees($plr_hyp_cash_cart_national, $request->montant, $frais); + $agentCommission = $this->calculateFees($plr_agent_cash_cart_national, $request->montant, $frais); + $superviseurCommission = $this->calculateFees($plr_sup_cash_cart_national, $request->montant, $frais); + $hyperviseurCommission = $this->calculateFees($plr_hyp_cash_cart_national, $request->montant, $frais); $walletAgent->balance_com += $agentCommission; $transaction->commission_ag = $agentCommission; @@ -1768,13 +1767,9 @@ class iLinkTransactionController extends Controller $data['montant_net_final'] = $this->toMoneyWithCurrency($data['montant_net_init'], $init_country, $request->final_country); break; case 2: //User - Envoi de wallet à carte - $this->validate($request, [ - 'final_country' => 'required|integer|exists:countries,id' - ]); - $final_country = $request->input('final_country'); $plr_user_wallet_cart_national = $this->getPaliers($paliers_commission_wallets, 'user_wallet_cart_national'); - $plr_user_wallet_cart_international = $this->getPaliers($paliers_commission_wallets, 'user_wallet_cart_international'); - $frais = ($init_country != $final_country) ? $this->calculateFees($plr_user_wallet_cart_international, $request->montant) : $this->calculateFees($plr_user_wallet_cart_national, $request->montant); +// $plr_user_wallet_cart_international = $this->getPaliers($paliers_commission_wallets, 'user_wallet_cart_international'); + $frais = $this->calculateFees($plr_user_wallet_cart_national, $request->montant); $data['frais'] = round($frais, 2); $data['montant_net'] = round($request->montant - $data['frais'], 2); break; @@ -1795,35 +1790,23 @@ class iLinkTransactionController extends Controller $data['montant_net'] = round($request->montant - $data['frais'], 2); break; case 10: //User - Retrait de carte vers wallet - $this->validate($request, [ - 'final_country' => 'required|integer|exists:countries,id' - ]); - $final_country = $request->input('final_country'); $plr_user_cart_wallet_national = $this->getPaliers($paliers_commission_wallets, 'user_cart_wallet_national'); - $plr_user_cart_wallet_international = $this->getPaliers($paliers_commission_wallets, 'user_cart_wallet_international'); - $frais = ($init_country != $final_country) ? $this->calculateFees($plr_user_cart_wallet_international, $request->montant) : $this->calculateFees($plr_user_cart_wallet_national, $request->montant); +// $plr_user_cart_wallet_international = $this->getPaliers($paliers_commission_wallets, 'user_cart_wallet_international'); + $frais = $this->calculateFees($plr_user_cart_wallet_national, $request->montant); $data['frais'] = round($frais, 2); $data['montant_net'] = round($request->montant + $data['frais'], 2); break; case 11: // User - Retrait de carte vers cash - $this->validate($request, [ - 'final_country' => 'required|integer|exists:countries,id' - ]); - $final_country = $request->input('final_country'); $plr_user_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'user_cart_cash_national'); - $plr_user_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'user_cart_cash_international'); - $frais = ($init_country != $final_country) ? $this->calculateFees($plr_user_cart_cash_international, $request->montant) : $this->calculateFees($plr_user_cart_cash_national, $request->montant); +// $plr_user_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'user_cart_cash_international'); + $frais = $this->calculateFees($plr_user_cart_cash_national, $request->montant); $data['frais'] = round($frais, 2); $data['montant_net'] = round($request->montant + $data['frais'], 2); break; case 13: // Agent - Retrait de la carte vers cash - $this->validate($request, [ - 'final_country' => 'required|integer|exists:countries,id', - ]); - $final_country = $request->input('final_country'); $plr_customer_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'customer_cart_cash_national'); - $plr_customer_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'customer_cart_cash_international'); - $frais = ($init_country != $final_country) ? $this->calculateFees($plr_customer_cart_cash_international, $request->montant) : $this->calculateFees($plr_customer_cart_cash_national, $request->montant); +// $plr_customer_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'customer_cart_cash_international'); + $frais = $this->calculateFees($plr_customer_cart_cash_national, $request->montant); $data['frais'] = round($frais, 2); $data['montant_net'] = round($request->montant + $data['frais'], 2); break; @@ -1852,13 +1835,9 @@ class iLinkTransactionController extends Controller $data['montant_net_final'] = $this->toMoneyWithCurrency($data['montant_net_init'], $init_country, $request->final_country); break; case 16: // Agent - Envoi de cash vers une carte visa - $this->validate($request, [ - 'final_country' => 'required|integer|exists:countries,id' - ]); - $final_country = $request->input('final_country'); $plr_customer_cash_cart_national = $this->getPaliers($paliers_commission_wallets, 'customer_cash_cart_national'); - $plr_customer_cash_cart_international = $this->getPaliers($paliers_commission_wallets, 'customer_cash_cart_international'); - $frais = ($init_country != $final_country) ? $this->calculateFees($plr_customer_cash_cart_international, $request->montant) : $this->calculateFees($plr_customer_cash_cart_national, $request->montant); +// $plr_customer_cash_cart_international = $this->getPaliers($paliers_commission_wallets, 'customer_cash_cart_international'); + $frais = $this->calculateFees($plr_customer_cash_cart_national, $request->montant); $data['frais'] = round($frais, 2); $data['montant_net'] = round($request->montant - $data['frais'], 2); break; diff --git a/app/Models/WalletIlinkTransaction.php b/app/Models/WalletIlinkTransaction.php index d953eff..2541f6f 100644 --- a/app/Models/WalletIlinkTransaction.php +++ b/app/Models/WalletIlinkTransaction.php @@ -201,7 +201,7 @@ class WalletIlinkTransaction extends Model public function card_rules() { return [ - 'final_country' => 'required|integer|exists:countries,id', +// 'final_country' => 'required|integer|exists:countries,id', 'numero_carte' => 'required', 'cvv' => 'required|size:3', 'expiration_date' => 'required|date_format:m/y|after_or_equal:today', @@ -211,7 +211,7 @@ class WalletIlinkTransaction extends Model public function user_card_rules() { return [ - 'final_country' => 'required|integer|exists:countries,id', +// 'final_country' => 'required|integer|exists:countries,id', 'cvv' => 'required|size:3', ]; }