hey ich hätte da mal eine Frage, also es geht grundsätzlich um den Umgang mit einem ipn-script. Ganz am Anfang geht es ja darum, ein Produkt auszuwählen und dann den "buy-now-Button" zu drücken, der dann schlussendlich auf das ipn-Script umleitet. Das Schema für das script wäre dann:
Aber was wenn der user nun bevor er den "buy-now-Button" betätigt, noch eine andere Option auswählen muss( z.B. select-option mit den Farben rot,blau und grün )? Angenommen, der user vergisst diese Option auszuwählen und drückt auf den "buy-now-Button". Sollte ich es dann so machen? :
sollte ich es dann so machen?
PHP:
<?php
// Check to see there are posted variables coming into the script
if ($_SERVER['REQUEST_METHOD'] != "POST") die ("No Post Variables");
// Initialize the $req variable and add CMD key value pair
$req = 'cmd=_notify-validate';
// Read the post from PayPal
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// Now Post all of that back to PayPal's server using curl, and validate everything with PayPal
// Use CURL instead of PHP for this for a more universally operable script (not fsockopen)
//$url = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_notify-validate;
$url = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_notify-validate";
$curl_result=$curl_err='';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/x-www-form-urlencoded", "Content-Length: " . strlen($req)));
curl_setopt($ch, CURLOPT_HEADER , 0);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$curl_result = @curl_exec($ch);
$curl_err = curl_error($ch);
curl_close($ch);
$req = str_replace("&", "\n", $req); // Make it a nice list => Possibility to email it to yourselve for reporting
// Check that the result verifies
if (strpos($curl_result, "VERIFIED") !== false) {
$req .= "\n\nPaypal Verified OK";
} else {
$req .= "\n\nData NOT verified from Paypal!";
exit();
}
/* CHECK THESE 4 THINGS BEFORE PROCESSING THE TRANSACTION, HANDLE THEM AS YOU WISH
1. Make sure that business email returned is your business email
2. Make sure that the transaction’s payment status is “completed”
3. Make sure there are no duplicate txn_id
4. Make sure the payment amount matches what you charge for items. (Defeat Price-Jacking) */
// END ALL SECURITY CHECKS NOW IN THE DATABASE IT GOES ------------------------------------
////////////////////////////////////////////////////
// Assigning local variables from the POST variables
// Place the transaction into the database
// Mail yourself the details
?>
PHP:
if(isset($_POST['Farbe'])) { // das ganze ipn-script von oben }