asp.net - ASP.NET 表单中的 Paypal 表单

标签 asp.net paypal

干杯,

我在将 Paypal 购物车集成到我的 ASP.NET C# 项目时遇到问题。 问题是 Paypal 购物车在 FORM 标签内,所以如果我将它放在我的服务器表单标签内,它将无法工作。

看起来像这样:

<body>
<form id="form1" runat="server">
<form target="_self" action="https://www.paypal.com/cgi-bin/webscr" method="post">
      <input type="hidden" name="cmd" value="_cart">
      <input type="hidden" name="business" value="MySecretEmail@hidden.com">
      <input type="hidden" name="display" value="1">
      <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_viewcart_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_US/i/scr/pixel.gif" width="1" height="1">
      </form>
</form>
</body>

有什么办法可以防止这种情况发生吗?我在 google 上搜索,在 Stackoverflow 上我找到了这个链接:PayPal Name-Value Pair API Basics ,但老实说,这对我来说没有任何意义,因为我不是程序员。

谢谢!

最佳答案

解决此问题的最简单方法是使用 asp:button 的 PostBackUrl 属性。使用此方法,ASP 生成您的 JavaScript 来处理外部帖子。

这允许正确呈现表单并且不需要任何解决方法。请记住,由于您的代码已经在表单标签中,因此您的 Paypal 项目不需要包装在额外的标签中。

例如

<input type='hidden' name='cmd' value='_cart'/>
<input type='hidden' name='upload' value='1'/>
<input type='hidden' name='business' value='business@business.com'/>
<input type='hidden' name='currency_code' value='aud'/>
<input type='hidden' name='item_number_1' value='item number_1'>
<input type='hidden' name='item_name_1' value='16x16 inch square canvas'>
<input type='hidden' name='amount_1' value='70'>
<input type='hidden' name='item_number_2' value='item number_2'>
<input type='hidden' name='item_name_2' value=' 48x20 rectangular canvas'>
<input type='hidden' name='amount_2' value='104'>
<asp:Button ID="Button1" PostBackUrl='https://www.paypal.com/cgi-bin/webscr' runat="server" />

希望这对您有所帮助。

关于asp.net - ASP.NET 表单中的 Paypal 表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8340752/

相关文章:

javascript - 页面闲置一段时间后,为什么没有数据传给客户端?

c# - 如何根据数据行计数从代码后面将css类添加到 'hyperlink'内部的 'Repeater control'

C# 如何在多个列表框中显示项目?

php - Composer.phar 安装问题

iphone - 在 Apple 和 Android 上购买实物商品和服务的可能性

php - 在 PHP 中使用 PayPal 确认已处理的付款

asp.net - HTTPWebRequest "PUT"错误状态 405 IIS7 中不允许的方法

c# - ASP MVC 2 : Error with dropdownlist on POST

Paypal 批量支付 API 'RISK_DECLINE'

paypal - 捕获付款 : The requested action could not be performed, 语义不正确,或业务验证失败