Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP]Płatności payu
Forum PHP.pl > Forum > Przedszkole
trifek
Witam serdecznie,
Próbuję podłączyć płatności payu - ale chyba robię coś nie tak sad.gif
Mam taki kod:
  1. $id_payu = 123456; // klucz payu
  2. $zlacz = $zlacz."13a980d4f851f3d9a1cfc792fb1f5e50"; //drugi klucz
  3. $podpis = hash("md5", $zlacz);
  4. $OpenPayU_Signature = "sender=".$id_payu.";algorithm=MD5;signature=".$podpis;
  5.  
  6.  
  7. <form method="POST" action="https://secure.payu.com/api/v2_1/orders" id="payu-payment-form" class="" name="nazwa_formularza">
  8. <input type="hidden" name="notifyUrl" value="<?php echo $gt_myurl;?>order/OrderNotify.php" />
  9. <input type="hidden" name="continueUrl" value="<?php echo $gt_myurl;?>/cms/admin/start.html?strona=edytuj_moje_dane&rekord=<?php echo $_GET['rekord'];?>&stan=ok" />
  10. <input type="hidden" name="customerIp" value="<?php echo IP_prawdziwe();?>" />
  11. <input type="hidden" name="merchantPosId" value="<?php echo $id_payu;?>" />
  12. <input type="hidden" name="description" value="Przedłużenie abonamentu firmy <?php echo baza_odczyt($row['nazwa']);?>" />
  13. <input type="hidden" name="currencyCode" value="PLN" />
  14. <input type="hidden" name="totalAmount" value="<?php echo $kwota_przedluzenia;?>" />
  15. <input type="hidden" name="extOrderId" value="<?php echo baza_odczyt($row['gt_id']);?>.<?php echo rand(1000000,10000000000); ?>" />
  16. <input type="hidden" name="products[0].name" value="Przedłużenie abonamentu firmy <?php echo baza_odczyt($row['nazwa']);?>" />
  17. <input type="hidden" name="products[0].unitPrice" value="<?php echo $kwota_przedluzenia;?>" />
  18. <input type="hidden" name="products[0].quantity" value="1" />
  19. <input type="hidden" name="buyer.email" value="<?php echo baza_odczyt($row['email']);?>" />
  20. <input type="hidden" name="buyer.phone" value="<?php echo baza_odczyt($row['tel']);?>" />
  21. <input type="hidden" name="buyer.firstName" value="<?php echo baza_odczyt($row['nazwa']);?>" />
  22. <input type="hidden" name="OpenPayu-Signature" value="<?php echo $OpenPayU_Signature;?>" /><button type="submit" id="fwefwefw" class="fwefwefw"></button>
  23. </form>


W wyniku tego kodu otrzymuję przykładowo taki formularz:
  1.  
  2. <form method="POST" action="https://secure.payu.com/api/v2_1/orders" id="payu-payment-form" class="" name="nazwa_formularza">
  3. <input type="hidden" name="notifyUrl" value="http://127.0.0.1/lunchtime/order/OrderNotify.php" />
  4. <input type="hidden" name="continueUrl" value="http://127.0.0.1/?stan=ok" />
  5. <input type="hidden" name="customerIp" value="127.0.0.1" />
  6. <input type="hidden" name="merchantPosId" value="123456" />
  7. <input type="hidden" name="description" value="xxxxxxxxxxx" />
  8. <input type="hidden" name="currencyCode" value="PLN" />
  9. <input type="hidden" name="totalAmount" value="10000" />
  10. <input type="hidden" name="extOrderId" value="1.8034607548" />
  11. <input type="hidden" name="products[0].name" value="xxxxxxxxxxx" />
  12. <input type="hidden" name="products[0].unitPrice" value="10000" />
  13. <input type="hidden" name="products[0].quantity" value="1" />
  14. <input type="hidden" name="buyer.email" value="email@wp.pl" />
  15. <input type="hidden" name="buyer.phone" value="telefon" />
  16. <input type="hidden" name="buyer.firstName" value="imii" />
  17. <input type="hidden" name="OpenPayu-Signature" value="sender=123456;algorithm=MD5;signature=09be80f7f539182c97f2883e8c89fb28" /><button type="submit" id="fwefwefw" class="fwefwefw"></button>
  18. </form>
  19.  


Czy to jest poprawne?
Payu zgłasza mi błąd: Dostęp zabroniony.

Nie wiem czy to kwestia danych testowych - czy coś mam nie tak z tymi podpisami :/
mlawnik
Pisz, po to mają support.
trueblue
123456 to Twój POS id?
trifek
nie, wkleiłem tutaj specjalnie takie (przykładowe) smile.gif
trueblue
Hash jest poprawnie obliczany?
No, i raczej powiadomienia nie przyjdą na Twój localhost.
trifek
localhost - to wiem.... Tego hasha nie jestem pewien :/
Pyton_000
Cytat
Parametr algorithm może przyjmować poniższe wartości:

SHA-256,
SHA-384,
SHA-512,
trifek
Nie pomogło sad.gif
Znalazłem taki link: http://developers.payu.com/pl/classic_api....ning_parameters

