+ Add User - Envoi de wallet à banque

+ Add Agent - Envoi de cash vers banque
This commit is contained in:
Djery-Tom 2020-11-23 15:27:25 +01:00
parent ed12235c96
commit c171ce1af9
6 changed files with 206 additions and 23 deletions

View File

@ -62,6 +62,8 @@ class iLinkTransactionController extends Controller
* oneOf={ * oneOf={
* @OA\Schema(ref="#/components/schemas/user_payement_of_operator"), * @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_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 = { * 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"} * "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" : { * "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"} * "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, * "status" : 200,
* "response" : "Retrait de la banque vers le wallet\nInformations de la transaction :\n - Numéro : 2XWQD7ZD9E7R\n - Montant de la transaction : 100000 FCFA\n * "response" : "Retrait de la banque vers le wallet\nInformations de la transaction :\n - Numéro : 2XWQD7ZD9E7R\n - Montant de la transaction : 100000 FCFA\n
- Frais : 0 FCFA\n - Montant net d\\'envoi: 100000 FCFA\n - Compte émetteur : BZdsWkdfl\n - Banque : UBA Cameroon\n - IBAN : \n\nCe message a été envoyé dans le mail de l'émetteur", - Frais : 0 FCFA\n - Montant net d\\'envoi: 100000 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\nInformations de la transaction :\n - Numéro : NA69C5RTBY7B\n - Montant de la transaction : 100000 FCFA\n
- Frais : 0 FCFA\n - Montant net d'envoi: 100000 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\nInformations de la transaction :\n - Numéro : E58K8ZFPB5AN\n - Montant de la transaction : 100000 FCFA\n - Frais : 0 FCFA\n - Montant net d'envoi: 100000 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 * "error":null
* } * }
* }, * },
@ -444,42 +472,77 @@ class iLinkTransactionController extends Controller
return $this->errorResponse(trans('messages.incorrect_user_password')); return $this->errorResponse(trans('messages.incorrect_user_password'));
} }
break; 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 case 4: //User - Envoi de wallet à banque
$this->validate($request, [ $this->validate($request, [
'iban' => 'required',
'id_wallet_network' => 'required|integer|min:0|not_in:0', 'id_wallet_network' => 'required|integer|min:0|not_in:0',
'id_bank' => 'required|integer|min:0|not_in:0',
]); ]);
$user = $walletUser->user; $user = $walletUser->user;
if (!$this->checkPassword($request->password, $user->encrypted_password, $user->salt)) if (!$this->checkPassword($request->password, $user->encrypted_password, $user->salt))
return $this->errorResponse(trans('messages.incorrect_user_password')); 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) if ($request->montant > $walletUser->balance)
return $this->errorResponse(trans('errors.insufficient_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 //Reverifier si l'operateur est toujours associé au reseau
$network_bank = NetworksOperator::where('id_network', $request->id_wallet_network)->where('id_operator_country', $request->id_bank)->first(); $network_bank = NetworksOperator::where('id_network', $request->id_wallet_network)->where('id_operator_country', $user->id_bank_country)->first();
if (!$network_bank) 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') 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; $country_code = $network_bank->network->country->code_country;
$bank_code = $network_bank->operators_country->code; $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: case 0:
return $this->errorResponse(trans('errors.invalid_iban')); return $this->errorResponse(trans('errors.invalid_iban') . '. ' . trans('errors.update_banking_information'));
case 1: 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: 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; $transaction->frais = $frais = 0;
@ -493,8 +556,8 @@ class iLinkTransactionController extends Controller
$transaction->id_wallet_hyp = $walletHyperviseur->id; $transaction->id_wallet_hyp = $walletHyperviseur->id;
$transaction->frais = $frais; $transaction->frais = $frais;
$transaction->date = new \DateTime(); $transaction->date = new \DateTime();
$transaction->bank = $network_bank->operators_country->operator->nom; $transaction->bank = $user->bank->operators_country->operator->nom;
$transaction->country = $network_bank->network->country->name; $transaction->country = $user->bank->network->country->name;
$transaction->id_bank = $request->id_bank; $transaction->id_bank = $request->id_bank;
$transaction->iban = $request->iban; $transaction->iban = $request->iban;
$transaction->date = $this->getCurrentTime($init_country); $transaction->date = $this->getCurrentTime($init_country);
@ -1149,11 +1212,87 @@ class iLinkTransactionController extends Controller
return $this->errorResponse(trans('messages.incorrect_user_password')); return $this->errorResponse(trans('messages.incorrect_user_password'));
} }
break; 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 case 18: // Agent - Envoi de cash vers banque
$this->validate($request, [ $this->validate($request, [
'iban' => 'required', 'iban' => 'required',
'id_wallet_network' => 'required|integer|min:0|not_in:0', 'id_wallet_network' => 'required|integer|min:0|not_in:0',
'id_bank' => '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); $agent = AgentPlus::findOrFail($network_agent->agent_id);
if (!$this->checkPassword($request->password, $agent->encrypted_password, $agent->salt)) if (!$this->checkPassword($request->password, $agent->encrypted_password, $agent->salt))
@ -1207,11 +1346,11 @@ class iLinkTransactionController extends Controller
Log::info($transaction->toArray()); Log::info($transaction->toArray());
Log::info('------------------------------------------------------------------------------------------------'); Log::info('------------------------------------------------------------------------------------------------');
$message = trans('messages.successful_user_send_to_bank', $message = trans('messages.successful_agent_send_from_cash_to_bank',
['id_transaction' => $transaction->id_transaction, 'amount' => $this->toMoney($transaction->montant, $init_country), ['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), '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]); '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')); 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))) if (!(isset($user->iban) && isset($user->id_bank_country)))
return $this->errorResponse(trans('errors.wallet_not_linked_to_bank_account')); 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 // Envoyer la trame vers banque pour debiter le compte client et recharger le compte bancaire de iLink
// -----> // ----->

View File

@ -82,4 +82,5 @@ Paying network : :network :country',
"operator_not_associated_with_network" => "This operator is not associated with your network", "operator_not_associated_with_network" => "This operator is not associated with your network",
"not_matching_operator" => "This operator is not a :type_operator", "not_matching_operator" => "This operator is not a :type_operator",
"wallet_not_linked_to_bank_account" => "Your wallet is not linked to a bank account", "wallet_not_linked_to_bank_account" => "Your wallet is not linked to a bank account",
"update_banking_information" => "Update your banking information",
]; ];

