Intégration Paybox
This commit is contained in:
parent
e668bdf240
commit
69f2d5ec72
@ -90,4 +90,19 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
||||
);
|
||||
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
|
||||
}
|
||||
|
||||
protected function _initRouter()
|
||||
{
|
||||
$this->bootstrap('frontController');
|
||||
$front = $this->getResource('frontController');
|
||||
$router = $front->getRouter();
|
||||
|
||||
//Route pour prestations
|
||||
$route = new Zend_Controller_Router_Route('/id/:client/*', array(
|
||||
'controller' => 'presta',
|
||||
'action' => 'index',
|
||||
));
|
||||
$router->addRoute('presta', $route);
|
||||
return $router;
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ resources.layout.layoutPath = APPLICATION_PATH "/views"
|
||||
resources.view.basePath = APPLICATION_PATH "/views"
|
||||
autoloaderNamespaces[] = "Application_"
|
||||
autoloaderNamespaces[] = "Scores_"
|
||||
autoloaderNamespaces[] = "Paybox_"
|
||||
|
||||
; Scores configuration
|
||||
profil.server.name = local
|
||||
|
@ -1,5 +1,23 @@
|
||||
<?php
|
||||
class PrestaController extends Zend_Controller_Action
|
||||
{
|
||||
public function indexAction(){}
|
||||
public function indexAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
$id = $request->getParam('client');
|
||||
|
||||
switch($id) {
|
||||
//Prestation KOMPASS, livraison rapport pdf
|
||||
case '144':
|
||||
$siren = $request->getParam('siren');
|
||||
$url = '/report/index/siren/'.$siren;
|
||||
$this->redirect($url);
|
||||
break;
|
||||
default:
|
||||
//Erreur
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -49,6 +49,12 @@ class ReportController extends Zend_Controller_Action
|
||||
'siren'=>$response->Siren
|
||||
));
|
||||
|
||||
//Session
|
||||
$session->CmdSiren = $response->Siren;
|
||||
$session->CmdRaisonSociale = $response->Nom;
|
||||
$session->CmdAdresseL1 = $response->Adresse;
|
||||
$session->CmdAdresseL2 = $response->CP . ' ' . $response->Ville;;
|
||||
|
||||
//Nombre
|
||||
$response = $ws->getLiens($siren);
|
||||
if ( $response !== false ) {
|
||||
@ -92,7 +98,7 @@ class ReportController extends Zend_Controller_Action
|
||||
'controller' => 'report',
|
||||
'action' => 'index',
|
||||
'siren' => $siren,
|
||||
));
|
||||
), null, true);
|
||||
|
||||
//Affichage du formulaires
|
||||
$form = new Application_Form_Command();
|
||||
@ -118,19 +124,24 @@ class ReportController extends Zend_Controller_Action
|
||||
$commandM = new Application_Model_Command();
|
||||
try {
|
||||
$commandM->insert($form->getValues());
|
||||
|
||||
//Passage à la page suivante
|
||||
$url = $this->view->url(array(
|
||||
'controller'=>'report',
|
||||
'action'=>'deliver',
|
||||
'action'=>'paiement', //deliver
|
||||
'id' => $form->getValue('cmdId'),
|
||||
));
|
||||
), null, true);
|
||||
$this->redirect($url);
|
||||
|
||||
//=> Aller à la page de paiement
|
||||
|
||||
|
||||
} catch (Zend_Db_Adapter_Exception $e) {
|
||||
$this->view->msg = "Impossible de passer la commande.";
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
} /*else {
|
||||
|
||||
//Write the state to the session
|
||||
$cmdState = 1;
|
||||
@ -139,15 +150,19 @@ class ReportController extends Zend_Controller_Action
|
||||
$this->redirect($url);
|
||||
} else {
|
||||
$session->state = $cmdState;
|
||||
$this->view->Siren = $session->CmdSiren;
|
||||
$this->view->RaisonSociale = $session->CmdRaisonSociale;
|
||||
$this->view->AdresseL1 = $session->CmdAdresseL1;
|
||||
$this->view->AdresseL2 = $session->CmdAdresseL2;
|
||||
}
|
||||
|
||||
if ( !isset($session->CmdID) || empty($session->CmdID) ) {
|
||||
|
||||
//Get the report
|
||||
if (intval($siren)>100) {
|
||||
$report = new Scores_Partner_Report('indiscore3', $siren, 'mricois', 'ju2loh6o');
|
||||
$html = $report->getContent();
|
||||
|
||||
//$report = new Scores_Partner_Report('indiscore3', $siren, 'mricois', 'ju2loh6o');
|
||||
//$html = $report->getContent();
|
||||
$html = 'blabla';
|
||||
if ( $html !== false ) {
|
||||
|
||||
$c = Zend_Registry::get('config');
|
||||
@ -169,11 +184,160 @@ class ReportController extends Zend_Controller_Action
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
//Test
|
||||
$session = new Zend_Session_Namespace('Cmd');
|
||||
$this->view->CmdID = 'test';
|
||||
$this->view->Siren = $session->CmdSiren;
|
||||
$this->view->RaisonSociale = $session->CmdRaisonSociale;
|
||||
$this->view->AdresseL1 = $session->CmdAdresseL1;
|
||||
$this->view->AdresseL2 = $session->CmdAdresseL2;
|
||||
|
||||
$this->view->form = $form;
|
||||
$this->view->siren = $siren;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sélection du mode de paiement
|
||||
*/
|
||||
public function paiementAction()
|
||||
{
|
||||
$this->_helper->layout()->disableLayout();
|
||||
|
||||
$request = $this->getRequest();
|
||||
|
||||
//Commande ID
|
||||
$cmdId = $request->getParam('id');
|
||||
|
||||
//Write the state to the session
|
||||
$cmdState = 4;
|
||||
|
||||
$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;
|
||||
}*/
|
||||
|
||||
$this->view->CmdID = $session->CmdID;
|
||||
|
||||
$cmdId = '525ffc4501a4d';
|
||||
$this->view->CmdID = $cmdId;
|
||||
$this->view->Siren = $session->CmdSiren;
|
||||
$this->view->RaisonSociale = $session->CmdRaisonSociale;
|
||||
$this->view->AdresseL1 = $session->CmdAdresseL1;
|
||||
$this->view->AdresseL2 = $session->CmdAdresseL2;
|
||||
|
||||
//Lire la bdd
|
||||
$commandM = new Application_Model_Command();
|
||||
$row = $commandM->fetchRow('cmdId="'.$cmdId.'"');
|
||||
if ($row !== null) {
|
||||
|
||||
//Paybox : Liste des types de paiements possible
|
||||
$paybox = new Paybox_System();
|
||||
$paybox->setUrlPaiement();
|
||||
$paybox->setEmail($row->email);
|
||||
$paybox->setReference($cmdId);
|
||||
$paybox->setMontant(10.00);
|
||||
$paybox->setUrlParameters();
|
||||
$paybox->calculateHMAC();
|
||||
|
||||
//Set PBX_EFFECTUE, PBX_REFUSE, PBX_ANNULE, PBX_ATTENTE, PBX_REPONDRE_A
|
||||
|
||||
$this->view->PayboxUrl = $paybox->getFormUrl();
|
||||
$this->view->PayboxValues = $paybox->getFormParameters();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function retourAction()
|
||||
{
|
||||
$this->_helper->layout()->disableLayout();
|
||||
|
||||
$request = $this->getRequest();
|
||||
|
||||
//PBX_RETOUR
|
||||
/*
|
||||
* eta:E
|
||||
* ref: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)
|
||||
* transaction: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é
|
||||
*/
|
||||
|
||||
/* Code retour eta:E
|
||||
00000
|
||||
Opération réussie.
|
||||
00001
|
||||
La connexion au centre d’autorisation 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 d’autorisation [voir §12.1 Codes réponses du centre d’autorisation].
|
||||
En cas d’autorisation de la transaction par le centre d’autorisation 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 d’un 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 d’attente > 15 mn par l’internaute/acheteur au niveau de la page de paiements.
|
||||
00031
|
||||
Réservé
|
||||
00032
|
||||
Réservé
|
||||
00033
|
||||
Code pays de l’adresse IP du navigateur de l’acheteur 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.
|
||||
*/
|
||||
|
||||
|
||||
//Get cmd id
|
||||
$eta = $request->getParam('eta');
|
||||
|
||||
|
||||
|
||||
//Request PAYBOX to validate the payment
|
||||
//Valider les bons de commande
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -183,6 +347,10 @@ class ReportController extends Zend_Controller_Action
|
||||
|
||||
$request = $this->getRequest();
|
||||
|
||||
//Get the response from PAYBOX
|
||||
|
||||
|
||||
|
||||
$c = Zend_Registry::get('config');
|
||||
$pathCmd = $c->profil->path->data;
|
||||
|
||||
@ -194,6 +362,11 @@ class ReportController extends Zend_Controller_Action
|
||||
|
||||
$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;
|
||||
|
1
application/views/scripts/presta/index.phtml
Normal file
1
application/views/scripts/presta/index.phtml
Normal file
@ -0,0 +1 @@
|
||||
<div class="alert alert-danger"><strong>Erreur !</strong> </div>
|
@ -21,12 +21,36 @@
|
||||
|
||||
<div><?=$this->msg?></div>
|
||||
|
||||
<p>* Champs obligatoires</p>
|
||||
|
||||
<form role="form" name="commande" action="<?=$this->form->getAction()?>" method="<?=$this->form->getMethod()?>">
|
||||
<form name="commande" action="<?=$this->form->getAction()?>" method="<?=$this->form->getMethod()?>">
|
||||
<input type="hidden" name="cmdId" value="<?=$this->CmdID?>" />
|
||||
<input type="hidden" name="siren" value="<?=$this->siren?>" />
|
||||
|
||||
<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 : 10,00 €</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
|
||||
<h3>Informations personnelles</h3>
|
||||
<p>* Champs obligatoires</p>
|
||||
|
||||
<div class="form-group">
|
||||
<label><?=$this->form->email->getLabel()?><?php if ($this->form->email->isRequired()) { echo ' *'; }?></label>
|
||||
<input type="email" name="<?=$this->form->email->getName()?>" class="form-control" value="<?=$this->form->email->getValue()?>" placeholder="<?=$this->form->email->getDescription()?>">
|
||||
@ -135,7 +159,11 @@
|
||||
<?php }?>
|
||||
</div>
|
||||
|
||||
<input type="submit" value="<?=$this->form->submit->getLabel()?>" class="btn btn-default" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clearfix"><input type="submit" value="<?=$this->form->submit->getLabel()?>" class="btn btn-primary pull-right" /></div>
|
||||
</form>
|
||||
|
||||
<?php } else {?>
|
||||
@ -153,5 +181,4 @@
|
||||
|
||||
<?php echo $this->inlineScript(); ?>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
</html>
|
@ -84,5 +84,4 @@
|
||||
|
||||
<?php echo $this->inlineScript(); ?>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
</html>
|
@ -73,8 +73,17 @@
|
||||
|
||||
</ul>
|
||||
|
||||
<div class="row clearfix">
|
||||
|
||||
<div class="clearfix"><a type="button" class="btn btn-primary pull-right" href="<?=$this->ButtonUrl?>">Commander</a></div>
|
||||
<div class="col-md-6">
|
||||
<div class="alert alert-info">Prix : 10,00 €</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<a type="button" class="btn btn-primary pull-right" href="<?=$this->ButtonUrl?>">Commander</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php }?>
|
||||
|
||||
@ -87,5 +96,4 @@
|
||||
|
||||
<?php echo $this->inlineScript(); ?>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
</html>
|
89
application/views/scripts/report/paiement.phtml
Normal file
89
application/views/scripts/report/paiement.phtml
Normal file
@ -0,0 +1,89 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="viewport" content="width=device-width, initial-scale=1.0" >
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
|
||||
<meta http-equiv="Content-Language" content="fr-FR" >
|
||||
<title>Kompass - Achat Bilan Financier</title>
|
||||
<link href="/libs/bootstrap-v3.0.0/css/bootstrap.min.css" media="all" rel="stylesheet" type="text/css" >
|
||||
<link href="/themes/default/css/justified-nav.css" media="all" rel="stylesheet" type="text/css" >
|
||||
<!--[if lt IE 9]> <script type="text/javascript" src="/libs/html5shiv.js"></script><![endif]-->
|
||||
<!--[if lt IE 9]> <script type="text/javascript" src="/libs/respond.min.js"></script><![endif]-->
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
|
||||
<div class="page-header">
|
||||
<h2>RAPPORT FINANCIER COMPLET <small>Mode de paiement</small></h2>
|
||||
</div>
|
||||
|
||||
<?php if ( $this->CmdID ) {?>
|
||||
|
||||
<form name="commande" action="" method="">
|
||||
<input type="hidden" name="cmdId" value="<?=$this->CmdID?>" />
|
||||
<input type="hidden" name="siren" value="<?=$this->siren?>" />
|
||||
|
||||
<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 : 10,00 €</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
|
||||
<h3>Sélection du mode de paiement</h3>
|
||||
|
||||
<?php if ($this->PayboxValues) {?>
|
||||
|
||||
<form method="" action="post">
|
||||
|
||||
<?php foreach ( $this->PayboxValues as $field) {?>
|
||||
<input type="hidden" name="<?=$field['name']?>" value="<?=$field['value']?>" />
|
||||
<?php }?>
|
||||
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
Une fois le paiement effectué merci de cliquer sur le bouton "Retour boutique" afin de
|
||||
consulter vos documents.
|
||||
|
||||
<?php }?>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<?php } else {?>
|
||||
|
||||
<div class="alert alert-danger"><strong>Erreur !</strong> </div>
|
||||
|
||||
<?php }?>
|
||||
|
||||
<!-- Site footer -->
|
||||
<div class="footer">
|
||||
<p>© Scores & Décisions <?=date('Y')?></p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php echo $this->inlineScript(); ?>
|
||||
</body>
|
||||
</html>
|
@ -79,7 +79,7 @@ class Application_Form_Command extends Zend_Form
|
||||
)
|
||||
);
|
||||
$this->addElement('submit', 'submit',array(
|
||||
'label' => 'Commander',
|
||||
'label' => 'Mode de paiement',
|
||||
'ignore' => true,
|
||||
)
|
||||
);
|
||||
|
61
library/Paybox/Config.php
Normal file
61
library/Paybox/Config.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
class Paybox_Config
|
||||
{
|
||||
protected $PBX_SITE;
|
||||
|
||||
protected $PBX_RANG;
|
||||
|
||||
protected $PBX_IDENTIFIANT;
|
||||
|
||||
protected $KEY;
|
||||
|
||||
protected $SERVER;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
if (APPLICATION_ENV == 'production') {
|
||||
$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->PAIEMENT_URL = $serveur['url'];
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
// else : La machine est disponible mais les services ne le sont pas.
|
||||
}
|
||||
if(!$serveurOK){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
17
library/Paybox/Config/Prod.php
Normal file
17
library/Paybox/Config/Prod.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
class Paybox_Config_Prod
|
||||
{
|
||||
public $key = '';
|
||||
|
||||
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",
|
||||
),
|
||||
);
|
||||
|
||||
}
|
19
library/Paybox/Config/Test.php
Normal file
19
library/Paybox/Config/Test.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
class Paybox_Config_Test
|
||||
{
|
||||
public $key = '0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF';
|
||||
|
||||
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',
|
||||
);
|
||||
|
||||
}
|
7
library/Paybox/Response.php
Normal file
7
library/Paybox/Response.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
class Paybox_Response
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
257
library/Paybox/System.php
Normal file
257
library/Paybox/System.php
Normal file
@ -0,0 +1,257 @@
|
||||
<?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 l’acheteur
|
||||
- PBX_RETOUR = Liste des variables à retourner par Paybox
|
||||
- PBX_HASH = Type d’algorithme de hachage pour le calcul de l’empreinte
|
||||
- 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
|
||||
- L’affichage du logo Paybox
|
||||
- Les boutons de validation/annulation/retour boutique
|
||||
- Les langues
|
||||
- Le fond d’écran
|
||||
- Et bien d’autres 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 l’empreinte 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;
|
||||
|
||||
/**
|
||||
* Configuration de la réponse
|
||||
* Chaine <nom de variable>:<lettre> concaténé par ;
|
||||
* @var string
|
||||
*/
|
||||
protected $PBX_RETOUR;
|
||||
|
||||
/**
|
||||
* 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',
|
||||
);
|
||||
|
||||
protected $URL_PAIEMENT;
|
||||
|
||||
protected $URL_PARAMETERS;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUrlParameters()
|
||||
{
|
||||
$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_PAEIMENT) ) {
|
||||
return $this->URL_PAIEMENT;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calcul le HMAC
|
||||
* @return void
|
||||
*/
|
||||
public function calculateHMAC()
|
||||
{
|
||||
$binKey = pack("H*", $this->KEY);
|
||||
$this->PBX_HMAC = strtoupper(hash_hmac('sha512', $this->URL_PARAMETERS, $binKey));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user