How can get transaction details from paypal after successful payment

10,882

It's not going to be quite that simple. You'll need to setup Payment Data Transfer (PDT) in order to get details sent back to your return URL after the buyer completes the payment.

This is useful if you're simply going to display details back to the user, but it's not recommended for updating your own database, sending out email notifications, etc. because there is no guarantee this page will ever be reached so the code won't always run.

For that sort of thing you'll want to use Instant Payment Notification (IPN). This works very similar to PDT except that it will always POST data to your IPN listener on your server regardless of whether or not the user makes it back to your return URL, and it happens outside of your checkout system all together.

Share:
10,882
user1844626
Author by

user1844626

Updated on June 04, 2022

Comments

  • user1844626
    user1844626 about 2 years


    My sent data to paypal is

    "https://www.paypal.com/cgi-bin/webscr/cmd=_cart&upload=1&[email protected]&currency_code=USD&bn=BusinessName&return=http://www.sellersite.com&item_number_1=55&item_name_1=battery&amount_1=55&quantity_1=2&item_number_2=52&item_name_2=bat&amount_2=5&quantity_2=3"
    

    And I want to show those sent data(item number, item name,amount,quantity) and the paypal transaction id to the buyer on "http://www.sellersite.com" after successful payment. (Suppose, the seller has the merchant account with paypal and he would enter that paypal id into database from admin section of the website. So,I would not think about his paypal account settings, my job is just to create the environment for paypal payment for the seller.)

    If I write a script like

    $T_ID=$_REQUEST['tx']; // or $T_ID=$_GET['tx']; **ref(tx):- "https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/howto_html_paymentdatatransfer"
    
    $item=$_REQUEST['item_number_1']; // or $item=$_GET['item_number_1'];
    

    Then would I get those data from paypal ?

    Please tell me.

    -Thanks.

    • user1844626
      user1844626 over 11 years
      Thanks for your help. Although I didn't try yet but I'm trusting your answer.
  • user1844626
    user1844626 over 11 years
    Yes, I've been studying IPN since yesterday and it seems better to me than PDT. Would you please tell me if my client seller wants to accept only instant payment type (ref:cms.paypal.com/us/cgi-bin/…) and want to avoid all other payment status except 'Completed' then how should I create payment environment for him ? I mean could I send payment_type='instant' to paypal while send form data and what have to send to paypal for avoiding all payment status other than 'Completed' ?
  • user1844626
    user1844626 over 11 years
    And another thing, could I be able to get all transaction related variables from paypal on 'return' page like 'notify_url' page ? Or its better to capture those on 'notify_url' page and then show those data to buyer on 'return' page via SESSION variable?
  • Drew Angell
    Drew Angell over 11 years
    You can't really avoid anything other than completed. If the payment fails, it fails, and you'll get such a response back. You can set your account to avoid "Pending" by ensuring your Fraud Filters are configured accordingly and you don't have e-checks enabled as an option. This can be set in your profile under Payment Receiving Preferences. It's always recommended to check the status, though, and handle post order processing based on that.
  • Drew Angell
    Drew Angell over 11 years
    I typically just so the buyer a basic thank you message of some sort and tell them to refer to their email for an official receipt. Then I use IPN to generate email receipts and send them that way. If you really want to display details on the return page you'll need to configure PDT accordingly.
  • user1844626
    user1844626 over 11 years
    So, would it be better just to check the payment receiver email address,invoice number and mc_gross on notify_url page from the posted data from paypal and then send that data with replacing(if all correct then without replacing) mc_gross,invoice number and receiver email address after correction (if did not match with actual data) ? And check the payment status on admin page and manually clear them from queue to insert into database as sold item ?