Yafsa SY
My Projects

Neldam

In fact NELDAMPAY was a clone of the WARI money transfer company. The goal was to make the system more accessible with less shipping costs.

Date: Mon Jan 03 2022


In fact NELDAMPAY was a clone of the WARI money transfer company. The goal was to make the system more accessible with less shipping costs.

This project was my first one with PHP and Angular. You can find the repositories on my github neldam backend and neldam frontend .

Code and Snippets

PHP
1<?php 2 3namespace App\Controller; 4 5use App\Osms; 6 7use Twilio\Rest\Client; 8use App\Entity\BankAccount; 9use App\Entity\Transactions; 10use App\Repository\RolesRepository; 11use App\Repository\TarifsRepository; 12use Symfony\Component\Config\Definition\Exception\Exception; 13use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; 14use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; 15use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; 16 17class TransactionsController extends AbstractController 18{ 19 20 21 private $tokenstorage; 22 private $userPasswordEncoder; 23 private $tarifs; 24 25 26 public function __construct( UserPasswordEncoderInterface $userPasswordEncoder, TarifsRepository $tarifs) 27 { 28 29 30 $this->userPasswordEncoder = $userPasswordEncoder; 31 $this->tarifs = $tarifs; 32 } 33 34 35 public function __invoke(Transactions $data, TarifsRepository $tarifs, TokenStorageInterface $tokenstorage): Transactions 36 { 37 $this->tokenstorage = $tokenstorage; 38 39 40 #recuperation du User connecte 41 42 $userConn = $this->tokenstorage->getToken()->getUser(); 43 44 $data->setUserdepot($userConn); 45 46 47 #query le montant de depot pour en deduire les frais a setter 48 49 50 51 $montant = $data->getMontantdepot(); 52 53 $recupgrille = $tarifs->findByfrais($montant); 54 55 if($montant>=2000000){ 56 $frais = ($montant * 0.02); 57 58 } 59 else{ 60 61 $frais = $recupgrille[0]->getFees(); 62 63 } 64 //Empecher le user d'utiliser son compte apres affectation 65 $jour = new \DateTime(); 66 67 $firstday = $userConn->getAffectations()[0]->getDatedebut(); 68 $lastday = $userConn->getAffectations()[0]->getDatefin(); 69 if ($firstday > $jour || $jour > $lastday) { 70 throw new Exception("Vous n'etes affilie a aucun compte"); 71 } 72 73 $data->setFrais($frais); 74 75 #setter le montant net a percevoir 76 $montantnet = $montant - $frais; 77 78 $data->setMontantnet($montantnet); 79 80 #recuper le compte du userconn pour setter le compte qui a fait l'envoi 81 82 $comptesender = $userConn->getAffectations()[0]->getCompte(); 83 84 $data->setCompteenvoi($comptesender); 85 86 #setter le statut a false pour dire que y'a pas encore eu de retrait 87 88 $data->setStatustrans(false); 89 90 #parts des entites 91 $partetat = $frais *0.4; 92 $partsyst = $frais * 0.3; 93 $partenvoi = $frais * 0.1; 94 $partretrait = $frais * 0.2; 95 96 $data->setPartetat($partetat); 97 $data->setPartsysteme($partsyst); 98 $data->setPartcompteenvoi($partenvoi); 99 $data->setPartcompteretrait($partretrait); 100 101 102 103 #recuperation solde du compte 104 105 $solde=$comptesender->getSolde(); 106 107 108 if ($montantnet < $solde){ 109 110 $comptesender->setSolde($solde- $montantnet ); 111 112 //API SMS AVEC ORANGE 113 114 $config = array( 115 'clientId' => 'xxxxxx', 116 117 'clientSecret' => 'xxxxxxxx' 118 ); 119 120 $osms = new Osms($config); 121 122 // retrieve an access token 123 $response = $osms->getTokenFromConsumerKey(); 124 125 if (!empty($response['access_token'])) { 126 $senderAddress = 'tel:+221'. $data->getPhonesender(); 127 $receiverAddress = 'tel:+221'. $data->getPhonebenef(); 128 $message = 'Welcome to NELDAMPAY- ' . $data->getNomsender() . 'vient de vous envoyer' . $montantnet . 129 'FCFA CODE :' . $data->getCode() . 130 'Merci d\'utiliser nos services'; 131 $senderName = 'NELDAMPAY'; 132 133 $osms->sendSMS($senderAddress, $receiverAddress, $message, $senderName); 134 } else { 135 // error 136 } 137 return $data; 138 } 139 140 else { 141 throw new Exception(" Votre compte n'est pas en mesure de faire cette operation"); 142 } 143 144 145 146 } 147 } 148
TransactionsController.php
A powerful proof-of-work staking rig
PHP
1<?php 2 3namespace App\Controller; 4 5use App\Entity\BankAccount; 6use App\Repository\RolesRepository; 7use Symfony\Component\Config\Definition\Exception\Exception; 8use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; 9use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; 10use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; 11 12class BankController extends AbstractController 13{ 14 15 16 private $tokenstorage; 17 private $userPasswordEncoder; 18 private $repo; 19 20 21 public function __construct(RolesRepository $repo, UserPasswordEncoderInterface $userPasswordEncoder) 22 { 23 24 $this->repo = $repo; 25 $this->userPasswordEncoder = $userPasswordEncoder; 26 } 27 28 29 30 public function __invoke(BankAccount $data, TokenStorageInterface $tokenstorage): BankAccount 31 { 32 $this->tokenstorage = $tokenstorage; 33 34 35 #recuperation du User connecte 36 37 $userConn = $this->tokenstorage->getToken()->getUser(); 38 $data->setAdmin($userConn); 39 40 #recuperer le mot de passe por encodage 41 42 $userpart = $data->getPartenaire()->getUsers()[0]; 43 44 //recuperation password (saisi) 45 $pass = $data->getPartenaire()->getUsers()[0]->getPassword(); 46 47 $userpart->setPassword($this->userPasswordEncoder->encodePassword($userpart, $pass)); 48 49 $userpart->setRoles([$this->repo->findByLibelle("PARTNER")[0]]); 50 //montant premier depot 51 52 $montant = $data->getDepots()[0]->getMontant(); 53 54 if ($montant >= 500000) { 55 $data->getDepots()[0]->setCaissier($userConn); 56 57 $data->setSolde($montant); 58 return $data; 59 } else { 60 throw new Exception("Le montant doit etre superieur ou égale à 500.000"); 61 } 62 } 63} 64
bankController.php

Tech

SYMFONY ANGULAR ORANGE SMS API PLATFORM TWILIO


Email/Twitter/GitHub/LinkedIn