Module d'achat de credit en cours + inscription et test du ws getCredit

This commit is contained in:
Claire DELBOS 2017-02-24 12:44:16 +01:00
parent 52bf3a4d45
commit 996423d7ca
15 changed files with 984 additions and 34 deletions

View File

@ -27,6 +27,8 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
'default' => __DIR__ . '/modules/default/controllers',
'admin' => __DIR__ . '/modules/admin/controllers',
'file' => __DIR__ . '/modules/file/controllers',
'achatclient' => __DIR__ . '/modules/achatclient/controllers',
'compteclient' => __DIR__ . '/modules/compteclient/controllers',
));
return $front;

View File

@ -0,0 +1,135 @@
<?php
class Achatclient_IndexController extends Zend_Controller_Action
{
protected $theme;
/**
* Logger
* @var \Monolog\Logger
*/
protected $logger;
protected $tranches=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;
public function init()
{
if (Zend_Registry::isRegistered('logger')) {
$this->logger = Zend_Registry::get('logger');
}
$autoloader = Zend_Loader_Autoloader::getInstance();
// --- Theme
$this->theme = Zend_Registry::get('theme');
$request = $this->getRequest();
require_once 'Scores/WsScores.php';
}
/**
* Page d'accueil et de redirection
*/
public function indexAction()
{
$user = new Scores_Utilisateur();
$ok=$user->checkperm('searchent');
if(!$ok){
$this->redirect('/');
}
$ws = new WsScores();
$customer_credit = $ws->getCredit();
if(intval($customer_credit)>$this->maxcredit){
$this->view->msg='Vous détenez déjà le plafond de crédits autorisé.';
}
$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->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();
$this->view->PayboxUrl = $paybox->getFormUrl();
$this->view->PayboxValues = $paybox->getFormParameters();
//$pb=new Paybox_System('test');
//var_dump($pb);
}
/**
* Sélection du mode de paiement
*/
public function paiementTestAction()
{
$this->_helper->layout()->disableLayout();
$request = $this->getRequest();
//Commande ID
$cmdId = $request->getParam('id');
//Write the state to the session
$cmdState = 3;
$session = new Zend_Session_Namespace('Cmd');
//@todo : verifications
$cmdId = '525ffc4501a4d';
$this->view->CmdID = $cmdId;
$this->view->Siren = isset($session->CmdSiren)?$session->CmdSiren:'000000000';
$this->view->RaisonSociale = isset($session->CmdRaisonSociale)?$session->CmdRaisonSociale:'testdev';
$this->view->AdresseL1 = isset($session->CmdAdresseL1)?$session->CmdAdresseL1:'';
$this->view->AdresseL2 = isset($session->CmdAdresseL2)?$session->CmdAdresseL2:'';
$this->montantht=20;
$this->montant=20;
$this->tva=0;
//Lire la bdd
//$commandM = new Application_Model_Command();
//$row = $commandM->fetchRow('cmdId="'.$cmdId.'"');
$row=array('email' => 'test20170224091345.demo@intescia.com','id'=>4925);
if ($row !== null) {
$this->view->montant = $this->montantht." &euro; HT" . " (".$this->montant." &euro; TTC)";
$data = array(
'mt' => $this->montantht,
'tax' => $this->tva,
);
//$commandM->update($data, 'id='.$row->id);
//Paybox
require_once 'Paybox/Config.php';
require_once 'Paybox/Config/test.php';
require_once 'Paybox/System.php';
$paybox = new Paybox_System('test');
$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();
$this->view->PayboxUrl = $paybox->getFormUrl();
$this->view->PayboxValues = $paybox->getFormParameters();
$this->view->PayboxVerif=$paybox->URL_PARAMETERS;
}
}
}
?>

View File

@ -0,0 +1,30 @@
<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">
</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

