title: Integrating custom php website with paypal?
body: <p>I managed to integrate a custom website, with paypal...when creating an account on this website you need to pay a fee, trough paypall... So i redirect a user after registering, to paypall , where after he pays, he is redirected to a success page on my website, with a token key in the url as a parameter(i entered that success page from the merchant account). The only question is, how could i get the email of the customer who just registered and payed, from the paypal response, using this token key.</p>
  
  <p>If I create a custom form like the following:</p>
  
  <pre><code>     &lt;form id="paypalForm" method="POST" action="https://www.paypal.com/cgi-bin/webscr"&gt;
          &lt;input type="hidden" name="cmd" value="_notify-synch"&gt;
          &lt;input type="hidden" name="tx" value="&lt;?php echo $tokenKey; ?&gt;"&gt;
          &lt;input type="hidden" name="at" value="&lt;?php echo $merchantPayPalltoken; ?&gt;"&gt;
          &lt;input type="submit"&gt;
       &lt;/form&gt;
  </code></pre>
  
  <p>and if i click on submit, i am redirected to a paypall screen where i get the info that i want, listed.</p>
  
  <p>But i tried to make this post call trough  jQuery.ajax, like following:</p>
  
  <pre><code>    var postVars = jQuery('#paypalForm').serialize();
      var url = 'https://www.paypal.com/cgi-bin/webscr';
      jQuery.ajax({
          type: "POST",
          url: url,
          data: postVars,
          success: function(data){
                alert("success email = "+data.payer_email);
  
            },
  
        error:function(xhr, ajaxOptions, thrownError){
  
                 alert('status = '+xhr.status+' thrownError = '+thrownError+ ' response = '+xhr.responseText);
  
  
            } 
      });
  </code></pre>
  
  <p>but it always enters in the error part of the response, not in success.</p>
  
  <p>I would need that email info from pay-pal to activate that user account on my website,  after he payed.</p>
  
  <p>Or should i make this part by creating a session variable with the users email right before redirecting him to paypall for payment, and when the user is redirected back to success page, to get the email from session. Would this be a safe way to do it?</p>
  
  <p>Many thanks</p>