Jump to content

Paybox Probleme Calcul HMAC


Recommended Posts

Bonjour,

 

Je m'explique, je réalise un site e-commerce pour mon client et il me demande d'utiliser la solution paybox, que je ne maitrise absolument pas.

 

J'ai reçu la documentation gigantesque de Paybox mais malheuresement je n'arrive pas à trouver une issue à mon probleme.

 

Je n'arrive en fait pas à m'interfacer avec la page de paiement que Paybox a créé pour moi.

 

Je vous met, ci-dessous, mon code afin que vous me disiez la ou il pourrai potentiellement y avoir un probleme

 

Merci d'avance

 

 

paybox.tpl :

<p class="payment_module">

<a href="javascript:$('#paybox_form').submit();" title="{l s='Pay by credit card' mod='paybox'}">

<img src="{$module_template_dir}paybox.jpg" alt="{l s='Pay by credit card' mod='paybox'}" />

{l s='Pay by credit card' mod='paybox'}

</a>

</p>

 

<form method="POST" action="https://tpeweb1.paybox.com/cgi/MYchoix_pagepaiement.cgi" id="paybox_form" class="hidden">

<input type="hidden" name="PBX_SITE" value="{$pbx_site}" />

<input type="hidden" name="PBX_MODE" value="1" />

<input type="hidden" name="PBX_RANG" value="{$pbx_rang}" />

<input type="hidden" name="PBX_IDENTIFIANT" value="{$pbx_identifiant}" />

<input type="hidden" name="PBX_TOTAL" value="{$order_total}" />

<input type="hidden" name="PBX_DEVISE" value="978" />

<input type="hidden" name="PBX_CMD" value="01" />

<input type="hidden" name="PBX_PORTEUR" value="{$customer->email}" />

<input type="hidden" name="PBX_RETOUR" value="Mt:M;Ref:R;Auto:A;Erreur:E;sign:K" />

<input type="hidden" name="PBX_HASH" value="SHA512" />

<input type="hidden" name="PBX_TIME" value="{$datetime}" />

<input type="hidden" name="PBX_HMAC" value="{$pbx_hmac}" />

<input type="submit" value="Envoyer" />

</form>

 

paybox.php :

Je vous met juste la fonction hookPayment, car si je comprends bien c'est elle qui envoie les datas via leur cgi

 

public function hookPayment($params)

{

global $smarty;

 

$customer = new Customer(intval($params['cart']->id_customer));

$pbx_site = Configuration::get('PAYBOX_SITE');

$pbx_rang = Configuration::get('PAYBOX_RANG');

$pbx_identifiant = Configuration::get('PAYBOX_IDENTIFIANT');

$pbx_urlhttp = Configuration::get('PAYBOX_URLHTTP');

//P = Cart Payment

//PD = Payment Demand

$payment_type = 'CP';

$order_total = number_format($params['cart']->getOrderTotal(true, 3), 2,'', '');

 

//payment id is composed with cart number and

$id_payment=$params['cart']->id.';'.$payment_type.';'.date('d-m-y-H:i:s');

 

$pbx_currency = "978";

//fix currency code for paybox

 

/*if($currency=="EUR"){$pbx_currency = 978;}

if($currency=="USD"){$pbx_currency = 840;}

if($currency=="CHF"){$pbx_currency = 4217;}

*/

 

$datetime = date("c");

 

//$datetime = "2013-02-08T11:39:16+02:00";

 

/* $msg = "PBX_SITE=".$pbx_site.

"&PBX_MODE=1".

"&PBX_RANG=".$pbx_rang."&PBX_IDENTIFIANT=".$pbx_identifiant.

"&PBX_TOTAL=".$order_total."&PBX_DEVISE=978"."&PBX_CMD=01"."&PBX_PORTEUR=".$customer->email."&PBX_RETOUR=Mt:M;Ref:R;Auto:A;Erreur:E;sign:K".

"&PBX_HASH=SHA512"."&PBX_TIME=".$datetime; */

 

 

$msg = array(

"PBX_SITE=".$pbx_site,

"PBX_MODE=1",

"PBX_RANG=".$pbx_rang,

"PBX_IDENTIFIANT=".$pbx_identifiant,

"PBX_TOTAL=".$order_total,

"PBX_DEVISE=978",

"PBX_CMD=01",

"PBX_PORTEUR=".$customer->email,

"PBX_RETOUR=Mt:M;Ref:R;Auto:A;Erreur:E;sign:K",

"PBX_HASH=SHA512",

"PBX_TIME=".$datetime,

"PBX_HMAC=".$pbx_hash

);

 

$msg = implode('&', $msg);

 

$pbx_hash = "SHA512";

 

 

$keyTest = "0CAF45E1BB4A2C04A4CA64946D16DE876E61E514EB34850C3DE0DC274D1DF869FC6F8E151A5A1416C009D30D0220337BC6AC74E912BDD8C1CFB6788E9A36DB03";

 

$binKey = pack("H*", $keyTest);

$hmac = strtoupper(hash_hmac('SHA512', $msg, $binKey));

$pbx_hmac = $hmac;

$smarty->assign(array(

'pbx_site' => $pbx_site,

'pbx_rang' => $pbx_rang,

'pbx_identifiant' => $pbx_identifiant,

'pbx_currency' => $pbx_currency,

'id_payment' => $id_payment,

'order_total' => $order_total,

'pbx_urlhttp' =>$pbx_urlhttp,

'datetime' => $datetime,

'pbx_hmac' => $pbx_hmac,

'customer' => $customer,

'url_ok' => $pbx_urlhttp ? 'http://'.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'history.php' : 'http://'.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'modules/paybox/validation.php',

'url_cancel' => 'http://'.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'order.php',

'return_format' => 'pbx_amount:M;ref:R;pbx_auth:A;pbx_trans:T;pbx_error:E;pbx_sign:K',

'url_ko' => $pbx_urlhttp ? 'http://'.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'order.php' : 'http://'.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'modules/paybox/validation.php'

));

return $this->display(__FILE__, 'paybox.tpl');

}

 

 

Si vous pouviez m'aider, car la je ne comprends vraiment pas ....

 

D'avance merci

 

TyFlashDeveloper

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...