最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【记录】想办法弄出一个允许自己添加图标的PayPal捐赠的支付链接

WordPress crifan 4172浏览 0评论

【背景】

折腾:

【记录】给Wordpress网站crifan.com中文章下方添加捐赠按钮

期间,需要去弄一个像:

我的Google Adsense帐户被关 – 阮一峰的网络日志

中的美元的图标,点击后,可以去打开PayPal页面,支持捐赠美元。

【折腾过程】

1.搜:

paypal 捐赠链接

找到:

贝宝捐赠 – 贝宝

但是显示出来的效果是:

PayPal的图标和链接。

不是我要的这种可以自己定义图标的。

2.所以再去参考:

我的Google Adsense帐户被关 – 阮一峰的网络日志

里面的美元的图标效果:

(1)先看看其内部链接是啥:

https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&[email protected]&currency_code=USD&amount=0.99&return=http://www.ruanyifeng.com/thank.html&item_name=Ruan%20YiFeng%27s%20Blog&undefined_quantity=1&no_note=0

哦,大概看懂了了:

就是一个paypal的连接,然后在url中加上参数

包括自己的账户和其他一些参数。

(2)再去点击看看打开页面效果如何:

yifeng ruan gmail com for paypal donate page part up

yifeng ruan gmail com for paypal donate page part down

3.后来去分析了:

https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&[email protected]&currency_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
?cmd=_xclick
&[email protected]
&currency_code=USD
&amount=0.99
&return=http://www.ruanyifeng.com/thank.html
&item_name=Ruan%20YiFeng%27s%20Blog
&undefined_quantity=1
&no_note=0

贝宝捐赠 – 贝宝

中的html源码:

<form name="_xclick" action="https://www.paypal.com/cn/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="[email protected]">
<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

的:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">

    <!-- Identify your business so that you can collect the payments. -->
    <input type="hidden" name="business"
        value="[email protected]">

    <!-- 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"
    src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif"
    alt="PayPal - The safer, easier way to pay online">
    <img alt="" border="0" width="1" height="1"
    src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
</form>

可以考虑,

到时候的cmd弄成_donations,以及再加个amount为1

4.去组合自己的PayPal的捐赠的url地址:

(1)https://www.paypal.com/cgi-bin/webscr

不变

(2)?cmd=_xclick

换成:

?cmd=_donations

(3)&[email protected]

换成:

&[email protected]

(4)&currency_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:

如图:

search python found idle python gui

use python urllib quote to encode string

即:

Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on win32

Type "copyright", "credits" or "license()" for more information.

>>> 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&[email protected]&currency_code=USD&amount=1&item_name=Crifan%20Li%27s%20Blog%3A%20crifan.com&undefined_quantity=1

然后点击打开看看效果:

generated paypal donate page is only show 1 usd can not change

但是只显示了1美元->即使想要多捐点,都没法修改想要捐赠的钱

5.所以,再去改为_xclick的url:

https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&[email protected]&currency_code=USD&amount=1&item_name=Crifan%20Li%27s%20Blog%3A%20crifan.com&undefined_quantity=1

看看效果:

new paypal xclick page can edit donate usd

new paypal xclick page can edit donate usd page bottom

很明显:

_xclick所产生的页面,就是可以编辑修改想要捐赠的钱数的页面了,就达到想要的效果了:

如果想要捐美元,不改的话,默认是1美元

想要多捐点(或少捐点)也可以可以修改的。

 

【总结】

至此,PayPal的捐赠页面链接,就通过自己组合生成了:

https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&[email protected]&currency_code=USD&amount=1&item_name=Crifan%20Li%27s%20Blog%3A%20crifan.com&undefined_quantity=1

点击后即可打开PayPal捐赠页面,且支持修改捐赠钱数。

转载请注明:在路上 » 【记录】想办法弄出一个允许自己添加图标的PayPal捐赠的支付链接

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 0.165 seconds, using 22.10MB memory