Moderators Dragos Posted March 30, 2014 Moderators Report Share Posted March 30, 2014 Pentru cei care vor sa implementeze plata prin PayU, trebuie sa returnati in anumite cazuri un string format din mai multi parametri precedati de lungimea valorilor lor pe care se aplica un hmac_md5 cu cheia de la cont.Am creat functia de mai jos care face asta, alaturi de un exemplu pentru comunicarea cu IPN.<?phpfunction genereaza_hash($array,$key){ $string = ""; foreach($array as $vector) { $string .= strlen($vector) . $vector; } $string = hash_hmac("md5",$string,$key); return $string;}$data = date("YmdHis",time());$pentruhash = array($_POST['IPN_PID'][0],$_POST['IPN_PNAME'][0],$_POST['IPN_DATE'],$data);$cheie = "abdefghijklmnopqrstuvwxyz";$hash = genereaza_hash($pentruhash,$cheie);echo "<EPAYMENT>$data|$hash</EPAYMENT>";?> Quote Link to comment Share on other sites More sharing options...
eusimplu Posted March 30, 2014 Report Share Posted March 30, 2014 Din cate stiu are deja payu un fisier cu o functie de genul. Este in contul de client, undeva pe la resurse sau ceva de genul, alaturi de alte cateva jucarii gen documentatia.Dar felicitari Quote Link to comment Share on other sites More sharing options...
Moderators Dragos Posted March 30, 2014 Author Moderators Report Share Posted March 30, 2014 Aia din LiveUpdate nu este utila decat in anumite cazuri. Mi-am frecat nervii cu aia pana am scris-o pe asta. Quote Link to comment Share on other sites More sharing options...
Gushterul Posted April 17, 2014 Report Share Posted April 17, 2014 (edited) Da functia de la PayU din sursele lor este o struto-camila Problema in codul de mai sus(care oricum este bine venit), este ca PayU mai are uneori si array-uri. Eu am ceva de genul celui de mai jos (ma rog, cu trashul de rigoare care nu are nici un sens:)))<?phpforeach($_POST as $varpost => $value) { if(is_array($value)) { foreach($value as $vararray => $subvalue) { $string_test=$string_test.strlen($subvalue).$subvalue;#echo $vararray; if($varpost=="IPN_PNAME") {$info_product=$subvalue;if($post_ipn_pname=="") $post_ipn_pname=$subvalue;} if($varpost=="IPN_INFO") $info_product=$info_product." ".$subvalue; if($varpost=="IPN_DATE") if($post_ipn_date=="")$post_ipn_date=$subvalue; if($varpost=="IPN_PID") if($post_ipn_pid=="") $post_ipn_pid=$subvalue; } } else { if($varpost!="HASH")$string_test=$string_test.strlen($value).$value;#echo $varpost; if($varpost=="IPN_DATE") {$post_ipn_date=$value;$post_date=$value;} if($varpost=="HASH") $post_hash=$value; } }$hash=mhash(MHASH_MD5,$string_test,"HASHUL TAU");$string_hash=bin2hex($hash);?> Edited April 17, 2014 by Gushterul added php tag Quote Link to comment Share on other sites More sharing options...