How can I post a form using paypal subscription button? Or is there any way to post a form containing paypal content only?

StackOverflow https://stackoverflow.com/questions/7835957

  •  27-10-2019
  •  | 
  •  

Question

I am using PayPal subscription I have issue with paypal subscribe button. I have subscribe button with 4 subscription options. I want to add this selected option in query string. So that my query string will look like this:

https://www.paypal.com/cgi-bin/webscr?cmd=_s-lick&hosted_button_id=Y1TOJTYQ2ALDJ&os0=Silver Membership

In above query string I want to set selected option for os0 parameter.

My Code:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">

<input type="hidden" name="cmd" value="_s-xclick"/>
<input type="hidden" name="hosted_button_id" value="X9TEPZ7Q2ALDJ"/>
<table>
<tr><td><input type="hidden" name="on0" value="Memberships">Memberships</td></tr><tr><td>
<select name="os0">
<option value="Registration - One month">Registration - One month : $1.00USD - monthly</option>
<option value="Trial Membership">Trial Membership : $25.00USD - monthly</option>
<option value="Silver Membership">Silver Membership : $250.00USD - yearly</option>
<option value="Gold Membership">Gold Membership : $400.00USD - yearly</option>
</select> 
</td></tr>
</table>
<input type="hidden" name="currency_code" value="USD"/>
<input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal — The safer, easier way to pay online."/>
<img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1"/>                            
<a id="paypalDonate" target="_blank" href ="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Y1TOJTYQ2ALDJ&os0=document.getelementbyid(os0).value">

<img border="0" id="payPalImage" src="https://www.paypalobjects.com/en_GB/i/btn/btn_subscribeCC_LG.gif" alt="Donate to DevtheWeb.NET" />
</a>
</form>
Was it helpful?

Solution 2

I fixed the issue by using ImageButton instead of anchor tag.

as below:

<asp:ImageButton ID="payPalImage" ImageUrl="https://www.paypalobjects.com/en_GB/i/btn/btn_subscribeCC_LG.gif" runat="server" OnClick="payPalImage_Click" />

On click event of ImageButton, in back end file(.cs file), I attached selected subscription option like:

protected string _SubscriptionVal = "";

....
protected void payPalImage_Click(object sender, ImageClickEventArgs e)
{
    _SubscriptionVal = Request["os0"];
    Response.Redirect("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=X34EQZ8Q2AFASLDJ&os0="+_SubscriptionVal);
}

and finally I could able to redirect to paypal account with appropriate values.

OTHER TIPS

It's not possible. Either don't use dropdowns and use the email link PayPal gives you (which is basically the link you have, minus the option select), or use a <form> POST.
You cannot combine a dropdown selection with a link.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top