Let me tell you what i was doing. - I am try to make a page in which there is only one single textfield is there and you have to enter the amount in it and just click over the send button it now it will take you to the paypal page if he pays than it will show the success page other wise it will show the error page. Here is the online example of this code and this code is showing me the error that is " Invalid Token". link for online check simplyitsols [dot] com /demo/ assignment / test [dot] php one more problem i am having that when you open the page it will show the error. Without submitting it means it calls the function as we open the page. code i am using is <form method=post action=<?php echo $_SERVER['PHP_SELF'] ?>> <input type="text" name="amount" id="amount"><input type=submit name=submit value=checkout></form> HTML: if(isset ($_POST["submit"])){ $amount=$_POST["amount"]; $method="DoExpressCheckoutPayment"; print_r(PPHttpPost($method, $nvpStr_,$amount));}function PPHttpPost($methodName_, $nvpStr_,$amount) { $environment = 'live'; // Set up your API credentials, PayPal end point, and API version. $API_UserName = urlencode('#######'); $API_Password = urlencode('#######'); $API_Signature = urlencode('#######'); $API_Endpoint = "https://api-3t.paypal.com/nvp"; $version = urlencode('72.0'); // setting the curl parameters. $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $API_Endpoint); curl_setopt($ch, CURLOPT_VERBOSE, 1); // Set the curl parameters. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); // Set the API operation, version, and API signature in the request. $nvpreq = "METHOD=$methodName_&VERSION=$version&PAYMENTACTION=Authorization&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature$nvpStr_"; // Set the request as a POST FIELD for curl. curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq); // Get response from the server. $httpResponse = curl_exec($ch); if(!$httpResponse) { exit('$methodName_ failed: '.curl_error($ch).'('.curl_errno($ch).')'); } // Extract the response details. $httpResponseAr = explode("&", $httpResponse); $httpParsedResponseAr = array(); foreach ($httpResponseAr as $i => $value) { $tmpAr = explode("=", $value); if(sizeof($tmpAr) > 1) { $httpParsedResponseAr[$tmpAr[0]] = $tmpAr[1]; } } if((0 == sizeof($httpParsedResponseAr)) || !array_key_exists('ACK', $httpParsedResponseAr)) { exit("Invalid HTTP Response for POST request($nvpreq) to $API_Endpoint."); } return $httpParsedResponseAr;} PHP:
Well, for starters you have to define a function BEFORE you try to call it. Your if statement to run PPHttpPost has to come AFTER the function is defined. Though it would be a lot easier to diagnose if the code wasn't a poorly formatted illegible mess. If it's actually formatted in the file as one giant long line most of the code is ignored as a comment. (...though I'm HOPING you just cut and paste from a crappy editor that mangled it).