<?php 
 
$xml = "<?xml version='1.0' encoding='utf-8' ?> 
<order> 
    <userAccountId>4976023</userAccountId> 
    <currency>EUR</currency> 
    <label>order label</label> 
    <ageGroup>ALL</ageGroup> 
    <categoryId>19</categoryId> 
    <urlAcquital><![CDATA[http://www.exemple.com/acquittement.php]]></urlAcquital> 
    <urlOk><![CDATA[http://www.exemple.com/ok.php]]></urlOk> 
    <urlKo><![CDATA[http://www.exemple.com/ko.php]]></urlKo> 
    <urlCancel><![CDATA[http://www.exemple.com/cancel.php]]></urlCancel> 
    <urlInstall><![CDATA[http://www.exemple.com/install.php]]></urlInstall> 
    <urlLogo><![CDATA[http://www.exemple.com/logo.gif]]></urlLogo> 
 
    <!-- optional --> 
    <locale>fr_FR</locale> 
    <issuerAccountLogin>issuerlogin@hipay.com</issuerAccountLogin> 
 
    <data> 
        <nom1>value 1</nom1> 
        <nom2>value 2</nom2> 
        <nom3>value 3</nom3> 
    </data> 
    <items> 
        <item id='1'> 
            <name>first product name</name> 
            <infos>first product description</infos> 
            <amount>5.2</amount> 
            <categoryId>19</categoryId> 
            <quantity>1</quantity> 
            <reference>REF1</reference> 
            <taxes> 
                <tax id='1'> 
                    <label>shipping</label> 
                    <amount>25</amount> 
                </tax> 
                <tax id='2'> 
                    <label>VAT</label> 
                    <amount>19.6%</amount> 
                </tax> 
            </taxes> 
        </item> 
        <item id='2'> 
            <name>second product name</name> 
            <infos>second product description</infos> 
            <amount>2.14</amount> 
            <categoryId>19</categoryId> 
            <quantity>2</quantity> 
            <reference>REF2</reference> 
            <taxes> 
                <tax id='1'> 
                    <label>VAT</label> 
                    <amount>19.6%</amount> 
                </tax> 
                <tax id='2'> 
                    <label>shipping</label> 
                    <amount>5.25</amount> 
                </tax> 
            </taxes> 
        </item> 
    </items> 
    <!-- optional : replace XXX with the user account id --> 
    <!--<affiliates> 
        <affiliate id='XXX'> 
            <amount>15%</amount> 
        </affiliate> 
        <affiliate id='XXX'> 
            <amount>0.5</amount> 
        </affiliate> 
    </affiliates>--> 
</order>"; 
 
/* 
 * Var $data contain the XML string describing your order 
 */ 
 $data = trim($xml); 
 
/** 
 * data crypting using RSA 
 */ 
function encrypt($source, $privateKey) 
{ 
    $maxLength = 117; 
 
    $output = ""; 
    while ($source) 
    { 
        $slice = substr($source, 0, $maxLength); 
        $source = substr($source, $maxLength); 
 
        openssl_private_encrypt($slice, $encrypted, $privateKey); 
        $output .= $encrypted; 
    } 
 
    return $output; 
} 
 
/** 
 * sign data using your private RSA key 
 */ 
function sign($data, $privateKey) 
{ 
    $output = ""; 
    openssl_private_encrypt(sha1($data), $output, $privateKey); 
 
    return $output; 
} 
 
// RSA private key 
$privateKey = '-----BEGIN PRIVATE KEY----- 
MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAKgDsfhJ3vfP+868 
3RnxELQULbBm/QyVcTxgvEXZi5Vp6QGLJNiVQe4T+ELFVWvh7PQ+/bFihesJxhfX 
X/akCZR1ltiKLhFM4q31EAJIxqGRTBp/SMYmsnVtuEVl1Rchheyk8Z5D+GD1XBCf 
PI8KaE0GTCG92mS6VV+7T51C2AW7AgMBAAECgYAX/5cfIOYRPYr5J67pMq6xGiTA 
iqVgc8Qd3K9nxsASUnNuvgJAUWl+aSnP18Hwy+99n7W67Zi1TssVwrS5VQrtB3Lf 
G6X/Ky533coppZx+nc4306q6NIYRk2PGxXQVJ5uPEE8YPSr98pCAxfXWjmL+Wdzs 
XdimfIqiAvH13s+LwQJBANFo3q9heN/EQ6pgTjzlHQ1lr4hywbPtv01q3T6YwuC4 
0ESQBQoxBKjIMp/xWz6Lq/Mxg/VxEayAJ/KL/MMnh2ECQQDNZR7ldjyrpSexih2r 
LSCUSScCQIoWtY7ltuG75pP7NataVUb1DFPqY0LsmUPs2vDZ6a90pULU62GxMP6i 
mc6bAkACy76lYszFWA57ONvyjjCMHD5yuO2DJHp4YyPfERURAQau06ltkGf6hOnA 
Hu3T8PNzxMZ5QXA1+GQQJfRS+rUhAkAAq7HcIfS0wsdMZx0NsAoJMev0r+1DgbhD 
u8Mk7+3Pxi8XDmw65J1piIVxbFaycUyUCZVPFjMPqu0YvQY31bS9AkB6RvhakQhh 
6uUG4dwKgcTfzzhj/2FyRr6aWaX1cWhkzrVewawEWoDA78k43oPN/JpOOF67N6PI 
SBnfQt1uBHZm
-----END PRIVATE KEY-----'; 
 
/** 
 * Data are first encoded using base64 before crypting in order not to 
 * alter your encoding system (windows/dos, mac, unix ...). 
 */ 
$crypted = base64_encode(encrypt(base64_encode($data), $privateKey)); 
$sign = base64_encode(sign(base64_encode($data), $privateKey)); 
 
?> 
 
<form target='_blank' action='https://payment.hipay.com/index/form/' method='post' > 
    <input type='hidden' name='mode' value='MODE_C' /> 
    <input type='hidden' name='website_id' value='105693' /> 
    <input type='hidden' name='sign' value="<?php echo $sign ?>" /> 
    <input type='hidden' name='data' value="<?php echo $crypted ?>" /> 
    <input type='image' name='send' src="https://payment.hipay.com/images/bt_payment3.gif" /> 
</form> 