Installation

Follow these steps to install this script on your wiki.

  1. Go to Service managmenent inside the Control Panel.
  2. Under Add Service, click Local and select type Extension.
  3. Enter a descriptive name and the SID: sid://mindtouch.com/2007/12/dekiscript
  4. Add "manifest" to the config section with value set to http://scripts.mindtouch.com/paypal.xml
  5. Add extra configuration values as listed below under Configuration (If Configuration is not listed below, ignore this step.)
  6. Click on add service.

Related Links: DekiScript service, Extension Overview, DekiScript Overview, Extension Demos.


Overview

Add a PayPal button to your wiki. This script requires MindTouch Deki 1.8.3 or later.

Configuration:

Config KeyTypeDescription
price/{product-name}numSet the price for the product with name 'product-name'.
emailstrThe email for your PayPal account.

Functions:

  1. paypal.buynow
  2. paypal.donate

paypal.buynow(name, image) : xml

Easily add a Buy Now button to your wiki page

Parameters:

NameTypeDescription
namestrName of product to sell.
imageuri(optional) Custom button image.


paypal.donate(name, image) : xml

Easily add a Donation button to your wiki page

Parameters:

NameTypeDescription
namestrName of product to sell.
imageuri(optional) Custom button image.


Source Code

<extension>
	<title>PayPal Extension</title>
  <label>PayPal</label>
  <copyright>Copyright (c) 2008 MindTouch, Inc.</copyright>
  <description>Add a PayPal button to your wiki.</description>
	<uri.help>http://wiki.developer.mindtouch.com/MindTouch_Deki/Extensions/Paypal</uri.help>
	<uri.logo>http://scripts.mindtouch.com/logos/paypal-logo.gif</uri.logo> 
	<namespace>paypal</namespace>

  <config>
    <param name="price/{product-name}" type="num">Set the price for the product with name 'product-name'.</param>
    <param name="email" type="str">The email for your PayPal account.</param>
  </config>
  
	<function>
		<name>buynow</name>
		<description>Easily add a Buy Now button to your wiki page</description>
		<param name="name" type="str">Name of product to sell.</param>
		<param name="image" type="uri" optional="true">Custom button image.</param>
		<return>
			<html xmlns:eval="http://mindtouch.com/2007/dekiscript">
				<body>
					<eval:if test="!config['price'][args.name]">Product name "<eval:expr>args.name</eval:expr>" doesn't exist.  Please check your configuration.</eval:if>
					<eval:if test="config['price'][args.name]">
						<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
							<input type="hidden" name="cmd" value="_xclick" />
							<input type="hidden" name="business" eval:value="config['email']" />
							<input type="hidden" name="item_name"  eval:value="args.name" />
							<input type="hidden" name="amount" eval:value="config['price'][args.name]" />
							<input type="hidden" name="no_shipping" value="2" />
							<input type="hidden" name="no_note" value="1" />
							<input type="hidden" name="currency_code" value="USD" />
							<input type="hidden" name="bn" value="IC_Sample" />
							<input type="image" eval:src="args.image ?? 'https://www.paypal.com/en_US/i/btn/x-click-but23.gif'" name="submit" />
							<img alt="" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" />
						</form>
					</eval:if>
				</body>
			</html>
		</return>
	</function>
  
	<function>
		<name>donate</name>
		<description>Easily add a Donation button to your wiki page</description>
		<param name="name" type="str">Name of product to sell.</param>
		<param name="image" type="uri" optional="true">Custom button image.</param>
		<return>
			<html xmlns:eval="http://mindtouch.com/2007/dekiscript">
				<body>
					<eval:if test="!config['price'][args.name]">Product name "<eval:expr>args.name</eval:expr>" doesn't exist.  Please check your configuration.</eval:if>
					<eval:if test="config['price'][args.name]">
						<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
							<input type="hidden" name="cmd" value="_xclick" />
							<input type="hidden" name="business" eval:value="config['email']" />
							<input type="hidden" name="item_name"  eval:value="args.name" />
							<input type="hidden" name="amount" eval:value="config['price'][args.name]" />
							<input type="hidden" name="no_shipping" value="2" />
							<input type="hidden" name="no_note" value="1" />
							<input type="hidden" name="currency_code" value="USD" />
							<input type="hidden" name="bn" value="IC_Sample" />
							<input type="image" eval:src="args.image ?? 'https://www.sandbox.paypal.com/en_US/i/btn/x-click-but21.gif'" name="submit" />
							<img alt="" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" />
						</form>
					</eval:if>
				</body>
			</html>
		</return>
	</function>
</extension>



Samples


Output

To embed the PayPal Buy Now button:

{{ paypal.buynow("wiki") }} 

./paypal buynow.png

To embed the PayPal Donation button:

{{ paypal.donate("wiki") }} 

./paypal donate.png

Tag page
You must login to post a comment.
Powered by MindTouch Deki v.8.08.1