A piece of advice : Never process the post payment logic (i.e. logging the transaction data in your database, verifying the payment and generating License Key, sending email to the payer with shipping information etc) from PayPal_Returned event even though you can collect all transaction data from PDT. Because, if the payer closes his / her browser while living in PayPal website before coming back to your website, then, PayPal_Returned event will never fire and so you will miss that transaction. Always use IPN for processing post payment logic. Use PayPal_Returned event to convey 'Thank you' Message or doing some additional Read-Only tasks. What is a Read Only task ? Read Only task means, "the task that can be done by reading your database without writing / updating the database". Get the Transaction-ID from the PayPal_Returned event, query your database using that Transaction-ID and find out if any information is already recorded by IPN event. If found, show the download link / shipping information etc from your database.
In order to use PDT, you must have Full Trust configuration in your ASP.NET website, otherwise you will always get e.PDT.Status = PayPalPDT.StatusCodes.Communication_Error from PayPal_Returned event. Because, prior to firing PayPal_Returned event, the control communicates with PayPal website in the background to verify the transaction using a method from WebClient class. Web Client class methods require Full Trust configuration.
If you do not have full trust configuration, you cannot use the PDT feature even manually coding by yourself or using any other technique at all.
PDT Authentication Token property value will not be persisted in ViewState as it is a sensitive data. You can set PDT Token from Design Mode (persisted in ASPX markup). You can also set it programmatically from Page_Load event. But, if you set this value from a Post-back event (i.e. Click event) then, you will get unexpected result.
If you are testing in SandBox, you should change the property 'NotifySyncDestination = PayPal_Sandbox'. Otherwise, you will always get PDT Status = FAIL. But if you did not set the License Key (Trial Mode) then, no matter what value you set for this property, this component will always use NotifySyncDestination = PayPal_Sandbox.
Handling Payment Data Transfer (PDT) & Return from a dedicated Web Form.
The PayPalReturnHandler component is designed for the scenario where you want to use a dedicated page for handling the Return from PayPal instead of handling the PayPal_Returned event of the same button. If you handle the PayPal_Returned event directly from your Payment Button (BuyNow button, Donation button etc) then, you do not need this component at all.
In order to associate a PayPalReturnHandler component with a PayPal Return event caused by a Payment Button (i.e. BuyNow Button, Donation Button etc..) that is hosted in a different page, you need to follow the following steps:
(The example is shown for a BuyNow button, but the same procedure works for all other button controls)
Accessing Additional Data Items:
Payment Data Transfer:
If you are not satisfied only with the transaction id, rather you want the all the transaction data, you can get that by activating Payment Data Transfer. Payment Data Transfer (PDT) is a secure method to retrieve the details about a PayPal transaction so that you can display them to your customer who are redirected back to your site upon payment completion.
PDT Authentication Token:
When you activate PDT, you will get an identification token named "PDT authentication token". It is a string value that identifies your account to PayPal. If you want to handle PDT using this component, you must provide this token to the component. The following screen shot shows how you can do that in Design Time.
Once you have set the PDT Authentication Token, you are ready to use snippet like this:
If the component does not find any PDT Token, e.PDT.Status will be set as "PayPalPDT.StatusCodes.NOT_Handling_PDT" and no transaction related data will be available except the Transaction ID.
Last updated on 4 July 2012, Wednesday, 11:55:37 PM