asp.netpaypalpaypal-pdt

Why does PayPal PDT return all variables in Return URL query string instead of just transaction id?


I have a PayPal subscribe button which is working with ReturnURL and PDT enabled. This button is being used on an aspx page in ASP.Net.

The problem is that once the transaction on paypal completes all PDT variables are being returned as query string variables in ReturnURL page; I thought only transactionid (i.e. tx) would be returned in query string of ReturnURL and I would have to post this transaction id and my token to PayPal to get other transaction details like transaction status etc.

Question Why does PDT return all variables like transaction status, item number, amount and currency code rather than just the transaction id as mentioned in their documentation?

This means I do not have to write code to get other transaction details by posting to PayPal from my ReturnURL page since I am getting all details already from query string of ReturnURL, but this sounds against what PayPal documentation says.

ReturnURL after transaction completes

http://localhost/xyz/pp.aspx?c=0&tx=3MA744263S4136832&st=Completed&amt=100%2e00&cc=USD&cm=&item_number=brokerplans&sig=mVojxSFzXH%2fk0RBOwUAMe8kq8jt7glCdnKYFfk9kZxWkuqru4wM1yfkD8FiAJVaoHeGlWY252ZiWwuCw0VJ8L8RU%2bUtnzGTVEgq3w1MQbqsCfZUwImlIfo%2fgV88wYf8V%2fgNgUmVCxBweZ8faFsKDlRr08julLC7ancjIDOkOY2o%3d

The PayPal documentation at https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/paymentdatatransfer/ shows the following as workflow for PDT:

Workflow for PDT


Solution

  • I finally got the answer after some more research from my side.

    Answer : The query string variables that PayPal sends with ReturnURL are just a small set of PDT transaction variables, and the developer needs to POST to PayPal as mentioned in their documentation to get the full/complete set of transaction variables.

    So, you must POST to PayPal even if you get st=Completed in your ReturnURL query string variables.

    In my case, after I did a POST as per PayPal documentation from Page_Load event of my ReturnURL aspx page, I got a lot more variables as shown below.

    You can see that payment_status is returned in this full set which was called by a different name of st in the query string variables received with ReturnURL. The same is with transaction id, which was called tx in query string variable but is called txn_id in POST response.

    Variables received from PayPal after POST to PayPal from ReturnURL aspx page

    SUCCESS
    transaction_subject=Plans
    payment_date=11%3A12%3A13+May+17%2C+2016+PDT
    txn_type=subscr_payment
    subscr_id=I-BRSWRVNGN324
    last_name=buyer
    option_selection1=Basic
    residence_country=US
    item_name=Plans
    payment_gross=100.00
    mc_currency=USD
    business=xyz123-facilitator%40gmail.com
    payment_type=instant
    protection_eligibility=Ineligible
    payer_status=verified
    payer_email=sun21170-buyer%40gmail.com
    txn_id=3MA744263S4136832
    receiver_email=abc123-facilitator%40gmail.com
    first_name=test
    option_name1=Plan+Options
    payer_id=45HWR9TGYNPD8
    receiver_id=9H9UCPFXX96KG
    item_number=brokerplans
    payment_status=Completed
    payment_fee=3.20
    mc_fee=3.20
    btn_id=3335152
    mc_gross=100.00
    charset=windows-1252