+ Update response email for agent operation
This commit is contained in:
parent
f2e8318347
commit
7e3ce25b86
|
@ -57,7 +57,7 @@ class UserController extends Controller
|
||||||
if ($identification->status == 1) {
|
if ($identification->status == 1) {
|
||||||
return $this->errorResponse(trans('messages.identification_already_validated'));
|
return $this->errorResponse(trans('messages.identification_already_validated'));
|
||||||
}
|
}
|
||||||
// dd($request->allFiles());
|
// dd($request->all());
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'id_network' => 'required|integer|min:0|not_in:0',
|
'id_network' => 'required|integer|min:0|not_in:0',
|
||||||
'id_country' => 'required|integer|min:0|not_in:0',
|
'id_country' => 'required|integer|min:0|not_in:0',
|
||||||
|
@ -67,7 +67,7 @@ class UserController extends Controller
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$identification->idNetwork = $request->id_network;
|
$identification->idNetwork = $request->id_network;
|
||||||
$identification->id_country = $request->id_country;
|
$identification->country_id = $request->id_country;
|
||||||
$identification->document_image_front = $this->uploadImage($request,'document_image_front','D-F',"documents");
|
$identification->document_image_front = $this->uploadImage($request,'document_image_front','D-F',"documents");
|
||||||
$identification->document_image_back = $this->uploadImage($request,'document_image_back','D-B',"documents");
|
$identification->document_image_back = $this->uploadImage($request,'document_image_back','D-B',"documents");
|
||||||
$identification->user_image = $this->uploadImage($request,'user_image','U',"photos");
|
$identification->user_image = $this->uploadImage($request,'user_image','U',"photos");
|
||||||
|
|
|
@ -43,7 +43,7 @@ class iLinkTransactionController extends Controller
|
||||||
'type' => 'required|integer|min:0|not_in:0',
|
'type' => 'required|integer|min:0|not_in:0',
|
||||||
'id_wallet_agent' => 'integer|min:0|not_in:0',
|
'id_wallet_agent' => 'integer|min:0|not_in:0',
|
||||||
'id_wallet_user' => 'integer|min:0|not_in:0',
|
'id_wallet_user' => 'integer|min:0|not_in:0',
|
||||||
'password'=>'required'
|
'password' => 'required'
|
||||||
]);
|
]);
|
||||||
$type = TypeIlinkTransaction::findOrFail($request->type);
|
$type = TypeIlinkTransaction::findOrFail($request->type);
|
||||||
|
|
||||||
|
@ -127,15 +127,46 @@ class iLinkTransactionController extends Controller
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 12: // Agent - Retrait en cash
|
case 12: // Agent - Retrait en cash
|
||||||
|
$this->validate($request, $transaction->remove_cash_rules());
|
||||||
|
$agent = AgentPlus::findOrFail($network_agent->agent_id);
|
||||||
|
if ($this->checkPassword($request->password, $agent->encrypted_password, $agent->salt)) {
|
||||||
|
$transaction = WalletIlinkTransaction::find($request->id_transaction);
|
||||||
|
if($transaction){
|
||||||
|
if($transaction->status_retrait == 0){
|
||||||
|
if($this->checkPassword($request->code_retrait, $transaction->encrypted_code_retrait, $transaction->code_retrait_salt)){
|
||||||
|
$part_ag = floatval($transaction->frais * $config->taux_com_ag_retrait_cash/ 100) ;
|
||||||
|
$part_sup = floatval($transaction->frais * $config->taux_com_sup_retrait_cash/ 100);
|
||||||
|
$walletAgent->balance_princ -= $transaction->montant_retrait;
|
||||||
|
$walletAgent->balance_com += $part_ag;
|
||||||
|
$walletSuperviseur->balance_com += $part_sup ;
|
||||||
|
$walletHyperviseur->balance_com -= ($part_ag + $part_sup);
|
||||||
|
$transaction->status_retrait = 1;
|
||||||
|
$transaction->date_retrait = new \DateTime();
|
||||||
|
$walletAgent->save();
|
||||||
|
$walletSuperviseur->save();
|
||||||
|
$walletHyperviseur->save();
|
||||||
|
$transaction->save();
|
||||||
|
return $this->successResponse(trans('messages.successful_transaction'));
|
||||||
|
}else{
|
||||||
|
return $this->errorResponse('Code de retrait invalide');
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return $this->errorResponse('Retrait déjà éffectuée');
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return $this->errorResponse('Cette transaction n\'existe pas',Response::HTTP_NOT_FOUND);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return $this->errorResponse(trans('messages.incorrect_user_password'));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 13: // Agent - Retrait de la carte vers cash
|
case 13: // Agent - Retrait de la carte vers cash
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 14: // Agent - Envoi de cash vers wallet iLink
|
case 14: // Agent - Envoi de cash vers wallet iLink
|
||||||
$this->validate($request, $transaction->first_rules());
|
$this->validate($request, $transaction->cash_wallet_rules());
|
||||||
$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)) {
|
||||||
$user = User::where('user_code', $request->user_code)->firstOrFail();
|
$user = User::where('user_code', $request->user_code)->firstOrFail();
|
||||||
$walletUser = WalletsUser::where('idUser', $user->id)->firstOrFail();
|
$walletUser = WalletsUser::where('idUser', $user->id)->firstOrFail();
|
||||||
|
|
||||||
|
@ -166,16 +197,19 @@ class iLinkTransactionController extends Controller
|
||||||
$transaction->id_wallet_sup = $walletSuperviseur->id;
|
$transaction->id_wallet_sup = $walletSuperviseur->id;
|
||||||
$transaction->id_wallet_hyp = $walletHyperviseur->id;
|
$transaction->id_wallet_hyp = $walletHyperviseur->id;
|
||||||
$transaction->save();
|
$transaction->save();
|
||||||
$this->sendMail($user->email, trans('messages.successful_transaction'), trans('messages.successful_deposit_ilink',['montant'=> $montantDepot]));
|
$this->sendMail($user->email, trans('messages.successful_transaction'), trans('messages.successful_deposit_ilink',
|
||||||
|
['id_transaction' => $transaction->id, 'amount' => $this->toMoney($transaction->montant,$request->init_country), 'net_init' =>$this->toMoney($montantDepot,$request->init_country) ,
|
||||||
|
'net_final' =>$this->convertMoney($montantDepot,$request->init_country,$request->final_country) ,'fees' => $this->toMoney($frais,$request->init_country) ,'tax' => $this->toMoney($taxe,$request->init_country),
|
||||||
|
'user_code' => $request->user_code]));
|
||||||
return $this->successResponse(trans('messages.successful_transaction'));
|
return $this->successResponse(trans('messages.successful_transaction'));
|
||||||
}else{
|
} else {
|
||||||
return $this->errorResponse(trans('messages.incorrect_user_password'));
|
return $this->errorResponse(trans('messages.incorrect_user_password'));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 15: // Agent - Envoi de cash vers autre wallet
|
case 15: // Agent - Envoi de cash vers autre wallet
|
||||||
// $this->validate($request, $transaction->first_rules());
|
$this->validate($request, $transaction->cash_cash_rules());
|
||||||
$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)) {
|
||||||
$frais = ($request->init_country != $request->final_country) ? $this->calculateFees($plr_agent_depot_autre_wallet, $request->montant) : $this->calculateFees($plr_agent_depot_autre_wallet_national, $request->montant);
|
$frais = ($request->init_country != $request->final_country) ? $this->calculateFees($plr_agent_depot_autre_wallet, $request->montant) : $this->calculateFees($plr_agent_depot_autre_wallet_national, $request->montant);
|
||||||
$taxe = ($request->init_country != $request->final_country) ? $this->calculateTax($taxesInternationales, $frais) : $this->calculateTax($taxesNationales, $frais);
|
$taxe = ($request->init_country != $request->final_country) ? $this->calculateTax($taxesInternationales, $frais) : $this->calculateTax($taxesNationales, $frais);
|
||||||
$montantDepot = $request->montant - $frais - $taxe;
|
$montantDepot = $request->montant - $frais - $taxe;
|
||||||
|
@ -204,14 +238,14 @@ class iLinkTransactionController extends Controller
|
||||||
$transaction->id_wallet_sup = $walletSuperviseur->id;
|
$transaction->id_wallet_sup = $walletSuperviseur->id;
|
||||||
$transaction->id_wallet_hyp = $walletHyperviseur->id;
|
$transaction->id_wallet_hyp = $walletHyperviseur->id;
|
||||||
$transaction->save();
|
$transaction->save();
|
||||||
}else{
|
} else {
|
||||||
return $this->errorResponse(trans('messages.incorrect_user_password'));
|
return $this->errorResponse(trans('messages.incorrect_user_password'));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 16: // Agent - Envoi de cash vers une carte visa
|
case 16: // Agent - Envoi de cash vers une carte visa
|
||||||
$this->validate($request, $transaction->card_rules());
|
$this->validate($request, $transaction->cash_cash_rules());
|
||||||
$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)) {
|
||||||
$expiration_date = \DateTime::createFromFormat('m/y', $request->expiration_date);
|
$expiration_date = \DateTime::createFromFormat('m/y', $request->expiration_date);
|
||||||
if (!$expiration_date)
|
if (!$expiration_date)
|
||||||
$expiration_date = new \DateTime();
|
$expiration_date = new \DateTime();
|
||||||
|
@ -263,20 +297,22 @@ class iLinkTransactionController extends Controller
|
||||||
} else {
|
} else {
|
||||||
return $this->errorResponse(trans('errors.visa_api_failed'), Response::HTTP_INTERNAL_SERVER_ERROR);
|
return $this->errorResponse(trans('errors.visa_api_failed'), Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
return $this->errorResponse(trans('messages.incorrect_user_password'));
|
return $this->errorResponse(trans('messages.incorrect_user_password'));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 17: // Agent - Envoi de cash vers cash
|
case 17: // Agent - Envoi de cash vers cash
|
||||||
$this->validate($request, $transaction->cash_cash_rules());
|
$this->validate($request, array_merge($transaction->cash_cash_rules(), [
|
||||||
|
'email_emetteur' => '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)) {
|
||||||
$frais = ($request->init_country != $request->final_country)? $this->calculateFees($plr_agent_cash_cash, $request->montant) : $this->calculateFees($plr_agent_cash_cash_national, $request->montant);
|
$frais = ($request->init_country != $request->final_country) ? $this->calculateFees($plr_agent_cash_cash, $request->montant) : $this->calculateFees($plr_agent_cash_cash_national, $request->montant);
|
||||||
$taxe = ($request->init_country != $request->final_country) ? $this->calculateTax($taxesInternationales , $frais) : $this->calculateTax($taxesNationales ,$frais);
|
$taxe = ($request->init_country != $request->final_country) ? $this->calculateTax($taxesInternationales, $frais) : $this->calculateTax($taxesNationales, $frais);
|
||||||
$montantRetrait = $request->montant - $frais - $taxe;
|
$montantRetrait = $request->montant - $frais - $taxe;
|
||||||
$commisionAgent = floatval( $frais * $config->taux_com_ag_envoi_cash / 100) ;
|
$commisionAgent = floatval($frais * $config->taux_com_ag_envoi_cash / 100);
|
||||||
$commisionSuper = floatval( $frais * $config->taux_com_sup_envoi_cash / 100) ;
|
$commisionSuper = floatval($frais * $config->taux_com_sup_envoi_cash / 100);
|
||||||
$commisionHyper = floatval( $frais * $config->taux_com_hyp_envoi_cash / 100);
|
$commisionHyper = floatval($frais * $config->taux_com_hyp_envoi_cash / 100);
|
||||||
|
|
||||||
$transaction->montant_retrait = $montantRetrait;
|
$transaction->montant_retrait = $montantRetrait;
|
||||||
$walletAgent->balance_com += $commisionAgent;
|
$walletAgent->balance_com += $commisionAgent;
|
||||||
|
@ -290,7 +326,7 @@ class iLinkTransactionController extends Controller
|
||||||
$transaction->id_wallet_hyp = $walletHyperviseur->id;
|
$transaction->id_wallet_hyp = $walletHyperviseur->id;
|
||||||
|
|
||||||
$code_retrait = $this->random_string();
|
$code_retrait = $this->random_string();
|
||||||
$hash = $this->hashSSHA($code_retrait);
|
$hash = $this->hashSSHA($code_retrait);
|
||||||
$transaction->encrypted_code_retrait = $hash['encrypted'];
|
$transaction->encrypted_code_retrait = $hash['encrypted'];
|
||||||
$transaction->code_retrait_salt = $hash['salt'];
|
$transaction->code_retrait_salt = $hash['salt'];
|
||||||
|
|
||||||
|
@ -303,10 +339,13 @@ class iLinkTransactionController extends Controller
|
||||||
$walletSuperviseur->save();
|
$walletSuperviseur->save();
|
||||||
$walletHyperviseur->save();
|
$walletHyperviseur->save();
|
||||||
$transaction->save();
|
$transaction->save();
|
||||||
$this->sendMail($request->email_emetteur, trans('messages.successful_transaction'), trans('messages.successful_send_cash',['montant'=> $montantRetrait,
|
$this->sendMail($request->email_emetteur, trans('messages.successful_transaction'), trans('messages.successful_send_cash',
|
||||||
'code'=> $code_retrait]));
|
['sender_name' => $request->prenom_emetteur . ' ' . $request->nom_emetteur, 'receiver_name' => $request->prenom_destinataire . ' ' . $request->prenom_destinataire,
|
||||||
|
'id_transaction' => $transaction->id, 'amount' => $this->toMoney($transaction->montant,$request->init_country), 'net_init' =>$this->toMoney($montantRetrait,$request->init_country) ,
|
||||||
|
'net_final' =>$this->convertMoney($montantRetrait,$request->init_country,$request->final_country) ,'fees' => $this->toMoney($frais,$request->init_country) ,'tax' => $this->toMoney($taxe,$request->init_country),
|
||||||
|
'code' => wordwrap($code_retrait , 4 , ' ' , true )]));
|
||||||
return $this->successResponse(trans('messages.successful_transaction'));
|
return $this->successResponse(trans('messages.successful_transaction'));
|
||||||
}else{
|
} else {
|
||||||
return $this->errorResponse(trans('messages.incorrect_user_password'));
|
return $this->errorResponse(trans('messages.incorrect_user_password'));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -405,7 +444,7 @@ 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');
|
||||||
$character_set_array[] = array('count' => 4, 'characters' => '23456789');
|
$character_set_array[] = array('count' => 4, 'characters' => '23456789');
|
||||||
$temp_array = array();
|
$temp_array = array();
|
||||||
foreach ($character_set_array as $character_set) {
|
foreach ($character_set_array as $character_set) {
|
||||||
|
|
|
@ -24,6 +24,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
* @property Collection|Admin[] $admins
|
* @property Collection|Admin[] $admins
|
||||||
* @property Collection|ConfigGame[] $config_games
|
* @property Collection|ConfigGame[] $config_games
|
||||||
* @property Collection|Identification[] $identifications
|
* @property Collection|Identification[] $identifications
|
||||||
|
* @property Collection|WalletIlinkTransaction[] $wallet_ilink_transactions
|
||||||
*
|
*
|
||||||
* @package App\Models
|
* @package App\Models
|
||||||
*/
|
*/
|
||||||
|
@ -64,6 +65,11 @@ class Country extends Model
|
||||||
|
|
||||||
public function identifications()
|
public function identifications()
|
||||||
{
|
{
|
||||||
return $this->hasMany(Identification::class, 'country');
|
return $this->hasMany(Identification::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function wallet_ilink_transactions()
|
||||||
|
{
|
||||||
|
return $this->hasMany(WalletIlinkTransaction::class, 'final_country');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Reliese Model.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Currency
|
||||||
|
*
|
||||||
|
* @property int $id
|
||||||
|
* @property string $code
|
||||||
|
* @property int $numeric
|
||||||
|
* @property string $symbol
|
||||||
|
* @property string $name_en
|
||||||
|
* @property string $name_fr
|
||||||
|
*
|
||||||
|
* @property Collection|Country[] $countries
|
||||||
|
*
|
||||||
|
* @package App\Models
|
||||||
|
*/
|
||||||
|
class Currency extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'currencies';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'numeric' => 'int'
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'code',
|
||||||
|
'numeric',
|
||||||
|
'symbol',
|
||||||
|
'name_en',
|
||||||
|
'name_fr'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function countries()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Country::class, 'idCurrency');
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,6 +19,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
* @property string $encrypted_code_retrait
|
* @property string $encrypted_code_retrait
|
||||||
* @property string $code_retrait_salt
|
* @property string $code_retrait_salt
|
||||||
* @property int $status_retrait
|
* @property int $status_retrait
|
||||||
|
* @property Carbon $date_retrait
|
||||||
* @property string $id_destinataire
|
* @property string $id_destinataire
|
||||||
* @property string $type_id_destinataire
|
* @property string $type_id_destinataire
|
||||||
* @property int $network_destinataire
|
* @property int $network_destinataire
|
||||||
|
@ -85,6 +86,7 @@ class WalletIlinkTransaction extends Model
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $dates = [
|
protected $dates = [
|
||||||
|
'date_retrait',
|
||||||
'expiration_date',
|
'expiration_date',
|
||||||
'date'
|
'date'
|
||||||
];
|
];
|
||||||
|
@ -96,6 +98,7 @@ class WalletIlinkTransaction extends Model
|
||||||
'encrypted_code_retrait',
|
'encrypted_code_retrait',
|
||||||
'code_retrait_salt',
|
'code_retrait_salt',
|
||||||
'status_retrait',
|
'status_retrait',
|
||||||
|
'date_retrait',
|
||||||
'id_destinataire',
|
'id_destinataire',
|
||||||
'type_id_destinataire',
|
'type_id_destinataire',
|
||||||
'network_destinataire',
|
'network_destinataire',
|
||||||
|
@ -154,7 +157,7 @@ class WalletIlinkTransaction extends Model
|
||||||
|
|
||||||
// Regles de validation
|
// Regles de validation
|
||||||
//Envoi de cash vers wallet iLink
|
//Envoi de cash vers wallet iLink
|
||||||
public function first_rules()
|
public function cash_wallet_rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'user_code'=>'required',
|
'user_code'=>'required',
|
||||||
|
@ -181,13 +184,21 @@ class WalletIlinkTransaction extends Model
|
||||||
'final_country' =>'required|integer|min:0|not_in:0',
|
'final_country' =>'required|integer|min:0|not_in:0',
|
||||||
'nom_emetteur'=>'required',
|
'nom_emetteur'=>'required',
|
||||||
'prenom_emetteur'=>'required',
|
'prenom_emetteur'=>'required',
|
||||||
'email_emetteur'=>'required',
|
|
||||||
'type_document_emetteur'=>'required',
|
'type_document_emetteur'=>'required',
|
||||||
'id_document_emetteur'=>'required',
|
'id_document_emetteur'=>'required',
|
||||||
'nom_destinataire'=>'required',
|
'nom_destinataire'=>'required',
|
||||||
'prenom_destinataire'=>'required',
|
'prenom_destinataire'=>'required',
|
||||||
'type_document_destinataire'=>'required',
|
'type_document_destinataire'=>'required',
|
||||||
'id_document_destinataire'=>'required',
|
'id_document_destinataire'=>'required',
|
||||||
|
'id_destinataire' => 'required',
|
||||||
|
'montant'=> 'required|numeric|min:0|not_in:0'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function remove_cash_rules(){
|
||||||
|
return [
|
||||||
|
'id_transaction' =>'required|integer|min:0|not_in:0',
|
||||||
|
'code_retrait' =>'required|size:16',
|
||||||
'montant'=> 'required|numeric|min:0|not_in:0'
|
'montant'=> 'required|numeric|min:0|not_in:0'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,31 +4,79 @@
|
||||||
namespace App\Traits;
|
namespace App\Traits;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Models\Country;
|
||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
use Brick\Money\CurrencyConverter;
|
||||||
|
use Brick\Money\ExchangeRateProvider\PDOProvider;
|
||||||
|
use Brick\Money\ExchangeRateProvider\PDOProviderConfiguration;
|
||||||
|
use Brick\Money\ExchangeRateProvider\BaseCurrencyProvider;
|
||||||
|
use Brick\Money\Money;
|
||||||
|
use Brick\Math\RoundingMode;
|
||||||
|
use PDO;
|
||||||
|
|
||||||
trait Helper
|
trait Helper
|
||||||
{
|
{
|
||||||
public function sendMail($email , $title , $messageText){
|
public function sendMail($email, $title, $messageText)
|
||||||
|
{
|
||||||
|
|
||||||
$recipients = [$email];
|
$recipients = [$email];
|
||||||
Mail::mailer('smtp')->raw($messageText, function ($message) use ($recipients,$title) {
|
Mail::mailer('smtp')->raw($messageText, function ($message) use ($recipients, $title) {
|
||||||
$message->subject($title);
|
$message->subject($title);
|
||||||
$message->to($recipients);
|
$message->to($recipients);
|
||||||
});
|
});
|
||||||
// return $this->successResponse("mail envoye");
|
// return $this->successResponse("mail envoye");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkPassword($password , $encrypted_password , $salt)
|
public function checkPassword($password, $encrypted_password, $salt)
|
||||||
{
|
{
|
||||||
$encrypted_password_to_check = base64_encode(sha1($password . $salt, true) . $salt);
|
$encrypted_password_to_check = base64_encode(sha1($password . $salt, true) . $salt);
|
||||||
return $encrypted_password_to_check == $encrypted_password;
|
return $encrypted_password_to_check == $encrypted_password;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hashSSHA($string) {
|
public function hashSSHA($string)
|
||||||
|
{
|
||||||
$salt = sha1(rand());
|
$salt = sha1(rand());
|
||||||
$salt = substr($salt, 0, 10);
|
$salt = substr($salt, 0, 10);
|
||||||
$encrypted = base64_encode(sha1($string . $salt, true) . $salt);
|
$encrypted = base64_encode(sha1($string . $salt, true) . $salt);
|
||||||
$hash = array("salt" => $salt, "encrypted" => $encrypted);
|
$hash = array("salt" => $salt, "encrypted" => $encrypted);
|
||||||
return $hash;
|
return $hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function toMoney($amount, $id_country)
|
||||||
|
{
|
||||||
|
$country = Country::findOrFail($id_country);
|
||||||
|
$money = Money::of(round($amount, 0),$country->currency->code);
|
||||||
|
return $money->formatTo('fr_FR');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function convertMoney($amount , $init_country , $final_country)
|
||||||
|
{
|
||||||
|
// set to whatever your rates are relative to
|
||||||
|
$baseCurrency = 'USD';
|
||||||
|
|
||||||
|
// use your own credentials, or re-use your existing PDO connection
|
||||||
|
$pdo = new PDO('mysql:host=' .env('DB_HOST') . ';dbname=' .env('DB_DATABASE'), env('DB_USERNAME'), env('DB_PASSWORD'));
|
||||||
|
|
||||||
|
$configuration = new PDOProviderConfiguration();
|
||||||
|
|
||||||
|
$configuration->tableName = 'exchange_rate';
|
||||||
|
$configuration->exchangeRateColumnName = 'exchange_rate';
|
||||||
|
$configuration->targetCurrencyColumnName = 'target_currency';
|
||||||
|
$configuration->sourceCurrencyCode = $baseCurrency;
|
||||||
|
|
||||||
|
// this provider loads exchange rates from your database
|
||||||
|
$provider = new PDOProvider($pdo, $configuration);
|
||||||
|
|
||||||
|
// this provider calculates exchange rates relative to the base currency
|
||||||
|
$provider = new BaseCurrencyProvider($provider, $baseCurrency);
|
||||||
|
|
||||||
|
// this currency converter can now handle any currency pair
|
||||||
|
$converter = new CurrencyConverter($provider);
|
||||||
|
$init_country = Country::findOrFail($init_country);
|
||||||
|
$final_country = Country::findOrFail($final_country);
|
||||||
|
$init_money = Money::of(round($amount, 0),$init_country->currency->code);;
|
||||||
|
$final_money = $converter->convert($init_money, $final_country->currency->code, RoundingMode::DOWN);
|
||||||
|
return $final_money->formatTo('fr_FR');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.2.5",
|
"php": "^7.2.5",
|
||||||
|
"brick/money": "^0.4.5",
|
||||||
"guzzlehttp/guzzle": "^6.5",
|
"guzzlehttp/guzzle": "^6.5",
|
||||||
"illuminate/mail": "^7.13",
|
"illuminate/mail": "^7.13",
|
||||||
"laravel/lumen-framework": "^7.0",
|
"laravel/lumen-framework": "^7.0",
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "38b17bef54c08bf451d9d7db7a488b12",
|
"content-hash": "5adcfbb33de444fa415816ca02cd157e",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "brick/math",
|
"name": "brick/math",
|
||||||
|
@ -51,6 +51,58 @@
|
||||||
],
|
],
|
||||||
"time": "2020-02-17T13:57:43+00:00"
|
"time": "2020-02-17T13:57:43+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "brick/money",
|
||||||
|
"version": "0.4.5",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/brick/money.git",
|
||||||
|
"reference": "91f2b5bc35646f172b038e46bb496ad18db59c3c"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/brick/money/zipball/91f2b5bc35646f172b038e46bb496ad18db59c3c",
|
||||||
|
"reference": "91f2b5bc35646f172b038e46bb496ad18db59c3c",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"brick/math": "~0.7.3 || ~0.8.0",
|
||||||
|
"php": "^7.1|^8.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"brick/varexporter": "~0.2.1",
|
||||||
|
"ext-dom": "*",
|
||||||
|
"ext-pdo": "*",
|
||||||
|
"php-coveralls/php-coveralls": "^2.2",
|
||||||
|
"phpunit/phpunit": "^7.5.15"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-intl": "Required to format Money objects"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Brick\\Money\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"description": "Money and currency library",
|
||||||
|
"keywords": [
|
||||||
|
"brick",
|
||||||
|
"currency",
|
||||||
|
"money"
|
||||||
|
],
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/brick/money",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2020-05-31T14:17:02+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "doctrine/inflector",
|
"name": "doctrine/inflector",
|
||||||
"version": "1.3.1",
|
"version": "1.3.1",
|
||||||
|
|
|
@ -28,5 +28,21 @@ Welcome to the iLink World family !!!
|
||||||
|
|
||||||
Regards,
|
Regards,
|
||||||
ILinkWorld team.',
|
ILinkWorld team.',
|
||||||
'successful_deposit_ilink' => 'Your ilink account has been reloaded with :montant'
|
'successful_deposit_ilink' => 'Deposit to an iLink wallet. User code: :user_code
|
||||||
|
Transaction information:
|
||||||
|
- Transaction ID : :id_transaction
|
||||||
|
- Amount of the transaction : :amount
|
||||||
|
- Net amount of the country of departure : :net_init
|
||||||
|
- Net amount of the destination country : :net_final
|
||||||
|
- Fees : :fees
|
||||||
|
- Tax : :tax',
|
||||||
|
'successful_send_cash'=>'Sent by :sender_name to :receiver_name.
|
||||||
|
Transaction information:
|
||||||
|
- Transaction ID : :id_transaction
|
||||||
|
- Amount of the transaction : :amount
|
||||||
|
- Net amount of the country of departure : :net_init
|
||||||
|
- Net amount of the destination country : :net_final
|
||||||
|
- Fees : :fees
|
||||||
|
- Tax : :tax
|
||||||
|
- Withdrawal code : :code'
|
||||||
];
|
];
|
||||||
|
|
|
@ -28,7 +28,21 @@ Bienvenue dans la famille iLink World !!!
|
||||||
|
|
||||||
Cordialement,
|
Cordialement,
|
||||||
Equipe iLinkWorld.',
|
Equipe iLinkWorld.',
|
||||||
'successful_deposit_ilink' => 'Votre compte ilink a été rechargé d\'un montant de :montant',
|
'successful_deposit_ilink' => 'Dépot vers un wallet iLink. Code de l\'utilisateur : :user_code
|
||||||
'successful_send_cash' => 'Vous avez envoyé une somme de :montant .
|
Informations de la transaction :
|
||||||
Code de retrait : :code',
|
- Transaction ID : :id_transaction
|
||||||
|
- Montant de la transaction : :amount
|
||||||
|
- Montant net du pays de départ : :net_init
|
||||||
|
- Montant net du pays de destination : :net_final
|
||||||
|
- Frais : :fees
|
||||||
|
- Taxe : :tax',
|
||||||
|
'successful_send_cash' => 'Envoi effectué par :sender_name à :receiver_name.
|
||||||
|
Informations de la transaction :
|
||||||
|
- Transaction ID : :id_transaction
|
||||||
|
- Montant de la transaction : :amount
|
||||||
|
- Montant net du pays de départ : :net_init
|
||||||
|
- Montant net du pays de destination : :net_final
|
||||||
|
- Frais : :fees
|
||||||
|
- Taxe : :tax
|
||||||
|
- Code de retrait : :code',
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in New Issue