@ -0,0 +1,63 @@
<div class="page-header">
<h2>ACHAT de CREDITS <small>Mode de paiement</small></h2>
</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>
<?php if ($this->PayboxValues) {?>
<?=$this->PayboxVerif?>
<form method="post" action="<?=$this->PayboxUrl?>">
<?php foreach ( $this->PayboxValues as $field) {?>
<?=$field['name']?> ===> <?=$field['value']?><br>
<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 } else {?>
<div class="alert alert-danger"><strong>Erreur !</strong> </div>
<?php }?>

View File

@ -41,7 +41,6 @@ class AuthController extends Zend_Controller_Action
$this->_helper->layout()->disableLayout();
$this->view->headLink()
//->appendStylesheet($this->theme->pathStyle.'/inexweb.css', 'all')
->appendStylesheet($this->theme->pathStyle.'/user.css', 'all');
$request = $this->getRequest();

View File

@ -66,7 +66,7 @@
</div>
<div class="row">
<div class="bannierebas">&nbsp;</div>
<dim class="alert alert-info"><?=$this->msg;?></div>
</div>
</div>

43
composer.lock generated
View File

@ -205,16 +205,16 @@
},
{
"name": "guzzlehttp/psr7",
"version": "1.3.1",
"version": "1.4.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
"reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b"
"reference": "04a6d1a00ea5da0727ee94309a9f0d3dbaecb569"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/5c6447c9df362e8f8093bda8f5d8873fe5c7f65b",
"reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/04a6d1a00ea5da0727ee94309a9f0d3dbaecb569",
"reference": "04a6d1a00ea5da0727ee94309a9f0d3dbaecb569",
"shasum": ""
},
"require": {
@ -250,16 +250,23 @@
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
{
"name": "Tobias Schultze",
"homepage": "https://github.com/Tobion"
}
],
"description": "PSR-7 message implementation",
"description": "PSR-7 message implementation that also provides common utility methods",
"keywords": [
"http",
"message",
"request",
"response",
"stream",
"uri"
"uri",
"url"
],
"time": "2016-06-24T23:00:38+00:00"
"time": "2017-02-21T01:20:32+00:00"
},
{
"name": "monolog/monolog",
@ -597,16 +604,16 @@
},
{
"name": "symfony/browser-kit",
"version": "v3.2.2",
"version": "v3.2.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/browser-kit.git",
"reference": "548f8230bad9f77463b20b15993a008f03e96db5"
"reference": "394a2475a3a89089353fde5714a7f402fbb83880"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/browser-kit/zipball/548f8230bad9f77463b20b15993a008f03e96db5",
"reference": "548f8230bad9f77463b20b15993a008f03e96db5",
"url": "https://api.github.com/repos/symfony/browser-kit/zipball/394a2475a3a89089353fde5714a7f402fbb83880",
"reference": "394a2475a3a89089353fde5714a7f402fbb83880",
"shasum": ""
},
"require": {
@ -650,11 +657,11 @@
],
"description": "Symfony BrowserKit Component",
"homepage": "https://symfony.com",
"time": "2017-01-02T20:32:22+00:00"
"time": "2017-01-31T21:49:23+00:00"
},
{
"name": "symfony/css-selector",
"version": "v3.2.2",
"version": "v3.2.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/css-selector.git",
@ -707,16 +714,16 @@
},
{
"name": "symfony/dom-crawler",
"version": "v3.2.2",
"version": "v3.2.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/dom-crawler.git",
"reference": "27d9790840a4efd3b7bb8f5f4f9efc27b36b7024"
"reference": "b814b41373fc4e535aff8c765abe39545216f391"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/27d9790840a4efd3b7bb8f5f4f9efc27b36b7024",
"reference": "27d9790840a4efd3b7bb8f5f4f9efc27b36b7024",
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/b814b41373fc4e535aff8c765abe39545216f391",
"reference": "b814b41373fc4e535aff8c765abe39545216f391",
"shasum": ""
},
"require": {
@ -759,7 +766,7 @@
],
"description": "Symfony DomCrawler Component",
"homepage": "https://symfony.com",
"time": "2017-01-02T20:32:22+00:00"
"time": "2017-01-21T17:14:11+00:00"
},
{
"name": "symfony/polyfill-mbstring",

69
library/Paybox/Config.php Normal file
View File

@ -0,0 +1,69 @@
<?php
class Paybox_Config
{
protected $PBX_SITE;
protected $PBX_RANG;
protected $PBX_IDENTIFIANT;
protected $KEY;
protected $SERVER;
protected $URL_PAIEMENT;
protected $PBX_TYPEPAIEMENT="CARTE";
protected $PBX_TYPECARTE="VISA";
protected $PBX_MODE=1;
public function __construct($test = false)
{
if ($test === false) {
$config = new Paybox_Config_Prod();
} else {
$config = new Paybox_Config_Test();
}
foreach ( $config->variables as $var => $value ) {
$this->{'PBX_'.$var} = $value;
}
$this->KEY = $config->key;
$this->SERVER = $config->server;
}
/**
* Check server availability and set the paiement url
* @return boolean
*/
public function checkservers()
{
$serveurOK = "";
foreach($this->SERVER as $serveur)
{
$doc = new DOMDocument();
$doc->loadHTMLFile($serveur['ping']);
$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;
$this->URL_PAIEMENT = $serveur['url'];
return true;
break;
}
// else : La machine est disponible mais les services ne le sont pas.
}
if(!$serveurOK){
return false;
}
}
}

