无法访问 PayPal“立即购买” 在 ASP.NET 中的单个页面上工作的按钮
我承认我是 ASP.NET 和 Web 表单的菜鸟。 我在单个页面上合并一些 PayPal“立即购买”按钮时遇到问题。 基本上,问题是无论单击哪个“立即购买”按钮,用户都会被带到 PayPal 购买页面上最后一个按钮代表的产品。
我的第一个按钮的代码是这样的...
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="ABC123">
<asp:ImageButton runat="server" id="PPImageButton1" PostBackUrl="https://www.paypal.com/cgi-bin/webscr" ImageUrl="https://www.paypal.com/en_US/i/btn/btn_buynow_SM.gif"/>
我的第二个按钮类似于...
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="ABC456">
<asp:ImageButton runat="server" id="PPImageButton2" PostBackUrl="https://www.paypal.com/cgi-bin/webscr" ImageUrl="https://www.paypal.com/en_US/i/btn/btn_buynow_SM.gif"/>
如何使第一个按钮将值 ABC123 而不是 ABC456 发送到 PayPal 服务?
I confess I am a noob to asp.net and web forms. I'm having an issue incorporating a few PayPal "Buy Now" buttons on a single page. Basically, the problem is no matter which "Buy Now" button is clicked, the user is taken to PayPal to buy the product represented by the last button on the page.
The code for my first button is something like this...
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="ABC123">
<asp:ImageButton runat="server" id="PPImageButton1" PostBackUrl="https://www.paypal.com/cgi-bin/webscr" ImageUrl="https://www.paypal.com/en_US/i/btn/btn_buynow_SM.gif"/>
My second button is similar to...
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="ABC456">
<asp:ImageButton runat="server" id="PPImageButton2" PostBackUrl="https://www.paypal.com/cgi-bin/webscr" ImageUrl="https://www.paypal.com/en_US/i/btn/btn_buynow_SM.gif"/>
How can I make the first button send value ABC123 to the PayPal service instead of ABC456?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
按钮的 POST 内容是提交按钮周围的 FORM 标记中的每个输入。 因此,要让每个按钮提交一组单独的隐藏字段,您需要将按钮和所需的隐藏字段包装在单独的表单中:
The POST content of a button is every input in the FORM tag that surrounds the submit button. So to have each button submit a separate set of hidden fields you need to wrap the button and the desired hidden fields in a separate form:
我的菜鸟解决方案是将每个“立即购买”按钮及其相关字段从 aspx 页面中删除,并将每组放在单独的 html 页面中。
在 aspx 页面中删除按钮和其他字段的位置,插入一个指向 html 页面的 iframe,如下所示:
My noob solution for this was to cut each of the buy-it-now buttons and its associated fields out of the aspx page, and put each set in a separate html page.
In the place in the aspx page where you removed the button and other fields, insert an iframe which points to the html page like this:
我可以通过从 jQuery 的 DOM 中删除所有其他按钮容器来使其工作。 添加一个类到您的容器,并将一个 CssClass 添加到 ImageButton、“PayPalImageButtons”
和 jQuery
我的下一步是处理删除的元素高度,并且在加载 PayPal 页面时可能会出现一个“请稍候”对话框
I was able to get it to work by removing all the other button containers from the DOM in jQuery. Add a class to your container, and add a CssClass to the ImageButton, "PayPalImageButtons"
and the jQuery
My next step is dealing with the removed elements height and maybe a Please Wait dialog while the PayPal page is loaded