【背景】
折腾:
【记录】给Wordpress网站crifan.com中文章下方添加捐赠按钮
期间,需要去弄一个像:
我的Google Adsense帐户被关 – 阮一峰的网络日志
中的美元的图标,点击后,可以去打开PayPal页面,支持捐赠美元。
【折腾过程】
1.搜:
paypal 捐赠链接
找到:
但是显示出来的效果是:
PayPal的图标和链接。
不是我要的这种可以自己定义图标的。
2.所以再去参考:
我的Google Adsense帐户被关 – 阮一峰的网络日志
里面的美元的图标效果:
(1)先看看其内部链接是啥:
哦,大概看懂了了:
就是一个paypal的连接,然后在url中加上参数
包括自己的账户和其他一些参数。
(2)再去点击看看打开页面效果如何:
3.后来去分析了:
https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=yifeng.ruan@gmail.com¤cy_code=USD&amount=0.99&return=http://www.ruanyifeng.com/thank.html&item_name=Ruan%20YiFeng%27s%20Blog&undefined_quantity=1&no_note=0 == https://www.paypal.com/cgi-bin/webscr |
和
中的html源码:
1 2 3 4 5 6 7 8 | <input type= "hidden" name= "cmd" value= "_xclick" > <input type= "hidden" name= "business" value= "me@mybiz.com" > <input type= "hidden" name= "item_name" value= "Team In Training" > <input type= "hidden" name= "currency_code" value= "CNY" > <input type= "hidden" name= "amount" value= "25.00" > <input type= "image" src= "http://www.paypal.com/zh_CN/i/btn/x-click-butcc-donate.gif" border= "0" name= "submit" alt= "使用贝宝支付——快捷、免费、安全!" > </form> |
正好是一一对应的。
换句话说:
我是可以自己组合出来,一个类似于阮一峰的那个链接的。
所以,自己去弄一个。
弄之前,又去参考了:
PayPal Payments Standard Overview – PayPal Developer
->
Contribution Payments – Donate Buttons – PayPal Developer
的:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <!-- Identify your business so that you can collect the payments. --> <input type= "hidden" name= "business" value= "donations@kcparkfriends.org" > <!-- Specify a Donate button. --> <input type= "hidden" name= "cmd" value= "_donations" > <!-- Specify details about the contribution --> <input type= "hidden" name= "item_name" value= "Friends of the Park" > <input type= "hidden" name= "item_number" value= "Fall Cleanup Campaign" > <input type= "hidden" name= "amount" value= "25.00" > <input type= "hidden" name= "currency_code" value= "USD" > <!-- Display the payment button. --> <input type= "image" name= "submit" border= "0" alt= "PayPal - The safer, easier way to pay online" > <img alt= "" border= "0" width= "1" height= "1" </form> |
可以考虑,
到时候的cmd弄成_donations,以及再加个amount为1
4.去组合自己的PayPal的捐赠的url地址:
(1)https://www.paypal.com/cgi-bin/webscr
不变
(2)?cmd=_xclick
换成:
?cmd=_donations
(3)&business=yifeng.ruan@gmail.com
换成:
&business=green-waste@163.com
(4)¤cy_code=USD
保留不变
(5)&amount=0.99
换成:
&amount=1
(6)&return=http://www.ruanyifeng.com/thank.html
不要:
暂时懒得弄那个感谢页面了。以后有空再弄。到时候弄好了再加也不迟。
(7)&item_name=Ruan%20YiFeng%27s%20Blog
可以用python去帮忙encode:
如图:
即:
Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on win32 >>> import urllib >>> urllib.quote("Crifan Li’s Blog: crifan.com") ‘Crifan%20Li%27s%20Blog%3A%20crifan.com’ >>> |
所以,此处就是:
&item_name=Crifan%20Li%27s%20Blog%3A%20crifan.com
(8)&undefined_quantity=1
保持不变
(9)&no_note=0
去掉不要。
合并起来的url就是:
https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=green-waste@163.com¤cy_code=USD&amount=1&item_name=Crifan%20Li%27s%20Blog%3A%20crifan.com&undefined_quantity=1 |
然后点击打开看看效果:
但是只显示了1美元->即使想要多捐点,都没法修改想要捐赠的钱
5.所以,再去改为_xclick的url:
https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=green-waste@163.com¤cy_code=USD&amount=1&item_name=Crifan%20Li%27s%20Blog%3A%20crifan.com&undefined_quantity=1 |
看看效果:
很明显:
_xclick所产生的页面,就是可以编辑修改想要捐赠的钱数的页面了,就达到想要的效果了:
如果想要捐美元,不改的话,默认是1美元
想要多捐点(或少捐点)也可以可以修改的。
【总结】
至此,PayPal的捐赠页面链接,就通过自己组合生成了:
点击后即可打开PayPal捐赠页面,且支持修改捐赠钱数。
转载请注明:在路上 » 【记录】想办法弄出一个允许自己添加图标的PayPal捐赠的支付链接