View File

@ -0,0 +1,23 @@
<?php
class Paybox_Config_Prod
{
public $key = '249DE9DBD388E3430AC464ACFE23A668F1F3221432F96028468A5A0775AFEB8438C7F4DED096066109BBB5E1B2E22DC53D9D31181CC06DD4C6C1239110ADFFD7';
public $server = array(
array(
'ping' => "https://tpeweb.paybox.com/load.html",
'url' => "https://tpeweb.paybox.com/cgi/MYchoix_pagepaiement.cgi",
),
array(
'ping' => "https://tpeweb1.paybox.com/load.html",
'url' => "https://tpeweb1.paybox.com/cgi/MYchoix_pagepaiement.cgi",
),
);
public $variables = array(
'SITE' => '5136925',
'RANG' => '01',
'IDENTIFIANT' => '533616985',
);
}

View File

@ -0,0 +1,26 @@
<?php
class Paybox_Config_Test
{
public $key = '0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF';
//public $key = '249DE9DBD388E3430AC464ACFE23A668F1F3221432F96028468A5A0775AFEB8438C7F4DED096066109BBB5E1B2E22DC53D9D31181CC06DD4C6C1239110ADFFD7';
//public $key = 'E941B48379E0C65997F52FDA8DC920B358B1AAB99A6E3CCF584F97E6AC55FB3C701DE0CC0CCFAEC82A1B0AA865CCDA36A420C4043376BBAFB51790D8480E2F77';
public $server = array(
array(
'ping' => "https://preprod-tpeweb.paybox.com/load.html",
'url' => "https://preprod-tpeweb.paybox.com/cgi/MYchoix_pagepaiement.cgi",
),
);
/*public $variables = array(
'SITE' => '1999888',
'RANG' => '32',
'IDENTIFIANT' => '110647233',
);*/
public $variables = array(
'SITE' => '5136925',
'RANG' => '001',
'IDENTIFIANT' => '533616985',
);
}

View File

@ -0,0 +1,6 @@
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDe+hkicNP7ROHUssGNtHwiT2Ew
HFrSk/qwrcq8v5metRtTTFPE/nmzSkRnTs3GMpi57rBdxBBJW5W9cpNyGUh0jNXc
VrOSClpD5Ri2hER/GcNrxVRP7RlWOqB1C03q4QYmwjHZ+zlM4OUhCCAtSWflB4wC
Ka1g88CjFwRw/PB9kwIDAQAB
-----END PUBLIC KEY-----

198
library/Paybox/Response.php Normal file
View File

