Merge branch 'inextenso' of ssh://gogs.sd.lan:10022/SCORES/extranet into inextenso

This commit is contained in:
benoitpotier 2017-02-27 15:35:48 +01:00
commit 03d7564a11
6 changed files with 164 additions and 96 deletions

View File

@ -11,13 +11,17 @@ class Achatclient_IndexController extends Zend_Controller_Action
protected $logger;
protected $tranches=array(
'195' => array(
'200' => array('montant' => 2000,'montantht' => 1667, 'tva' => 333, ),
'500' => array('montant' => 5000,'montantht' => 4167, 'tva' => 833, ),
'1000' => array('montant' => 10000,'montantht' => 8333, 'tva' => 1667, ),
),
);
protected $maxcredit=2000;
protected $libdroits = 'searchent';
public function init()
{
if (Zend_Registry::isRegistered('logger')) {
@ -26,7 +30,7 @@ class Achatclient_IndexController extends Zend_Controller_Action
$autoloader = Zend_Loader_Autoloader::getInstance();
// --- Theme
$this->theme = Zend_Registry::get('theme');
$request = $this->getRequest();
$this->view->title='Votre compte crédits en ligne';
require_once 'Scores/WsScores.php';
}
@ -35,40 +39,102 @@ class Achatclient_IndexController extends Zend_Controller_Action
*/
public function indexAction()
{
//Validation des droits
$user = new Scores_Utilisateur();
$ok=$user->checkperm('searchent');
$ok=$user->checkperm($this->libdroits);
if(!$ok){
$this->redirect('/');
$this->error('index','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 déjà le plafond de crédits autorisé.';
return;
}
$infos=array('user' => $user,'wscredit' => $customer_credit);
$this->view->infos=$infos;
var_dump($infos);die;
$this->logger->info(print_r($infos,1));
if ($infos === false) {
$this->logger->info(print_r($user,1));
if ($customer_credit === false and false) {
$this->error('index','Compte indisponible');
$this->forward('soap', 'error');
}
//Paybox
Zend_Loader::loadClass('Paybox_System');
$paybox = new \Paybox\System(false);
$paybox->setUrlPaiement();
$paybox->setEmail($row->email);
$paybox->setReference($cmdId);
$paybox->setMontant($this->montant);
$paybox->setUrlRepondreA("http://".$request->getHttpHost()."/report/checkpmt");
$paybox->setUrlParameters("http://".$request->getHttpHost()."/report/retour");
$paybox->calculateHMAC();
//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__);
}
$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'],
'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',
);
/*@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();
//$pb=new Paybox_System('test');
//var_dump($pb);
}
}
public function pbanswer(){
echo 'thanks';die;
}
/**
* Sélection du mode de paiement
*/
@ -130,6 +196,21 @@ class Achatclient_IndexController extends Zend_Controller_Action
}
}
public function footerAction(){
}
private function error($ligne=0,$message=""){
switch($ligne){
case "index":
case "paiement":
$this->view->msg=$message;
throw new Exception($message);
break;
default:
echo $ligne.' : '.$message;die;
}
}
}
?>

View File

@ -1,30 +1,37 @@
<style>
div .credit{
margin-left:25px;
}
</style>
<div id="center">
<div id="oldform" method="POST" action="https://preprod-tpeweb.paybox.com/cgi/MYchoix_pagepaiement.cgi">
<input type="hidden" name="PBX_SITE" value="1999888">
<input type="hidden" name="PBX_RANG" value="32">
<input type="hidden" name="PBX_IDENTIFIANT" value="110647233">
<input type="hidden" name="PBX_TOTAL" value="999">
<input type="hidden" name="PBX_DEVISE" value="978">
<input type="hidden" name="PBX_CMD" value="TEST Paybox">
<input type="hidden" name="PBX_PORTEUR" value="test@paybox.com">
<input type="hidden" name="PBX_RETOUR" value="Mt:M;Ref:R;Auto:A;Erreur:E">
<input type="hidden" name="PBX_HASH" value="SHA512">
<input type="hidden" name="PBX_TIME" value="2013-10-11T09:42:08+00:00">
<input type="hidden" name="PBX_HMAC" value="D47AB2FDC9ADF9669651C6F8F785F698FB77C75AE314D0060A0528B434F4FE12BA3D027D066A1E8038FA56E7704EC882AA8E44FB36D44957A0F5BA8BE03E03E9">
<input type="submit" value="PayerOld">
<h1><?=$this->titre?></h1>
<h2>Votre compte crédit</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>Vos choix de commande</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;?> />&nbsp;&nbsp;<?=$credit?>&nbsp;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>
<form method="POST" action="https://preprod-tpeweb.paybox.com/cgi/MYchoix_pagepaiement.cgi" target="_blank">
<input type="hidden" name="PBX_SITE" value="5136925">
<input type="hidden" name="PBX_RANG" value="001">
<input type="hidden" name="PBX_IDENTIFIANT" value="533616985">
<input type="hidden" name="PBX_TOTAL" value="20">
<input type="hidden" name="PBX_DEVISE" value="978">
<input type="hidden" name="PBX_CMD" value="TEST Paybox">
<input type="hidden" name="PBX_PORTEUR" value="test@paybox.com">
<input type="hidden" name="PBX_RETOUR" value="Mt:M;Ref:R;Auto:A;Erreur:E">
<input type="hidden" name="PBX_HASH" value="SHA512">
<input type="hidden" name="PBX_TIME" value="<?=Date('Y-m-dTH:i:s+00:00'); ?>">
<input type="hidden" name="PBX_HMAC" value="E941B48379E0C65997F52FDA8DC920B358B1AAB99A6E3CCF584F97E6AC55FB3C701DE0CC0CCFAEC82A1B0AA865CCDA36A420C4043376BBAFB51790D8480E2F77">
PBX_EFFECTUE
<input type="submit" value="Payer">
</form></div>

