The IPNHandler component is designed for the scenario where you want to use a dedicated page for handling Instant Payment Notification instead of handling the IPN_Notified event of the same button. If you handle the IPN_Notified event directly from your Payment Button (BuyNow button, Donation button etc) then, you do not need this component at all.
In order to associate the IPNHandler component with a PayPal IPN Notified event caused by a Payment Button (i.e. BuyNow Button, Donation Button etc..) 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)
- In the design mode of a BuyNow Button, open the smart tag wizard and go to the tab named "Step 3 (IPN) as shown in the following screen shot. Check the second option and provide the relative path of the dedicated PayPal IPN handler file.
- Once you have done that, you know that, "~/DedicatedIPNHandler.aspx" is the page which will be called by PayPal Instant Payment Notification system. So, you should place an instance of the IPNHandler component in this web form.
- Now, create an aspx page named "~/DedicatedIPNHandler.aspx" and place an instance of the IPNHandler component as follows:
The "IPN_Notified" event of the IPNHandler component will be fired as soon as the page is loaded (called by PayPal IPN). You should place only one instance of this control in an aspx page. Because, if you place multiple instances, all instance's IPN_Notified event will be fired as soon as the page is loaded which is not an expected matter at all.
This page is supposed to be called by PayPal IPN and so there is no need to place any User Interface control or HTML elements in this page. Even though if you place any HTML on this page, all HTML rendering will be suppressed whenever this page is loaded.
- Once you have placed an instance of this component into your web form, attach an event handler method for the event "IPN_Notified". This event handler method is the method which will contain your business logic. When the IPN_Notified event is fired, all transaction information becomes available as strongly typed object (categorized collection of composite properties and collections) through the Event Argument.
You can access the additional data items from IPN_Notified event as shown in the following snippet.
By default, the temporary folder used for storing additional data items is "~/App_Data/". Because, usually this folder is privileged with WRITE permission. You could change that path from the property 'InternalSettings.TemporaryFolder" as shown below:
But if you changed that path and if you want access the additional data items from a Dedicated IPNHandler component, then, you need to change the property 'TemporaryFolderUsedForAdditionalDataItems' as well as shown below: