MediaWiki扩展:PayPal支付
天下维客,你可以修改的网络知识库
本文取自元维基,欢迎共同翻译、整理与大家共享,促进中文wiki发展^_^
目录 |
Overview
This (simple) extension could be used for the donations-sites, if therefor you have a PayPal-Account.
这个简单的扩展,可以用来添加网站的“捐赠”功能。需要你已经有了一个Paypal帐号。
This extension will create a PayPal-Button, which leads users to your PayPal-Donation-Site.
这个扩展会生成一个Paypal键,引导用户到Paypal的付款页面。
Create a new site in your extension-folder, named "PayPal.php" with following content:
在你的extension目录下,建立一个名为“PayPal.php”的文件,内容为:
<?php
# Example WikiMedia extension
# with WikiMedia's extension mechanism it is possible to define
# new tags of the form
# <TAGNAME> some text </TAGNAME>
# the function registered by the extension gets the text between the
# tags as input and can transform it into arbitrary HTML code.
# Note: The output is not interpreted as WikiText but directly
# included in the HTML output. So Wiki markup is not supported.
# To activate the extension, include it from your LocalSettings.php
# with: include("extensions/YourExtensionName.php");
$wgExtensionFunctions[] = "wfPayPal";
function wfPayPal() {
global $wgParser;
$wgParser->setHook( "paypal", "renderPayPal" );
}
# The callback function for converting the input text to HTML output
function renderPayPal( $input ) {
# $argv is an array containing any arguments passed to the
# extension ike <example argument="foo" bar>..
$output = "<br/>$input";
$output .= "<form action='https://www.paypal.com/cgi-bin/webscr' method='post'>";
$output .= "<input type='hidden' name='cmd' value='_s-xclick'>";
$output .= "<input type='image' src='https://www.paypal.com/de_DE/i/btn/x-click-but04.gif' border='0' name='submit' alt='Zahlen Sie mit PayPal - schnell, kostenlos und sicher!'>";
$output .= "<input type='hidden' name='encrypted' value=' THIS_SHOULD_BE_REPLACED'>";
$output .= "</form>";
return $output;
}
?>
Replace the "THIS_SHOULD_BE_REPLACED"-section with your code, brought to you by PayPal
用Paypal的代码替换"THIS_SHOULD_BE_REPLACED"这一部分
(should be something like -----BEGIN PKCS7-----MIIHNwY (.........)-----END PKCS7-----).
(就是那串如同这个一样的: -----BEGIN PKCS7-----MIIHNwY (.........)-----END PKCS7-----).
Open your LocalSettings.php, and insert at the end of file:
打开LocalSettings.php, 在文件的最后插入:
include("extensions/PayPal.php");
If you do so, you can make the PayPal-Button visible by using:
如果你已经完成了这些,你就可以在页面上用下面的代码显示Paypal键了:
<paypal></paypal>
其他方法
In addition to the above solution this one allows multiple paypal buttons.
Features
- paypal button is defined through the means of a parser hook which means you do not have to enable html!
- support for multiple paypal buttons through 1 tag.
Usage
- <paypal></paypal> translates to the default paypal button (button 1)
- <paypal>2</paypal> translates to button 2
- <paypal>2 description</paypal> translates to button 2 and additionaly the text 'description' is placed next to the paypal button.
- <paypal>description</paypal> translates to the default button (button 1) and additionaly the text 'description' is placed next to the paypal button.
Download and Installation Instructions
http://www.ipbwiki.com/index.php/IpbWiki_Paypal_Extension
原文参见: PayPal extension