@ -0,0 +1,198 @@
<?php
class Paybox_Response
{
protected $data;
protected $sign;
protected $errCode = 0;
protected $errLabel = 'Impossible de valider le paiement.';
protected $values = array();
public function __construct(){}
/**
*
* @param array $values
*/
public function setData($values)
{
if ( !array_key_exists('sign', $values) )
return;
//Set and remove the sign
$this->setSign($values['sign']);
unset($values['sign']);
$this->values = $values;
//Concat datas with &
$this->data = '';
$i = 0;
$max = count($values);
foreach( $values as $key => $val ) {
if ( !in_array($key, array('eta', 'id', 'type', 'mt', 'auto', 'idtrans')))
continue;
$this->data.= $key."=".urlencode($val);
$i++;
if ( $i<$max ) {
$this->data.= '&';
}
}
// If the last char is &, remove it
if ( substr($this->data, -1) == '&' ) {
$this->data = substr($this->data, 0, strlen($this->data)-1);
}
}
/**
* Défini la signature
* @param string $value
*/
protected function setSign($value)
{
$this->sign = base64_decode($value);
}
/**
*
*/
protected function isDataSign()
{
if (empty($this->data))
return false;
if (empty($this->sign))
return false;
$cert = file_get_contents(__DIR__.'/Key/pubkey.pem');
$pubkeyid = openssl_pkey_get_public($cert);
// state whether signature is okay or not
$ok = openssl_verify($this->data, $this->sign, $pubkeyid, OPENSSL_ALGO_SHA1);
// free the key from memory
openssl_free_key($pubkeyid);
if ($ok == 1) {
return true;
} elseif ($ok == 0) {
return false;
} else {
return false;
}
}
/**
* Vérifie le code retour
* @return boolean
*/
protected function checkEta()
{
$code = $this->values['eta'];
if ( intval($code) === 0 ) {
return true;
}
switch($code) {
/*
00000
Opération réussie.
00001
La connexion au centre dautorisation a échoué ou une erreur interne est survenue. Dans ce cas, il est souhaitable de faire une tentative sur le site secondaire : tpeweb1.paybox.com.
001xx
Paiement refusé par le centre dautorisation [voir §12.1 Codes réponses du centre dautorisation].
En cas dautorisation de la transaction par le centre dautorisation de la banque ou de létablissement financier privatif, le code erreur “00100” sera en fait remplacé directement par “00000”.
=> Liste des codes erreurs
00003
Erreur Paybox. Dans ce cas, il est souhaitable de faire une tentative sur le site secondaire FQDN tpeweb1.paybox.com.
00004
Numéro de porteur ou cryptogramme visuel invalide.
00006
Accès refusé ou site/rang/identifiant incorrect.
00008
Date de fin de validité incorrecte.
00009
Erreur de création dun abonnement.
00010
Devise inconnue.
00011
Montant incorrect.
00015
Paiement déjà effectué.
00016
Abonné déjà existant (inscription nouvel abonné). Valeur U de la variable PBX_RETOUR.
00021
Carte non autorisée.
00029
Carte non conforme. Code erreur renvoyé lors de la documentation de la variable « PBX_EMPREINTE ».
00030
Temps dattente > 15 mn par linternaute/acheteur au niveau de la page de paiements.
00031
Réservé
00032
Réservé
00033
Code pays de ladresse IP du navigateur de lacheteur non autorisé.
00040
Opération sans authentification 3-DSecure, bloquée par le filtre.
99999
Opération en attente de validation par lémetteur du moyen de paiement.
*/
default:
$this->errCode = 0;
$this->errLabel = 'Validation du paiement incorrect';
}
return false;
}
/**
*
* @return boolean
*/
public function checkData()
{
//Vérification de la signature
if ( $this->isDataSign() === false ) {
return false;
}
//Vérifier le retour des données
$vars = array('eta');
foreach ( $vars as $var ) {
if ( method_exists($this, 'check'.ucfirst($var)) ) {
if ( $this->{'check'.ucfirst($var)}() === true ) {
return true;
}
}
}
//eta:E;id:R;type:P;pays:Y;mt:M;auto:A;idtrans:S;sign:K
return false;
}
/**
* Get error message
* @return stdClass
*/
public function getError()
{
$return = new stdClass();
$return->code = $this->errCode;
$return->label = $this->errLabel;
return $return;
}
}

309
library/Paybox/System.php Normal file
View File

