+ Add "User - Envoi de wallet à banque" and "Agent - Envoi de cash à banque"
This commit is contained in:
parent
f30e522c10
commit
29374c8cc4
|
@ -107,20 +107,20 @@ class TransmittingNetworksController extends Controller
|
||||||
$configTransmitter = ConfigWallet::where('id_network', $request->network_emetteur)->first();
|
$configTransmitter = ConfigWallet::where('id_network', $request->network_emetteur)->first();
|
||||||
|
|
||||||
if (!$configRecipient)
|
if (!$configRecipient)
|
||||||
return $this->errorResponse("Ce reseau destinataire n'est pas configuré dans notre systeme");
|
return $this->errorResponse(trans('errors.recipient_network_not_configured'));
|
||||||
|
|
||||||
if ($configRecipient->type != 'ilink')
|
if ($configRecipient->type != 'ilink')
|
||||||
return $this->errorResponse("Ce reseau destinataire n'est pas autorise à recevoir des transactions dans notre systeme");
|
return $this->errorResponse(trans('errors.recipient_network_not_authorized'));
|
||||||
|
|
||||||
if (!$configTransmitter)
|
if (!$configTransmitter)
|
||||||
return $this->errorResponse("Ce reseau emetteur n'est pas configuré dans notre systeme");
|
return $this->errorResponse(trans('errors.transmitter_network_not_configured'));
|
||||||
|
|
||||||
if ($configTransmitter->type != 'autre')
|
if ($configTransmitter->type != 'autre')
|
||||||
return $this->errorResponse("Ce reseau emetteur n'est pas autorise à recevoir des transactions dans notre systeme");
|
return $this->errorResponse(trans('errors.transmitter_network_not_authorized'));
|
||||||
|
|
||||||
$transmittingNetwork = TransmittingNetwork::where('id_network', $request->network_emetteur)->where('id_configWallet', $configRecipient->id)->first();
|
$transmittingNetwork = TransmittingNetwork::where('id_network', $request->network_emetteur)->where('id_configWallet', $configRecipient->id)->first();
|
||||||
if (!$transmittingNetwork)
|
if (!$transmittingNetwork)
|
||||||
return $this->errorResponse("Ce reseau n'est pas reconnu comme etant un reseau emetteur du reseau destinataire");
|
return $this->errorResponse(trans('errors.transmitter_network_not_recognized'));
|
||||||
|
|
||||||
|
|
||||||
$transaction = new WalletIlinkTransaction();
|
$transaction = new WalletIlinkTransaction();
|
||||||
|
|
|
@ -23,6 +23,7 @@ use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class iLinkTransactionController extends Controller
|
class iLinkTransactionController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -377,8 +378,57 @@ class iLinkTransactionController extends Controller
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4: //User - Envoi de wallet à banque
|
case 4: //User - Envoi de wallet à banque
|
||||||
// Non disponible
|
|
||||||
//Pas de taxes
|
$this->validate($request, [
|
||||||
|
'iban' => 'required',
|
||||||
|
'id_wallet_network' => 'required|integer|min:0|not_in:0',
|
||||||
|
'id_bank' => 'required|integer|min:0|not_in:0',
|
||||||
|
]);
|
||||||
|
$user = $walletUser->user;
|
||||||
|
if (!$this->checkPassword($request->password, $user->encrypted_password, $user->salt))
|
||||||
|
return $this->errorResponse(trans('messages.incorrect_user_password'));
|
||||||
|
|
||||||
|
if ($request->montant > $walletUser->balance)
|
||||||
|
return $this->errorResponse(trans('errors.insufficient_balance'));
|
||||||
|
|
||||||
|
// $rep = $this->checkUserIdentification($user->id);
|
||||||
|
// if ($rep instanceof JsonResponse)
|
||||||
|
// return $rep;
|
||||||
|
|
||||||
|
//Verifier si la banque est associée au reseau
|
||||||
|
$result = DB::select("SELECT * FROM networks_banks nb INNER JOIN banks_countries bc ON bc.id = nb.id_bank_country
|
||||||
|
WHERE nb.id_network = :id_network AND bc.id_bank = :id_bank;", ["id_network" => $request->id_wallet_network, 'id_bank' => $request->id_bank]);
|
||||||
|
if (sizeof($result) == 0)
|
||||||
|
return $this->errorResponse(trans('errors.bank_not_associated_with_network'));
|
||||||
|
|
||||||
|
$transaction->frais = $frais = 0;
|
||||||
|
$transaction->taxe = $taxe = 0;
|
||||||
|
// $walletUser->balance -= $transaction->montant;
|
||||||
|
//Emettre une trame SSL pour recharger le compte bancaire du montant de la transaction
|
||||||
|
$transaction->commission_banque = 0;
|
||||||
|
|
||||||
|
$transaction->commission_hyp = 0;
|
||||||
|
|
||||||
|
$transaction->id_wallet_hyp = $walletHyperviseur->id;
|
||||||
|
$transaction->frais = $frais;
|
||||||
|
$transaction->date = new \DateTime();
|
||||||
|
$transaction->id_bank = $request->id_bank;
|
||||||
|
$transaction->iban = $request->iban;
|
||||||
|
// $walletUser->save();
|
||||||
|
$transaction->id_transaction = $this->getTransactionID();
|
||||||
|
// $transaction->save();
|
||||||
|
|
||||||
|
Log::info('-------------------------- User - Envoi de wallet à banque ------------------------------------');
|
||||||
|
Log::info($transaction->toArray());
|
||||||
|
Log::info('------------------------------------------------------------------------------------------------');
|
||||||
|
|
||||||
|
$message = trans('messages.successful_user_send_to_bank',
|
||||||
|
['id_transaction' => $transaction->id_transaction, 'amount' => $this->toMoney($transaction->montant, $init_country),
|
||||||
|
'net' => $this->toMoney($transaction->montant, $init_country), 'iban' => $request->iban, 'fees' => $this->toMoney($frais, $init_country),
|
||||||
|
'sender_code' => $user->user_code]);
|
||||||
|
// $this->sendMail($user->email, trans('messages.successful_transaction'), $message);
|
||||||
|
return $this->successResponse($message . trans('messages.sent_by_mail'));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
// case 5: //User - Envoi de carte à wallet
|
// case 5: //User - Envoi de carte à wallet
|
||||||
// $frais =$montant * $config->taux_com_user_carte_wallet / 100;
|
// $frais =$montant * $config->taux_com_user_carte_wallet / 100;
|
||||||
|
@ -1013,13 +1063,60 @@ class iLinkTransactionController extends Controller
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 18: // Agent - Envoi de cash vers banque
|
case 18: // Agent - Envoi de cash vers banque
|
||||||
// Indisponible
|
$this->validate($request, [
|
||||||
break;
|
'iban' => 'required',
|
||||||
|
'id_wallet_network' => 'required|integer|min:0|not_in:0',
|
||||||
|
'id_bank' => 'required|integer|min:0|not_in:0',
|
||||||
|
]);
|
||||||
|
$agent = AgentPlus::findOrFail($network_agent->agent_id);
|
||||||
|
if (!$this->checkPassword($request->password, $agent->encrypted_password, $agent->salt))
|
||||||
|
return $this->errorResponse(trans('messages.incorrect_user_password'));
|
||||||
|
|
||||||
|
if ($request->montant > $walletAgent->balance_princ)
|
||||||
|
return $this->errorResponse(trans('errors.insufficient_balance'));
|
||||||
|
|
||||||
|
//Verifier si la banque est associée au reseau
|
||||||
|
$result = DB::select("SELECT * FROM networks_banks nb INNER JOIN banks_countries bc ON bc.id = nb.id_bank_country
|
||||||
|
WHERE nb.id_network = :id_network AND bc.id_bank = :id_bank;", ["id_network" => $request->id_wallet_network, 'id_bank' => $request->id_bank]);
|
||||||
|
if (sizeof($result) == 0)
|
||||||
|
return $this->errorResponse(trans('errors.bank_not_associated_with_network'));
|
||||||
|
|
||||||
|
$transaction->frais = $frais = 0;
|
||||||
|
$transaction->taxe = $taxe = 0;
|
||||||
|
// $walletUser->balance -= $transaction->montant;
|
||||||
|
//Emettre une trame SSL pour recharger le compte bancaire du montant de la transaction
|
||||||
|
$transaction->commission_banque = 0;
|
||||||
|
|
||||||
|
$transaction->commission_hyp = 0;
|
||||||
|
|
||||||
|
$transaction->id_wallet_hyp = $walletHyperviseur->id;
|
||||||
|
$transaction->id_wallet_ag = $walletAgent->id;
|
||||||
|
$transaction->id_wallet_sup = $walletSuperviseur->id;
|
||||||
|
$transaction->frais = $frais;
|
||||||
|
$transaction->date = new \DateTime();
|
||||||
|
$transaction->id_bank = $request->id_bank;
|
||||||
|
$transaction->iban = $request->iban;
|
||||||
|
// $walletUser->save();
|
||||||
|
$transaction->id_transaction = $this->getTransactionID();
|
||||||
|
// $transaction->save();
|
||||||
|
|
||||||
|
Log::info('-------------------------- Agent - Envoi de cash vers banque ------------------------------------');
|
||||||
|
Log::info($transaction->toArray());
|
||||||
|
Log::info('------------------------------------------------------------------------------------------------');
|
||||||
|
|
||||||
|
$message = trans('messages.successful_user_send_to_bank',
|
||||||
|
['id_transaction' => $transaction->id_transaction, 'amount' => $this->toMoney($transaction->montant, $init_country),
|
||||||
|
'net' => $this->toMoney($transaction->montant, $init_country), 'iban' => $request->iban, 'fees' => $this->toMoney($frais, $init_country),
|
||||||
|
'sender_code' => $codeGenerer->code_membre]);
|
||||||
|
// $this->sendMail($user->email, trans('messages.successful_transaction'), $message);
|
||||||
|
|
||||||
|
return $this->successResponse($message . trans('messages.sent_by_mail'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function lastUserTransactions($id_user)
|
public
|
||||||
|
function lastUserTransactions($id_user)
|
||||||
{
|
{
|
||||||
$user = User::findOrFail($id_user);
|
$user = User::findOrFail($id_user);
|
||||||
$wallet_user = WalletsUser::where('idUser', $user->id)->firstOrFail();
|
$wallet_user = WalletsUser::where('idUser', $user->id)->firstOrFail();
|
||||||
|
@ -1060,7 +1157,8 @@ class iLinkTransactionController extends Controller
|
||||||
return $this->successResponse($transactions);
|
return $this->successResponse($transactions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function lastAgentTransactions($id_wallet_agent)
|
public
|
||||||
|
function lastAgentTransactions($id_wallet_agent)
|
||||||
{
|
{
|
||||||
$transactions = DB::select('SELECT wit.id_transaction, tit.nom as operation_fr , tit.name as operation_en, wit.montant ,wit.nom_emetteur, wit.prenom_emetteur, wit.id_wallet_user,wit.frais,wit.taxe,wit.id_destinataire,
|
$transactions = DB::select('SELECT wit.id_transaction, tit.nom as operation_fr , tit.name as operation_en, wit.montant ,wit.nom_emetteur, wit.prenom_emetteur, wit.id_wallet_user,wit.frais,wit.taxe,wit.id_destinataire,
|
||||||
wit.nom_destinataire, wit.prenom_destinataire, wit.type , wit.id_wallet_user, wit.init_country, wit.final_country , wit.network_destinataire , wit.montant_net_final_country ,
|
wit.nom_destinataire, wit.prenom_destinataire, wit.type , wit.id_wallet_user, wit.init_country, wit.final_country , wit.network_destinataire , wit.montant_net_final_country ,
|
||||||
|
@ -1095,7 +1193,8 @@ class iLinkTransactionController extends Controller
|
||||||
return $this->successResponse($transactions);
|
return $this->successResponse($transactions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function calculateCommission(Request $request)
|
public
|
||||||
|
function calculateCommission(Request $request)
|
||||||
{
|
{
|
||||||
$rules = [
|
$rules = [
|
||||||
'type' => 'required|integer|min:0|not_in:0',
|
'type' => 'required|integer|min:0|not_in:0',
|
||||||
|
@ -1243,7 +1342,8 @@ class iLinkTransactionController extends Controller
|
||||||
return $this->successResponse($data);
|
return $this->successResponse($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTransactionRetrait(Request $request)
|
public
|
||||||
|
function getTransactionRetrait(Request $request)
|
||||||
{
|
{
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'id_transaction' => 'required',
|
'id_transaction' => 'required',
|
||||||
|
@ -1299,7 +1399,8 @@ class iLinkTransactionController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function getPaliers(array $paliers, $type)
|
private
|
||||||
|
function getPaliers(array $paliers, $type)
|
||||||
{
|
{
|
||||||
return array_values(array_filter($paliers, function ($palier) use ($type) {
|
return array_values(array_filter($paliers, function ($palier) use ($type) {
|
||||||
return $palier->type == $type;
|
return $palier->type == $type;
|
||||||
|
@ -1307,7 +1408,8 @@ class iLinkTransactionController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
//Calcul des frais internationaux
|
//Calcul des frais internationaux
|
||||||
private function calculateFees(array $paliers, $montant)
|
private
|
||||||
|
function calculateFees(array $paliers, $montant)
|
||||||
{
|
{
|
||||||
$size = sizeof($paliers);
|
$size = sizeof($paliers);
|
||||||
if ($size > 0) {
|
if ($size > 0) {
|
||||||
|
@ -1334,7 +1436,8 @@ class iLinkTransactionController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function random_string()
|
private
|
||||||
|
function random_string()
|
||||||
{
|
{
|
||||||
$character_set_array = array();
|
$character_set_array = array();
|
||||||
$character_set_array[] = array('count' => 12, 'characters' => 'ABCDEFGHJKMNPQRSTUVWXYZ');
|
$character_set_array[] = array('count' => 12, 'characters' => 'ABCDEFGHJKMNPQRSTUVWXYZ');
|
||||||
|
@ -1349,7 +1452,9 @@ class iLinkTransactionController extends Controller
|
||||||
return implode('', $temp_array);
|
return implode('', $temp_array);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getTransactionID(){
|
private
|
||||||
|
function getTransactionID()
|
||||||
|
{
|
||||||
do {
|
do {
|
||||||
$code = $this->generateTransactionCode();
|
$code = $this->generateTransactionCode();
|
||||||
$result = collect(DB::select('SELECT * FROM wallet_ilink_transaction WHERE id_transaction = :code', ['code' => $code]));
|
$result = collect(DB::select('SELECT * FROM wallet_ilink_transaction WHERE id_transaction = :code', ['code' => $code]));
|
||||||
|
@ -1359,7 +1464,9 @@ class iLinkTransactionController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function checkUserIdentification($id_user){
|
private
|
||||||
|
function checkUserIdentification($id_user)
|
||||||
|
{
|
||||||
$identification = Identification::where('id_user', $id_user)->first();
|
$identification = Identification::where('id_user', $id_user)->first();
|
||||||
if (isset($identification)) {
|
if (isset($identification)) {
|
||||||
if ($identification->status == 0)
|
if ($identification->status == 0)
|
||||||
|
@ -1368,6 +1475,7 @@ class iLinkTransactionController extends Controller
|
||||||
return $this->errorResponse(trans('errors.user_identification_required'));
|
return $this->errorResponse(trans('errors.user_identification_required'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// public function index(Request $request){
|
// public function index(Request $request){
|
||||||
//
|
//
|
||||||
// $notices = DB::select('select notices.id,notices.title,notices.body,notices.created_at,notices.updated_at,
|
// $notices = DB::select('select notices.id,notices.title,notices.body,notices.created_at,notices.updated_at,
|
||||||
|
@ -1383,7 +1491,8 @@ class iLinkTransactionController extends Controller
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public function cancel($id_transaction)
|
public
|
||||||
|
function cancel($id_transaction)
|
||||||
{
|
{
|
||||||
$transaction = WalletIlinkTransaction::where('id_transaction', $id_transaction)->firstOrFail();
|
$transaction = WalletIlinkTransaction::where('id_transaction', $id_transaction)->firstOrFail();
|
||||||
$transactionInverse = $transaction->replicate();
|
$transactionInverse = $transaction->replicate();
|
||||||
|
@ -1427,7 +1536,8 @@ class iLinkTransactionController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
//Verfier les limites reglementaires
|
//Verfier les limites reglementaires
|
||||||
public function checkReguationsLimits($identifiant, $init_country, $final_country, $montant_transaction, $is_id_document_emetteur = false)
|
public
|
||||||
|
function checkReguationsLimits($identifiant, $init_country, $final_country, $montant_transaction, $is_id_document_emetteur = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
$regulation = Regulation::where('id_country', $init_country)->first();
|
$regulation = Regulation::where('id_country', $init_country)->first();
|
||||||
|
@ -1472,7 +1582,8 @@ class iLinkTransactionController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recevoir le traitement d'une transaction venant d'un reseau payeur
|
// Recevoir le traitement d'une transaction venant d'un reseau payeur
|
||||||
public function receiveRequestProcessingResult(Request $request)
|
public
|
||||||
|
function receiveRequestProcessingResult(Request $request)
|
||||||
{
|
{
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'id_transaction' => 'required',
|
'id_transaction' => 'required',
|
||||||
|
|
|
@ -69,4 +69,10 @@ Paying network : :network :country',
|
||||||
"international_monthly_regulations_limits_reached" => "You have reached your international monthly limit.",
|
"international_monthly_regulations_limits_reached" => "You have reached your international monthly limit.",
|
||||||
"forbidden" => 'Forbidden',
|
"forbidden" => 'Forbidden',
|
||||||
"request_already_processed" => "This request has already been processed",
|
"request_already_processed" => "This request has already been processed",
|
||||||
|
"recipient_network_not_configured" => "This recipient network is not configured in our system",
|
||||||
|
"recipient_network_not_authorized" => "This recipient network is not authorized to receive transactions in our system",
|
||||||
|
"bank_not_associated_with_network" => "This bank is not associated with your network",
|
||||||
|
"transmitter_network_not_configured" => "This transmitter network is not configured in our system",
|
||||||
|
"transmitter_network_not_authorized" => "This sender network is not authorized to receive transactions in our system",
|
||||||
|
"transmitter_network_not_recognized" => 'This network is not recognized as being a sender network of the recipient network',
|
||||||
];
|
];
|
||||||
|
|
|
@ -270,4 +270,12 @@ Transaction Information:
|
||||||
- Country of destination: :final_country
|
- Country of destination: :final_country
|
||||||
- Recipient's names: :receiver_name
|
- Recipient's names: :receiver_name
|
||||||
- Collection code: :code",
|
- Collection code: :code",
|
||||||
|
'successful_user_send_to_bank' => 'Sending money from your account to the bank
|
||||||
|
Transaction Information:
|
||||||
|
- Number: :id_transaction
|
||||||
|
- Amount of the transaction: :amount
|
||||||
|
- Fees: :fees
|
||||||
|
- Net shipping amount:: net
|
||||||
|
- Issuer account: :sender_code
|
||||||
|
- IBAN: :iban',
|
||||||
];
|
];
|
||||||
|
|
|
@ -69,4 +69,10 @@ Réseau payeur : :network :country',
|
||||||
"international_monthly_regulations_limits_reached" => "Vous avez atteint votre limite mensuelle internationale.",
|
"international_monthly_regulations_limits_reached" => "Vous avez atteint votre limite mensuelle internationale.",
|
||||||
"forbidden" => "Interdit d'access",
|
"forbidden" => "Interdit d'access",
|
||||||
"request_already_processed" => "Cette requete a déja ete traitée",
|
"request_already_processed" => "Cette requete a déja ete traitée",
|
||||||
|
"recipient_network_not_configured" => "Ce reseau destinataire n'est pas configuré dans notre systeme",
|
||||||
|
"recipient_network_not_authorized" => "Ce reseau destinataire n'est pas autorise à recevoir des transactions dans notre systeme",
|
||||||
|
"bank_not_associated_with_network" => "Cette banque n'est pas associée à votre réseau",
|
||||||
|
"transmitter_network_not_configured" => "Ce reseau emetteur n'est pas configuré dans notre systeme",
|
||||||
|
"transmitter_network_not_authorized" => "Ce reseau emetteur n'est pas autorisé à recevoir des transactions dans notre systeme",
|
||||||
|
"transmitter_network_not_recognized" => "Ce réseau n'est pas reconnu comme etant un réseau emetteur du reseau destinataire",
|
||||||
];
|
];
|
||||||
|
|
|
@ -271,4 +271,12 @@ Informations de la transaction :
|
||||||
- Pays de destination : :final_country
|
- Pays de destination : :final_country
|
||||||
- Noms du destinataire : :receiver_name
|
- Noms du destinataire : :receiver_name
|
||||||
- Code de retrait : :code",
|
- Code de retrait : :code",
|
||||||
|
'successful_user_send_to_bank' => 'Envoi d\'argent de votre compte vers la banque
|
||||||
|
Informations de la transaction :
|
||||||
|
- Numéro : :id_transaction
|
||||||
|
- Montant de la transaction : :amount
|
||||||
|
- Frais : :fees
|
||||||
|
- Montant net d\'envoi: :net
|
||||||
|
- Compte émetteur : :sender_code
|
||||||
|
- IBAN : :iban',
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in New Issue