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

Skip Navigation Links.

Single-Item Payment: Buy Now Button

Buy Now buttons are suitable for single-item payments or purchases. A single Buy Now button can sell one or more copies of the same item. However, to sell different items you must create separate Buy Now buttons for each or use the Add To Cart Button .


If you did not upgrade your account to a Premier or Business account, you cannot receive payment. So, you should upgrade your PayPal account before you do any experiment with Website Payments Standard features. You can do this easily through the account itself by logging in and visiting https://www.paypal.com/us/cgi-bin/webscr?cmd=_business-upgrade-info

If you have done so, then you are just few step away from collecting money from your customers using a Buy Now Button. Please follow the following steps:

  1. Drag and drop an instance of the BuyNow Button control from your Visual Studio Toolbox as shown below:r />

  2. The first property of this control that you need to set is your Business Email Address or Merchant ID. Merchant ID is an alternative to using your Email address. It is better not to expose your business email address in order to protect your Email Inbox from SPAMs. You can get your Merchant ID from your PayPal account's Profile section. You can set either Business Email or Merchant ID from the Smart Tag or from the Property Editor.

  3. Now you may want to set few more properties like Amount, ItemName, ItemNumber etc and you can do all of these using the Wizard for the button which can be called by clicking the link found in the Smart Tag as shown in the following ScreenShot.



  4. Furthermore, you may choose to set the visual styles and PayPal page behaviors for the buy now button. Just click the button "Next" shown in the wizard and you will be taken to configure the display page as shown in the following screenshot.



    Please note: If your account is not upgraded to a Premier or Business account, then, you will not see any affect of these styling properties for PayPal page. For example, if you set a header image url, you will not see that image when you click the BuyNow button and taken to PayPal website. You will see your email address as the header of the page.

  5. Handling Instant Payment Notification (IPN) from PayPal:

    Instant Payment Notification is a mechanism by which you receive transaction data, and it allows you to integrate PayPal payments with your website’s back-end operations. While you are configuring your BuyNow Button so that your customer can submit it to PayPal, you can setup options for handling Instant Payment Notification (IPN) for the transaction related to the BuyNow Button too. It is very easy when you have this control as you wont have to do any change in your PayPal profile but handle IPN_Notified event and attach an event handler method. This control will send necessary information to PayPal so that IPN is activated and processed. Only you need to make sure that you have a PayPal premier or business account rather than just a personal account. Please Click here for learning IPN handling in details.

    Go to Step 3 by clicking the Next Button for setting up IPN related properties.



  6. Programming "Thank You for Payment" Page:

    Whenever your customer is transferred back to your website from PayPal website after completing or cancelling a payment (pursuant to submission of your BuyNow button), you can execute post payment business logic on your website by handling Payment Data Transfer (PDT). This control is capable of firing an event named PayPal_Returned whenever your customer is returned to your website from PayPal website. You can program this "Return page" very easily when you have this control. Please Click here for learning PDT handling in details.


    Go to Step 4 by clicking the Next Button for setting up PayPal return / PDT related properties.



  7. If you want to set this value programmatically in the run mode, you can use snippets (C#.Net) like this : Assume that the instance of the control in the page is named by "BuyNowButton1".



  8. If you already have provided the LicenseKey  from the design mode Smart Tag, then you are ready to accept payments from your customer from this page. If you run this page, the customer will be able to click the button and then he/she will be taken to PayPal website immediately and your customer will be asked to pay 490.23$ by PayPal. If you did not provide the License Key yet, your customer will be taken to PayPal SandBox.
  9.  

  10. You are done. It is very easy to collect money from your customers using this control.


Click Event:

You may want to set the properties of your BuyNow Button after the customer has clicked the Button for purchasing an item. For example, in your web form, you may have a text box asking your customer how may copies of the item he/she wants to buy. So, if the button is clicked, you can calculate the final price and then send the information to PayPal. In order to do that, this control has an event named "Click". It is similar to any standard ASP.NET button control's Click Event as shown in the following figure:

 

If you attach an event handler to this event, then the event handler method will be executed before the data is transferred to PayPal.

If your textbox for quantity information has ID = txtQuantity and if you want to set price for a single item = US$ 34.78, then following snippet (C#.Net) shows how to perform calculation within Click Event Handler:

 

Not only PayPal related properties, you can also set Image Button related properties like Image URL, Border Color, Border Width etc from the property editor.


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