@ -62,6 +62,8 @@ class iLinkTransactionController extends Controller
* oneOf = {
* @ OA\Schema ( ref = " #/components/schemas/user_payement_of_operator " ),
* @ OA\Schema ( ref = " #/components/schemas/user_remove_from_bank_to_wallet " ),
* @ OA\Schema ( ref = " #/components/schemas/user_send_from_wallet_to_bank " ),
* @ OA\Schema ( ref = " #/components/schemas/agent_send_from_cash_to_bank " ),
* }
* ),
* examples = {
@ -70,9 +72,17 @@ class iLinkTransactionController extends Controller
* " value " : { " type " : 19 , " id_wallet_user " : 9 , " id_wallet_network " : 101 , " no_facture " : " CDE1425533 " , " type_operator " : " water " , " id_operator " : 6 , " montant " : 100000 , " password " : " 1234 " }
* },
* " user_remove_from_bank_to_wallet " : {
" summary " : " User - Retrait du compte bancaire rattaché vers le wallet de l'utilisateur " ,
* " summary " : " User - Retrait du compte bancaire rattaché vers le wallet de l'utilisateur " ,
* " value " : { " type " : 20 , " id_wallet_user " : 1 , " montant " : 100000 , " password " : " 1234 " }
* }
* },
* " user_send_from_wallet_to_bank " : {
* " summary " : " User - Envoi de wallet à banque " ,
* " value " : { " type " : 4 , " id_wallet_user " : 9 , " id_wallet_network " : 101 , " montant " : 100000 , " password " : " 1234 " }
* },
* " agent_send_from_cash_to_bank " : {
* " summary " : " Agent - Envoi de cash vers banque " ,
* " value " : { " type " : 18 , " id_wallet_agent " : 9716 , " id_wallet_network " : 101 , " iban " : " CM15UBAA412341234123412341233 " , " id_bank " : 4 , " nom_emetteur " : " Djery " , " prenom_emetteur " : " Tom " , " email_emetteur " : " ddietchi@ilink-app.com " , " type_document_emetteur " : " passport " , " id_document_emetteur " : " 12345 " , " nom_destinataire " : " Brice " , " prenom_destinataire " : " zele " , " montant " : 100000 , " password " : " 1234 " }
* },
* }
* )
* ),
@ -97,6 +107,24 @@ class iLinkTransactionController extends Controller
* " status " : 200 ,
* " response " : " Retrait de la banque vers le wallet \n Informations de la transaction : \n - Numéro : 2XWQD7ZD9E7R \n - Montant de la transaction : 100 000 FCFA \n
- Frais : 0 FCFA\n - Montant net d\\ 'envoi: 100 000 FCFA\n - Compte émetteur : BZdsWkdfl\n - Banque : UBA Cameroon\n - IBAN : \n\nCe message a été envoyé dans le mail de l' émetteur " ,
* " error " : null
* }
* },
* " user_send_from_wallet_to_bank " : {
* " summary " : " User - Envoi de wallet à banque " ,
* " value " : {
* " status " : 200 ,
* " response " : " Envoi d'argent de votre compte vers la banque \n Informations de la transaction : \n - Numéro : NA69C5RTBY7B \n - Montant de la transaction : 100 000 FCFA \n
- Frais : 0 FCFA\n - Montant net d 'envoi: 100 000 FCFA\n - Compte émetteur : s6LD9PmCJC\n - Banque : UBA Cameroon\n - IBAN : \n\nCe message a été envoyé dans le mail de l' émetteur " ,
* " error " : null
* }
* },
* " agent_send_from_cash_to_bank " : {
* " summary " : " Agent - Envoi de cash vers banque " ,
* " value " : {
* " status " : 200 ,
* " response " : " Envoi d'argent en cash vers la banque \n Informations de la transaction : \n - Numéro : E58K8ZFPB5AN \n - Montant de la transaction : 100 000 FCFA \n - Frais : 0 FCFA \n - Montant net d'envoi: 100 000 FCFA \n
- Compte de l 'agent : 38LEDBostp\n - Noms de l' emetteur : Tom Djery\n - Noms du destinataire : zele Brice\n - IBAN du destinataire : CM15UBAA412341234123412341233\n - Banque : UBA Cameroon\n\nCe message a été envoyé dans le mail de l ' émetteur " ,
* " error " : null
* }
* },
@ -444,42 +472,77 @@ class iLinkTransactionController extends Controller
return $this -> errorResponse ( trans ( 'messages.incorrect_user_password' ));
}
break ;
/**
* @ OA\Schema (
* schema = " user_send_from_wallet_to_bank " ,
* title = " User - Envoi de wallet à banque " ,
* @ OA\Property ( property = " type " ,
* type = " integer " ,
* enum = { 4 },
* default = 4 ,
* description = " Type de la transaction "
* ),
* @ OA\Property ( property = " id_wallet_user " ,
* type = " integer " ,
* example = 9 ,
* description = " ID du wallet de l'utilisateur "
* ),
* @ OA\Property ( property = " id_wallet_network " ,
* type = " integer " ,
* example = 101 ,
* description = " ID du reseau auquel appartient le wallet "
* ),
* @ OA\Property ( property = " montant " ,
* type = " number " ,
* example = 10000 ,
* description = " Montant de la transaction "
* ),
* @ OA\Property ( property = " password " ,
* type = " string " ,
* description = " Mot de passe "
* )
* )
*/
case 4 : //User - Envoi de wallet à banque
$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' ));
$rep = $this -> checkUserIdentification ( $user -> id );
if ( $rep instanceof JsonResponse )
return $rep ;
if ( ! ( isset ( $user -> iban ) && isset ( $user -> id_bank_country )))
return $this -> errorResponse ( trans ( 'errors.wallet_not_linked_to_bank_account' ));
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
$network_bank = NetworksOperator :: where ( 'id_network' , $request -> id_wallet_network ) -> where ( 'id_operator_country' , $request -> id_bank ) -> first ();
//Reverifier si l'operateur est toujours associé au reseau
$network_bank = NetworksOperator :: where ( 'id_network' , $request -> id_wallet_network ) -> where ( 'id_operator_country' , $user -> id_bank_country ) -> first ();
if ( ! $network_bank )
return $this -> errorResponse ( trans ( 'errors.bank_not_associated_with_network' ));
return $this -> errorResponse ( trans ( 'errors. operator_not_associated_with_network') . '. ' . trans ( 'errors.update_banking_information '));
if ( $network_bank -> operators_country -> operator -> type != 'bank' )
return $this -> errorResponse ( trans ( 'errors.not_banking_operator' ));
return $this -> errorResponse ( trans ( 'errors.not_banking_operator' ) . '. ' . trans ( 'errors.update_banking_information' ) );
//Verifier le code IBAN
// Reverifier le code IBAN correspond toujours
$country_code = $network_bank -> network -> country -> code_country ;
$bank_code = $network_bank -> operators_country -> code ;
switch ( $this -> checkIBAN ( $request -> iban , $country_code , $bank_code )) {
switch ( $this -> checkIBAN ( $ user -> iban , $country_code , $bank_code )) {
case 0 :
return $this -> errorResponse ( trans ( 'errors.invalid_iban' ) );
return $this -> errorResponse ( trans ( 'errors.invalid_iban' ) . '. ' . trans ( 'errors.update_banking_information' ) );
case 1 :
return $this -> errorResponse ( trans ( 'errors.country_not_match_iban' ) );
return $this -> errorResponse ( trans ( 'errors.country_not_match_iban' ) . '. ' . trans ( 'errors.update_banking_information' ) );
case 2 :
return $this -> errorResponse ( trans ( 'errors.bank_not_match_iban' ) );
return $this -> errorResponse ( trans ( 'errors.bank_not_match_iban' ) . '. ' . trans ( 'errors.update_banking_information' ) );
}
$transaction -> frais = $frais = 0 ;
@ -493,8 +556,8 @@ class iLinkTransactionController extends Controller
$transaction -> id_wallet_hyp = $walletHyperviseur -> id ;
$transaction -> frais = $frais ;
$transaction -> date = new \DateTime ();
$transaction -> bank = $ network_ bank-> operators_country -> operator -> nom ;
$transaction -> country = $ network_ bank-> network -> country -> name ;
$transaction -> bank = $ user-> bank-> operators_country -> operator -> nom ;
$transaction -> country = $ user-> bank-> network -> country -> name ;
$transaction -> id_bank = $request -> id_bank ;
$transaction -> iban = $request -> iban ;
$transaction -> date = $this -> getCurrentTime ( $init_country );
@ -1149,11 +1212,87 @@ class iLinkTransactionController extends Controller
return $this -> errorResponse ( trans ( 'messages.incorrect_user_password' ));
}
break ;
/**
* @ OA\Schema (
* schema = " agent_send_from_cash_to_bank " ,
* title = " Agent - Envoi de cash vers banque " ,
* @ OA\Property ( property = " type " ,
* type = " integer " ,
* enum = { 18 },
* default = 18 ,
* description = " Type de la transaction "
* ),
* @ OA\Property ( property = " id_wallet_user " ,
* type = " integer " ,
* example = 9 ,
* description = " ID du wallet de l'agent "
* ),
* @ OA\Property ( property = " id_wallet_network " ,
* type = " integer " ,
* example = 101 ,
* description = " ID du reseau auquel appartient le wallet "
* ),
* @ OA\Property ( property = " iban " ,
* type = " string " ,
* description = " Identifiant bancaire "
* ),
* @ OA\Property ( property = " id_bank " ,
* type = " integer " ,
* example = 4 ,
* description = " ID de la banque "
* ),
* @ OA\Property ( property = " nom_emetteur " ,
* type = " string " ,
* description = " Noms de l'emetteur "
* ),
* @ OA\Property ( property = " prenom_emetteur " ,
* type = " string " ,
* description = " Prenoms de l'emetteur "
* ),
* @ OA\Property ( property = " email_emetteur " ,
* type = " string " ,
* description = " Email de l'emetteur "
* ),
* @ OA\Property ( property = " type_document_emetteur " ,
* type = " string " ,
* description = " Type de document que l'emetteur a fourni pour son identification "
* ),
* @ OA\Property ( property = " id_document_emetteur " ,
* type = " string " ,
* description = " ID de l'emetteur sur le document qu'il a fourni pour son identification "
* ),
* @ OA\Property ( property = " nom_destinataire " ,
* type = " string " ,
* description = " Noms du destinataire "
* ),
* @ OA\Property ( property = " prenom_destinataire " ,
* type = " string " ,
* description = " Prenoms du destinataire "
* ),
* @ OA\Property ( property = " montant " ,
* type = " number " ,
* example = 10000 ,
* description = " Montant de la transaction "
* ),
* @ OA\Property ( property = " password " ,
* type = " string " ,
* description = " Mot de passe "
* )
* )
*/
case 18 : // Agent - Envoi de cash vers banque
$this -> validate ( $request , [
'iban' => 'required' ,
'id_wallet_network' => 'required|integer|min:0|not_in:0' ,
'id_bank' => 'required|integer|min:0|not_in:0' ,
'nom_emetteur' => 'required' ,
'prenom_emetteur' => 'required' ,
'type_document_emetteur' => 'required' ,
'id_document_emetteur' => 'required' ,
'email_emetteur' => 'required' ,
'nom_destinataire' => 'required' ,
'prenom_destinataire' => 'required' ,
]);
$agent = AgentPlus :: findOrFail ( $network_agent -> agent_id );
if ( ! $this -> checkPassword ( $request -> password , $agent -> encrypted_password , $agent -> salt ))
@ -1207,11 +1346,11 @@ class iLinkTransactionController extends Controller
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 ),
$message = trans ( 'messages.successful_ agent_send_from_cash _to_bank',
[ 'id_transaction' => $transaction -> id_transaction , 'amount' => $this -> toMoney ( $transaction -> montant , $init_country ), 'receiver_name' => $request -> prenom_destinataire . ' ' . $request -> nom_destinataire ,
'net' => $this -> toMoney ( $transaction -> montant , $init_country ), 'iban' => $request -> iban , 'fees' => $this -> toMoney ( $frais , $init_country ), 'sender_name' => $request -> prenom_emetteur . ' ' . $request -> nom_emetteur ,
'sender_code' => $codeGenerer -> code_membre , 'bank' => $transaction -> bank , 'country' => $transaction -> country ]);
$this -> sendMail ( $ agent-> email , trans ( 'messages.successful_transaction' ), $message );
$this -> sendMail ( $ request-> email_emetteur , trans ( 'messages.successful_transaction' ), $message );
return $this -> successResponse ( $message . trans ( 'messages.sent_by_mail' ));
/**
@ -1361,6 +1500,26 @@ class iLinkTransactionController extends Controller
if ( ! ( isset ( $user -> iban ) && isset ( $user -> id_bank_country )))
return $this -> errorResponse ( trans ( 'errors.wallet_not_linked_to_bank_account' ));
//Reverifier si l'operateur est toujours associé au reseau
$network_bank = NetworksOperator :: where ( 'id_network' , $request -> id_wallet_network ) -> where ( 'id_operator_country' , $user -> id_bank_country ) -> first ();
if ( ! $network_bank )
return $this -> errorResponse ( trans ( 'errors.operator_not_associated_with_network' ) . '. ' . trans ( 'errors.update_banking_information' ));
if ( $network_bank -> operators_country -> operator -> type != 'bank' )
return $this -> errorResponse ( trans ( 'errors.not_banking_operator' ) . '. ' . trans ( 'errors.update_banking_information' ));
//Reverifier le code IBAN correspond toujours
$country_code = $network_bank -> network -> country -> code_country ;
$bank_code = $network_bank -> operators_country -> code ;
switch ( $this -> checkIBAN ( $user -> iban , $country_code , $bank_code )) {
case 0 :
return $this -> errorResponse ( trans ( 'errors.invalid_iban' ) . '. ' . trans ( 'errors.update_banking_information' ));
case 1 :
return $this -> errorResponse ( trans ( 'errors.country_not_match_iban' ) . '. ' . trans ( 'errors.update_banking_information' ));
case 2 :
return $this -> errorResponse ( trans ( 'errors.bank_not_match_iban' ) . '. ' . trans ( 'errors.update_banking_information' ));
}
// Envoyer la trame vers banque pour debiter le compte client et recharger le compte bancaire de iLink
// ----->