diff --git a/app/Http/Controllers/TransmittingNetworksController.php b/app/Http/Controllers/TransmittingNetworksController.php index df6c3a2..44008e4 100755 --- a/app/Http/Controllers/TransmittingNetworksController.php +++ b/app/Http/Controllers/TransmittingNetworksController.php @@ -42,7 +42,7 @@ class TransmittingNetworksController extends Controller * @OA\Post( * path="/emitTransaction", * summary="Emettre une transaction vers le backend de iLink APP", - * tags={"Transaction vers le backend de iLink APP"}, + * tags={"Transaction vers le backend de iLink App"}, * security={{"api_key":{}}}, * @OA\RequestBody( * description="Corps de la requete", diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php new file mode 100755 index 0000000..e1bff1c --- /dev/null +++ b/app/Http/Controllers/UserController.php @@ -0,0 +1,135 @@ +validate($request, [ + 'id_transaction' => 'required', + 'id_bank' => 'required', + 'is_verified' => 'required|boolean' + ]); + + $transaction = UsersBankingAccountVerification::where('id_transaction', $request->id_transaction)->first(); + if (!$transaction) + return $this->errorResponse(trans('errors.transaction_not_exist')); + + if ($transaction->was_treated) + return $this->errorResponse(trans('errors.treated_demand')); + + if ($transaction->id_bank_country != $request->id_bank) + return $this->errorResponse(trans('errors.not_authorized_to_process_request')); + + $transaction->is_verified = $request->is_verified; + $user = User::where('user_code', $transaction->user_code)->first(); + if (!$user) + return $this->errorResponse(trans('errors.unexpected_error')); + + if ($request->is_verified) { + $user->iban = $transaction->iban; + $user->id_bank_country = $transaction->id_bank_country; + $user->save(); + } + $transaction->was_treated = true; + $transaction->save(); + + if($request->is_verified){ + $identification = Identification::where('id_user',$user->id)->first(); + $owner = isset($identification) ? $identification->lastname.' '.$identification->firstname : $user->lastname.' '.$user->firstname; + + $network_bank = NetworksOperator::where('id_network', $transaction->id_network )->where('id_operator_country', $request->id_bank)->first(); + + $bank = isset($network_bank) ? $network_bank->operators_country->operator->nom : 'n/a'; + $country = isset($network_bank) ? $network_bank->network->country->name : 'n/a'; + + $message = trans('messages.successful_bank_account_attachment_message', + ['iban' => $transaction->iban, 'owner' => $owner , 'bank' => $bank , 'country' => $country ]); + + $this->sendMail($user->email, trans('messages.successful_bank_account_attachment'), $message); + }else{ + $this->sendMail($user->email, trans('messages.failed_bank_account_attachment'), trans('messages.failed_bank_account_attachment_message')); + } + + $this->successResponse(trans('messages.success_treated_demand')); + } +} diff --git a/app/Models/Identification.php b/app/Models/Identification.php new file mode 100644 index 0000000..622af15 --- /dev/null +++ b/app/Models/Identification.php @@ -0,0 +1,104 @@ + 'int', + 'status' => 'int', + 'idNetwork' => 'int', + 'country_id' => 'int' + ]; + + protected $dates = [ + 'birth_date', + 'expiry_date_document', + 'createdAt' + ]; + + protected $fillable = [ + 'firstname', + 'lastname', + 'birth_date', + 'town', + 'country', + 'identity_document', + 'id_identity_document', + 'expiry_date_document', + 'id_user', + 'status', + 'createdAt', + 'user_image', + 'document_image_front', + 'document_image_back', + 'idNetwork', + 'country_id' + ]; + + public function country() + { + return $this->belongsTo(Country::class); + } + + public function user() + { + return $this->belongsTo(User::class, 'id_user'); + } + + public function network() + { + return $this->belongsTo(Network::class, 'idNetwork'); + } + + public function rules() + { + return [ + 'lastname'=>'required', + 'birth_date'=> 'required|date|before_or_equal:today', + 'town'=>'required', + 'country'=> 'required', + 'identity_document'=> 'required', + 'id_identity_document'=> 'required', + 'expiry_date_document'=>'required|date|after_or_equal:today', + 'id_user' => 'required_without_all:phone_number|integer|min:0|not_in:0', + 'phone_number' => 'required_without_all:id_user' + ]; + } +} diff --git a/app/Models/NetworksOperator.php b/app/Models/NetworksOperator.php new file mode 100644 index 0000000..7f8dbe2 --- /dev/null +++ b/app/Models/NetworksOperator.php @@ -0,0 +1,47 @@ + 'int', + 'id_network' => 'int' + ]; + + protected $fillable = [ + 'id_operator_country', + 'id_network' + ]; + + public function operators_country() + { + return $this->belongsTo(OperatorsCountry::class, 'id_operator_country'); + } + + public function network() + { + return $this->belongsTo(Network::class, 'id_network'); + } +} diff --git a/app/Models/Operator.php b/app/Models/Operator.php new file mode 100644 index 0000000..3375c55 --- /dev/null +++ b/app/Models/Operator.php @@ -0,0 +1,43 @@ +belongsTo(TypeOperator::class, 'type', 'code'); + } + + public function operators_countries() + { + return $this->hasMany(OperatorsCountry::class, 'id_operator'); + } +} diff --git a/app/Models/OperatorsCountry.php b/app/Models/OperatorsCountry.php new file mode 100644 index 0000000..323f58d --- /dev/null +++ b/app/Models/OperatorsCountry.php @@ -0,0 +1,61 @@ + 'int', + 'id_country' => 'int', + 'status' => 'bool' + ]; + + protected $fillable = [ + 'id_operator', + 'id_country', + 'adresse', + 'code', + 'status' + ]; + + public function operator() + { + return $this->belongsTo(Operator::class, 'id_operator'); + } + + public function country() + { + return $this->belongsTo(Country::class, 'id_country'); + } + + public function networks_operators() + { + return $this->hasMany(NetworksOperator::class, 'id_operator_country'); + } +} diff --git a/app/Models/TypeOperator.php b/app/Models/TypeOperator.php new file mode 100644 index 0000000..c49cb83 --- /dev/null +++ b/app/Models/TypeOperator.php @@ -0,0 +1,39 @@ +hasMany(Operator::class, 'type', 'code'); + } +} diff --git a/app/Models/UsersBankingAccountVerification.php b/app/Models/UsersBankingAccountVerification.php new file mode 100644 index 0000000..cb378cf --- /dev/null +++ b/app/Models/UsersBankingAccountVerification.php @@ -0,0 +1,48 @@ + 'int', + 'id_network' => 'int', + 'is_verified' => 'bool', + 'was_treated' => 'bool' + ]; + + protected $fillable = [ + 'id_transaction', + 'user_code', + 'iban', + 'id_bank_country', + 'id_network', + 'is_verified', + 'was_treated' + ]; +} diff --git a/resources/lang/en/errors.php b/resources/lang/en/errors.php index acd942d..e27225f 100755 --- a/resources/lang/en/errors.php +++ b/resources/lang/en/errors.php @@ -84,4 +84,5 @@ Paying network : :network :country', "wallet_not_linked_to_bank_account" => "Your wallet is not linked to a bank account", "update_banking_information" => "Update your banking information", "wallet_already_linked_to_bank_account" => "Your wallet is already linked to your bank account", + 'treated_demand' => 'This request has already been processed', ]; diff --git a/resources/lang/en/messages.php b/resources/lang/en/messages.php index 8c8b197..9a9b378 100755 --- a/resources/lang/en/messages.php +++ b/resources/lang/en/messages.php @@ -289,7 +289,16 @@ Transaction Information: - Operator : :operator - Type of operator : :type_operator - Invoice number : :invoice_number", - 'successful_bank_account_attachment' => 'Connection of your bank account completed', + 'successful_bank_account_attachment' => 'Connection of your bank account has been validated', + 'successful_bank_account_attachment_message' => "Your request to link your bank account to your iLink World account has been validated. +Request Information: + - IBAN : :iban + - Bank : :bank: country + - Account holder names : :owner", + 'failed_bank_account_attachment' => 'Connection of your bank account has been rejected', + 'failed_bank_account_attachment_message' => "Your request to link your bank account to your iLink World account has been rejected. + +Please check your information carefully and submit a new request.", 'successful_user_remove_from_bank_to_wallet' => 'Withdrawal from the bank to the wallet Transaction Information: - Number: :id_transaction diff --git a/resources/lang/fr/errors.php b/resources/lang/fr/errors.php index 8583f91..2a4e3a2 100755 --- a/resources/lang/fr/errors.php +++ b/resources/lang/fr/errors.php @@ -84,4 +84,5 @@ Réseau payeur : :network :country', "wallet_not_linked_to_bank_account" => "Votre wallet n'est pas rattaché à un compte bancaire", "update_banking_information" => "Mettez à jour vos informations bancaires", "wallet_already_linked_to_bank_account" => "Votre wallet est déjà rattaché à votre compte bancaire", + 'treated_demand' => 'Cette demande a déjà été traitée', ]; diff --git a/resources/lang/fr/messages.php b/resources/lang/fr/messages.php index 798a146..ad97734 100755 --- a/resources/lang/fr/messages.php +++ b/resources/lang/fr/messages.php @@ -291,6 +291,15 @@ Informations de la transaction : - Type d'operateur : :type_operator - No facture : :no_facture", 'successful_bank_account_attachment' => 'Rattachement de votre compte bancaire effectué', + 'successful_bank_account_attachment_message' => "Votre demande de rattachement de votre compte bancaire à votre compte iLink World a été validée. +Informations sur la demande : + - IBAN : :iban + - Banque : :bank :country + - Noms du détenteur du compte : :owner", + 'failed_bank_account_attachment' => 'Rattachement de votre compte bancaire rejetée', + 'failed_bank_account_attachment_message' => "Votre demande de rattachement de votre compte bancaire à votre compte iLink World a été rejetée. + +Veuillez verifier attentivement vos informations et soumettre une nouvelle demande.", 'successful_user_remove_from_bank_to_wallet' => "Retrait de la banque vers le wallet Informations de la transaction : - Numéro : :id_transaction diff --git a/routes/web.php b/routes/web.php index 17bb420..9914d0a 100644 --- a/routes/web.php +++ b/routes/web.php @@ -19,5 +19,6 @@ $router->group(['prefix' => '', 'middleware' => 'auth'], function () use ($route // }); $router->post('emitTransaction', 'TransmittingNetworksController@emitPayment'); + $router->post('confirmUserBankAccount', 'UserController@confirmUserBankAccount'); });