Zmodyfikowałem formularz na takie coś:
  1. $pos_id = 123456;
  2. $session_idd = rand(1000000,10000000000));
  3. $pos_auth_key = 'oU2mdz6';
  4. $amount = 10000;
  5. $desc = "Przedłużenie xyz";
  6. $first_name = "imie";
  7. $last_name = 'nazwisko';
  8. $email_m = "email@mail.pl";
  9. $client_ip = IP_prawdziwe();
  10. $ts = strtotime(date("Y-m-d H:i:s"));
  11. $key1 = 'a6705d62fd76d65346329864512a25ca';
  12. $key2 = 'dd732fkune300f53b5bdafc934c1daa1d';
  13.  
  14.  
  15. $client_ipX = urlencode($client_ip);
  16. $amountX = urlencode($amount);
  17. $descX = urlencode($desc);
  18. $email_mX = urlencode($email_m);
  19. $first_nameX = urlencode($first_name);
  20. $last_nameX = urlencode($last_name);
  21. $pos_auth_keyX = urlencode($pos_auth_key);
  22.  
  23. $sig = ("amount=".$amountX."&client_ip=".$client_ipX."&desc=".$descX."&email=".$email_mX."&first_name=".$first_nameX."&js=1&last_name=".$last_nameX."&pos_auth_key=".$pos_auth_keyX."&pos_id=$pos_id&session_id=$session_idd.&ts=$ts&$key2");
  24. $sig = hash('sha256', $sig);


Mam taki formularz:
  1. <form action="https://secure.payu.com/paygw/UTF/NewPayment" method="POST" name="nazwa_formularza">
  2. <input type="hidden" name="first_name" value="<?php echo $first_name;?>">
  3. <input type="hidden" name="last_name" value="<?php echo $last_name;?>">
  4. <input type="hidden" name="email" value="<?php echo $email_m;?>">
  5. <input type="hidden" name="merchantPosId" value="<?php echo $pos_id;?>">
  6. <input type="hidden" name="pos_id" value="<?php echo $pos_id;?>">
  7. <input type="hidden" name="pos_auth_key" value="<?php echo $pos_auth_key;?>">
  8. <input type="hidden" name="session_id" value="<?php echo $session_idd; ?>">
  9. <input type="hidden" name="amount" value="<?php echo $amount;?>">
  10. <input type="hidden" name="desc" value="<?php echo $desc;?>">
  11. <input type="hidden" name="notifyUrl" value="<?php echo $gt_myurl;?>order/payu.php" />
  12. <input type="hidden" name="continueUrl" value="<?php echo $gt_myurl;?>/cms/admin/start.html?strona=edytuj_moje_dane&rekord=<?php echo $_GET['rekord'];?>&stan=ok" />
  13. <input type="hidden" name="customerIp" value="<?php echo $client_ip;?>" />
  14. <input type="hidden" name="js" value="1">
  15. <input type="hidden" name="ts" value="<?php echo $ts;?>">
  16. <input type="submit" value="" id="fwefwefw" class="fwefwefw">
  17. <input type="hidden" name="sig" value="<?php echo $sig; ?>">
  18. </form>

Co w efekcie daje formularz:
  1. <form action="https://secure.payu.com/paygw/UTF/NewPayment" method="POST" name="nazwa_formularza">
  2. <input type="hidden" name="first_name" value="firma podstawowa123362">
  3. <input type="hidden" name="last_name" value="x">
  4. <input type="hidden" name="email" value="email@wp.pl">
  5. <input type="hidden" name="merchantPosId" value="123456">
  6. <input type="hidden" name="pos_id" value="123456">
  7. <input type="hidden" name="pos_auth_key" value="oU2mdz6">
  8. <input type="hidden" name="session_id" value="12461086139">
  9. <input type="hidden" name="amount" value="10000">
  10. <input type="hidden" name="desc" value="Przedłużenie xyz">
  11. <input type="hidden" name="notifyUrl" value="http://127.0.0.1/pliki/order/payu.php" />
  12. <input type="hidden" name="continueUrl" value="http://127.0.0.1/plik/index.html?stan=ok" />
  13. <input type="hidden" name="customerIp" value="127.0.0.1" />
  14. <input type="hidden" name="js" value="1">
  15. <input type="hidden" name="ts" value="1470049656">
  16. <input type="submit" value="" id="fwefwefw" class="fwefwefw">
  17. <input type="hidden" name="sig" value="2d1aa1ab0ab646b7117e21d0565bf69fb1fda48834ba24a625a3cfa8aab9e568">
  18. </form>

Payu zwraca mi błąd:
Przepraszamy, nie udało się utworzyć transakcji (kod błędu: 103)

Prosimy o kontakt ze sklepem i podanie numeru błędu.
Dokonanie płatności będzie możliwe w inny sposób.


CO robię nie tak?
trueblue
Sprawdź czy na ich danych otrzymujesz taki sam hash jak w przykładzie.
motyl-pl
"103 brak lub błędna wartość parametru sig" kod 103

http://developers.payu.com/pl/classic_api.html
trifek
tylko co źle generuje?sad.gif Masz może jakiś pomysł?
trueblue
Podaj przykładowe dane (ts również) i pokaż jaki hash wyliczyłeś.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.