1

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.

Simon H
  • 2,495
  • 4
  • 30
  • 38
S.Giacinto
  • 337
  • 2
  • 13
  • When `echo`ing $hash - does it output what you would expect? – Ryan Dec 10 '13 at 14:45
  • It reuturns an MD5 hash, yes. – S.Giacinto Dec 10 '13 at 15:30
  • This is very old, I know, but you didn't come back to tell us how you solved it. One note to add: the hash can be an MD5 or an SHA2 hash. Which one the ONEPAY gateway expects will depend on a portal configuration option. Maybe check that option is set to MD5. – Jason Jul 26 '16 at 10:38
  • Two things I would advise here. (1) Put the source data into an array, then `ksort()` the array to make sure the values are in the correct order. (2) use `http_build_query()` to build the query string, to ensure any special characters (for a URL) are encoded correctly. The data being in an array will make this building easier. – Jason Jul 26 '16 at 10:48

2 Answers2

1

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

hilbert
  • 266
  • 4
  • 15
  • PHP's `md5()` function already returns the hash in lower case. It still pays to be certain, but this is likely not the problem. – Jason Jul 26 '16 at 10:45
0

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 ;)

Shao Khan
  • 441
  • 6
  • 31