View File

@ -1,36 +1,23 @@
<style>
div .credit{
margin-left:25px;
}
</style>
<div class="page-header">
<h2>ACHAT de CREDITS <small>Mode de paiement</small></h2>
<div id="center">
<h1>ACHAT de CREDITS <small>Confirmation</small></h1>
<?php //if ( $this->CmdID ):?>
<h2>Informations de la commande</h2>
<div class="credit">
Identifiant de commande : <?=$this->pbparams['cmdId']?><br>
Une fois le paiement effectué cliquer sur le bouton "Retour boutique" afin de
consulter vos documents, si la redirection automatique ne se fait pas.
</div>
<?php if ( $this->CmdID ) {?>
<div class="row">
<div class="col-md-6">
<h3>Informations de la commande</h3>
<dl class="dl-horizontal">
<dt>Siren : </dt>
<dd><?=$this->Siren?></dd>
<dt>Raison Sociale : </dt>
<dd><?=$this->RaisonSociale?></dd>
<dt>Adresse : </dt>
<dd><?=$this->AdresseL1?></dd>
<dt></dt>
<dd><?=$this->AdresseL2?></dd>
</dl>
<div class="alert alert-info">Prix : <?=$this->montant?></div>
</div>
<div class="col-md-6">
<h3>Sélection du mode de paiement</h3>
<h2>Sélection du mode de paiement</h2>
<div class="credit">
<?php if ($this->PayboxValues) {?>
<?=$this->PayboxVerif?>
<form method="post" action="<?=$this->PayboxUrl?>">
@ -40,24 +27,15 @@
<input type="hidden" name="<?=$field['name']?>" value="<?=$field['value']?>" />
<?php }?>
<div>
Une fois le paiement effectué cliquer sur le bouton "Retour boutique" afin de
consulter vos documents, si la redirection automatique ne se fait pas.
</div>
<input type="submit" class="btn btn-primary" value="Paiement"/>
</form>
<?php }?>
</div>
</div>
<?php // }?>
<?php } else {?>
<div class="alert alert-danger"><strong>Erreur !</strong> </div>
<?php }?>
</div>

View File

@ -22,8 +22,10 @@ class Paybox_Config
public function __construct($test = false)
{
if ($test === false) {
Zend_Loader::loadClass('Paybox_Config_Prod');
$config = new Paybox_Config_Prod();
} else {
Zend_Loader::loadClass('Paybox_Config_Test');
$config = new Paybox_Config_Test();
}

View File

@ -1,8 +1,8 @@
<?php
class Paybox_Config_Test
{
public $key = '0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF';
//public $key = '249DE9DBD388E3430AC464ACFE23A668F1F3221432F96028468A5A0775AFEB8438C7F4DED096066109BBB5E1B2E22DC53D9D31181CC06DD4C6C1239110ADFFD7';
//public $key = '0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF';
public $key = '249DE9DBD388E3430AC464ACFE23A668F1F3221432F96028468A5A0775AFEB8438C7F4DED096066109BBB5E1B2E22DC53D9D31181CC06DD4C6C1239110ADFFD7';
//public $key = 'E941B48379E0C65997F52FDA8DC920B358B1AAB99A6E3CCF584F97E6AC55FB3C701DE0CC0CCFAEC82A1B0AA865CCDA36A420C4043376BBAFB51790D8480E2F77';
public $server = array(
array(
@ -19,7 +19,7 @@ class Paybox_Config_Test
public $variables = array(
'SITE' => '5136925',
'RANG' => '001',
'RANG' => '01',
'IDENTIFIANT' => '533616985',
);

View File

@ -3399,7 +3399,7 @@ class WsScores
$message.= "\n\n";
}
$message.= "Referer : ".$_SERVER['HTTP_REFERER']."\n\n";
$message.= "Referer : ".isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:''."\n\n";
$message.= "Requete :\n ".$requete."\n";
$message.= "Reponse :\n ".$reponse."\n";