是否可以在查询字符串参数中指定 PayPal 固定捐赠金额?

Is it possible to specify the PayPal fixed donation amount in the querystring parameters?

假设我们有一个 <input> 元素,用户可以在其中输入数字(例如 500)。

当点击某个按钮时,我希望用户被重定向到 PayPal 捐赠页面,他们可以在其中指定金额,但将默认值设置为输入中设置的数字(500在这种情况下)。

PayPal url 是否允许这样的选项(可能通过查询字符串参数)?

是的,这是可能的。您需要创建一个开源捐赠按钮,以便捐赠者从您创建的表格中添加捐赠金额,而不是在 PayPal 托管页面上。

您需要将此添加到您的捐赠按钮代码中

<input type="text"   name="amount" size=10><br /><br />

下面是完整的捐赠按钮示例代码。

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_donations">
 <!-- Update to Your PayPal Email or Merchant ID -->
<input type="hidden" name="business" value="youremail@email.com">
<input type="hidden" name="lc" value="US">
 <!-- Update the Value to the Donation Name -->
<input type="hidden" name="item_name" value="Test Donations"><p>Please Enter an Amount</p>
 <!-- The below will allow your customers to enter an amount and this gets passed to PayPal -->
<input type="text"   name="amount" size=10><br /><br />
 <!-- The rest is the normal PayPal Donation button Info -->
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="cn" value="Add special instructions to the seller:">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHosted">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_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>

Creating Donation Buttons