Paypal- API

PCGamer

Mitglied
Hallo,

ich bin noch ein absoluter Anfänger bei den Thema Paypal API mit Php und hoffe das ihr mir weiterhelfen könnt.

Also das geht:
PHP:
<?php
echo "<div style='display:none'>
                <form name='paypal' action='https://www.paypal.com/cgi-bin/webscr' method='post'>
                  <input type='hidden' name='add' value='1'>
                  <input type='hidden' name='cmd' value='_cart'>
                  <input type='hidden' id='business' name='business' value='xxx'>
                  <input type='hidden' id='item_name' name='item_name' value='$user - Ballonfahrt Goehler'>
                  <input type='hidden' id='amount' name='amount' value='$preis'>
                  <input type='hidden' id='pp_return' name='return' value='$url'>
                  <input type='hidden' id='pp_rm' name='rm' value='2'>
                  <input type='hidden' id='pp_cancelReturn' name='cancel_return' value='$url_cancel'>
                  <input type='hidden' name='no_shipping' value='2'>
                  <input type='hidden' name='no_note' value='1'>
                  <input type='hidden' name='currency_code' value='EUR'>
                  <input type='hidden' name='lc' value='DE'>
                  <input type='hidden' name='bn' value='PP-ShopCartBF'>
                  <input type='submit' value='Jetzt mit PayPal bezahlen' tabindex='1' class='button'>
                </form></div>

                <script type='text/javascript'>
                document.paypal.submit();
                </script>";

Doch in disen Code wird per Javascript das Formular automatisch verschickt.

doch jetzt möchte ich sowas per PHP verschicken.
PHP:
<?php
  $host = "www.paypal.com";
  $path = "/cgi-bin/webscr";
  $data = 'cmd=_card';
  $data .= '&business=XXX';
  $data .= '&item_name=test';
  $data .= '&amount=0.51';
  $data .= '&no_shipping=1';
  $data .= '&no_note=1';
  $data .= '&currency_code=EUR';
  $data .= '&lc=DE';
  $data .= '&bn=PP-ShopCartBF';

	$fp = fsockopen($host, 80, $errno, $errstr, 30);

	if (!$fp) {
		$buffer .= "$errstr ($errno)<br />\n";
	} else {
		$out = "POST ".$path." HTTPS/1.1\r\n";
		$out .= "Host: ".$host."\r\n";
		$out .= "Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n";
		$out .= "Content-Length: ".strlen($data)."\r\n";
		$out .= "Connection: Close\r\n\r\n";
		$out .= $data;
		fwrite($fp, $out);

		while (!feof($fp)) {
			$buffer .= fgets($fp, 128);
		}
		fclose($fp);
	}
	echo "a : $buffer";

leider geht das nicht so ganz:( Ich dachte er leitet mich somit zur Paypal- Seite (Warenkorb), um meine Bezahlung durchzuführen.

Wenn ich den buffer ausgebe kommt nur
Code:
HTTP/1.1 301 Moved Permanently Date: Fri, 11 May 2012 17:06:05 GMT Server: Apache X-Frame-Options: SAMEORIGIN Set-Cookie: cwrClyrK4LoCV1fydGbAxiNL6iG=%7cloeu8x-YdtedgSFjriD7hZhqPTllYYyk8DQWhlBOSTzVVrU-SP1j6dPskK8h7H1mjUhz9W%7ctgvpiPTceYjCqujZ5pRNYN3HLBKkFHrNNNqCV6vpcunTsSROfsOBn1sqdiq9FxfMKS-Fp0%7c; domain=.paypal.com; path=/; HttpOnly Set-Cookie: cookie_check=yes; expires=Mon, 09-May-2022 17:06:05 GMT; domain=.paypal.com; path=/; HttpOnly Location: https://www.paypal.com/cgi-bin/webscr?cmd=_card&business=xxx&item_name=test&amount=0.51&no_shipping=1&no_note=1¤cy_code=EUR&lc=DE&bn=PP-ShopCartBF Vary: Accept-Encoding Connection: close Content-Type: text/html

Kann mir jemand helfen oder gibt es ein deutsches Paypal- API Tutorial?

Danke im vorraus
PCGamer
 
Zuletzt bearbeitet:
Zurück