title: PHP Adaptive payment with Paypal : Your payment can't be completed. Please return to the participating website and try again
body: <p>I am implementing code for php with adaptive payment after the transaction complete at last page i get the error that Your payment can't be completed. Please return to the participating website and try again. what is the wrong with this code. Here is my code.</p>
  
  <pre><code>enter code here
   &lt;?php
  
   //turn php errors on
  //ini_set("track_errors", true);
  
  //set PayPal Endpoint to sandbox
  
  
  $url = trim("https://svcs.sandbox.paypal.com/AdaptivePayments/Pay");
  
  
  
  
   $API_UserName = "s.patel_api1.sactp.ca"; //TODO
   $API_Password = "PA9YLDURHKTU52LH"; //TODO
   $API_Signature = "An5ns1Kso7MWUdW4ErQKJJJ4qi4-AOPwV4AdrC6q3hsN81pmNWMXn7f-"; //TODO
   $receiver_email = "rushi.mtech@gmail.com"; //TODO
  
   $amount = 25; //TODO
  
           //Default App ID for Sandbox    
       $API_AppID = "APP-80W284485P519543T";
  
   $API_RequestFormat = "NV";
   $API_ResponseFormat = "NV";
  
  
  
  
                $bodyparams = array (   "requestEnvelope.errorLanguage" =&gt; "en_US",
                "actionType" =&gt; "PAY",
                "cancelUrl" =&gt; "http://localhost/success.php",
                "returnUrl" =&gt; "http://localhost/cancel.php",
                "currencyCode" =&gt; "CAD",
                "receiverList.receiver.email" =&gt; $receiver_email,
                "receiverList.receiver.amount" =&gt; $amount
  );
  
    // convert payload array into url encoded query string
     $body_data = http_build_query($bodyparams, "", chr(38));
  
  
  try
  {
  
  
        $params = array("http" =&gt; array(
      "method" =&gt; "POST",                                                 
      "content" =&gt; $body_data,                                             
      "header" =&gt;  "X-PAYPAL-SECURITY-USERID: " . $API_UserName . "\r\n" .
               "X-PAYPAL-SECURITY-SIGNATURE: " . $API_Signature . "\r\n" .
               "X-PAYPAL-SECURITY-PASSWORD: " . $API_Password . "\r\n" .
               "X-PAYPAL-APPLICATION-ID: " . $API_AppID . "\r\n" .
               "X-PAYPAL-REQUEST-DATA-FORMAT: " . $API_RequestFormat . "\r\n" .
               "X-PAYPAL-RESPONSE-DATA-FORMAT: " . $API_ResponseFormat . "\r\n"
      ));
  
  
          //create stream context
          $ctx = stream_context_create($params);
  
  
        //open the stream and send request
          $fp = @fopen($url, "r", false, $ctx);
  
      //get response
       $response = stream_get_contents($fp);
  
         //check to see if stream is open
           if ($response === false) {
        throw new Exception("php error message = " . "$php_errormsg");
        }
  
              //close the stream
        fclose($fp);
  
   //parse the ap key from the response
  
       $keyArray = explode("&amp;", $response);
  
        foreach ($keyArray as $rVal){
       list($qKey, $qVal) = explode ("=", $rVal);
         $kArray[$qKey] = $qVal;
       }
       $rushi;
    //print the response to screen for testing purposes
     If ( $kArray["responseEnvelope.ack"] == "Success") {
  
       foreach ($kArray as $key =&gt;$value){
   // echo $key . ": " .$value . "&lt;br/&gt;";
      if($key == "payKey")
       {
      $rushi = $value;
      echo $rushi;
      }  
      }
      }
       else {
            echo 'ERROR Code: ' .  $kArray["error(0).errorId"] . " &lt;br/&gt;";
           echo 'ERROR Message: ' .  urldecode($kArray["error(0).message"]) . " &lt;br/&gt;";
             }   
  
        } 
  
  
       catch(Exception $e) {
        echo "Message: ||" .$e-&gt;getMessage()."||";
         }
  
  
  ?&gt;
  </code></pre>
  
  <p>Plus i embaded html from<a href="https://developer.paypal.com/docs/classic/adaptive-payments/ht_ap-embeddedPayment-curl-etc/" rel="nofollow">here</a> please guide me</p>