I am trying to integrate paypal's shopping cart into my site. To do this all i need to do is add an additem button for each item i intend to sell. If my site was coded in html, i would just paste the bellow code per each item :
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but22.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<input type="hidden" name="add" value="1">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="name@business.com">
<input type="hidden" name="item_name" value="toycar">
<input type="hidden" name="item_number" value="c90">
<input type="hidden" name="amount" value="3.00">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="bn" value="PP-ShopCartBF">
</form>
(the above creates an additem button for each item that when pressed it takes the user to the shopping cart hosted by paypal where they can see their items)
However im trying to acomplish the above in a more dynamic way by using a data grid, and changing the values of these items depending on the product selected by the user. In this way only one button is needed instead of one per item.
I have unsuccesfully tried placing the additem button on the ASP and have an onclick event handler method to take the posting action like so:
The above code grabs the name and price of the product from the textboxes that are dynamically updated when a new product is selected from the datagrid, however i am doing something wrong since i cannot get to the paypal's shopping cart site whenever i press the button to additem to cart.
Any hints?
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but22.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<input type="hidden" name="add" value="1">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="name@business.com">
<input type="hidden" name="item_name" value="toycar">
<input type="hidden" name="item_number" value="c90">
<input type="hidden" name="amount" value="3.00">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="bn" value="PP-ShopCartBF">
</form>
(the above creates an additem button for each item that when pressed it takes the user to the shopping cart hosted by paypal where they can see their items)
However im trying to acomplish the above in a more dynamic way by using a data grid, and changing the values of these items depending on the product selected by the user. In this way only one button is needed instead of one per item.
I have unsuccesfully tried placing the additem button on the ASP and have an onclick event handler method to take the posting action like so:
Code:
Private Sub ImageButton1_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
Dim URLString As String
Dim postValues As String
Dim byteArray As Byte()
Dim myWebClient As New System.Net.WebClient
Dim sendArray As Byte()
URLString = "https://www.paypal.com/cgi-bin/webscr"
postValues= "add=1&cmd=_cart&business=name@business.com&item_name=" & txtNombP.Text & "&item_number=" & txtCodP.Text & "&amount=" & Textprice.Text & "&no_note=1¤cy_code=USD&bn=PP-ShopCartBF"
myWebClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
byteArray = System.Text.Encoding.ASCII.GetBytes(postValues)
sendArray = myWebClient.UploadData(URLString, "POST", byteArray)
End Sub
Any hints?