ppext Event based wrapper for PayPal IPN, PDT and button manager

  1. Requirements
  2. Installation
  3. Usage
  4. Resources
  5. Change log
  6. Todo

Event based wrapper for PayPal IPN, PDT and button manager (NVP).

  • Manage buttons (PPButtonManager)
  • Process PDT events (PPPdtAction)
  • Process IPN events (PPInpAction)
  • Logging via Yii::log()


  • Yii 1.1 or above
  • curl
  • PHP 5.3 (only PPDefaultController, which is an example, use PPDefaultLegacyController for PHP 5.2+)


  • Extract into WebRoot/protected/modules/payPal

  • Edit WebRoot/protected/config/main.php and add the following

            'username'=>'Your PayPal API username',
            'password'=>'Your PayPal API password',
            'signature'=>'Your PayPal API signature',
            'email'=>'Your PayPal email address',
            'identityToken'=>'Your PayPal identity token',
  • If you enabled PPDbButtonManager, use WebRoot/protected/modules/payPal/data/ppbm.sql to create the database schema.


  • Take a look at WebRoot/protected/modules/payPal/controllers/PPDefaultController for an example on IPN and PDT listeners (payment processing).

  • Take a look at WebRoot/protected/modules/payPal/controllers/TestController for an example on the button manager (actually just test code, but it should give you a good idea of how it works).

PPPhpButtonManager should only be used for installation scripts and similar. PPDbButtonManager can be used to dynamically create buttons at any time (including installation scripts).

Example: Creating a "Buy Now" button

$buttonManager = Yii::app()->getModule('payPal')->buttonManager;
$buttonManager->createButton("My button", array('BUTTONTYPE'=>'BUYNOW'));

Example: PDT listener (IPN listeners are pretty much identical):

public function actionPdt() {
    $pdt = new PPPdtAction($this, "pdt");
    $pdt->onRequest = array($this, "pdtRequest");
    $pdt->onSuccess = array($this, "pdtSuccess");
    $pdt->onFailure = array($this, "pdtFailure");

public function pdtRequest($event) {
    // Just invoking a success event, processing done by IPN listener

public function pdtSuccess($event) {
    // Notify user about successfull payment
    $str = "Success<br />";
    foreach ($event->details as $k => $v)
        $str.="$k => $v<br />";

public function pdtFailure($event) {
    // Notify user about failed payment

All examples included in the source files are tested and functional in the sandbox, unless otherwise stated in example files.

Most classes and methods are documented using PHPDoc.


Forum thread

Change log

Version 0.4 (2010-11-02)
  • Moved txn_id check from PPIpnAction::run() to PPDefaultController and PPDefaultLegacyController
Version 0.3 (2010-10-29)
  • PPhpButtonManager: Changed createNewButtonModel() from public to protected
  • Implemented PPDbButtonManager
  • Renamed controllers to include PP prefix
  • Implemented PPDbButtonManager
  • Implemented PPDefaultLegacyController for PHP 5.2+
Version 0.2 (2010-10-28)
  • All IPN and PDT events are logged (success and failure)
  • Moved ipnRequest and pdtRequest from PPUtils into IPN- and PDT actions
  • Details about events (payments usually) is now stored in PPEvent::details
  • PPIpnAction and PPPdtAction cleaned up and tested
  • DefaultController (IPN and PDT example) cleaned up and tested
  • Updated documentation


  • Make 5.2+ compatible
  • Helper methods for common buttons
  • Standard payment processing methods (validating payment status, saving transactions in DB, ..)?
12 0
3 795 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Web Service
Tags: ipn, paypal, pdt, ppext
Developed by: stianlik
Created on: Oct 28, 2010
Last updated: 12 years ago


show all

Related Extensions