@ -0,0 +1,309 @@
<?php
/*
Page scores
===========
Choix du moyen de paiement
- Liste les cartres de paiement autorisées
Forçage du moyen de paiement
PBX_TYPEPAIEMENT
PBX_TYPECARTE
URL de Paybox System :
Variables à transmettre
- PBX_SITE = Numéro de site (fourni par Paybox)
- PBX_RANG = Numéro de rang (fourni par Paybox)
- PBX_IDENTIFIANT = Identifiant interne (fourni par Paybox)
- PBX_TOTAL = Montant total de la transaction
- PBX_DEVISE = Devise de la transaction
- PBX_CMD = Référence commande côté commerçant
- PBX_PORTEUR = Adresse E-mail de lacheteur
- PBX_RETOUR = Liste des variables à retourner par Paybox
- PBX_HASH = Type dalgorithme de hachage pour le calcul de lempreinte
- PBX_TIME = Horodatage de la transaction
- PBX_HMAC = Signature calculée avec la clé secrète
Gestion du HMAC
1 - Générer un clé par l'interface de backoffice
2 - Valider la clé, reception d'un email demandant la validation (la clé est valable 31 jours)
Pas possible plusieurs clés...
=> Pour le test clé définie
Page de paiement paybox
========================
Personnalisation
- Le logo en haut de page
- Laffichage du logo Paybox
- Les boutons de validation/annulation/retour boutique
- Les langues
- Le fond décran
- Et bien dautres options via un fichier CSS
=> Transmettre ces éléments à PayBox
*/
class Paybox_System extends Paybox_Config
{
/**
* Algorithme utilisé pour la signature du message
* SHA512, RIPEMD160, SHA224, SHA256, SHA384, MDC2
* @var string
*/
protected $PBX_HASH = 'SHA512';
/**
* Date à laquelle lempreinte HMAC a été calculée. Doit être URL-encodée
* Date au format ISO8601.
* @var string
*/
protected $PBX_TIME;
protected $PBX_HMAC;
/**
* Référence de commande
* @var string
*/
protected $PBX_CMD;
/**
* Devise (monnaie)
* Code monnaie de la transaction suivant la norme ISO 4217 (code numérique)
* Exemples :
* - Euro : 978
* - US Dollar : 840
* @var string
*/
protected $PBX_DEVISE = '978';
/**
* URL de retour en cas de succès
* @var string
*/
protected $PBX_EFFECTUE;
/**
* URL de retour en cas d'abandon
* @var string
*/
protected $PBX_ANNULE;
/**
* URL de retour en cas de refus de paiement
* @var string
*/
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 ;
* mt:M => Montant de la transaction
* eta:E
* Liste des erreurs possible
*
* id:R => Référence commande (précisée dans PBX_CMD)
* auto:A => numéro d'Autorisation (numéro remis par le centre dautorisation)
* type:P => Type de Paiement retenu (cf. PBX_TYPEPAIEMENT)
* idtrans:S => Numéro de TranSaction Paybox
* pays:Y => Code paYs de la banque émettrice de la carte. Format : ISO 3166 (alphabétique)
* sign:K => Signature sur les variables de l'URL. Format : url-encodé (toujours en dernier)
* @var string
*/
protected $PBX_RETOUR = 'eta:E;id:R;type:P;mt:M;auto:A;idtrans:S;sign:K';
/**
* Langue de la page de paiement
* @var string
*/
protected $PBX_LANGUE = '';
/**
* Adresse email du client
* @var string
*/
protected $PBX_PORTEUR = '';
/**
* TEST
* Code erreur à renvoyer pour tests
* @var string
*/
protected $PBX_ERRORCODETEST;
/**
* ORDRE des champs pour l'affichage du formulaire et le calcul du HMAC
* @var array
*/
protected $stackfields = array(
'PBX_SITE',
'PBX_RANG',
'PBX_IDENTIFIANT',
'PBX_TOTAL',
'PBX_DEVISE',
'PBX_CMD',
'PBX_PORTEUR',
'PBX_RETOUR',
'PBX_HASH',
'PBX_TIME',
);
public $URL_PARAMETERS;
public function __construct($test = false) {
parent::__construct($test);
}
public function getFormUrl()
{
return $this->URL_PAIEMENT;
}
public function getFormParameters()
{
$params = array();
foreach ( $this->stackfields as $field ) {
$value = $this->{$field};
if ( !empty($value) ) {
$params[] = array(
'name' => $field,
'value' => $value,
);
}
}
$params[] = array(
'name' => 'PBX_HMAC',
'value' => $this->PBX_HMAC,
);
return $params;
}
/**
* Défini le montant
* @param float $value
*/
public function setMontant($value)
{
$montant = str_replace(',', '', number_format($value, 2, ',', ''));
$this->PBX_TOTAL = $montant;
}
/**
* Set the command reference
* @param string $value
*/
public function setReference($value)
{
$this->PBX_CMD = $value;
}
/**
* Set user email
* @param string $value
*/
public function setEmail($value)
{
$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
*/
public function setUrlParameters($withReturnUrl = '')
{
if ( !empty($withReturnUrl) ) {
$this->setReturnUrl($withReturnUrl);
$this->stackfields = array_merge($this->stackfields, array(
'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 = '';
$i = 0;
foreach ( $this->stackfields as $field ) {
$value = $this->{$field};
if ( !empty($value) ) {
$params.= $field.'='.$value;
$i++;
if ( $i < count($this->stackfields) ) {
$params.= '&';
}
}
}
// If the last char is &, remove it
if ( substr($params, -1) == '&' ) {
$params = substr($params, 0, strlen($params)-1);
}
$this->URL_PARAMETERS = $params;
}
/**
* Return the paiement URL if available
* @return string|boolean
*/
public function setUrlPaiement()
{
$this->checkservers();
if ( !empty($this->URL_PAIEMENT) ) {
return $this->URL_PAIEMENT;
}
return false;
}
/**
* Calcul le HMAC
* @return void
*/
public function calculateHMAC()
{
$binKey = pack("H*", $this->KEY);
//echo "URL_PARAMETERS : ".$this->URL_PARAMETERS;die;
$this->PBX_HMAC = strtoupper(hash_hmac('sha512', $this->URL_PARAMETERS, $binKey));
}
/**
* Define Return URL
* @param string $url
*/
public function setReturnUrl($url)
{
$this->PBX_EFFECTUE = $url;
$this->PBX_REFUSE = $url;
$this->PBX_ATTENTE = $url;
$this->PBX_ANNULE = $url;
}
}

View File

@ -3347,6 +3347,29 @@ class WsScores
}
}
/**
* getListePrefs
*/
public function getCredit()
{
$filename = 'prefs';
$cache = new Cache($filename);
if ($cache->exist() && $this->cacheEnable ){
return $cache->getBlock('prefs');
}
try {
$client = $this->loadClient('gestion');
$reponse = $client->getCredits();
$cache->deletefile();
$cache->setBlock($reponse->credit);
return $reponse->credit;
} catch (SoapFault $fault) {
$this->soaperror(__FUNCTION__, $fault, $client->__getLastRequest(), $client->__getLastResponse());
//Placer exception pour affichage message
return false;
}
}
/**
* soaperror

View File

@ -1,3 +1,63 @@
<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';
@ -6,11 +66,11 @@ $lastname = 'macdonald';
$time = time();
/*
$login = 'jpdurail.demo@gmail.com';
$name = 'Jean Paul';
$lastname = 'DURAIL';
$time = '1434629722';
*/
$login = 'jpdurail.demo@gmail.com';
$name = 'Jean Paul';
$lastname = 'DURAIL';
$time = '1434629722';
*/
$key = 'rh5s4z';
$data = $login . '/' . $time . '/' . $key;
@ -28,12 +88,12 @@ echo "TOKEN : ".base64_encode(hash_hmac('sha256',$data,$key));
echo "<br/>";
/*
echo "<br/><br/>";
$algos = hash_algos();
foreach ($algos as $item) {
echo "<br/><br/>";
$algos = hash_algos();
foreach ($algos as $item) {
echo $item." TOKEN : ".hash($item, $data)." - BASE64 : ".base64_encode(hash($item, $data));
echo "<br/>";
}
*/
}
*/
*?>