View File

@ -299,4 +299,15 @@ Transaction Information:
- Issuer account: :sender_code - Issuer account: :sender_code
- Bank : :bank :country - Bank : :bank :country
- IBAN: :iban', - IBAN: :iban',
'successful_agent_send_from_cash_to_bank' => "Send money in cash to the bank
Transaction Information:
- Number : :id_transaction
- Amount of the transaction : :amount
- Fees : :fees
- Net shipping amount : :net
- Agent account : :sender_code
- Name of the sender : :sender_name
- Recipient's names : :receiver_name
- IBAN of the recipient : :iban
- Bank : :bank :country",
]; ];

View File

@ -3,7 +3,7 @@ return [
"EN_COURS" => "CURRENT", "EN_COURS" => "CURRENT",
"CASSE" => "BROKEN", "CASSE" => "BROKEN",
"EN_ATTENTE_DE_VALIDATION" => "PENDING VALIDATION", "EN_ATTENTE_DE_VALIDATION" => "PENDING VALIDATION",
"REMBOURSE" => "REFUND", "REMBOURSE" => "REFUNDED",
"NON_VALIDE" => "INVALID", "NON_VALIDE" => "INVALID",
"VALIDE" => "VALID", "VALIDE" => "VALID",
"SIMPLE" => "SIMPLE", "SIMPLE" => "SIMPLE",

View File

@ -82,4 +82,5 @@ Réseau payeur : :network :country',
"operator_not_associated_with_network" => "Cette operateur n'est pas associé à votre réseau", "operator_not_associated_with_network" => "Cette operateur n'est pas associé à votre réseau",
"not_matching_operator" => "Cet opérateur n'est pas un :type_operator", "not_matching_operator" => "Cet opérateur n'est pas un :type_operator",
"wallet_not_linked_to_bank_account" => "Votre wallet n'est pas rattaché à un compte bancaire", "wallet_not_linked_to_bank_account" => "Votre wallet n'est pas rattaché à un compte bancaire",
"update_banking_information" => "Mettez à jour vos informations bancaires",
]; ];

View File

@ -300,4 +300,15 @@ Informations de la transaction :
- Compte émetteur : :sender_code - Compte émetteur : :sender_code
- Banque : :bank :country - Banque : :bank :country
- IBAN : :iban", - IBAN : :iban",
'successful_agent_send_from_cash_to_bank' => "Envoi d'argent en cash vers la banque
Informations de la transaction :
- Numéro : :id_transaction
- Montant de la transaction : :amount
- Frais : :fees
- Montant net d'envoi: :net
- Compte de l'agent : :sender_code
- Noms de l'emetteur : :sender_name
- Noms du destinataire : :receiver_name
- IBAN du destinataire : :iban
- Banque : :bank :country",
]; ];