title: php paypal. A way to validate a payment before accepting the payments
body: <p>Is there a way to validate a payment before paypal proceed the order ?<br /></p>
  
  <p>I Use my own shopping cart. 
  When the customer click on Submit Order, I redirect the user on an other page call, PayPalRedirect.php <br /></p>
  
  <p><strong>PayPalRedirect.php</strong><br /></p>
  
  <pre><code>&lt;form name="paypalform" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"&gt;
  &lt;input type="hidden" name="cmd" value="_cart"&gt;
  &lt;input type="hidden" name="upload" value="1"&gt;
  &lt;input type="hidden" name="invoice" value="&lt;? echo $idInvoice; ?&gt;"&gt;
  &lt;input type="hidden" name="business" value="business_email@example.com"&gt;
  &lt;input type="hidden" name="notify_url" value="http://mydomain.com/catalog/IPNReceip"&gt;
  
  
   &lt;? 
      $cpt = 1;
          foreach($ordering as $k =&gt; $v)
          {
          ?&gt;
              &lt;input type="hidden" name="item_name_&lt;? echo $cpt?&gt;" value="&lt;? echo$v-&gt;Product-&gt;ProductNumber; ?&gt;"&gt;
              &lt;input type="hidden" name="quantity_&lt;? echo $cpt?&gt;" value="&lt;? echo $v-&gt;Qty; ?&gt;"&gt;
              &lt;input type="hidden" name="amount_&lt;? echo $cpt?&gt;" value="&lt;? echo $v-&gt;Price ?&gt;"&gt; 
              &lt;?
              $cpt++;
          }
      ?&gt;
  
  
  &lt;input type="hidden" name="currency_code" value="CAD"&gt;
  &lt;input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"&gt;
  &lt;/form&gt; 
  </code></pre>
  
  <p>I use this JavaScript to submit the form when the page is loaded:</p>
  
  <pre><code>&lt;script&gt;
  document.forms.paypalform.submit(); 
  &lt;/script&gt;
  </code></pre>
  
  <p>At this time all is alright. The user is Redirect to PayPal page and can login to PayPal and then pay the order.</p>
  
  <p>My question at this point is. Is there a way with PayPal to call a web service in my side (for example: <a href="http://mydomain.com/ValidatePayment.php" rel="nofollow">http://mydomain.com/ValidatePayment.php</a>) and pass all the items of the shoping cart that paypal receive to confirm that the  price is correct. If the price is not correct, I would like to response to paypal that the payment is invalid and cancel the transaction. All that before the customer click on PayNow of paypal page.
  How can I do this if it's possible?</p>
  
  <p>Thanks a lot</p>