Intégration de la vérification de paiement
This commit is contained in:
parent
5302700ab3
commit
97bc6debe9
@ -48,7 +48,7 @@ class DashboardController extends Zend_Controller_Action
|
||||
//Lister les commandes OK eta = 0
|
||||
else {
|
||||
$commandM = new Application_Model_Command();
|
||||
$sql = $commandM->select()->where('eta = ?',0);
|
||||
$sql = $commandM->select();
|
||||
$this->view->Commands = $commandM->fetchAll($sql);
|
||||
//Télécharger le rapport
|
||||
//Regénérer le rapport
|
||||
|
@ -268,8 +268,8 @@ class ReportController extends Zend_Controller_Action
|
||||
$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->setUrlParameters();
|
||||
$paybox->calculateHMAC();
|
||||
|
||||
$this->view->PayboxUrl = $paybox->getFormUrl();
|
||||
@ -368,25 +368,51 @@ class ReportController extends Zend_Controller_Action
|
||||
//Commande ID
|
||||
$cmdId = $request->getParam('id');
|
||||
|
||||
$cmdState = 5;
|
||||
//If REF and eta = 0, OK => file et commande moins d'un mois
|
||||
$ref = $request->getParam('ref');
|
||||
|
||||
$session = new Zend_Session_Namespace('Cmd');
|
||||
if ( $session->state > $cmdState || $session->CmdID != $cmdId ) {
|
||||
$url = $this->view->url(array(
|
||||
'controller' => 'report',
|
||||
'action' => 'index',
|
||||
'siren' => $session->CmdSiren,
|
||||
), null, true);
|
||||
$this->redirect($url);
|
||||
} else {
|
||||
$session->state = $cmdState;
|
||||
}
|
||||
|
||||
//Est ce que la commande existe
|
||||
$commandM = new Application_Model_Command();
|
||||
$where = $commandM->select()->where('cmdId=?', $cmdId);
|
||||
|
||||
if ( $ref === null ) {
|
||||
|
||||
//Session
|
||||
$cmdState = 5;
|
||||
|
||||
$session = new Zend_Session_Namespace('Cmd');
|
||||
if ( $session->state > $cmdState || $session->CmdID != $cmdId ) {
|
||||
$url = $this->view->url(array(
|
||||
'controller' => 'report',
|
||||
'action' => 'index',
|
||||
'siren' => $session->CmdSiren,
|
||||
), null, true);
|
||||
$this->redirect($url);
|
||||
} else {
|
||||
$session->state = $cmdState;
|
||||
}
|
||||
|
||||
//Est ce que la commande existe
|
||||
$this->view->CmdValide = false;
|
||||
|
||||
} else {
|
||||
|
||||
$cmdId = strtolower($cmdId);
|
||||
|
||||
//Check date
|
||||
$date = new Zend_Date();
|
||||
$dateN2 = $date->toString('yyyy-MM-dd HH:mm:ss');
|
||||
$date->sub(1, Zend_Date::MONTH);
|
||||
$dateN1 = $date->toString('yyyy-MM-dd HH:mm:ss');
|
||||
|
||||
$where->where("dateInsert BETWEEN ".$dateN1." AND ".$dateN2);
|
||||
}
|
||||
|
||||
$row = $commandM->fetchRow($where);
|
||||
if ( $row!==null ) {
|
||||
if ( $row==null ) {
|
||||
$this->view->msg = "Commande introuvable !";
|
||||
} else {
|
||||
|
||||
$this->view->msg = "Validation du paiement incorrecte.";
|
||||
|
||||
if ($row->eta == 0) {
|
||||
|
||||
@ -427,10 +453,58 @@ class ReportController extends Zend_Controller_Action
|
||||
}
|
||||
|
||||
$this->view->links = $links;
|
||||
$this->view->CmdValide = true;
|
||||
$this->view->msg = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* IPN Url to check paiement autorisation
|
||||
*/
|
||||
public function checkpmtAction()
|
||||
{
|
||||
$this->_helper->layout()->disableLayout();
|
||||
|
||||
$request = $this->getRequest();
|
||||
$params = $request->getParams();
|
||||
|
||||
//@todo : Check IP
|
||||
|
||||
|
||||
//Vérification que la commande existe
|
||||
$commandM = new Application_Model_Command();
|
||||
$row = $commandM->fetchRow('cmdId="'.$cmdId.'"');
|
||||
if ($row !== null) {
|
||||
/*
|
||||
* PBX_RETOUR
|
||||
* mt:M => Montant de la transaction
|
||||
* eta:E
|
||||
* id:R => Référence commande (précisée dans PBX_CMD)
|
||||
* auto:A => numéro d'Autorisation (numéro remis par le centre d’autorisation)
|
||||
* type:P => Type de Paiement retenu (cf. PBX_TYPEPAIEMENT)
|
||||
* idtrans:S => Numéro de TranSaction Paybox
|
||||
* sign:K => Signature sur les variables de l'URL. Format : url-encodé (toujours en dernier)
|
||||
*/
|
||||
$verify = new Paybox_Response();
|
||||
$verify->setData($params);
|
||||
if ( $verify->checkData() !== false ) {
|
||||
//Vérifier le montant
|
||||
if ( $this->montant == $params['mt'] ) {
|
||||
//Enregistrement des valeurs
|
||||
$data = array(
|
||||
'mt' => $this->montantht,
|
||||
'tax' => $this->tva,
|
||||
'eta' => $params['eta'],
|
||||
'auto' => $params['auto'],
|
||||
'type' => $params['type'],
|
||||
'idtrans' => $params['idtrans'],
|
||||
);
|
||||
$commandM->update($data, 'id='.$row->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display in blank page the html
|
||||
@ -579,14 +653,23 @@ class ReportController extends Zend_Controller_Action
|
||||
|
||||
//Prepare information in database
|
||||
if ( $bill === null ) {
|
||||
$lastItemSql = $billM->select()->order('id DESC')->limit(1);
|
||||
$annee = substr($row->dateInsert, 0,4);
|
||||
$mois = substr($row->dateInsert, 5,2);
|
||||
|
||||
$lastItemSql = $billM->select()
|
||||
->where('annee=?', $annee)
|
||||
->where('mois=?', $mois)
|
||||
->order('num DESC')->limit(1);
|
||||
$lastItem = $billM->fetchRow($lastItemSql);
|
||||
$NumCmd = $billM->insert(array(
|
||||
'id' => $lastItem->id+1,
|
||||
$NumCmd = $lastItem->num + 1;
|
||||
$billM->insert(array(
|
||||
'cmdId' => $cmdId,
|
||||
'annee' => $annee,
|
||||
'mois' => $mois,
|
||||
'num' => $NumCmd,
|
||||
));
|
||||
} elseif ( $bill !== null && $regen !== null ) {
|
||||
$NumCmd = $bill->id;
|
||||
$NumCmd = $bill->num;
|
||||
}
|
||||
|
||||
//Set filename
|
||||
|
@ -15,7 +15,9 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($this->Commands as $cmd) {?>
|
||||
<tr>
|
||||
<?php $class = '';?>
|
||||
<?php if ($cmd->eta!=0) { $class=' class="danger"'; }?>
|
||||
<tr<?=$class?>>
|
||||
<td><?=$cmd->cmdId?></td>
|
||||
<td><?=$cmd->siren?></td>
|
||||
<td><?=$cmd->email?></td>
|
||||
@ -35,11 +37,13 @@
|
||||
<a href="#" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
|
||||
Action <span class="caret"></span>
|
||||
</a>
|
||||
<?php if ($cmd->eta==0) {?>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="<?=$this->url(array('controller'=>'report', 'action'=>'getcmd', 'id'=>$cmd->cmdId))?>" target="_blank">Télécharger le document (si disponible)</a></li>
|
||||
<li><a href="#" target="_blank">Générer le document</a></li>
|
||||
<li><a href="<?=$this->url(array('controller'=>'report', 'action'=>'bill', 'id'=>$cmd->cmdId))?>" target="_blank">Télécharger la facture</a></li>
|
||||
</ul>
|
||||
<?php }?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
1
application/views/scripts/report/checkpmt.phtml
Normal file
1
application/views/scripts/report/checkpmt.phtml
Normal file
@ -0,0 +1 @@
|
||||
<?php
|
@ -1,5 +1,7 @@
|
||||
<?php echo $this->render('report/header.phtml')?>
|
||||
|
||||
<?php if ($this->CmdValide===true) {?>
|
||||
|
||||
<div class="page-header">
|
||||
<h2>RAPPORT FINANCIER COMPLET <small>Livraison du rapport complet</small></h2>
|
||||
</div>
|
||||
@ -62,4 +64,10 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php } else {?>
|
||||
|
||||
<div class="alert alert-danger"><?=$this->msg?></div>
|
||||
|
||||
<?php }?>
|
||||
|
||||
<?php echo $this->render('report/footer.phtml')?>
|
@ -1,6 +1,18 @@
|
||||
<!-- Site footer -->
|
||||
<div class="footer">
|
||||
<p>© Scores & Décisions <?=date('Y')?></p>
|
||||
<div class="col-md-4"><p>© Scores & Décisions <?=date('Y')?></p></div>
|
||||
|
||||
<div class="col-md-8">
|
||||
<form class="form-inline" method="post" action="<?=$this->url(array('controller'=>'report', 'action'=>'deliver'))?>">
|
||||
<div class="form-group col-md-6">
|
||||
<label class="sr-only" for="reference">Référence</label>
|
||||
<input type="text" class="form-control" id="reference" placeholder="Votre référence de commande" name="id">
|
||||
<input type="hidden" name="ref" value="lst" />
|
||||
</div>
|
||||
<button type="submit" class="btn btn-default">Ok</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@ -96,6 +96,12 @@ class Paybox_System extends Paybox_Config
|
||||
*/
|
||||
protected $PBX_REFUSE;
|
||||
|
||||
/**
|
||||
* URL IPN (Instant Payement Notification)
|
||||
* @var string
|
||||
*/
|
||||
protected $PBX_REPONDRE_A;
|
||||
|
||||
/**
|
||||
* Configuration de la réponse
|
||||
* Chaine <nom de variable>:<lettre> concaténé par ;
|
||||
@ -209,6 +215,15 @@ class Paybox_System extends Paybox_Config
|
||||
$this->PBX_PORTEUR = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the IPN Url
|
||||
* @param string $url
|
||||
*/
|
||||
public function setUrlRepondreA($url)
|
||||
{
|
||||
$this->PBX_REPONDRE_A = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define URL parameters as string to calculate HMAC
|
||||
* @param string $withReturnUrl
|
||||
@ -218,13 +233,19 @@ class Paybox_System extends Paybox_Config
|
||||
if ( !empty($withReturnUrl) ) {
|
||||
$this->setReturnUrl($withReturnUrl);
|
||||
$this->stackfields = array_merge($this->stackfields, array(
|
||||
'PBX_EFFECTUE',
|
||||
'PBX_REFUSE',
|
||||
'PBX_ATTENTE',
|
||||
'PBX_ANNULE',
|
||||
'PBX_EFFECTUE',
|
||||
'PBX_REFUSE',
|
||||
'PBX_ATTENTE',
|
||||
'PBX_ANNULE',
|
||||
));
|
||||
}
|
||||
|
||||
if ( !empty($this->PBX_REPONDRE_A) ) {
|
||||
$this->stackfields = array_merge($this->stackfields, array(
|
||||
'PBX_REPONDRE_A',
|
||||
));
|
||||
}
|
||||
|
||||
$dateTime = date('c');
|
||||
$this->PBX_TIME = $dateTime;
|
||||
$params = '';
|
||||
|
Loading…
Reference in New Issue
Block a user