Note that there are some explanatory texts on larger screens.

plurals
  1. POPaybox integration
    primarykey
    data
    text
    <p>I try to integrate <a href="http://www1.paybox.com/" rel="nofollow">Paybox</a> credit card transaction solution.</p> <p>I've tries at least 100 differents solutions (not kidding) but no one works and every time i got "Problème d'identification du commerce. Accès refusé !" message (in french).</p> <p>Here is the most "stable" code I have :</p> <pre><code>&lt;?php function gen_hmac($site, $rang, $identifiant, $devise, $cmd, $porteur, $hash, $time, $total, $retour, $key) { $msg = "PBX_SITE=". $site ."&amp;PBX_RANG=". $rang ."&amp;PBX_IDENTIFIANT=". $identifiant ."&amp;PBC_TOTAL=". $total ."&amp;PBX_DEVISE=". $devise ."&amp;PBC_CMD=". $cmd ."&amp;PBC_PORTEUR=". $porteur ."&amp;PBC_RETOUR=". $retour ."&amp;PBC_HASH=". $hash ."&amp;PBC_TIME=" . $time ; $binkey = pack("H*", $key); echo "&lt;!-- " . $msg . " --&gt;"; $hmac = strtoupper(hash_hmac('sha512', $msg, $binkey)); echo "&lt;!-- " . $hmac . " --&gt;"; return $hmac; } // static $site = 1999888; $rang = 32; //$identifiant = 110647233; $identifiant = 107904482; $devise = 978; $hash = "SHA512"; $key = "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"; $cmd = "TEST Paybox"; $porteur = "test@paybox.com"; $time = date("c"); //$time = "2011-02-28T11:01:50+01:00"; // variable $total = 1000; //$retour = "ref:R;trans:T;auto:A;tarif:M;abonnement:B;pays:Y;erreur:E"; $retour = "Mt:M;Ref:R;Auto:A;Erreur:E"; $hmac = gen_hmac($site, $rang, $identifiant, $devise, $cmd, $porteur, $hash, $time, $total, $retour, $key); ?&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Paybox TEST&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;?php //print_r(hash_algos()); ?&gt; &lt;form method="POST" action="https://preprod-tpeweb.paybox.com/cgi/MYchoix_pagepaiement.cgi"&gt; &lt;!--&lt;form method="POST" action="https://preprod-tpeweb.paybox.com/cgi/MYframepagepaiement_ip.cgi"&gt;--&gt; &lt;!--&lt;form method="POST" action="https://preprod-tpeweb.paybox.com/cgi/ChoixPaiementMobile.cgi"&gt;--&gt; &lt;input type="hidden" name="PBX_SITE" value="&lt;?php echo $site; ?&gt;" /&gt; &lt;input type="hidden" name="PBX_RANG" value="&lt;?php echo $rang; ?&gt;" /&gt; &lt;input type="hidden" name="PBX_IDENTIFIANT" value="&lt;?php echo $identifiant; ?&gt;" /&gt; &lt;input type="hidden" name="PBX_TOTAL" value="&lt;?php echo $total; ?&gt;" /&gt; &lt;input type="hidden" name="PBX_DEVISE" value="&lt;?php echo $devise; ?&gt;" /&gt; &lt;input type="hidden" name="PBX_CMD" value="&lt;?php echo $cmd; ?&gt;" /&gt; &lt;input type="hidden" name="PBX_PORTEUR" value="&lt;?php echo $porteur; ?&gt;" /&gt; &lt;input type="hidden" name="PBX_RETOUR" value="&lt;?php echo $retour; ?&gt;" /&gt; &lt;input type="hidden" name="PBX_HASH" value="&lt;?php echo $hash; ?&gt;" /&gt; &lt;input type="hidden" name="PBX_TIME" value="&lt;?php echo $time; ?&gt;" /&gt; &lt;input type="hidden" name="PBX_HMAC" value="&lt;?php echo $hmac; ?&gt;" /&gt; &lt;!--&lt;input type="hidden" name="PBX_REFUSE" value="http://test.fr/" /&gt; &lt;input type="hidden" name="PBX_ANNULE" value="http://test.fr/" /&gt; &lt;input type="hidden" name="PBX_EFFECTUE" value="http://test.fr/" /&gt;--&gt; &lt;input type="submit" value="envoyer" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Most statics values are from paybox test documentation.</p> <p>So do you know what's wrong with my code or do you know how to have more details about what is wrong on what is send to paybox server ?</p> <p>Sincerely</p> <p><strong>EDIT :</strong> More details about my goal. My real need is to code this in java, but I had a few code sample in php which finally helped.</p> <p>Now I try to find out how to generate a clean hmac/sha512 in java.</p> <pre><code>&lt;?php $key = "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"; $binkey = pack("H*", $key); echo strtoupper(hash_hmac('sha512', "ABC", $binkey)); ?&gt; </code></pre> <p>Outputs : 100A6A016A4B21AE120851D51C93B293D95B7D8A44B16ACBEFC2D1C9DF02B6F54FA3C2D6802E52FED5DF8652DDD244788A204682D2D1CE861FDA4E67F2792643</p> <p>So how can I, in java, recreate the same hmac algorigthm ?</p> <p>I've try a lot of things but no one achived my goal, but here is what I have currently :</p> <pre><code>private String generateHMAC( String datas ) { // final Charset asciiCs = Charset.forName( "utf-8" ); Mac mac; String result = ""; try { byte[] bytesKey = PayboxConstants.KEY.getBytes( ); final SecretKeySpec secretKey = new SecretKeySpec( bytesKey, "HmacSHA512" ); mac = Mac.getInstance( "HmacSHA512" ); mac.init( secretKey ); final byte[] macData = mac.doFinal( datas.getBytes( ) ); byte[] hex = new Hex( ).encode( macData ); result = new String( hex, "ISO-8859-1" ); } catch ( final NoSuchAlgorithmException e ) { AppLogService.error( e ); } catch ( final InvalidKeyException e ) { AppLogService.error( e ); } catch ( UnsupportedEncodingException e ) { AppLogService.error( e ); } return result.toUpperCase( ); } </code></pre> <p>But its ouput is : AA6492987D7A7AC81109E877315414806F1973CC47B897ECE713171A25A11B279329B1BFF39EA72A5EFB7EDCD71D1F34D5AAC49999A780BD13F019ED99685B80</p> <p>Which is definitly not equivalent to "cloned" php hmac algorithm.</p> <p>So what can I add to my java code to make it compliant with its php equalivalent ?</p> <p><strong>EDIT :</strong> Actually I managed to makes everything works together, and I available here : <a href="http://dev.lutece.paris.fr/plugins/plugin-paybox/index.html" rel="nofollow">http://dev.lutece.paris.fr/plugins/plugin-paybox/index.html</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload