Getting Started with the Code in This Book

The sample code in this book should serve as a good jumping-off point for however you want to use each hack in the real world. To that end, PayPal Hacks provides real code you can type in and run yourself.

PayPal's home is the Web, a heterogeneous place governed by well-defined standards. The concepts presented in this book work with any programming language or platform you might be using with your web site. However, the example code is primarily kept to three language and platform combinations, each inhabiting its own niche of the Internet ecology: server-side scripting, client-side (browser) scripting, and desktop applications.

Server-Side Scripting

Server-side scripts are installed on a web server. When a user requests a web page that contains a server-side script, the script is processed on the web server and its output is converted to HTML and delivered to the end user's web browser.

Most of the hacks in this book that involve server-side scripting are written in VBScript (Visual Basic Script), which runs on a web server with support for Microsoft Active Server Pages (ASP). The ASP/VBScript combination is one of the most popular platforms among webmasters and developers using Microsoft systems. Microsoft's newest web platform, ASP.NET, is growing rapidly; it is backward-compatible and will also run ASP/VBScript code.

You can host the VBScript examples using a modern Microsoft operating system, such as Microsoft Windows XP Professional, Microsoft Windows 2000 Professional, or Microsoft Windows 2003 Server. Each of these products comes with Microsoft's Internet Information Server (IIS), an ASP-capable web server. In practice, you might not have (or desire to set up) your own web server; many ISPs offer affordable (or free) space on preconfigured web servers that are capable of hosting ASP/VBScript.

To create ASP/VBScript pages, simply type them into your favorite text editor, whether you're using Microsoft's default Notepad or the powerful Vim editor, which is popular amongst Unix jocks. If you're already using an ASP-compatible web site editor, such as Dreamweaver or Microsoft Visual Studio, you can use that instead. Once you have created your ASP/VBScript pages, upload them to your web server (typically via FTP) and view them with your web browser. (The steps to do this vary; check with your ISP for specific instructions.)

To browse ASP/VBScript pages, you (or your customers) need only an ordinary web browser, such as Internet Explorer, Netscape Navigator, Mozilla, Opera, or even Lynx. You will, however, need to know the URLs of your ASP/VBScript pages (e.g., If you host the pages on the same computer as your web browser, the URL will likely start with http://localhost/. Because the VBScript is processed on the web server that turns it into HTML, your (or your customer's) web browser does not need any VBScript capabilities.

Although many of the hacks in this book are written in ASP/VBScript, Perl, Python, PHP, Java, and Cold Fusion are all good choices for developing eCommerce web pages that use PayPal as a payment method. No exotic features unique to VBScript are used, so the concepts and examples should readily translate to your favorite platform.

Client-Side (Browser) Scripting

Browser, or client-side, scripts are embedded in the HTML of the web page and are executed by the browser. The first and still most popular browser scripting technology is JavaScript. Since its introduction, JavaScript has been cloned by Microsoft (their offering is called JScript) and standardized by an international standards organization (resulting in ECMAScript). The bland flavor of JavaScript/JScript/ECMAScript used in the examples should be palatable to all modern JavaScript-capable browsers.

To try the JavaScript examples, you need only a text editor, such as Microsoft Notepad or VIM, or some other HTML authoring tool, such as Microsoft FrontPage, Macromedia Dreamweaver, NetObjects Fusion, or Adobe GoLive. Save your JavaScript-laden HTML pages to your computer's hard drive and view them in any modern browser with JavaScript support enabled.

Desktop Applications

The examples provided with PayPal's API hacks involve the building of desktop applications. Although they use the Internet and HTTP to access the PayPal API, these are standalone applications designed to work on your Windows desktop (as opposed to working from within a web browser).

While you can access the PayPal API from within any programming language that supports SOAP (.NET, Java, Perl, PHP), the examples in this book are all written in C# and require the Microsoft .NET Framework. To try these examples yourself, you need to first compile them with a C# development environment, such as Microsoft Visual Studio .NET or Borland C#Builder. (You can't use an older version of Visual Studio, because it won't support SOAP or .NET). To run the examples, you (and your employees or customers) need Microsoft's .NET Framework 1.1 installed on each computer on which your application is to run. The .NET framework is installed by default on Microsoft Windows XP and is freely available for previous versions of Windows, such as Windows 2000, from