PayOne interface not accepting my HASH value

2.7k Views Asked by At

I have been trying to get the PayOne FrontEnd interface to accept the hash value from my request, to absolutely no avail. I have a support ticket open but need a solution relatively quick, so here I am.

The error returned is "Hashwert Nicht Korrekt" (Hash value incorrect).

Here is my code:

$request="authorization"; 
$portalid = 2017373; 
$aid = 24413; 
$key = "secretkeychangedforsecuritoyreasons"; // Key (configurable in the payment portal) 

$id[1]=  "PART_100"; 
$pr[1]=  2000;
$no[1] = 1; 
$de[1] = "Registration Fee";
$va[1] = 19; 
$amount = round($pr[1]*$no[1]);
$clearingtype = "cc";
$mode = "test";
$currency="EUR"; 
$reference="24393"; 
$customerid="24393"; 

    $hash = md5(
             $aid . 
             $amount . 
             $currency . 
             $customerid .
             $clearingtype . 
             $de[1] . 
             $id[1] . 
             $mode .
             $no[1] . 
             $portalid . 
             $pr[1] . 
             $reference . 
             $request . 
             $va[1] . 
             $key
     ); 

$url="https://secure.pay1.de/frontend/?request=" . $request . 
"&aid=" . $aid . 
"&mode=" . $mode .
"&clearingtype=" . $clearingtype .
"&portalid=" . $portalid . 
"&customerid=" . $customerid . 
"&currency=" . $currency . 
"&amount=" . $amount . 
"&reference=" . $reference . 
"&id[1]=" . $id[1] . 
"&pr[1]=" . $pr[1] . 
"&no[1]=" . $no[1] . 
"&de[1]=" . $de[1] . 
"&va[1]=" . $va[1] . 
"&hash=" . $hash; 

header("Location: $url");

I have checked and re checked the docs and can find no errors in the way I am puttign it together. If I change single values like portalid, etc. it throws the appropriate error.

Any help would be appreciated.

2

There are 2 best solutions below

1
On

We use the following:

$req['aid']          = 09876; // Sub-AccountID
$req['portalid']     = 6789012; // portal-ID
$req['mode']         = "live"; // Live || test
$req['request']      = "authorization"; // Request
$req['id[1]']        = $YourProductID; // e.g. articleno
$req['pr[1]']        = $singleprice;
$req['no[1]']        = $count; // count or pieces
$req['de[1]']        = $articledescription;
$req['amount']       = $summary; // price summary
$req['currency']     = "EUR";
$req['reference']    = $unique_ref.$YourProductId; //my unique is time()
$req['customerid']   = $userId;
$req['clearingtype'] = $clearing; // cc || wlt
$req['encoding']     = "UTF-8";
$req['targetwindow'] = "top";

ksort($req); //so i know its important to sort

//building the hash
foreach ($req as $key => $val) {
    $req['hash'] = $req['hash'] . $val;
}

// all in md5() ... note your own payment ID
$req['hash'] = md5($req['hash'] . $YourPayOneID);

Hope it helps ;)

1
On

I found the following section in the client-api-documentation:

Attention: PAYONE Platform expects the calculated hash value converted to lower case; e.g. 87dbc7c369b85b7a699adff1a2b27bab

Maybe you have some capital letter in your hash? I do an ".toLowerCase()" (in Java) on the encrypted hash.

One other option: you forgot some parameters. on the first look i can't see the following: mid