Login    
 
 
 
 
Text/HTML
  
You are here :: Blogs Saturday, May 19, 2012

Search
Note: This uses the internal blog search engine. The Google search engine is also available at the top of the page.
  
Disclaimer

Please review the site disclaimer before downloading or using content found on this site

  
Categories
  
DEVSHED Blog
As always, I welcome your comments!
May 26

Written by: Steve Gray
5/26/2011 12:44 PM  RssIcon

When you create a web site in ASP.NET the form tag is included for you. This issue is magnified if you use master pages (who doesn’t?).

The issue is that the code that you get from PayPal has a <form> tag in it, and you can’t nest form tags. So your code doesn’t post correctly when the user clicks ‘Buy Now’.

Here’s a real easy way around that. There are two ways you can do this, as a link from the <HTML> code, or as a Response.Redirect from the code behind. The link will be less work, but also less flexible.

From the HTML, code something like this:

  1. <a href="https://www.paypal.com/cgi-bin/webscr
  2.   ?cmd=_xclick&business=YOUR-PAYPAL-EMAIL-HERE
  3.   &item_name=Widget
  4.   &amount=29.00
  5.   &undefined_quantity=1
  6.   &currency_code=USD">
  7. <img src="http://www.paypal.com/en_US/i/btn/x-click-but23.gif"
  8.   border="0" alt="Buy Now Using PayPal" />
  9. </a>

If you’ll compare the above to the code that you got from PayPal, you’ll see that we converted the <input> tags to be parameters in the query string.

From the code behind it looks like this:

  1. Protected Sub btnSubscribeYear_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubscribeYear.Click
  2.     Dim dblAmount As Double
  3.     dblAmount = Me.txtAmount.text
  4.  
  5.     https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amount=" & dblAmount & "&hosted_button_id=3IMNOTREAL3E3
  6. End Sub

 

Here’s a list of all the arguments (not guaranteed to be complete or correct, you’ll want to check with PayPal for complete information)

Argument                Description
business                Email address associated with seller's PayPal account
quantity                Quantity of items being sold
undefined_quantity      Allows user to edit quantity
item_name               Name of item
item_number             Optional item number
amount                  Price of each item (without currency symbol)
undefined_amount        Allows user to edit the amount (good for donations)
shipping                Price of shipping
currency_code           Code for type of currency (Default appears to be USD)
first_name              Customer's first name
last_name               Customer's last name
address1                Customer's first address line
address2                Customer's second address line
city                    Customer's city
state                   Customer's state
zip                     Customer's zip code
email                   Customer's email address
night_phone_a           Customers telephone area code
night_phone_b           Customers telephone prefix
night_phone_c           Remainder of customer's telephone number

Tags:
Categories:
As always, I welcome your comments!
  
 
 
Home | Products | Blogs | Contact Us | Links | God's Plan
Privacy Statement | Terms Of Use
 
Copyright 2011 by Devshed.us