ASP.NET PayPal Control for Website Payments Standard
Online Documentation.

Skip Navigation Links.

Using Additional Data Items & Cross Application State Management

State management is one of the key requirements for an application developer and so ViewState technology was developed for ASP.NET. But when you are using PayPal Website Payments Standard, you are forced to let your customer leave your website for going to PayPal website and after successful or cancelled payments, your customers are transferred back to your website from PayPal website. At that point, you have lost your ViewState data and the application has become stateless. In order to support a minimum level of statefulness, PayPal offers few pass through variables like ItemNumber, Custom, Invoice etc. Although you do not have complete freedom using those pass through variables as those are meant for special purposes and the values of these pass through variables are visible to your customers. Moreover, those pass through variables are of limited length. In order to overcome this limitation, we have implemented a special Collection type property named AdditionalDataItems. So, using this control, you can store as many data as you want into this property, and you will be able to access this property value in IPN handler or PDT handler. You can also store sensitive data to this property as this property value is stored in a temporary folder in your server and never sent to the client's browser.

Additional Data Items can be set both from design time and programmatically. We will show both ways in the following examples.

 

Walkthrough: Using Additional Data Items with a BuyNow Button to store user's Browser information, IP Address and operating system and retrieve these information in IPN_Notified event handler and store in your database.

Reason: Ok, PayPal will not give you any variable for your customer's IP address, browser's information etc. So, you may want to collect these information of a buyer associated to a specific transaction.

Step 1: Configure your Temporary folder. First, in order to use the additional data items feature, you need to define a folder in your application which will be used to store the temporary session data. From the design time Smart Tag, select the temp folder as shown below:

Please note: The value of this Temporary Storage folder is saved in the Web.Config file. So, please remember to upload your web.config file if you changed this value. Also, please remember to set WRITE permission to this folder as this folder will be used to store temporary files. If you cannot set WRITE permission to this folder, then you wont be able to use Additional Data Items feature at all.

Step 2: In the Click Event handler of your BuyNow button, add the following code snippet.

Step 3: In your IPN_Notified event handler, retrieve the additional data items as shown in the following snippet:

 

Thats all. It is really that easy.

Walkthrough: Giving a name to your shopping cart and using that name to identify the shopping cart in IPN_Notified event.

Reason: When you use "Upload Complete Cart" button, you will find a necessity of assigning a name to your shopping cart same like the ItemName property of a BuyNow Button. You may want to use different types of upload complete cart in your web application and it is always efficient to separate them by names. But, PayPal really does not give you any pass through variable for assigning a name to a shopping cart for specific transaction. But when you use our ASP.NET PayPal Control for Website Payments Standard, you do not have to worry about this limitation. You got the featured control which supports "Additional Data Items".

Step 1: Simply give a name to your shopping cart as shown in the followng screenshot.

Step 2: Retrieve the shopping cart name from the IPN_Notified event handler method as shown here.

 

There is another useful usage of this feature. You can set customer's information to your buy now button and use that information in PayPal_Returned event where customer cancelled the payment and returned to your website. Usually when your customer cancels a payment and return to your website, you wont have any data about the customer as PayPal does not have any customer information available. But when you transfer your customer to paypal, you can collect customer's information to the additional data items and retrieve those information in the PayPal_Returned event.

Ok, When can I use this feature and when I cannot ?

In order to use this feature you must

  1. Have full trust configuration hosting. Because, the additional data is stored in temporary folder and without a full trust configuration, it is not possible for a script to create a file in the server.
  2. Handle IPN_Notified event or PayPal_Returned event of the same Payment Button. i.e. if you are using a dedicated page for handling IPN or PDT, then you cannot use this feature. Because, Dedicated handler does not logically know who is the sender button for the transaction.

Questions: What is the "Delete temp files within (hours) ?

Answer: The temporary files stored in the temporary folder needs to be deleted after a time when you may not need them at all, right ? You can instruct the control to delete those temporary files in the temp folder created by the instance of the control  after a certain hours by specifying a integer value in the design time smart tag text box named "Delete Temp files within (hours)". If you set the value = 4, do not expect that the temp files will be deleted exactly after 4 hours, rather, after 4 hours, the first time the control is loaded, the temp files will be deleted. If you do not want this auto delete feature, then set this value = -1. By settings -1, the temp files will never be deleted. You may choose this value for better performance and you plan to delete the temp files by yourself later or by using some other maintainance script.

Still Confused ?

If you are still confused, please check the sample application that comes with the setup.exe file you have downloaded from our website. Also please do not hesitate to ask us as many questions as you want from our Help Desk