Module achat operationnel
This commit is contained in:
parent
591958dee8
commit
076a59c5bf
@ -45,6 +45,8 @@ class Achatclient_IndexController extends Zend_Controller_Action
|
||||
public function indexAction()
|
||||
{
|
||||
//Validation des droits
|
||||
$request = $this->getRequest();
|
||||
$this->view->msg=$request->getParam('message');
|
||||
$user = new Scores_Utilisateur();
|
||||
$ok=$user->checkperm($this->libdroits);
|
||||
if(!$ok){
|
||||
@ -63,14 +65,21 @@ class Achatclient_IndexController extends Zend_Controller_Action
|
||||
if(!isset($this->tranches[$user->getIdClient()])){
|
||||
$this->error('index','Fonction indisponible pour ce client');
|
||||
}
|
||||
$infos=array('user' => $user,'wscredit' => $customer_credit,'tranches' => $this->tranches[$user->getIdClient()]);
|
||||
$infos=array('user' => $user,'tranches' => $this->tranches[$user->getIdClient()]);
|
||||
$infos['balance']=array();
|
||||
foreach($infocredit->balance as $k => $v){
|
||||
$infos['balance'][$v->key]=$v->value;
|
||||
}
|
||||
if(intval($customer_credit)>$this->maxcredit){
|
||||
if(intval($infos['balance']['balance'])>$this->maxcredit){
|
||||
$this->view->msg='Vous détenez le plafond de crédits autorisé.';
|
||||
return;
|
||||
unset($infos['tranches']);
|
||||
}
|
||||
$infos['paid']=array();
|
||||
foreach($infocredit->paid as $no => $r){
|
||||
$infos['paid'][$no]=array();
|
||||
foreach($r as $o){foreach($o as $k => $v){
|
||||
$infos['paid'][$no][$v->key]=$v->value;
|
||||
}}
|
||||
}
|
||||
$this->logger->info(print_r($user,1));
|
||||
$this->view->infos=$infos;
|
||||
@ -101,7 +110,7 @@ class Achatclient_IndexController extends Zend_Controller_Action
|
||||
//Parametrage
|
||||
|
||||
$pbparam=array();
|
||||
$pbparams['cmdId']=implode('#',array($user->identity->id,time()));
|
||||
$pbparams['cmdId']=implode('ww',array($user->identity->id,time()));
|
||||
$pbparams['email']=$user->identity->email;
|
||||
$pbparams['montant']=$this->tranches[$idClient][$nb_credit]['montant'];
|
||||
$pbparams['montantht']=$this->tranches[$idClient][$nb_credit]['montantht'];
|
||||
@ -121,7 +130,7 @@ class Achatclient_IndexController extends Zend_Controller_Action
|
||||
'date_sent' => Date('Y-m-d H:i:s'),
|
||||
'date_received' => null,
|
||||
'paybox_answer' => null,
|
||||
'transaction' => json_encode(array('level' => 'Not confirmed', 'user' => $user->identity->id)),
|
||||
'transaction' => json_encode(array('level' => 'Not confirmed', 'date' => Date('Y-m-d H:i:s'),'user' => $user->identity->id)),
|
||||
'comment' => null,
|
||||
);
|
||||
$ws = new Scores_Ws_Client('credit', '0.1');
|
||||
|
@ -33,113 +33,37 @@ class Achatclient_PbanswerController extends Zend_Controller_Action
|
||||
$user = new Scores_Utilisateur();
|
||||
$ok=$user->checkperm($this->libdroits);
|
||||
if(!$ok){
|
||||
$this->error('index','Fonction indisponible');
|
||||
$this->msg = 'Fonction indisponible';
|
||||
}
|
||||
$ws = new WsScores();
|
||||
$customer_credit = $ws->getCredit();
|
||||
$infos=array('user' => $user,'wscredit' => $customer_credit,'tranches' => $this->tranches);
|
||||
if(intval($customer_credit)>$this->maxcredit){
|
||||
$this->view->msg='Vous détenez le plafond de crédits autorisé.';
|
||||
}
|
||||
$this->logger->info(print_r($user,1));
|
||||
if ($customer_credit === false and false) {
|
||||
$this->error('index','Compte indisponible');
|
||||
$this->forward('soap', 'error');
|
||||
}
|
||||
//Récupération des Parametres
|
||||
$infos=array('user' => $user,'wscredit' => intval($customer_credit),'tranches' => $this->tranches[$user->getIdClient()]);
|
||||
//var_dump($infos);die;
|
||||
$this->view->infos=$infos;
|
||||
$this->view->submitValue='Commander';
|
||||
|
||||
}
|
||||
public function paiementAction()
|
||||
{
|
||||
//Validation
|
||||
$request = $this->getRequest();
|
||||
$user = new Scores_Utilisateur();
|
||||
$ok=$user->checkperm($this->libdroits);
|
||||
if(!$ok){
|
||||
$this->error('paiement', __LINE__);
|
||||
$idCmd=$request->getParam('id');
|
||||
$infos=$request->getParams();
|
||||
if($infos['eta']=="00000"){
|
||||
$valid=1;
|
||||
$this->msg = 'Transaction enregistrée';
|
||||
}else{
|
||||
$valid=0;
|
||||
$this->msg = 'Transaction annulée';
|
||||
}
|
||||
$nb_credit=$request->getParam('nb_credit');
|
||||
if(intval($nb_credit)==0){
|
||||
$this->error('paiement','Vous devez définir le nombre de crédits');
|
||||
}
|
||||
$idClient=$user->getIdClient();
|
||||
if(intval($idClient)==0){
|
||||
$this->error('paiement', __LINE__);
|
||||
}
|
||||
if(!isset($this->tranches[$idClient]) || !isset($this->tranches[$idClient][$nb_credit])){
|
||||
$this->error('paiement', __LINE__);
|
||||
}
|
||||
//Parametrage
|
||||
|
||||
$pbparam=array();
|
||||
$pbparams['cmdId']=implode('#',array($user->identity->id,time()));
|
||||
$pbparams['email']=$user->identity->email;
|
||||
$pbparams['montant']=$this->tranches[$idClient][$nb_credit]['montant']/100;
|
||||
$pbparams['montantht']=$this->tranches[$idClient][$nb_credit]['montantht']/100;
|
||||
$pbparams['tva']=$this->tranches[$idClient][$nb_credit]['tva']/100;
|
||||
$ws = new WsScores();
|
||||
//$customer_credit = $ws->addCredit();
|
||||
$insdata=array(
|
||||
'idClient' =>$user->identity->idClient,
|
||||
'idCmd' => $pbparams['cmdId'],
|
||||
$ligneCredit=array(
|
||||
'idUser' =>$user->identity->id,
|
||||
'idCmd' => $idCmd,
|
||||
'login' => $user->identity->username,
|
||||
'nbCredit' => $nb_credit,
|
||||
'amount' => $this->tranches[$idClient][$nb_credit]['montant'],
|
||||
'amount_ht' => $this->tranches[$idClient][$nb_credit]['montantht'],
|
||||
'amount_tva' => $this->tranches[$idClient][$nb_credit]['tva'],
|
||||
'currency' => 'EUR',
|
||||
'valid' => 0,
|
||||
'date_sent' => Date('Y-m-d H:i:s'),
|
||||
'date_received' => null,
|
||||
'paybox_answer' => json_encode(array('user' => $user)),
|
||||
'comment' => 'Beforecall',
|
||||
'valid' => $valid,
|
||||
'date_received' => Date('Y-m-d H:i:s'),
|
||||
'paybox_answer' => json_encode($infos),
|
||||
'transaction' => json_encode(array('level' => 'Paybox Cancelled', 'date' => Date('Y-m-d H:i:s'),'user' => $user->identity->id)),
|
||||
'comment' => null,
|
||||
);
|
||||
/*@todo
|
||||
$ws = new WsScores();
|
||||
$customer_credit = $ws->addCredit($insdata);
|
||||
*/
|
||||
//Paybox
|
||||
Zend_Loader::loadClass('Paybox_Config');
|
||||
Zend_Loader::loadClass('Paybox_System');
|
||||
$paybox = new Paybox_System(true);
|
||||
$paybox->setUrlPaiement();
|
||||
$paybox->setEmail($pbparams['email']);
|
||||
$paybox->setReference($pbparams['cmdId']);
|
||||
$paybox->setMontant($pbparams['montant']);
|
||||
//echo "http://".$request->getHttpHost()."/achatclient/pbanswer";die;
|
||||
//$paybox->setUrlRepondreA("http://".$request->getHttpHost()."/achatclient/checkpmt");
|
||||
$paybox->setUrlParameters("http://".$request->getHttpHost()."/achatclient/pbanswer");
|
||||
$paybox->calculateHMAC();
|
||||
//$_POST=$paybox->getFormParameters();
|
||||
//$this->redirect($paybox->getFormUrl());
|
||||
$this->view->pbparams = $pbparams;
|
||||
$this->view->PayboxUrl = $paybox->getFormUrl();
|
||||
$this->view->PayboxValues = $paybox->getFormParameters();
|
||||
|
||||
}
|
||||
public function pbanswerAction(){
|
||||
$request = $this->getRequest();
|
||||
$user = new Scores_Utilisateur();
|
||||
$ok=$user->checkperm($this->libdroits);
|
||||
if(!$ok){
|
||||
$this->view->msg='Problème d\'autentification';
|
||||
$ws = new Scores_Ws_Client('credit', '0.1');
|
||||
try {
|
||||
$params = new stdClass();
|
||||
$params->ligneCredit = json_encode($ligneCredit);
|
||||
$stage = $ws->payCredit($params);
|
||||
} catch(Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
$answer=$request->getParam('answer');
|
||||
if(empty($answer)){
|
||||
$this->view->msg='Problème technique';
|
||||
|
||||
}
|
||||
switch($answer){
|
||||
case "error":
|
||||
return;
|
||||
break;
|
||||
}
|
||||
$this->view->msg='Annulation de votre transaction';
|
||||
|
||||
$this->redirect("http://".$request->getHttpHost()."/achatclient/?message=".$this->msg);
|
||||
}
|
||||
|
||||
private function error($ligne=0,$message=""){
|
||||
|
@ -2,6 +2,13 @@
|
||||
div .credit{
|
||||
margin-left:25px;
|
||||
}
|
||||
td.nbr{
|
||||
text-align:right;
|
||||
}
|
||||
#message{
|
||||
color:red;
|
||||
font-size:14px;
|
||||
}
|
||||
</style>
|
||||
<div id="center">
|
||||
|
||||
@ -10,7 +17,8 @@ div .credit{
|
||||
<h2>Résumé de vos crédits</h2>
|
||||
<div class="credit">
|
||||
<p>
|
||||
Le compte <?=isset($this->infos['user']->identity->username)?$this->infos['user']->identity->username:""?> détient actuellement <?=intval($this->infos['wscredit'])?> crédits.<br>
|
||||
Le compte <?=isset($this->infos['user']->identity->username)?$this->infos['user']->identity->username:""?>
|
||||
détient actuellement <?=intval($this->infos['balance']['balance'])?> crédits.<br>
|
||||
<?php if(isset($this->infos['balance']['created'])):?>
|
||||
Premier achat le <?=Date('d/m/Y',strtotime($this->infos['balance']['created']))?>.<br>
|
||||
<?php endif;?>
|
||||
@ -22,7 +30,7 @@ Dernière mise à jour le <?=Date('d/m/Y',strtotime($this->infos['balance']['upd
|
||||
</div>
|
||||
<?php if(isset($this->infos) && isset($this->infos['tranches'])):?>
|
||||
<h2>Commander des crédits</h2>
|
||||
<form action="<?=$this->url(array('controller'=>'index', 'action'=>'paiement'))?>" method="GET" id="creditform">
|
||||
<form action="<?=$this->url(array('controller'=>'index', 'action'=>'paiement'))?>" method="POST" id="creditform">
|
||||
<div class="credit">
|
||||
<?php $ok=true;foreach($this->infos['tranches'] as $credit => $item):?>
|
||||
<br><input type="radio" name="nb_credit" value="<?=$credit?>" <?php if($ok){?>checked="checked"<?php }$ok=false;?> /> <?=$credit?> Crédits (<?=$item['montant']/100?> Euros)
|
||||
@ -42,6 +50,15 @@ Dernière mise à jour le <?=Date('d/m/Y',strtotime($this->infos['balance']['upd
|
||||
<?php endif;?>
|
||||
<?php if(isset($this->infos) && isset($this->infos['paid'])):?>
|
||||
<h2>Historique de vos achats</h2>
|
||||
<table class="data" style="max-width:80%;">
|
||||
<?php foreach($this->infos['paid'] as $row):?>
|
||||
<tr>
|
||||
<td><?=Date('d/m/Y H:i:s',strtotime($row['date_sent']))?></td>
|
||||
<td class="nbr"><?=$row['amount']/100?> Euros</td>
|
||||
<td><?=($row['valid']==0?'Annulée':'Enregistrée')?></td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</table>
|
||||
<?php endif;?>
|
||||
|
||||
</div>
|
||||
|
@ -1,37 +0,0 @@
|
||||
<style>
|
||||
div .credit{
|
||||
margin-left:25px;
|
||||
}
|
||||
</style>
|
||||
<div id="center">
|
||||
|
||||
<h1>Votre compte crédits en ligne</h1>
|
||||
|
||||
<h2>Fiche crédits</h2>
|
||||
<div class="credit">
|
||||
<p>
|
||||
Le compte <?=isset($this->infos['user']->identity->username)?$this->infos['user']->identity->username:""?> détient actuellement <?=intval($this->infos['wscredit'])?> crédits.<br>
|
||||
</p>
|
||||
<div id="message" class="alert alert-info"><?=$this->msg?></div>
|
||||
</div>
|
||||
<?php if(isset($this->infos) && isset($this->infos['tranches'])):?>
|
||||
<h2>Commander des crédits</h2>
|
||||
<form action="<?=$this->url(array('controller'=>'index', 'action'=>'paiement'))?>" method="GET" id="creditform">
|
||||
<div class="credit">
|
||||
<?php $ok=true;foreach($this->infos['tranches'] as $credit => $item):?>
|
||||
<input type="radio" name="nb_credit" value="<?=$credit?>" <?php if($ok){?>checked="checked"<?php }$ok=false;?> /> <?=$credit?> Crédits (<?=$item['montant']/100?> Euros)
|
||||
<?php endforeach;?>
|
||||
</div>
|
||||
<div class="submit">
|
||||
<p class="submit-button">
|
||||
<input type="submit" class="button" value="<?php echo $this->submitValue?>" />
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
$('#creditform').submit(function($data){
|
||||
//@todo des vérifs si besoin
|
||||
});
|
||||
</script>
|
||||
<?php endif;?>
|
||||
</div>
|
@ -5,10 +5,10 @@ return array(
|
||||
'debug' => true,
|
||||
'errorMsg' => array('MSG'),
|
||||
),
|
||||
'infoCredit' => array(
|
||||
'debug' => true,
|
||||
'errorMsg' => array('MSG'),
|
||||
),
|
||||
'infoCredit' => array(
|
||||
'debug' => true,
|
||||
'errorMsg' => array('MSG'),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -1,99 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>In Extenso - Connexion SSO</title>
|
||||
<?php
|
||||
$testidentities=array(
|
||||
'valide de test' => array(
|
||||
'partner' => "inextenso",
|
||||
'user' => "jpdurail.demo@gmail.com",
|
||||
'mail' => "jpdurail.demo@gmail.com",
|
||||
'name' => "RICOIS",
|
||||
'lastname' => "Michael",
|
||||
),
|
||||
'mcdo' => array(
|
||||
'partner' => "inextenso",
|
||||
'user' => "r.macdonald@scores-decisions.com",
|
||||
'mail' => "r.macdonald@scores-decisions.com",
|
||||
'name' => "ronald",
|
||||
'lastname' => "macdonald",
|
||||
),
|
||||
'nouveau de test' => array(
|
||||
'partner' => "inextenso",
|
||||
'user' => "test201702221637.demo@gmail.com",
|
||||
'mail' => "test".Date("YmdHis").".demo@gmail.com",
|
||||
'name' => "DELBOS",
|
||||
'lastname' => "Claire",
|
||||
),
|
||||
'invalide de test' => array(
|
||||
'partner' => "inextenso2",
|
||||
'user' => "invalide.demo@gmail.com",
|
||||
'mail' => "invalide.demo@gmail.com",
|
||||
'name' => "VILAIN",
|
||||
'lastname' => "Claire",
|
||||
),
|
||||
);
|
||||
$identity=$testidentities['nouveau de test'];
|
||||
$time = time();
|
||||
$key = 'rh5s4z';
|
||||
$data = $identity['mail'] . '/' . $time . '/' . $key;
|
||||
$token = hash('sha256', $data);
|
||||
//$token=base64_encode(hash_hmac('sha256',$data));
|
||||
$url='http://extranet.sd.dev/sso/inextenso';
|
||||
$url2='http://extranet.sd.dev/auth?partner2=inextenso';
|
||||
?>
|
||||
</head>
|
||||
<body onload="document.ssoForm.submit();">
|
||||
<form id="ssoForm" name="ssoForm" method="GET" action="<?=$url;?>" target="_blank">
|
||||
<?php ?>
|
||||
<!-- partner : <input type="text" name="partner" value="<?=$identity['partner'];?>"><br> -->
|
||||
mail : <input type="text" name="mail" value="<?=$identity['mail'];?>"><br>
|
||||
name : <input type="text" name="name" value="<?=$identity['name'];?>"><br>
|
||||
lastname : <input type="text" name="lastname" value="<?=$identity['lastname'];?>"><br>
|
||||
<!-- codeclient : <input type="text" name="codeclient" value=195><br> -->
|
||||
token : <input type="text" name="token" value="<?php echo $token;?>" size="150"><br>
|
||||
time : <input type="text" name="time" value="<?php echo $time; ?>"><?php echo Date('Y-m-d H:i:s',$time); ?><br>
|
||||
<!-- siret : <input type="text" name="siret" value="4294967295"><br> -->
|
||||
Si vous n'êtes pas automatiquement redirigé vers le service, cliquez sur ce bouton :
|
||||
<a target="_blank" href="http://extranet.sd.dev/sso/inextenso?mail=<?=$identity['mail'];?>&name=<?=$identity['name'];?>&lastname=<?=$identity['lastname'];?>&token=<?=$token;?>&time=<?=$time;?>">Ouvrir</a>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
|
||||
$login = 'r.macdonald@scores-decisions.com';
|
||||
$name = 'ronald';
|
||||
$lastname = 'macdonald';
|
||||
$time = time();
|
||||
|
||||
/*
|
||||
$login = 'jpdurail.demo@gmail.com';
|
||||
$name = 'Jean Paul';
|
||||
$lastname = 'DURAIL';
|
||||
$time = '1434629722';
|
||||
*/
|
||||
|
||||
$key = 'rh5s4z';
|
||||
$data = $login . '/' . $time . '/' . $key;
|
||||
$token = hash('sha256', $data);
|
||||
|
||||
echo "Lien : <a target=\"_blank\" href=\"http://extranet.sd.dev/sso/inextenso?mail=".$login."&name=".$name."&lastname=".$lastname."&token=".$token."&time=".$time."\">Ouvrir</a>";
|
||||
echo "<br/>";
|
||||
echo "SHA256 : ".$token;
|
||||
echo "<br/>";
|
||||
echo "TOKEN : ".base64_encode($token);
|
||||
echo "<br/>";
|
||||
echo "SHA256 HMAC : ".hash_hmac('sha256',$data,$key);
|
||||
echo "<br/>";
|
||||
echo "TOKEN : ".base64_encode(hash_hmac('sha256',$data,$key));
|
||||
echo "<br/>";
|
||||
|
||||
/*
|
||||
echo "<br/><br/>";
|
||||
$algos = hash_algos();
|
||||
foreach ($algos as $item) {
|
||||
echo $item." TOKEN : ".hash($item, $data)." - BASE64 : ".base64_encode(hash($item, $data));
|
||||
echo "<br/>";
|
||||
}
|
||||
*/
|
||||
*?>
|
||||
|
Loading…
Reference in New Issue
Block a user