Website Payments Standard PHP Toolkit

VERSION 1.0.0

This document describes web samples that use advanced features for Website Payments Standard - including button encryption, Payment Data Transfer (PDT), and Instant Payment Notification (IPN) in the following sections:


Intended audience

The following are examples of Website Payments Standard's advanced features, which include code for its function:

These code samples aren't needed if you don't use these features. PayPal provides easier methods to create payment buttons. Learn more about buttons at https://www.paypal.com/IntegrationCenter/ic_standard_home.html#BuyNowButtons


Required software

The following software is required:

Software

Download Location

PHP 4.3.0 (or Higher)

Download
PayPal supports PHP version 4.3.0 or higher. PayPal recommends that you use the latest version.

PHP OpenSSL Extention


If you plan to use the Encrypted Website Payments (EWP) functionality of the SDK, you will need to install the PHP OpenSSL Extention.

OpenSSL

Download
The PayPal PHP SDK requires you to encrypt your API Certificate into PKCS7 format. This step require the OpenSSL encryption tool.


Installing the WPS PHP Toolkit

Unzip the PayPal_PHP_WPS_Toolkit.zip file, for example to C:\. You will see a paypal_php_wps_toolkit folder created under C:\.


Installing and Running the samples

Follow the instructions of the PayPal WPS Toolkit PHP Samples README file.

The web samples consist of the following:

The default EWP credentials used by these samples are:

Default Business Account: sdk-seller@sdk.com
Cert ID: B62GVU8RWNBFC
Path to EWP certificate: <install_directory>\samples\web\cert\my-pubcert.pem
Path to EWP private key: <install_directory>\samples\web\cert\my-prvkey.pem
Path to PayPal Public: certificate: <install_directory>\samples\web\cert\paypal_cert_pem.txt

The main page of the samples - index.html - contains links to each sample.

 

Creating an encrypted Buy Now button

This sample shows how to dynamically encrypt payment data before sending the request to PayPal

Encrypted Buy Now button Create an encrypted Buy Now button and complete payment on PayPal

The primary files for this sample are:

File

Description

InputButtonParameters.php

This page collects payment parameters for the Buy Now button to be generated by encryption.

Called by index.html.

Calls BuyNow.php.

BuyNow.php

This page generates the encrypted BuyNow button using payment parameters collected through the InputButtonParameters.php page.

The code collects Buy Now parameters from the form displayed by InputButtonParameters.php then constructs Buy Now button by calling encryptButton method of the EWPServices class supplied with the toolkit.

After the button parameters are signed and encrypted using the sdk-ewp-cert.pem certificate, the sdk-ewp-key.pem key, and the sandbox-cert.pem; the BuyNow button is displayed with the encrypted BLOB.

Called by InputButtonParameters.php.

uses EWPServices class which in turn uses PPCrypto class. The encryption is done using PHP OenSSL Extention functions.

PDTResponse.php

This page gets the PDT Get Parameters of the PDT transaction, and posts back the same to get the status of the Website Payments Standard transaction

Called by PayPal to give notification about the Website Payment Standard transaction status.

Credentials.php This page shows the credentials used for encrypting the Buy Now button.
IPNListner.php This handler file listen for the IPN postback from the PayPal server, and logs a message in the IPN log file.

 

Common files

File

Description

index.html

The main web page with links to each sample.

Calls InputButtonParameters.php, paypal-ipn.log, and Credentials.php.

sdk.css Cascading Style Sheet (CSS) used by all sample pages.
utility.php

This is the configuration file for the samples.This file contains the parameters needed to encrypt the Buy Now button parameters.

PayPal includes the following EWP credentials for encrypting the Buy Now button:

EWP credentials

Default Business Account sdk-three_api1.sdk.com
Default Email Account sdk.seller@gmail.com
Cert ID B62GVU8RWNBFC
EWP certificate my-pubcert.pem
EWP Private Key my-prvkey.pem
Identity 6vwLEY_ogPGnoQac2a0x4PRsSGrmzJPMkyGbJtpiCSwrkYsNSYxWfPY2ZLO

 

paypal-ipn.log IPN log file - logs all IPN details received through listener with DateTime stamp.

Documentation

The Website Payments Standard Integration Guide is available in PDF format.

PDF https://www.paypal.com/en_US/pdf/PP_WebsitePaymentsStandard_IntegrationGuide.pdf