Table of Contents Previous Next Index

The PHP SDK for the SOAP API

The PHP SDK for the SOAP API
The SDK is composed of API Services and user profiles that define characteristics of the users of those services. This section includes the following topics:
l
l
l
l
l
l
l
This chapter details the software and hardware supported and required by the PayPal SDK and its installation.
Configuring PHP and Apache for the SDK
The PHP SDK relies on the following required PHP packages:
l
l
l
l
Configure PHP and Apache as follows to use the PayPal SDK:
1.
2.
3.
# For PHP 4 do something like this:
LoadModule php4_module "c:/php/php4apache2.dll"
# Don't forget to copy the php4apache2.dll file from the sapi directory!
AddType application/x-httpd-php .php
# For PHP 5 do something like this:
LoadModule php5_module "c:/php/php5apache2.dll"
AddType application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "C:/php"
Go to your PHP installation directory and edit the php.ini file. Find extensions section, and uncomment (remove the semicolons at the beginning) the following two lines:
;extension=php_curl.dll
;extension=php_openssl.dll
4.
php –info
Supported Standards
The PayPal SDK has been verified to work with the following standards.
Table D.1
Supported Human Languages
The PayPal SDK is available in U.S. English.
SDK Version Number
This guide describes PayPal PHP SDK version 4.3.1.
Downloading and Installing the SDK
The latest version of the PayPal SDK is available at https://www.paypal.com/sdk.
Be sure you have configured PHP and your web server as detailed in “Configuring PHP and Apache for the SDK”.
You can install the SDK on a local computer or on a remote computer.
Installing on Local Computer
Follow these steps to install the SDK on your local computer.
1.
2.
unzip paypal_php_sdk.zip
tar vxf paypal_php_sdk.tar
tar vxfz paypal_php_sdk.tar.gz
3.
cd install_dir\php-sdkphp install.php
4.
When you are prompted for your target web directory, enter the name of your PHP web directory. The target directory must be under the document root of the PHP server.
Installing on Remote Computer from Microsoft Windows
You can install the SDK to a remote computer that runs an FTP server.You need to know the following information to complete the remote installation:
l
l
l
l
Follow these steps to install the SDK on your local computer.
1.
2.
unzip paypal_php_sdk.zip
tar vxf paypal_php_sdk.tar
tar vxfz paypal_php_sdk.tar.gz
3.
cd install_dir\php-sdk
remote_intall.bat
4.
Example Remote Installation
C:\php-sdk>remote_install.bat
This installer will overwrite any existing files in the target directory. To cancel, press Control-C and then Y.
Press any key to continue . . .
Enter the FTP server to install on: yourDomainName
Username for FTP: yourFTPusername
Password for FTP: yourFTPpassword
Please enter the path (relative to your FTP root) for the paypal-php-sdk directory: yourRemoteInstallDirectory
Please enter the path (relative to your FTP root) for the paypal-sdk-samples directory: yourRemoteInstallDirectoryInThePHPDocumentRoot
SDK Directories and Configuration Files
The PHP SDK components are organized into different subdirectories, as shown below”
APIProfile and EWPProfile implementations and the ProfileHandler definitions, with two deafult profile handlers: ProfileHandler_File and ProfileHandler_Array.
Auto-generated data type files from which the PayPal type classes inherit, and two parent classes: XSDType and XSDSimpleType.
Configuration File
The PayPal SDK is distributed with the configuration properties file SDK_root/lib/PayPal/conf/paypal-sdk.php.dist.
If you want to change the configuration, copy this file to:
SDK_root/lib/PayPal/conf/paypal-sdk.php
SDK Logging
The PayPal SDK uses PEAR’s logging capability.
Setting Log Levels
The SDK varies the amount of detail it logs according to three logging levels.
Set the value of the log_level parameter in the SDK_root/lib/PayPal/conf/paypal-sdk.php file.
Table D.4
Because SOAP requests and responses are asynchronous, the recording of requests and responses might appear out of sequence in the log file.
Because DEBUG logging can degrade the performance of the SDK, be careful about using it for day-to-day operation.
Table D.5
Full text of SOAP requests and responses and other debugging messages. Because DEBUG logging can degrade the performance of the SDK, be careful about using it for day-to-day operation.
Note:
Because SOAP requests and responses are asynchronous, the recording of requests and responses might appear out of sequence in the log file.
Logfile Location
In the log_dir parameter, set the name of the directory where the SDK should write its logfile.
API Services
Integrated access to the PayPal Web Services APIs is one of the main features of the PayPal SDK. As shown in Figure D.1, “PayPal SDK API Services: High-Level View”, the PayPal SDK uses the underlying platform’s SOAP toolkit to communicate with the PayPal API endpoint. Stub classes representing the requests, the responses, and their data are provided to set request parameters and read response values. These classes are auto-generated from the PayPal WSDL file.
Figure D.1
Profiles
Before the SDK can be used, it must know the profile of the user accessing its services. A profile is a collection of information about a merchant or developer who uses the PayPal SDK. An API profile is associated with API Services and includes:
l
l
l
l
l
An EWP profile is associated with EWP Services includes:
l
l
l
l
l
For more information about how EWP works, see the Website Payments Standard Integration Guide.
Overview to Profile-related Classes
The primary interfaces and classes for SDK profiles are described below.
This class defines the basic information that PayPal needs to know about a user of the PayPal Web Service APIs. Developers must create an instance of APIProfile for each account that accesses the APIs. For single-merchant developers, only a single APIProfile instance is needed. PayPal provides a default implementation suitable for the needs of most SDK developers. However, you are free to write a custom implementation if you need additional functionality the default class does not offer.
The ProfileHandler class manages the storage and retrieval of APIProfile and EWPProfile objects. PayPal provides two basic implementations: ProfileHandler_Array and ProfileHandler_File to serialize and deserialize the data in profiles to and from a file on the disk.
Sample Applications
The PayPal SDK includes sample applications in the SDK_root/samples. The sample applications are divided into two groups:
1.
2.
Sample API User with API Signature
The samples come with an API Signature for use with the SDK and the PayPal Sandbox. This API Signature belongs to the following user:
A‑IzJhZZjhg29XQ2qnhapuwxIDzyAZQ92FRP5dqBzVesOkzbdUONzmOU
Sample API User and Certificate
The samples come with a PayPal Web Services API digital certificate for use with the SDK and the PayPal Sandbox. This certificate belongs to the following user:
SDK_root\samples\Certs\sdk-seller.p12
Running the Samples
Run the samples by opening the following URL:
http://yourWebServer:port/webDir/paypal_php_samples/
webDir will vary depending on the target PHP Web directory you specified to install.php when you installed the SDK.