Created
July 13, 2017 09:45
payxbox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// création des propriétés pour génerer la clé hmac | |
$this->dateTime = date("c"); | |
$this->pbx_site = SgtmConfig::$pbx_site; | |
$this->pbx_rang = SgtmConfig::$pbx_rang; | |
$this->pbx_identifiant = SgtmConfig::$pbx_identifiant; | |
$this->pbx_total = intval($this->total*100); | |
$this->pbx_cmd = $this->reservations['reservations'][0]->codeReservationMere; | |
$this->pbx_porteur = $this->passengers->{1}->mail; | |
$this->pbx_repondre_a = JRoute::_('index.php?option=com_resa2&task=confirmation', true, 1); | |
$this->pbx_retour = 'Mt:M;Ref:R;Auto:A;Erreur:E'; | |
$this->pbx_effectue = JRoute::_('index.php?option=com_resa2&view=ok&crm='.$crm, true, 1); | |
$this->pbx_annule = JRoute::_('index.php?option=com_resa2&view=ko&crm='.$crm, true, 1); | |
$this->pbx_refuse = JRoute::_('index.php?option=com_resa2&view=ko&crm='.$crm, true, 1); | |
// On crée la chaîne à hacher sans URLencodage | |
$msg = "PBX_SITE=" . $this->pbx_site . | |
"&PBX_RANG=" . $this->pbx_rang . | |
"&PBX_IDENTIFIANT=" . $this->pbx_identifiant . | |
"&PBX_TOTAL=" . $this->pbx_total . | |
"&PBX_DEVISE=978" . | |
"&PBX_CMD=" . $this->pbx_cmd . | |
"&PBX_PORTEUR=" . $this->pbx_porteur . | |
"&PBX_RETOUR=" . $this->pbx_retour . | |
"&PBX_REPONDRE_A=" . $this->pbx_repondre_a . | |
"&PBX_EFFECTUE=" . $this->pbx_effectue . | |
"&PBX_ANNULE=" . $this->pbx_annule . | |
"&PBX_REFUSE=" . $this->pbx_refuse . | |
"&PBX_HASH=SHA512" . | |
"&PBX_TIME=" . $this->dateTime; | |
// Si la clé est en ASCII, On la transforme en binaire | |
$binKey = pack("H*", SgtmConfig::$hmac); | |
// On calcule l’empreinte (à renseigner dans le paramètre PBX_HMAC) grâce à la fonction hash_hmac et // | |
// la clé binaire | |
// On envoi via la variable PBX_HASH l'algorithme de hachage qui a été utilisé (SHA512 dans ce cas) | |
// Pour afficher la liste des algorithmes disponibles sur votre environnement, décommentez la ligne // | |
// suivante | |
$this->hmac = strtoupper(hash_hmac('sha512', $msg, $binKey)); | |
$serveurs = array('tpeweb.paybox.com', //serveur primaire | |
'tpeweb1.paybox.com'); //serveur secondaire | |
$serveurOK = ""; | |
//phpinfo(); <== voir paybox | |
foreach($serveurs as $serveur){ | |
$doc = new DOMDocument(); | |
$doc->loadHTMLFile('https://'.$serveur.'/load.html'); | |
$server_status = ""; | |
$element = $doc->getElementById('server_status'); | |
if($element){ | |
$server_status = $element->textContent; | |
} | |
if($server_status == "OK"){ | |
// Le serveur est prêt et les services opérationnels | |
$serveurOK = $serveur; | |
break; | |
} | |
// else : La machine est disponible mais les services ne le sont pas. | |
} | |
curl_close($ch); | |
if(!$serveurOK){ | |
die("Erreur : Aucun serveur n'a été trouvé"); | |
} | |
// Activation de l'univers de préproduction | |
if(SgtmConfig::$debug) { | |
$serveurOK = 'preprod-tpeweb.paybox.com'; | |
} | |
//Création de l'url cgi paybox | |
$this->serveurOK = 'https://'.$serveurOK.'/cgi/MYchoix_pagepaiement.cgi'; | |
parent::display($tpl);// on affiche la vue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- c'est la vue en gros --> | |
<div class="sgtm_step5"> | |
<form method="POST" action="<?= $this->serveurOK; ?>"> | |
<p>En cliquant sur le bouton suivant, je confirme accepter les conditions générales de vente de SGTM.</p> | |
<!-- new stuff --> | |
<input type="<?=$type ?>" name="PBX_SITE" value="<?= $this->pbx_site ?>"> | |
<input type="<?=$type ?>" name="PBX_RANG" value="<?= $this->pbx_rang ?>"> | |
<input type="<?=$type ?>" name="PBX_IDENTIFIANT" value="<?= $this->pbx_identifiant ?>"> | |
<input type="<?=$type ?>" name="PBX_TOTAL" value="<?= $this->pbx_total ?>"> | |
<input type="<?=$type ?>" name="PBX_DEVISE" value="978"> | |
<input type="<?=$type ?>" name="PBX_CMD" value="<?= $this->pbx_cmd ?>"> | |
<input type="<?=$type ?>" name="PBX_PORTEUR" value="<?= $this->pbx_porteur ?>"> | |
<input type="<?=$type ?>" name="PBX_RETOUR" value="<?= $this->pbx_retour ?>"> | |
<input type="<?=$type ?>" name="PBX_REPONDRE_A" value="<?= $this->pbx_repondre_a ?>"> | |
<input type="<?=$type ?>" name="PBX_EFFECTUE" value="<?= $this->pbx_effectue ?>"> | |
<input type="<?=$type ?>" name="PBX_ANNULE" value="<?= $this->pbx_annule ?>"> | |
<input type="<?=$type ?>" name="PBX_REFUSE" value="<?= $this->pbx_refuse ?>"> | |
<input type="<?=$type ?>" name="PBX_HASH" value="SHA512"> | |
<input type="<?=$type ?>" name="PBX_TIME" value="<?php echo $this->dateTime; ?>"> | |
<input type="<?=$type ?>" name="PBX_HMAC" value="<?php echo $this->hmac; ?>"> | |
<input type="submit" value="Payer maintenant"> | |
</form> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment