error_email = "webmaster@example.com"; // We send an identical response back to PayPal for verification $paypal_ipn->send_response(); // PayPal will tell us whether or not this order is valid. // This will prevent people from simply running your order script // manually if( !$paypal_ipn->is_verified() ) { // bad order, someone must have tried to run this script manually $paypal_ipn->error_out("Bad order (PayPal says it's invalid)"); } // payment status switch( $paypal_ipn->get_payment_status() ) { case 'Completed': // order is good break; case 'Pending': // money isn't in yet, just quit. // paypal will contact this script again when it's ready $paypal_ipn->error_out("Pending Payment"); break; case 'Failed': // whoops, not enough money $paypal_ipn->error_out("Failed Payment"); break; case 'Denied': // denied payment by us // not sure what causes this one $paypal_ipn->error_out("Denied Payment"); break; default: // order is no good $paypal_ipn->error_out("Unknown Payment Status" . $paypal_ipn->get_payment_status()); break; } // end switch // If we made it down here, the order is verified and payment is complete. // You could log the order to a MySQL database or do anything else at this point. // Email the information to us $date = date("D M j G:i:s T Y", time()); $message .= "\n\nThe following info was received from PayPal - $date:\n\n"; @reset($paypal_info); while( @list($key,$value) = @each($paypal_info) ) { $message .= $key . ':' . " \t$value\n"; } mail("root@example.com", "[$date] PayPal Payment Notification", $message); ?>