feat(ilink transaction): use card country id in each card operation and commission calculation

This commit is contained in:
Djery-Tom 2023-07-26 13:52:32 +01:00
parent 1d278c10ba
commit d954a2b43e
5 changed files with 163 additions and 119 deletions

View File

@ -109,12 +109,13 @@ class WalletController extends Controller
// Wallets users iLink // Wallets users iLink
public function showWalletUser($id_user) public function showWalletUser($id_user)
{ {
$wallet = collect(DB::select('SELECT wu.*, u.user_code , u.numero_carte , u.expiration_date ,n2.id as id_wallet_network, n2.name as network , cc.name as country, cc.currency_code , cw.has_nano_credit from wallets_users wu $wallet = collect(DB::select('SELECT wu.*, u.user_code , u.numero_carte , u.expiration_date ,n2.id as id_wallet_network, n2.name as network , cc.name as country, cc.currency_code , card_cc.currency_code as card_currency_code, cw.has_nano_credit from wallets_users wu
INNER JOIN users u ON u.id = wu.idUser INNER JOIN users u ON u.id = wu.idUser
INNER JOIN networks n1 ON n1.id = u.network_id INNER JOIN networks n1 ON n1.id = u.network_id
INNER JOIN networks n2 ON n2.country_id = n1.country_id INNER JOIN networks n2 ON n2.country_id = n1.country_id
INNER JOIN configWallet cw ON cw.id_network = n2.id INNER JOIN configWallet cw ON cw.id_network = n2.id
INNER JOIN countries_currencies cc ON cc.id = n2.country_id INNER JOIN countries_currencies cc ON cc.id = n2.country_id
LEFT JOIN countries_currencies card_cc ON card_cc.id = u.card_country_id
WHERE wu.idUser = :id_user AND cw.type = \'ilink\' LIMIT 1', ['id_user' => $id_user]))->first(); WHERE wu.idUser = :id_user AND cw.type = \'ilink\' LIMIT 1', ['id_user' => $id_user]))->first();
if ($wallet) { if ($wallet) {
return $this->successResponse($wallet); return $this->successResponse($wallet);

View File

@ -176,7 +176,13 @@ class iLinkTransactionController extends Controller
$walletSuperviseur = Wallet::findOrFail($wallet_agent_sup->wallet_id); $walletSuperviseur = Wallet::findOrFail($wallet_agent_sup->wallet_id);
} else { } else {
$walletUser = WalletsUser::findOrFail($id_wallet_user); $walletUser = WalletsUser::findOrFail($id_wallet_user);
$transaction->init_country = $init_country = $walletUser->user->network->country->id; // Pour les operations à cartes, le pays initial c'est le pays de la carte
if(in_array($type->id, [10, 11])){
$init_country = $walletUser->user->card_country_id;
}else{
$init_country = $walletUser->user->network->country->id;
}
$transaction->init_country = $init_country;
$result = ConfigWallet::join('networks', 'networks.id', '=', 'configWallet.id_network') $result = ConfigWallet::join('networks', 'networks.id', '=', 'configWallet.id_network')
->where('networks.country_id', $init_country)->where('configWallet.type', 'ilink') ->where('networks.country_id', $init_country)->where('configWallet.type', 'ilink')
->select('configWallet.id')->first(); ->select('configWallet.id')->first();
@ -340,7 +346,7 @@ class iLinkTransactionController extends Controller
$transaction->save(); $transaction->save();
$message = trans('messages.successful_user_send_to_wallet', $message = trans('messages.successful_user_send_to_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), 'net_final' => $this->toMoney($transaction->montant_net_final_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);
@ -361,39 +367,42 @@ class iLinkTransactionController extends Controller
$transaction->expiration_date = $user->expiration_date; $transaction->expiration_date = $user->expiration_date;
$transaction->numero_carte = $user->numero_carte; $transaction->numero_carte = $user->numero_carte;
// $final_country = $request->input('final_country'); $final_country = $user->card_country_id;
$plr_user_wallet_cart_national = $this->getPaliers($paliers_commission_wallets, 'user_wallet_cart_national'); $transaction->final_country = $final_country;
// $plr_user_wallet_cart_international = $this->getPaliers($paliers_commission_wallets, 'user_wallet_cart_international');
$plr_hyp_user_wallet_cart_national = $this->getPaliers($paliers_commission_wallets, 'hyp_user_wallet_cart_national');
// $plr_hyp_user_wallet_cart_international = $this->getPaliers($paliers_commission_wallets, 'hyp_user_wallet_cart_international');
$plr_bank_user_wallet_cart_national = $this->getPaliers($paliers_commission_wallets, 'bank_user_wallet_cart_national');
// $plr_bank_user_wallet_cart_international = $this->getPaliers($paliers_commission_wallets, 'bank_user_wallet_cart_international');
$frais = $this->calculateFees($plr_user_wallet_cart_national, $request->montant); $plr_user_wallet_cart_national = $this->getPaliers($paliers_commission_wallets, 'user_wallet_cart_national');
$plr_user_wallet_cart_international = $this->getPaliers($paliers_commission_wallets, 'user_wallet_cart_international');
$plr_hyp_user_wallet_cart_national = $this->getPaliers($paliers_commission_wallets, 'hyp_user_wallet_cart_national');
$plr_hyp_user_wallet_cart_international = $this->getPaliers($paliers_commission_wallets, 'hyp_user_wallet_cart_international');
$plr_bank_user_wallet_cart_national = $this->getPaliers($paliers_commission_wallets, 'bank_user_wallet_cart_national');
$plr_bank_user_wallet_cart_international = $this->getPaliers($paliers_commission_wallets, 'bank_user_wallet_cart_international');
$frais = $this->calculateFees($init_country != $final_country ? $plr_user_wallet_cart_international : $plr_user_wallet_cart_national, $request->montant);
$fees = $this->getBasicTransactionFees([ $fees = $this->getBasicTransactionFees([
'amount' => $request->montant, 'amount' => $request->montant,
'country_id' => $init_country, 'country_id' => $final_country,
'payment_type' => PaymentType::CASH_IN, 'payment_type' => PaymentType::CASH_IN,
'payment_method' => PaymentMethod::CARD 'payment_method' => PaymentMethod::CARD
]); ]);
$frais += $fees; $frais += $fees;
$taxe = $this->calculateTax($taxesNationales, $frais); $taxe = $this->calculateTax($init_country != $final_country ? $taxesInternationales : $taxesNationales, $frais);
$transaction->taxe = $taxe; $transaction->taxe = $taxe;
$transaction->frais = $frais;
$transaction->montant_net = $montantDepot = $transaction->montant - $frais - $taxe; $transaction->montant_net = $montantDepot = $transaction->montant - $frais - $taxe;
$identification = Identification::with(['country'])->where('id_user', $user->id)->first(); $transaction->montant_net_final_country = $this->toMoneyAmount($montantDepot, $init_country, $request->final_country);
$customer_country_code = $identification ? Country::where('name', $identification->country)->first()?->code_country : $user->network->country->code_country;
$identification = Identification::with(['country'])->where('id_user', $user->id)->first();
$countryCurrency = CountriesCurrency::findOrFail($final_country);
// PayOut through payment service // PayOut through payment service
$this->handlePayOut($transaction, [ $this->handlePayOut($transaction, [
'card_no' => $user->numero_carte, 'card_no' => $user->numero_carte,
'exp_month' => date("m", strtotime($user->expiration_date)), 'exp_month' => date("m", strtotime($user->expiration_date)),
'exp_year' => date("Y", strtotime($user->expiration_date)), 'exp_year' => date("Y", strtotime($user->expiration_date)),
'cvc' => $request->input('cvv'), 'cvc' => $request->input('cvv'),
'amount' => $montantDepot, 'amount' => $transaction->montant_net_final_country,
'currency' => $this->getCurrency($init_country), 'currency' => $countryCurrency->currency_code,
'payment_method' => 'CARD', 'payment_method' => 'CARD',
'customer_id' => $user->id, 'customer_id' => $user->id,
'customer_email' => $user->email, 'customer_email' => $user->email,
@ -402,18 +411,17 @@ class iLinkTransactionController extends Controller
'customer_phone_number' => $user->phone, 'customer_phone_number' => $user->phone,
'customer_address' => $identification ? $identification->town : $user->adresse, 'customer_address' => $identification ? $identification->town : $user->adresse,
'customer_city' => $identification ? $identification->town : $user->adresse, 'customer_city' => $identification ? $identification->town : $user->adresse,
'customer_country' => $customer_country_code, 'customer_country' => $countryCurrency->code_country,
'reason' => "User - Envoi de wallet à carte" 'reason' => "User - Envoi de wallet à carte"
]); ]);
$walletUser->balance -= $transaction->montant; $walletUser->balance -= $transaction->montant;
//Emettre une trame SSL pour recharger le compte de la banque partenaire du montant de sa commission //Emettre une trame SSL pour recharger le compte de la banque partenaire du montant de sa commission
$transaction->commission_banque = $this->calculateFees($plr_bank_user_wallet_cart_national, $request->montant, $frais); $transaction->commission_banque = $this->calculateFees($init_country != $final_country ? $plr_bank_user_wallet_cart_international : $plr_bank_user_wallet_cart_national, $request->montant, $frais);
$transaction->commission_hyp = $this->calculateFees($plr_hyp_user_wallet_cart_national, $request->montant, $frais); $transaction->commission_hyp = $this->calculateFees($init_country != $final_country ? $plr_hyp_user_wallet_cart_international : $plr_hyp_user_wallet_cart_national, $request->montant, $frais);
$walletHyperviseur->balance_com += $transaction->commission_hyp; $walletHyperviseur->balance_com += $transaction->commission_hyp;
$transaction->id_wallet_hyp = $walletHyperviseur->id; $transaction->id_wallet_hyp = $walletHyperviseur->id;
$transaction->frais = $frais;
$walletHyperviseur->save(); $walletHyperviseur->save();
$walletUser->save(); $walletUser->save();
$transaction->id_transaction = $this->getTransactionID(); $transaction->id_transaction = $this->getTransactionID();
@ -421,7 +429,8 @@ class iLinkTransactionController extends Controller
$transaction->save(); $transaction->save();
$message = trans('messages.successful_user_send_to_cart', $message = trans('messages.successful_user_send_to_cart',
['id_transaction' => $transaction->id_transaction, 'amount' => $this->toMoney($transaction->montant, $init_country), ['id_transaction' => $transaction->id_transaction, 'amount' => $this->toMoney($transaction->montant, $init_country),
'net' => $this->toMoney($montantDepot, $init_country), 'fees' => $this->toMoney($frais, $init_country), 'net_init' => $this->toMoney($montantDepot, $init_country), 'net_final' => $this->toMoney($transaction->montant_net_final_country, $final_country), 'fees' => $this->toMoney($frais + $taxe, $init_country),
'init_country' => $this->getCountryName($init_country), 'final_country' => $this->getCountryName($final_country),
'sender_code' => $user->user_code, 'cart_number' => wordwrap($transaction->numero_carte, 4, ' ', true)]); 'sender_code' => $user->user_code, 'cart_number' => wordwrap($transaction->numero_carte, 4, ' ', true)]);
$this->sendMail($user->email, trans('messages.successful_transaction'), $message); $this->sendMail($user->email, trans('messages.successful_transaction'), $message);
$response_message = $message . trans('messages.sent_by_mail'); $response_message = $message . trans('messages.sent_by_mail');
@ -697,16 +706,16 @@ class iLinkTransactionController extends Controller
$transaction->expiration_date = $user->expiration_date; $transaction->expiration_date = $user->expiration_date;
$transaction->numero_carte = $user->numero_carte; $transaction->numero_carte = $user->numero_carte;
// $final_country = $request->input('final_country'); $final_country = $walletUser->user->network->country->id;
// $transaction->final_country = $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_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_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_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 = $this->calculateFees($plr_user_cart_wallet_national, $request->montant); $frais = $this->calculateFees($init_country != $final_country ? $plr_user_cart_wallet_international : $plr_user_cart_wallet_national, $request->montant);
$fees = $this->getBasicTransactionFees([ $fees = $this->getBasicTransactionFees([
'amount' => $request->montant, 'amount' => $request->montant,
'country_id' => $init_country, 'country_id' => $init_country,
@ -714,12 +723,14 @@ class iLinkTransactionController extends Controller
'payment_method' => PaymentMethod::CARD 'payment_method' => PaymentMethod::CARD
]); ]);
$frais += $fees; $frais += $fees;
$taxe = $this->calculateTax($taxesNationales, $frais); $taxe = $this->calculateTax($init_country != $final_country ? $taxesInternationales : $taxesNationales, $frais);
$transaction->taxe = $taxe; $transaction->taxe = $taxe;
$transaction->frais = $frais;
$transaction->montant_net = $montantRetrait = $transaction->montant + ($frais + $taxe); $transaction->montant_net = $montantRetrait = $transaction->montant + ($frais + $taxe);
$transaction->montant_net_final_country = $this->toMoneyAmount($montantRetrait, $init_country, $final_country);
$identification = Identification::where('id_user', $user->id)->first(); $identification = Identification::where('id_user', $user->id)->first();
$customer_country_code = $identification ? Country::where('name', $identification->country)->first()?->code_country : $user->network->country->code_country; $countryCurrency = CountriesCurrency::findOrFail($init_country);
$payment_transaction_id = $request->input('payment_transaction_id'); $payment_transaction_id = $request->input('payment_transaction_id');
$result = $this->handlePayIn($transaction, [ $result = $this->handlePayIn($transaction, [
@ -728,7 +739,7 @@ class iLinkTransactionController extends Controller
'exp_year' => date("Y", strtotime($user->expiration_date)), 'exp_year' => date("Y", strtotime($user->expiration_date)),
'cvc' => $request->input('cvv'), 'cvc' => $request->input('cvv'),
'amount' => $montantRetrait, 'amount' => $montantRetrait,
'currency' => $this->getCurrency($init_country), 'currency' => $countryCurrency->currency_code,
'payment_method' => 'CARD', 'payment_method' => 'CARD',
'customer_id' => $user->id, 'customer_id' => $user->id,
'customer_email' => $user->email, 'customer_email' => $user->email,
@ -736,7 +747,7 @@ class iLinkTransactionController extends Controller
'customer_surname' => $identification ? $identification->lastname : $user->lastname, 'customer_surname' => $identification ? $identification->lastname : $user->lastname,
'customer_address' => $identification ? $identification->town : $user->adresse, 'customer_address' => $identification ? $identification->town : $user->adresse,
'customer_city' => $identification ? $identification->town : $user->adresse, 'customer_city' => $identification ? $identification->town : $user->adresse,
'customer_country' => $customer_country_code, 'customer_country' => $countryCurrency->code_country,
'reason' => "User - Retrait de carte vers wallet" 'reason' => "User - Retrait de carte vers wallet"
], $payment_transaction_id); ], $payment_transaction_id);
@ -744,14 +755,13 @@ class iLinkTransactionController extends Controller
return $result; return $result;
} }
$transaction->commission_banque = $this->calculateFees($plr_bank_user_cart_cash_national, $request->montant, $frais); $transaction->commission_banque = $this->calculateFees($init_country != $final_country ? $plr_bank_user_cart_cash_international : $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 //Emettre une trame SSL pour recharger le compte de la banque partenaire du montant de sa commission
$walletUser->balance += $transaction->montant; $walletUser->balance += $transaction->montant_net_final_country;
$transaction->commission_hyp = $this->calculateFees($plr_hyp_user_cart_cash_national, $request->montant, $frais); $transaction->commission_hyp = $this->calculateFees($init_country != $final_country ? $plr_hyp_user_cart_cash_international : $plr_hyp_user_cart_cash_national, $request->montant, $frais);
$walletHyperviseur->balance_com += $transaction->commission_hyp; $walletHyperviseur->balance_com += $transaction->commission_hyp;
$transaction->id_wallet_hyp = $walletHyperviseur->id; $transaction->id_wallet_hyp = $walletHyperviseur->id;
$transaction->frais = $frais;
$walletHyperviseur->save(); $walletHyperviseur->save();
$walletUser->save(); $walletUser->save();
$transaction->id_transaction = $this->getTransactionID(); $transaction->id_transaction = $this->getTransactionID();
@ -759,7 +769,8 @@ class iLinkTransactionController extends Controller
$transaction->save(); $transaction->save();
$message = trans('messages.successful_user_remove_from_cart_to_wallet', $message = trans('messages.successful_user_remove_from_cart_to_wallet',
['id_transaction' => $transaction->id_transaction, 'amount' => $this->toMoney($transaction->montant, $init_country), ['id_transaction' => $transaction->id_transaction, 'amount' => $this->toMoney($transaction->montant, $init_country),
'total' => $this->toMoney($montantRetrait, $init_country), 'fees' => $this->toMoney($frais, $init_country), 'net_init' => $this->toMoney($montantRetrait, $init_country),'net_final' => $this->toMoney($transaction->montant_net_final_country, $final_country),
'fees' => $this->toMoney($frais + $taxe, $init_country), 'init_country' => $this->getCountryName($init_country), 'final_country' => $this->getCountryName($final_country),
'sender_code' => $user->user_code, 'cart_number' => wordwrap($transaction->numero_carte, 4, ' ', true)]); 'sender_code' => $user->user_code, 'cart_number' => wordwrap($transaction->numero_carte, 4, ' ', true)]);
$this->sendMail($user->email, trans('messages.successful_transaction'), $message); $this->sendMail($user->email, trans('messages.successful_transaction'), $message);
$response_message = ($message . trans('messages.sent_by_mail')); $response_message = ($message . trans('messages.sent_by_mail'));
@ -776,17 +787,17 @@ class iLinkTransactionController extends Controller
$transaction->expiration_date = $user->expiration_date; $transaction->expiration_date = $user->expiration_date;
$transaction->numero_carte = $user->numero_carte; $transaction->numero_carte = $user->numero_carte;
$transaction->final_country = $init_country;
// $final_country = $request->input('final_country');
// $transaction->final_country = $final_country;
$plr_user_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'user_cart_cash_national');
// $plr_user_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'user_cart_cash_international');
$plr_hyp_user_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'hyp_user_cart_cash_national');
// $plr_hyp_user_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'hyp_user_cart_cash_international');
$plr_bank_user_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'bank_user_cart_cash_national');
// $plr_bank_user_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'bank_user_cart_cash_international');
$frais = $this->calculateFees($plr_user_cart_cash_national, $request->montant); $final_country = $walletUser->user->network->country->id;
$transaction->final_country = $final_country;
$plr_user_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'user_cart_cash_national');
$plr_user_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'user_cart_cash_international');
$plr_hyp_user_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'hyp_user_cart_cash_national');
$plr_hyp_user_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'hyp_user_cart_cash_international');
$plr_bank_user_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'bank_user_cart_cash_national');
$plr_bank_user_cart_cash_international = $this->getPaliers($paliers_commission_wallets, 'bank_user_cart_cash_international');
$frais = $this->calculateFees($init_country != $final_country ? $plr_user_cart_cash_international : $plr_user_cart_cash_national, $request->montant);
$fees = $this->getBasicTransactionFees([ $fees = $this->getBasicTransactionFees([
'amount' => $request->montant, 'amount' => $request->montant,
'country_id' => $init_country, 'country_id' => $init_country,
@ -794,13 +805,14 @@ class iLinkTransactionController extends Controller
'payment_method' => PaymentMethod::CARD 'payment_method' => PaymentMethod::CARD
]); ]);
$frais += $fees; $frais += $fees;
$taxe = $this->calculateTax($taxesNationales, $frais); $taxe = $this->calculateTax($init_country != $final_country ? $taxesInternationales : $taxesNationales, $frais);
$transaction->taxe = $taxe; $transaction->taxe = $taxe;
$transaction->frais = $frais;
$transaction->montant_net = $montantRetrait = $transaction->montant + ($frais + $taxe); $transaction->montant_net = $montantRetrait = $transaction->montant + ($frais + $taxe);
$transaction->montant_net_final_country = $transaction->montant; $transaction->montant_net_final_country = $this->toMoneyAmount($montantRetrait, $init_country, $final_country);
$countryCurrency = CountriesCurrency::findOrFail($init_country);
$identification = Identification::where('id_user', $user->id)->first(); $identification = Identification::where('id_user', $user->id)->first();
$customer_country_code = $identification ? Country::where('name', $identification->country)->first()?->code_country : $user->network->country->code_country;
$payment_transaction_id = $request->input('payment_transaction_id'); $payment_transaction_id = $request->input('payment_transaction_id');
@ -810,7 +822,7 @@ class iLinkTransactionController extends Controller
'exp_year' => date("Y", strtotime($user->expiration_date)), 'exp_year' => date("Y", strtotime($user->expiration_date)),
'cvc' => $request->input('cvv'), 'cvc' => $request->input('cvv'),
'amount' => $montantRetrait, 'amount' => $montantRetrait,
'currency' => $this->getCurrency($init_country), 'currency' => $countryCurrency->currency_code,
'payment_method' => 'CARD', 'payment_method' => 'CARD',
'customer_id' => $user->id, 'customer_id' => $user->id,
'customer_email' => $user->email, 'customer_email' => $user->email,
@ -818,7 +830,7 @@ class iLinkTransactionController extends Controller
'customer_surname' => $identification ? $identification->lastname : $user->lastname, 'customer_surname' => $identification ? $identification->lastname : $user->lastname,
'customer_address' => $identification ? $identification->town : $user->adresse, 'customer_address' => $identification ? $identification->town : $user->adresse,
'customer_city' => $identification ? $identification->town : $user->adresse, 'customer_city' => $identification ? $identification->town : $user->adresse,
'customer_country' => $customer_country_code, 'customer_country' => $countryCurrency->code_country,
'reason' => "User - Retrait de carte vers cash" 'reason' => "User - Retrait de carte vers cash"
], $payment_transaction_id); ], $payment_transaction_id);
@ -826,7 +838,7 @@ class iLinkTransactionController extends Controller
return $result; return $result;
} }
$transaction->commission_banque = $this->calculateFees($plr_bank_user_cart_cash_national, $request->montant, $frais); $transaction->commission_banque = $this->calculateFees($init_country != $final_country ? $plr_bank_user_cart_cash_international : $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 //Emettre une trame SSL pour recharger le compte de la banque partenaire du montant de sa commission
$code_retrait = $this->random_string(); $code_retrait = $this->random_string();
@ -834,10 +846,9 @@ class iLinkTransactionController extends Controller
$transaction->encrypted_code_retrait = $hash['encrypted']; $transaction->encrypted_code_retrait = $hash['encrypted'];
$transaction->code_retrait_salt = $hash['salt']; $transaction->code_retrait_salt = $hash['salt'];
$transaction->commission_hyp = $this->calculateFees($plr_hyp_user_cart_cash_national, $request->montant, $frais); $transaction->commission_hyp = $this->calculateFees($init_country != $final_country ? $plr_hyp_user_cart_cash_international : $plr_hyp_user_cart_cash_national, $request->montant, $frais);
$walletHyperviseur->balance_com += $transaction->commission_hyp; $walletHyperviseur->balance_com += $transaction->commission_hyp;
$transaction->id_wallet_hyp = $walletHyperviseur->id; $transaction->id_wallet_hyp = $walletHyperviseur->id;
$transaction->frais = $frais;
$transaction->date = $this->getCurrentTime($init_country); $transaction->date = $this->getCurrentTime($init_country);
$transaction->status_retrait = 0; $transaction->status_retrait = 0;
$walletHyperviseur->save(); $walletHyperviseur->save();
@ -845,8 +856,9 @@ class iLinkTransactionController extends Controller
$transaction->save(); $transaction->save();
$message = trans('messages.successful_user_remove_from_cart_to_cash', $message = trans('messages.successful_user_remove_from_cart_to_cash',
['id_transaction' => $transaction->id_transaction, 'amount' => $this->toMoney($transaction->montant, $init_country), ['id_transaction' => $transaction->id_transaction, 'amount' => $this->toMoney($transaction->montant, $init_country),
'final_country' => $this->getCountryName($init_country), 'init_country' => $this->getCountryName($init_country), 'net_init' => $this->toMoney($montantRetrait, $init_country),'net_final' => $this->toMoney($transaction->montant_net_final_country, $final_country),
'total' => $this->toMoney($transaction->montant, $init_country), 'fees' => $this->toMoney($frais, $init_country), 'code' => wordwrap($code_retrait, 4, ' ', true), 'fees' => $this->toMoney($frais + $taxe, $init_country), 'init_country' => $this->getCountryName($init_country), 'final_country' => $this->getCountryName($final_country),
'code' => wordwrap($code_retrait, 4, ' ', true),
'sender_code' => $user->user_code, 'cart_number' => wordwrap($transaction->numero_carte, 4, ' ', true)]); 'sender_code' => $user->user_code, 'cart_number' => wordwrap($transaction->numero_carte, 4, ' ', true)]);
$this->sendMail($user->email, trans('messages.successful_transaction'), $message); $this->sendMail($user->email, trans('messages.successful_transaction'), $message);
$response_message = $message . trans('messages.sent_by_mail'); $response_message = $message . trans('messages.sent_by_mail');
@ -2134,7 +2146,12 @@ class iLinkTransactionController extends Controller
} else { } else {
$walletUser = WalletsUser::findOrFail($request->id_wallet_user); $walletUser = WalletsUser::findOrFail($request->id_wallet_user);
// Pour les operations à cartes, le pays initial c'est le pays de la carte
if(in_array($request->type, [10, 11])){
$init_country = $walletUser->user->card_country_id;
}else{
$init_country = $walletUser->user->network->country->id; $init_country = $walletUser->user->network->country->id;
}
$result = ConfigWallet::join('networks', 'networks.id', '=', 'configWallet.id_network') $result = ConfigWallet::join('networks', 'networks.id', '=', 'configWallet.id_network')
->where('networks.country_id', $init_country)->where('configWallet.type', 'ilink') ->where('networks.country_id', $init_country)->where('configWallet.type', 'ilink')
->select('configWallet.id')->first(); ->select('configWallet.id')->first();
@ -2198,19 +2215,22 @@ class iLinkTransactionController extends Controller
$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
$final_country = $walletUser->user->card_country_id;
$plr_user_wallet_cart_national = $this->getPaliers($paliers_commission_wallets, 'user_wallet_cart_national'); $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');
$frais = $this->calculateFees($plr_user_wallet_cart_national, $request->montant); $frais = $this->calculateFees($init_country != $final_country ? $plr_user_wallet_cart_international : $plr_user_wallet_cart_national, $request->montant);
$fees = $this->getBasicTransactionFees([ $fees = $this->getBasicTransactionFees([
'amount' => $request->montant, 'amount' => $request->montant,
'country_id' => $init_country, 'country_id' => $final_country,
'payment_type' => PaymentType::CASH_IN, 'payment_type' => PaymentType::CASH_IN,
'payment_method' => PaymentMethod::CARD 'payment_method' => PaymentMethod::CARD
]); ]);
$frais += $fees; $frais += $fees;
$taxe = $this->calculateTax($taxesNationales, $frais); $taxe = $this->calculateTax($init_country != $final_country ? $taxesInternationales : $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_init'] = round($request->montant - $data['frais'], 2);
$data['exchange_rate'] = $this->getExchangeRate($init_country, $final_country);
$data['montant_net_final'] = $this->toMoneyWithCurrency($data['montant_net_init'], $init_country, $final_country);
break; break;
case 3: // User - Envoi wallet à cash case 3: // User - Envoi wallet à cash
$this->validate($request, [ $this->validate($request, [
@ -2242,9 +2262,11 @@ class iLinkTransactionController extends Controller
$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
$final_country = $walletUser->user->network->country->id;
$plr_user_cart_wallet_national = $this->getPaliers($paliers_commission_wallets, 'user_cart_wallet_national'); $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');
$frais = $this->calculateFees($plr_user_cart_wallet_national, $request->montant); $frais = $this->calculateFees($init_country != $final_country ? $plr_user_cart_wallet_international : $plr_user_cart_wallet_national, $request->montant);
$fees = $this->getBasicTransactionFees([ $fees = $this->getBasicTransactionFees([
'amount' => $request->montant, 'amount' => $request->montant,
'country_id' => $init_country, 'country_id' => $init_country,
@ -2252,14 +2274,18 @@ class iLinkTransactionController extends Controller
'payment_method' => PaymentMethod::CARD 'payment_method' => PaymentMethod::CARD
]); ]);
$frais += $fees; $frais += $fees;
$taxe = $this->calculateTax($taxesNationales, $frais); $taxe = $this->calculateTax($init_country != $final_country ? $taxesInternationales : $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_init'] = round($request->montant + $data['frais'], 2);
$data['exchange_rate'] = $this->getExchangeRate($init_country, $final_country);
$data['montant_net_final'] = $this->toMoneyWithCurrency($data['montant_net_init'], $init_country, $final_country);
break; break;
case 11: // User - Retrait de carte vers cash case 11: // User - Retrait de carte vers cash
$final_country = $walletUser->user->network->country->id;
$plr_user_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'user_cart_cash_national'); $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');
$frais = $this->calculateFees($plr_user_cart_cash_national, $request->montant); $frais = $this->calculateFees($init_country != $final_country ? $plr_user_cart_cash_international : $plr_user_cart_cash_national, $request->montant);
$fees = $this->getBasicTransactionFees([ $fees = $this->getBasicTransactionFees([
'amount' => $request->montant, 'amount' => $request->montant,
'country_id' => $init_country, 'country_id' => $init_country,
@ -2267,9 +2293,11 @@ class iLinkTransactionController extends Controller
'payment_method' => PaymentMethod::CARD 'payment_method' => PaymentMethod::CARD
]); ]);
$frais += $fees; $frais += $fees;
$taxe = $this->calculateTax($taxesNationales, $frais); $taxe = $this->calculateTax($init_country != $final_country ? $taxesInternationales : $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_init'] = round($request->montant + $data['frais'], 2);
$data['exchange_rate'] = $this->getExchangeRate($init_country, $final_country);
$data['montant_net_final'] = $this->toMoneyWithCurrency($data['montant_net_init'], $init_country, $final_country);
break; break;
case 13: // Agent - Retrait de la carte vers cash case 13: // Agent - Retrait de la carte vers cash
$plr_customer_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'customer_cart_cash_national'); $plr_customer_cart_cash_national = $this->getPaliers($paliers_commission_wallets, 'customer_cart_cash_national');

View File

@ -22,6 +22,7 @@ use Illuminate\Database\Eloquent\Model;
* @property string $user_code * @property string $user_code
* @property string $numero_carte * @property string $numero_carte
* @property Carbon $expiration_date * @property Carbon $expiration_date
* * @property int|null $card_country_id
* @property string $adresse * @property string $adresse
* @property float $solde * @property float $solde
* @property string $encrypted_password * @property string $encrypted_password

View File

@ -83,14 +83,17 @@ This message was sent to the sender\'s email',
'sent_by_mail_to_recipient' => " 'sent_by_mail_to_recipient' => "
This message was sent to the recipient's email", This message was sent to the recipient's email",
'successful_user_send_to_cart' => 'Sending money to a visa card made. 'successful_user_send_to_cart' => "Sending money from your account to your card
Transaction information : Transaction information:
- ID : :id_transaction - Number: :id_transaction
- Amount of the transaction : :amount - Transaction amount: :amount
- Fees : :fees - Fees and taxes: :fees
- Net shipping amount : :net - Departure country: :init_country
- Issuer account :sender_code - Net amount: :net_init
- Card number: :cart_number', - Sender account:: sender_code
- Country of destination: :final_country
- Recipient card number:: cart_number
- Net amount: :net_final",
'successful_user_send_to_cash' => 'Sending money from account to cash 'successful_user_send_to_cash' => 'Sending money from account to cash
Transaction information : Transaction information :
- Number: :id_transaction - Number: :id_transaction
@ -115,25 +118,29 @@ Transaction information:
- Country of destination: :init_country - Country of destination: :init_country
- Issuer account : :sender_code - Issuer account : :sender_code
- Withdrawal code : :code', - Withdrawal code : :code',
'successful_user_remove_from_cart_to_wallet'=>'Withdrawing money from your card to your account 'successful_user_remove_from_cart_to_wallet' => "Withdrawing money from your card to your account
Transaction information: Transaction information:
- Number : :id_transaction
- Amount of the transaction : :amount
- Fees : :fees
- Total withdrawal amount : :total
- Recipient account : :sender_code
- Card number : :cart_number',
'successful_user_remove_from_cart_to_cash' => 'Withdrawing money from your card to cash
Transaction information :
- Number: :id_transaction - Number: :id_transaction
- Amount of the transaction: :amount - Amount: :amount
- Fees: :fees - Fees and taxes: :fees
- Country of departure: :init_country - Departure country: :init_country
- Total withdrawal amount: :total - Net amount: :net_init
- Country of destination: :init_country - Card number: :cart_number
- User code : :sender_code - Country of destination: :final_country
- Card number : :cart_number - Recipient account:: sender_code
- Withdrawal code : :code', - Net amount: :net_final",
'successful_user_remove_from_cart_to_cash' => "Withdrawing money from your card to cash
Transaction information:
- Number: :id_transaction
- Transaction amount: :amount
- Fees and taxes: :fees
- Departure country: :init_country
- Net amount: :net_init
- Card number: :cart_number
- Country of destination: :final_country
- Net amount: :net_final,
- User code: :sender_code
- Withdrawal code: :code",
'successful_agent_remove_cash' => 'Withdrawal of money from a geolocated agent 'successful_agent_remove_cash' => 'Withdrawal of money from a geolocated agent
Transaction information : Transaction information :
- Number : :id_transaction - Number : :id_transaction

View File

@ -65,32 +65,35 @@ Informations de la transaction :
- Noms du destinataire : :receiver_name - Noms du destinataire : :receiver_name
- Montant net : :net_final - Montant net : :net_final
- Code de retrait : :code', - Code de retrait : :code',
'successful_user_send_to_wallet' => 'Envoi d\'argent compte à compte 'successful_user_send_to_wallet' => "Envoi d'argent compte à compte
Informations de la transaction : Informations de la transaction :
- Numéro : :id_transaction - Numéro : :id_transaction
- Montant : :amount - Montant : :amount
- Frais et Taxes : :fees - Frais et taxes : :fees
- Pays de départ : :init_country - Pays de départ : :init_country
- Compte émetteur : :sender_code - Compte émetteur : :sender_code
- Montant net : :net_init - Montant net : :net_init
- Pays de destination : :final_country - Pays de destination : :final_country
- Réseau payeur : :network :final_country - Réseau payeur : :network :final_country
- Compte destinataire : :receiver_code - Compte destinataire : :receiver_code
- Montant net : :net_final', - Montant net : :net_final",
'sent_by_mail' => ' 'sent_by_mail' => '
Ce message a été envoyé dans le mail de l\'émetteur', Ce message a été envoyé dans le mail de l\'émetteur',
'sent_by_mail_to_recipient' => " 'sent_by_mail_to_recipient' => "
Ce message a été envoyé dans le mail du destinataire", Ce message a été envoyé dans le mail du destinataire",
'successful_user_send_to_cart' => 'Envoi d\'argent de votre compte vers votre carte visa 'successful_user_send_to_cart' => "Envoi d'argent de votre compte vers votre carte
Informations de la transaction : Informations de la transaction :
- Numéro : :id_transaction - Numéro : :id_transaction
- Montant de la transaction : :amount - Montant de la transaction : :amount
- Frais : :fees - Frais et taxes : :fees
- Montant net d\'envoi: :net - Pays de départ : :init_country
- Montant net : :net_init
- Compte émetteur : :sender_code - Compte émetteur : :sender_code
- N︒ carte destinataire : :cart_number', - Pays de destination : :final_country
- N︒ carte destinataire : :cart_number
- Montant net : :net_final",
'successful_user_send_to_cash' => 'Envoi d\'argent compte à cash 'successful_user_send_to_cash' => 'Envoi d\'argent compte à cash
Informations de la transaction : Informations de la transaction :
- Numéro : :id_transaction - Numéro : :id_transaction
@ -115,25 +118,29 @@ Informations de la transaction :
- Pays de destination : :init_country - Pays de destination : :init_country
- Compte émetteur : :sender_code - Compte émetteur : :sender_code
- Code de retrait : :code', - Code de retrait : :code',
'successful_user_remove_from_cart_to_wallet' => 'Retrait d\'argent de votre carte vers votre compte 'successful_user_remove_from_cart_to_wallet' => "Retrait d'argent de votre carte vers votre compte
Informations de la transaction : Informations de la transaction :
- Numéro : :id_transaction - Numéro : :id_transaction
- Montant de la transaction : :amount - Montant : :amount
- Frais : :fees - Frais et taxes : :fees
- Montant total de retrait: :total
- Compte destinataire : :sender_code
- Numero de la carte : :cart_number',
'successful_user_remove_from_cart_to_cash' => 'Retrait d\'argent de votre carte vers cash
Informations de la transaction :
- Numéro : :id_transaction
- Montant de la transaction : :amount
- Frais : :fees
- Pays de départ : :init_country - Pays de départ : :init_country
- Montant total de retrait: :total - Montant net : :net_init
- Numéro de la carte : :cart_number
- Pays de destination : :final_country - Pays de destination : :final_country
- Compte destinataire : :sender_code
- Montant net : :net_final",
'successful_user_remove_from_cart_to_cash' => "Retrait d'argent de votre carte vers cash
Informations de la transaction :
- Numéro : :id_transaction
- Montant de la transaction : :amount
- Frais et taxes : :fees
- Pays de départ : :init_country
- Montant net : :net_init
- Numéro de la carte : :cart_number
- Pays de destination : :final_country
- Montant net : :net_final,
- Code utilisateur : :sender_code - Code utilisateur : :sender_code
- Numero de la carte : :cart_number - Code de retrait : :code",
- Code de retrait : :code',
'successful_agent_remove_cash' => 'Retrait d\'argent chez un agent géolocalisé 'successful_agent_remove_cash' => 'Retrait d\'argent chez un agent géolocalisé
Informations de la transaction : Informations de la transaction :
- Numéro : :id_transaction - Numéro : :id_transaction