Chce wprowadzic do strony platnosci paypal.

Dane przekazywane sa do paypal poprzez nastepujacy formularz:

  1. <FORM ACTION="https://www.sandbox.paypal.com/uk/cgi-bin/webscr" METHOD="POST">
  2. <INPUT TYPE="hidden" name="cmd" value="_xclick">
  3. <input type="hidden" name="amount" value="{TOTAL_PRICE_TO_PAY}">
  4. <input type="hidden" name="business" value="track__1212504437_biz@op.pl">
  5. <input type="hidden" name="item_name" value="teazone order nr. {ORDER_ID}">
  6. <input type="submit" value="go">
  7. </form>


Platnosc odbywa sie bez problemu. Wybralem sposob PDT. IPN niestety nie dziala... moze z tego samego powodu.

Plik ktory "odbiera" platnosc ma nastepujaca tresc:

  1. <?php
  2. // read the post from PayPal system and add 'cmd'
  3. $req = 'cmd=_notify-synch';
  4.  
  5. $tx_token = $_GET['tx'];
  6. $auth_token = "ke8Hlh6ycV***********************************8";
  7. $req .= "&tx=$tx_token&at=$auth_token";
  8.  
  9. // post back to PayPal system to validate
  10. $header .= "POST /cgi-bin/webscr HTTP/1.0r\n";
  11. $header .= "Content-Type: application/x-www-form-urlencodedr\n";
  12. $header .= "Content-Length: " . strlen($req) . "r\nr\n";
  13. $fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
  14. // If possible, securely post back to paypal using HTTPS
  15. // Your PHP server will need to be SSL enabled
  16. // $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
  17.  
  18. if (!$fp) {
  19. // HTTP ERROR
  20. } else {
  21. fputs ($fp, $header . $req);
  22. // read the body data
  23. $res = '';
  24. $headerdone = false;
  25. while (!feof($fp)) {
  26. $line = fgets ($fp, 1024);
  27. if (strcmp($line, "r\n") == 0) {
  28. // read the header
  29. $headerdone = true;
  30. }
  31. else if ($headerdone)
  32. {
  33. // header has been read. now read the contents
  34. $res .= $line;
  35. }
  36. }
  37.  
  38. // parse the data
  39. $lines = explode("\n", $res);
  40. $keyarray = array();
  41. if (strcmp ($lines[0], "SUCCESS") == 0) {
  42. for ($i=1; $i<count($lines);$i++){
  43. list($key,$val) = explode("=", $lines[$i]);
  44. $keyarray[urldecode($key)] = urldecode($val);
  45. }
  46. // check the payment_status is Completed
  47. // check that txn_id has not been previously processed
  48. // check that receiver_email is your Primary PayPal email
  49. // check that payment_amount/payment_currency are correct
  50. // process payment
  51. $firstname = $keyarray['first_name'];
  52. $lastname = $keyarray['last_name'];
  53. $itemname = $keyarray['item_name'];
  54. $amount = $keyarray['payment_gross'];
  55.  
  56. echo ("<p><h3>Thank you for your purchase!</h3></p>");
  57.  
  58. echo ("<b>Payment Details</b><br>\n");
  59. echo ("<li>Name: $firstname $lastname</li>\n");
  60. echo ("<li>Item: $itemname</li>\n");
  61. echo ("<li>Amount: $amount</li>\n");
  62. echo ("");
  63. }
  64. else if (strcmp ($lines[0], "FAIL") == 0) {
  65. // log for manual investigation
  66. }
  67.  
  68. }
  69.  
  70. fclose ($fp);
  71.  foreach($lines as $v)
  72.  {
  73.  echo $v."<br>";
  74.  }
  75. ?>


powyzszy kod sciagniety ze strony paypal. Jedyna modyfikacja jest echo na koncu.

Niestety za kazdym razem zwracana jest FAIL Error 4003. Z tego co sie zorientowalem blad ten oznacza brak takiej transakcji, a dokladniej dane wyslane sa rozne od danych odebranych.

Niestety nie wiem co z tym zrobic... zwyczajnie brakuje i pomyslow. Bede wdzieczny za jakas pomoc. Pozdrawiam.