Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6569831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:40:50+00:00 2026-05-25T14:40:50+00:00

Is there a way to validate a payment before paypal proceed the order ?

  • 0

Is there a way to validate a payment before paypal proceed the order ?

I Use my own shopping cart.
When the customer click on Submit Order, I redirect the user on an other page call, PayPalRedirect.php

PayPalRedirect.php

<form name="paypalform" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="invoice" value="<? echo $idInvoice; ?>">
<input type="hidden" name="business" value="business_email@example.com">
<input type="hidden" name="notify_url" value="http://mydomain.com/catalog/IPNReceip">


 <? 
    $cpt = 1;
        foreach($ordering as $k => $v)
        {
        ?>
            <input type="hidden" name="item_name_<? echo $cpt?>" value="<? echo$v->Product->ProductNumber; ?>">
            <input type="hidden" name="quantity_<? echo $cpt?>" value="<? echo $v->Qty; ?>">
            <input type="hidden" name="amount_<? echo $cpt?>" value="<? echo $v->Price ?>"> 
            <?
            $cpt++;
        }
    ?>


<input type="hidden" name="currency_code" value="CAD">
<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!">
</form> 

I use this JavaScript to submit the form when the page is loaded:

<script>
document.forms.paypalform.submit(); 
</script>

At this time all is alright. The user is Redirect to PayPal page and can login to PayPal and then pay the order.

My question at this point is. Is there a way with PayPal to call a web service in my side (for example: http://mydomain.com/ValidatePayment.php) 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?

Thanks a lot

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:40:50+00:00Added an answer on May 25, 2026 at 2:40 pm

    I don’t think it is possible to do what you want. Once you send the client over to Paypal, they will handle the payment and send you a confirmation at the end.

    If you want to make sure the client paid the correct amount, you should check the confirmation that Paypal sends you.

    As you probably know Paypal has two payment confirmation mechanisms – PDT and IPN.

    PDT relies on the client coming back to your website after the payment. Once the client makes the payment, Paypal will send you a PDT message with the details of the transaction. This information is what you can use to show a receipt to the client. The issue is if the client closes his browser immediately after making a payment. If that happens, you may never receive the PDT message.

    IPN does not rely on the client coming back to your website. Every time a client makes a payment, Paypal will send you an IPN message with the details of the transaction.

    You can use either one or both to confirm that payment was completed. And you can also check that the payment was made for the amount you were expecting.

    See below the flow I use on my website:

    1 – client presses button to make payment with Paypal

    2 – my website sends client to Paypal with the details of the transaction

    3 – Paypal handles the payment

    4 – once payment is completed, Paypal will send the client back to my website with a PDT message.

    5 – my website sends a confirmation message to Paypal to check that the PDT message is legit and came from Paypal.

    6 – Paypal sends back a message with all the details of the transaction, including price paid.

    7 – my website checks the confirmation message from Paypal and shows a receipt on screen to my client

    8 – Paypal will also send an IPN message once a payment is made to my seller account.

    9 – when my website receives an IPN message, it sends back a message to Paypal to confirm that the message is legit and was originated from Paypal.

    10 – my website then checks the confirmation message sent back from Paypal and confirms the payment was correct.

    Note that in most cases I will receive two messages from Paypal (one PDT and one IPN). It is ok because I keep track of each transaction and if I receive an IPN for a transaction where I have already marked as paid, I simply discard the IPN message.

    Note that if you receive the PDT message you don’t really need the IPN message. However I recommend you implement both just in case the client closes his browser before Paypal has a chance to send him back to your website.

    In both messages (PDT and IPN) Paypal tells you if the payment cleared or not. As you probably know, some payment types do not clear until a few days after they are submitted to Paypal. Paypal recommends that you don’t ship the product until the payment has cleared. Paypal will send you another IPN message once the payment is cleared.

    I have two scripts on my website – one to handle the PDT messages and another one to handle the IPN messages. They are very similar when handling payment confirmation. See below an example:

    $req = 'cmd=_notify-synch';
    
    $tx_token = $_GET['tx'];
    $auth_token = "enter your own authorization token";
    $req .= "&tx=$tx_token&at=$auth_token";
    
    // post back to PayPal system to validate
    $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
    $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
    $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
    
    //$fp = fsockopen ('http://www.sandbox.paypal.com', 80, $errno, $errstr, 30);
    // If possible, securely post back to paypal using HTTPS
    // Your PHP server will need to be SSL enabled
    // replace www.sandbox.paypal.com with www.paypal.com when you go live
    $fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
    
    if (!$fp)
    {
        // HTTP ERROR
    }
    else
    {
        fputs ($fp, $header . $req);
        // read the body data
        $res = '';
        $headerdone = false;
        while (!feof($fp))
        {
            $line = fgets ($fp, 1024);
            if (strcmp($line, "\r\n") == 0)
            {
                // read the header
                $headerdone = true;
            }
            else if ($headerdone)
            {
                // header has been read. now read the contents
                $res .= $line;
            }
        }
    
        // parse the data
        $lines = explode("\n", $res);
        $keyarray = array();
        if (strcmp ($lines[0], "SUCCESS") == 0)
        {
            for ($i=1; $i<count($lines);$i++)
            {
                list($key,$val) = explode("=", $lines[$i]);
                $keyarray[urldecode($key)] = urldecode($val);
            }
            $firstname = $keyarray['first_name'];
            $lastname = $keyarray['last_name'];
            $itemname = $keyarray['item_name'];
            $amount = $keyarray['payment_gross'];
            $invoiceid = $keyarray['invoice'];
            $profileid = $keyarray['subscr_id'];
            // check the payment_status is Completed
            // check that txn_id has not been previously processed
            // check that receiver_email is your Primary PayPal email
            // check that payment_amount/payment_currency are correct
            // process payment
            // show receipt to client
        }
    }
    

    I hope this helps. Please feel free to ask follow up questions.

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there some way to validate the image size (height and width) before upload
Is there any way to validate datetime field before inserting it into appropriate table?
Is there a way to validate that one text_field does not equal another before
Is there a way to validate on the client side browser whether the size
Is there any way to validate the contents of a CEdit box without subclassing?
Is there any way to validate spring context xml files in eclipse? Features like:
Is there any way to validate using DataAnnotations in WPF & Entity Framework?
Is there a way to validate an XML file against a DTD with Qt's
I'm getting warnings about CSS3.0 properties like text-overflow. Is there a way to validate
Is there a way in the .NET framework to validate that a process has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.