PHPackages                             hakito/cakephp-paypal-rest-plugin - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. hakito/cakephp-paypal-rest-plugin

ActiveCakephp-plugin[HTTP &amp; Networking](/categories/http)

hakito/cakephp-paypal-rest-plugin
=================================

PayPal plugin for CakePHP using the REST api

v4.0.0(3y ago)74845[3 issues](https://github.com/hakito/CakePHP-PayPalRest-Plugin/issues)GPL-2.0PHP

Since Sep 13Pushed 2y ago2 watchersCompare

[ Source](https://github.com/hakito/CakePHP-PayPalRest-Plugin)[ Packagist](https://packagist.org/packages/hakito/cakephp-paypal-rest-plugin)[ Docs](https://github.com/hakito/CakePHP-PayPalRest-Plugin)[ RSS](/packages/hakito-cakephp-paypal-rest-plugin/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (10)Dependencies (4)Versions (11)Used By (0)

[![Build Status](https://camo.githubusercontent.com/f4eb5bdb5e95b0ef96ce84118368cde4151511f3c9ee38adb60f000a41117abb/68747470733a2f2f6170702e7472617669732d63692e636f6d2f68616b69746f2f43616b655048502d50617950616c526573742d506c7567696e2e7376673f6272616e63683d6d6173746572)](https://app.travis-ci.com/hakito/CakePHP-PayPalRest-Plugin)[![Coverage Status](https://camo.githubusercontent.com/80577f2c3da213fbd55dc2f46faf3f13582a87fd9f8d5579711e862a6f389005/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f68616b69746f2f43616b655048502d50617950616c526573742d506c7567696e2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/hakito/CakePHP-PayPalRest-Plugin?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/06e770540bed9013ba84fa1199675a75f90b61da8de8d91c9b95c801018224ce/68747470733a2f2f706f7365722e707567782e6f72672f68616b69746f2f63616b657068702d70617970616c2d726573742d706c7567696e2f762f737461626c652e737667)](https://packagist.org/packages/hakito/cakephp-paypal-rest-plugin) [![Total Downloads](https://camo.githubusercontent.com/108ed168839d5f8d05ce514d68ab592d1bbd106d665e21d9b8af105f846895f4/68747470733a2f2f706f7365722e707567782e6f72672f68616b69746f2f63616b657068702d70617970616c2d726573742d706c7567696e2f646f776e6c6f6164732e737667)](https://packagist.org/packages/hakito/cakephp-paypal-rest-plugin) [![Latest Unstable Version](https://camo.githubusercontent.com/60bec1807b7d5059b820522d32d5a8187107264faacc308b877a934190c04968/68747470733a2f2f706f7365722e707567782e6f72672f68616b69746f2f63616b657068702d70617970616c2d726573742d706c7567696e2f762f756e737461626c652e737667)](https://packagist.org/packages/hakito/cakephp-paypal-rest-plugin) [![License](https://camo.githubusercontent.com/3ae19dc8568c583c46d8577414d0d743c00ae99ae30a7dbb22952245d0652669/68747470733a2f2f706f7365722e707567782e6f72672f68616b69746f2f63616b657068702d70617970616c2d726573742d706c7567696e2f6c6963656e73652e737667)](https://packagist.org/packages/hakito/cakephp-paypal-rest-plugin)

CakePHP-PayPalRest-Plugin
=========================

[](#cakephp-paypalrest-plugin)

Simple PayPal plugin for CakePHP 4.x using the [REST api (v1)](https://developer.paypal.com/docs/api/payments/v1/).

Installation
------------

[](#installation)

If you are using composer simply add it with:

```
composer require hakito/cakephp-paypal-rest-plugin
```

Load the plugin
---------------

[](#load-the-plugin)

Load the plugin in your bootstrap:

```
public function bootstrap()
{
    // Call parent to load bootstrap from files.
    parent::bootstrap();

    $this->addPlugin(\PayPal\Plugin::class, ['routes' => true]);
}
```

Creating tables
---------------

[](#creating-tables)

Create the database pay\_pal\_payments table with the following command:

```
bin/cake migrations migrate -p PayPal
```

Configuration
-------------

[](#configuration)

You can find a sample configuration in tests/config/PayPal.php. Just override the settings in your own bootstrap.php.

Usage
-----

[](#usage)

Following is the minimal set to start a payment request:

```
class OrdersController extends AppController {

    public function initialize()
    {
        parent::initialize();
        $this->loadComponent('PayPal.PayPal', []);
    }

    public yourPaymentAction($order) {
        foreach ($order['OrderedItem'] as $orderedItem)
        {
            $quantity = $orderedItem['quantity'];
            $price = $orderedItem['price'];
            $itemName = $orderedItem['name'];
            $itemId = $orderedItem['id'];

            // money values are always integer values in cents
            $this->PayPal->AddArticle($itemName, $quantity, $price, $itemId);
        }

        // optional shipping fee
        $this->PayPal->Shipping = 123; // money values are always integer values in cents

        // Url the client is redirected to when PayPal payment is performed successfully
        // NOTE: This does not mean that the payment is COMPLETE.
        $okUrl = Router::url('/paymentOk', true);

        // Url the client is redirected to whe PayPal payment fails or was cancelled
        $nOkUrl = Router::url('/paymentFailed', true);

        return $this->PayPal->PaymentRedirect($order['id'], $okUrl, $nOkUrl);
    }
}
```

To receive the payment notifications in your app the Plugin expects 3 event handlers

```
$payPalPayments = TableRegistry::getTableLocator()->get('PayPal.PayPalPayments');
$eventManager = $payPalPayments->getEventManager();
$eventManager->setEventList(new EventList());

// Will be called just after PayPal redirects the customer
// back to your site. (You could start a transaction here)
$eventManager->on('PayPal.BeforePaymentExecution',
function($event, $remittanceIdentifier)
{
    // Handled is expected to be set to TRUE, otherwise the plugin
    // will throw an exception
    return ['handled' => true];
});

// Will be called when the REST api call fails or
// the saleState != 'completed' or paymentState != 'approved'
// (You could rollback a transaction here)
$eventManager->on('PayPal.CancelPaymentExecution',
function($event, $remittanceIdentifier) {});

// Will be called after the REST api call
// and only if the saleState == 'completed' and paymentState == 'approved'
// (You could commit a transaction here)
$eventManager->on('PayPal.AfterPaymentExecution',
function($event, $remittanceIdentifier) {});
```

To issue a full refund lookup the payment and issue the refund.

```
$payPalPayment = $payPalPayments->findByRemittanceIdentifier($remittanceIdentifier);
$payPalPayments->refundPayment($payPalPayment);
```

Remarks
-------

[](#remarks)

The current implementation does not support automatic handling payments in pending state.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance11

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~325 days

Recently: every ~204 days

Total

10

Last Release

1338d ago

Major Versions

v1.3.0.0 → v2.02020-06-21

v2.0 → v3.02020-07-16

v3.0.0.1 → v4.0.02022-07-23

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/320853?v=4)[Gerd Katzenbeisser](/maintainers/hakito)[@hakito](https://github.com/hakito)

---

Top Contributors

[![hakito](https://avatars.githubusercontent.com/u/320853?v=4)](https://github.com/hakito "hakito (69 commits)")

---

Tags

restcakephppaymentpaypal

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hakito-cakephp-paypal-rest-plugin/health.svg)

```
[![Health](https://phpackages.com/badges/hakito-cakephp-paypal-rest-plugin/health.svg)](https://phpackages.com/packages/hakito-cakephp-paypal-rest-plugin)
```

###  Alternatives

[angelleye/paypal-php-library

PHP wrapper for PayPal APIs

243440.9k](/packages/angelleye-paypal-php-library)[mixerapi/mixerapi

Streamline development of API-first applications in CakePHP

4441.8k](/packages/mixerapi-mixerapi)[cakedc/cakephp-api

Api plugin for CakePHP

61100.6k](/packages/cakedc-cakephp-api)[andrej-griniuk/cakephp-fractal-transformer-view

CakePHP view builder utilizing Fractal library for entities transformation

1890.7k](/packages/andrej-griniuk-cakephp-fractal-transformer-view)[sprintcube/cakephp-rest

Rest API plugin for CakePHP 3

256.6k](/packages/sprintcube-cakephp-rest)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
