Search

Are you looking for test card numbers?

Would you like to contact support?

Classic-integration icon

Level 2/3 data for Hosted Payment Pages

Adyen is phasing out Hosted Payment Pages
This page is for the classic Hosted Payment Pages (HPP) integration, which we are no longer developing.
We strongly recommend switching to one of the newer Level 2/3 data integrations.

Level 2 or Level 3 (L2/L3) data provides commercial shoppers with additional information about purchases on their card statements. It allows companies to track how much is spent on their corporate cards where a single card may have multiple users.
Companies can also track the amount of sales tax to pay or reconcile transactions using a unique customer code. Transactions submitted with L2/L3 data that meet requirements have lower interchange rates.

Code example

Below is a code example for submitting L2/L3 data in an authorisation using the Adyen Hosted Payment Pages (HPP):

<?php    /*
     This PHP code provides a payment form for the Adyen Hosted Payment Pages
     */

    /*
     account details
     $skinCode:        the skin to be used
     $merchantAccount: the merchant account we want to process this payment with.
     $sharedSecret:    the shared HMAC key.
     */

    $skinCode        = "[skin code e.g. GBIMwmE4]";
    $merchantAccount = "[merchant Account e.g. TestCompanyCOM]";
    $hmacKey         = "[HMAC key e.g. D21EB2ASD44BA234C8A0AF13CF0BCACA3D4727C6162630D712C857124B213270]";

    /*
     payment-specific details
     */

    $params = array(
                    "merchantReference" => "SKINTEST-1435226439255",
                    "merchantAccount"   =>  $merchantAccount,
                    "currencyCode"      => "USD",
                    "paymentAmount"     => "1190",
                    "sessionValidity"   => "2020-07-11T07:07:13-08:00",
                    "shopperLocale"     => "en_GB",
                    "skinCode"          => $skinCode,
                    "brandCode"         => "",
                    "shopperEmail"      => "test@adyen.com",
                    "shopperReference"  => "YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j",

                    // L2/l3 Data lines
                    "enhancedSchemeData.destinationPostalCode" => "94025-1452",
                    "enhancedSchemeData.shipFromPostalCode" => "94025-1452",
                    "enhancedSchemeData.destinationStateProvinceCode" => "CA",
                    "enhancedSchemeData.destinationCountryCode" => "US",
                    "enhancedSchemeData.freightAmount" => "0",
                    "enhancedSchemeData.dutyAmount" => "0",
                    "enhancedSchemeData.orderDate" => "290518",
                    "enhancedSchemeData.customerReference" => "100001",
                    "enhancedSchemeData.totalTaxAmount" => "190",
                    "enhancedSchemeData.itemDetailLine1.commodityCode" => "82101603",
                    "enhancedSchemeData.itemDetailLine1.description" => "Ads",
                    "enhancedSchemeData.itemDetailLine1.productCode" => "Ads",
                    "enhancedSchemeData.itemDetailLine1.quantity" => "1",
                    "enhancedSchemeData.itemDetailLine1.unitOfMeasure" => "EAC",
                    "enhancedSchemeData.itemDetailLine1.unitPrice" => "1000",
                    "enhancedSchemeData.itemDetailLine1.totalAmount" => "1190",

    );

    /*
     process fields
     */

    // The character escape function
    $escapeval = function($val) {
        return str_replace(':','\\:',str_replace('\\','\\\\',$val));
    };

    // Sort the array by key using SORT_STRING order
    ksort($params, SORT_STRING);

    // Generate the signing data string
    $signData = implode(":",array_map($escapeval,array_merge(array_keys($params), array_values($params))));

    // base64-encode the binary result of the HMAC computation
    $merchantSig = base64_encode(hash_hmac('sha256',$signData,pack("H*" , $hmacKey),true));
    $params["merchantSig"] = $merchantSig;

    ?>

<!-- Complete submission form -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Adyen Payment</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</head>
<body>
<form name="adyenForm" action="https://test.adyen.com/hpp/select.shtml" method="post">
<?php
    foreach ($params as $key => $value){
        echo '        <input type="hidden" name="' .htmlspecialchars($key,   ENT_COMPAT | ENT_HTML401 ,'UTF-8').
        '" value="' .htmlspecialchars($value, ENT_COMPAT | ENT_HTML401 ,'UTF-8') . '" />' ."\n" ;
    }
    ?>
<input type="submit" value="Submit" />
</form>
</body>
</html>