在网站上预先填写捐款金额 [英] Pre-populate Donation Amount on Website

查看:72
本文介绍了在网站上预先填写捐款金额的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要完成的是让用户在网站上的文本输入中输入一个金额,当点击贝宝捐赠按钮时,付款表单中会预先填充他们在文本输入中输入的金额.

我看过其他帖子,这些帖子的答案似乎在过去已经解决了这个问题,但是在尝试自己实施相同的解决方案时,我无法让它工作......如果这是对一个小无知的人所做的我的疏忽,然后我提前道歉.

这是我在选择捐赠按钮类型并选择捐赠者输入他们自己的捐赠金额"选项时从贝宝获得的代码片段

<input type="hidden" name="cmd" value="_s-xclick"><input type="hidden" name="hosted_button_id" value="XXXXXXXXXX"><input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - 更安全、更简单在线支付方式!"><img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"></表单>

这是为其他人解决此问题的帖子:Paypal 自定义金额为立即捐赠"按钮

按照那个帖子所说的,我修改了我的贝宝片段:

<input type="hidden" name="cmd" value="_s-xclick"><input type="text" name="amount" id="amount" value""><input type="hidden" name="hosted_button_id" value="XXXXXXXXXXX"><input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - 更安全、更简单在线支付方式!"><img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"></表单>

所以,我刚刚添加了 <input type="text" name="amount" id="amount" value"">,据我所知,这应该允许我将我输入的值传递给付款表单.由于某种原因,这不起作用.

非常感谢您的帮助!

解决方案

您使用的是托管按钮,因此您不能像那样直接在按钮代码中设置数量.如果你想这样做,你需要使用一个未托管的按钮,你可以进入 PayPal 中的按钮编辑器并取消选中PayPal 上的保存按钮"选项.也就是说,您应该能够设置捐赠按钮,让人们在 PayPal 页面上而不是在您自己的页面上输入金额并将其传递出去,因此您可能需要研究一下.

非托管按钮的缺点是人们可以在按钮代码中看到金额、您的电子邮件地址等,他们可能会查看源代码、复制代码、更改值,然后加载它并向您付款比他们应该为产品少的数量.当然,希望您在运送产品或提供对仅限订阅的网站的访问之前就已制定程序来解决此问题,但这只是您需要牢记的事情.

另一种选择是切换到 Express Checkout API.这基本上是标准按钮的 API 版本,但是当使用 API 时,浏览器中实际上看不到这些代码,因此人们无法尝试弄乱它.

What I want to accomplish is to have user enter an amount into text input on website, and when the paypal donate button is clicked, the payment form is pre-populated with the amount that they entered into the text input.

I have seen other posts which have answers that seem to have solved this problem in the past, but while trying to implement the same solution myself, I am unable to get it work... If this is do to a small ignorant oversight on my part, then I apologize in advance.

Here is the code snippet that I get from paypal when I choose a donate button type and select the option "Donors enter their own contribution amount"

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
    <input type="hidden" name="cmd" value="_s-xclick">
    <input type="hidden" name="hosted_button_id" value="XXXXXXXXXX">
    <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_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>

Here is a post that has solved this issue for others: Paypal custom amount for "Donate Now" button

Following what that post has to say, I modified my paypal snippet thusly:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
    <input type="hidden" name="cmd" value="_s-xclick">
    <input type="text" name="amount" id="amount" value"">
    <input type="hidden" name="hosted_button_id" value="XXXXXXXXXXX">
    <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_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>

So, I've just added <input type="text" name="amount" id="amount" value"">, which from what I understand should have allowed me to pass the value of my input to the payment form. This isn't working for some reason.

Help would be very much appreciated!

解决方案

You're using a hosted button, so you can't set the amount directly within the button code like that. If you want to do that you'll need to use an un-hosted button, which you can go by going into the button editor in PayPal and unchecking the "save button on PayPal" option. That said, you should be able to setup the donate button to let people enter the amount on the PayPal page rather than on your own page and passing it over, so you might want to look into that.

The downside to the non-hosted button is people can see the amount, your email address, etc. in the button code and they could potentially view source, copy the code, change the values, then load it up and pay you a lesser amount than they should for a product. Of course, hopefully you'd have procedures in place to catch this before shipping a product or providing access to a subscription only website, but it's just something you'd need to keep in mind.

Another option would be to switch to the Express Checkout API. This is basically the API version of standard buttons, but when using the API none of that code is actually seen in a browser so people can't try to mess with it.

这篇关于在网站上预先填写捐款金额的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