PHPackages                             robmcvey/cakephp-paypal - 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. [Payment Processing](/categories/payments)
4. /
5. robmcvey/cakephp-paypal

ActiveCakephp-plugin[Payment Processing](/categories/payments)

robmcvey/cakephp-paypal
=======================

PayPal plugin

1.0.3(11y ago)604443[8 issues](https://github.com/robmcvey/cakephp-paypal/issues)[3 PRs](https://github.com/robmcvey/cakephp-paypal/pulls)PHPPHP &gt;=5.2.8CI failing

Since Apr 13Pushed 6y ago12 watchersCompare

[ Source](https://github.com/robmcvey/cakephp-paypal)[ Packagist](https://packagist.org/packages/robmcvey/cakephp-paypal)[ RSS](/packages/robmcvey-cakephp-paypal/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (5)Used By (0)

Paypal Plugin for CakePHP 2.x
=============================

[](#paypal-plugin-for-cakephp-2x)

[![Build Status](https://camo.githubusercontent.com/04eb988c3e7e14ff2f8cc6204b746f130ffe270fcc6e39a3fea5b02c5ef3effc/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f726f626d637665792f63616b657068702d70617970616c2e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/robmcvey/cakephp-paypal)

A CakePHP plugin to interact with Paypal's "classic" and new REST APIs.

### Requirements

[](#requirements)

- CakePHP 2.x
- A PayPal Website Payments Pro account

### Installation

[](#installation)

*\[Manual\]*

- Download this:
- Unzip that download.
- Copy the resulting folder to `app/Plugin`
- Rename the folder you just copied to `Paypal`

*\[GIT Submodule\]*

In your app directory type:

```
git submodule add -b master git://github.com/robmcvey/cakephp-paypal.git Plugin/Paypal
git submodule init
git submodule update
```

*\[GIT Clone\]*

In your `Plugin` directory type:

```
git clone -b master git://github.com/robmcvey/cakephp-paypal.git Paypal
```

### Usage

[](#usage)

Make sure the plugin is loaded in `app/Config/bootstrap.php`.

```
CakePlugin::load('Paypal');
```

PayPal Classic Methods
----------------------

[](#paypal-classic-methods)

Create an instance of the class with your PayPal credentials. For testing purposes, ensure `sandboxMode` is set to `true`.

```
App::uses('Paypal', 'Paypal.Lib');

$this->Paypal = new Paypal(array(
	'sandboxMode' => true,
	'nvpUsername' => '{username}',
	'nvpPassword' => '{password}',
	'nvpSignature' => '{signature}'
));
```

### SetExpressCheckout

[](#setexpresscheckout)

Create an order(s) in the following format. `setExpressCheckout` will return a string URL to redirect the customer to.

```
$order = array(
	'description' => 'Your purchase with Acme clothes store',
	'currency' => 'GBP',
	'return' => 'https://www.my-amazing-clothes-store.com/review-paypal.php',
	'cancel' => 'https://www.my-amazing-clothes-store.com/checkout.php',
	'custom' => 'bingbong',
	'shipping' => '4.50',
	'items' => array(
		0 => array(
			'name' => 'Blue shoes',
			'description' => 'A pair of really great blue shoes',
			'tax' => 2.00,
			'subtotal' => 8.00,
			'qty' => 1,
		),
		1 => array(
			'name' => 'Red trousers',
			'description' => 'Tight pair of red pants, look good with a hat.',
			'tax' => 1.50,
			'subtotal' => 6.00,
			'qty' => 3,
		),
	)
);
 try {
	$this->Paypal->setExpressCheckout($order);
} catch (Exception $e) {
	// $e->getMessage();
}
```

### GetExpressCheckoutDetails

[](#getexpresscheckoutdetails)

Once the customer has returned to your site (see `return` URL above) you can request their details with the token returned from the `setExpressCheckout` method.

```
try {
	$this->Paypal->getExpressCheckoutDetails($token);
} catch (Exception $e) {
	// $e->getMessage();
}
```

### DoExpressCheckoutPayment

[](#doexpresscheckoutpayment)

Complete the transaction using the same order details. The `$token` and `$payerId` will be returned from the `setExpressCheckout` method.

This method may throw a `PaypalRedirectException` if a user's funding method (the credit card or bank account associated with their PayPal account) needs updating. The exception message will contain a URL to redirect the user to where they will be prompted to update their funding method.

```
$order = array(
	'description' => 'Your purchase with Acme clothes store',
	'currency' => 'GBP',
	'return' => 'https://www.my-amazing-clothes-store.com/review-paypal.php',
	'cancel' => 'https://www.my-amazing-clothes-store.com/checkout.php',
	'custom' => 'bingbong',
	'shipping' => '4.50',
	'items' => array(
		0 => array(
			'name' => 'Blue shoes',
			'description' => 'A pair of really great blue shoes',
			'tax' => 2.00,
			'subtotal' => 8.00,
			'qty' => 1,
		),
		1 => array(
			'name' => 'Red trousers',
			'description' => 'Tight pair of red pants, look good with a hat.',
			'tax' => 1.50,
			'subtotal' => 6.00,
			'qty' => 3,
		),
	)
);

try {
	$this->Paypal->doExpressCheckoutPayment($order, $token, $payerId);
} catch (PaypalRedirectException $e) {
	$this->redirect($e->getMessage());
} catch (Exception $e) {
	// $e->getMessage();
}
```

### DoDirectPayment

[](#dodirectpayment)

Charge a credit card. Ensure you are using SSL and following PCI compliance guidelines.

```
$payment = array(
	'amount' => 30.00,
	'card' => '4008 0687 0641 8697', // This is a sandbox CC
	'expiry' => array(
		'M' => '2',
		'Y' => '2016',
	),
	'cvv' => '321',
	'currency' => 'USD' // Defaults to GBP if not provided
);

try {
	$this->Paypal->doDirectPayment($payment);
} catch (Exception $e) {
	// $e->getMessage();
}
```

### RefundTransaction

[](#refundtransaction)

Refund a transaction. Transactions can only be refunded up to 60 days after the completion date.

```
$refund = array(
	'transactionId' => '96L684679W100181R' 	// Original PayPal Transcation ID
	'type' => 'Partial', 					// Full, Partial, ExternalDispute, Other
	'amount' => 30.00, 						// Amount to refund, only required if Refund Type is Partial
	'note' => 'Refund because we are nice',	// Optional note to customer
	'reference' => 'abc123',  				// Optional internal reference
	'currency' => 'USD'  					// Defaults to GBP if not provided
);

try {
	$this->Paypal->refundTransaction($refund);
} catch (Exception $e) {
	// $e->getMessage();
}
```

PayPal REST Methods
-------------------

[](#paypal-rest-methods)

Create an instance of the class with your PayPal credentials, including your client ID and secret key For testing purposes, ensure `sandboxMode` is set to `true`.

```
App::uses('Paypal', 'Paypal.Lib');

$this->Paypal = new Paypal(array(
	'sandboxMode' => true,
	'nvpUsername' => '{username}',
	'nvpPassword' => '{password}',
	'nvpSignature' => '{signature}',
	'oAuthClientId' => '{client ID}',
	'oAuthSecret' => '{secret key}',
));
```

### Store card in vault

[](#store-card-in-vault)

You can store a customer's card in the vault, in return for a token which can be used for future transactions.

```
$creditCard = array(
	'payer_id' => 186,
	'type' => 'visa',
	'card' => 'xxxxxxxxxxxx8697',
	'cvv2' => 232,
	'expiry' => array(
	    'M' => '2',
        'Y' => '2018',
    ),
	'first_name' => 'Joe',
	'last_name' => 'Shopper'
);

try {
	$this->Paypal->storeCreditCard($creditCard);
} catch (Exception $e) {
	// $e->getMessage();
}
```

### Charge a stored card

[](#charge-a-stored-card)

Once a card is stored in the vault, you can make a charge(s) on that card using the token issued when it was first stored.

```
$cardPayment = array(
	'intent' => 'sale',
	'payer' => array(
		'payment_method' => 'credit_card',
		'funding_instruments' => array(
			0 => array(
				'credit_card_token' => array(
					'credit_card_id' => 'CARD-39N7854321M2DDC2',
					'payer_id' => '186'
				)
			)
		)
	),
	'transactions' => array(
		0 => array(
			'amount' => array(
				'total' => '0.60',
				'currency' => 'GBP',
				"details" => array(
					"subtotal" => "0.50",
					"tax" => "0.10",
					"shipping" => "0.00"
		        )
			),
			'description' => 'This is test payment'
		)
	)
);

try {
	$this->Paypal->chargeStoredCard($cardPayment);
} catch (Exception $e) {
	// $e->getMessage();
}
```

PayPal Adaptive Payments
------------------------

[](#paypal-adaptive-payments)

Create an instance of the class with your PayPal credentials, including your Adaptive App ID and Adaptive username. For testing purposes, ensure `sandboxMode` is set to `true`.

```
App::uses('Paypal', 'Paypal.Lib');

$this->Paypal = new Paypal(array(
	'sandboxMode' => true,
	'nvpUsername' => '{username}',
	'nvpPassword' => '{password}',
	'nvpSignature' => '{signature}',
	'adaptiveAppID' => '{adaptive app id}',
	'adaptiveUserID' => '{adaptive user id}'
));
```

### GetVerifiedStatus

[](#getverifiedstatus)

The GetVerifiedStatus API operation lets you determine whether the specified PayPal account's status is verified or unverified.

```
try {
	$this->Paypal->getVerifiedStatus('hello@gmail.com')
} catch (Exception $e) {
	// $e->getMessage();
}
```

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community24

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 90% 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

Unknown

Total

1

Last Release

4111d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/782eb48d307c924bc056b0643684ad25ef594326faee0d859527c0dca15d6f48?d=identicon)[ajibarra](/maintainers/ajibarra)

---

Top Contributors

[![robmcvey](https://avatars.githubusercontent.com/u/222958?v=4)](https://github.com/robmcvey "robmcvey (108 commits)")[![ajibarra](https://avatars.githubusercontent.com/u/794722?v=4)](https://github.com/ajibarra "ajibarra (3 commits)")[![MichaelHoughton](https://avatars.githubusercontent.com/u/5341149?v=4)](https://github.com/MichaelHoughton "MichaelHoughton (2 commits)")[![mikkelson](https://avatars.githubusercontent.com/u/5843723?v=4)](https://github.com/mikkelson "mikkelson (2 commits)")[![josegonzalez](https://avatars.githubusercontent.com/u/65675?v=4)](https://github.com/josegonzalez "josegonzalez (1 commits)")[![zot24](https://avatars.githubusercontent.com/u/678498?v=4)](https://github.com/zot24 "zot24 (1 commits)")[![fafa973](https://avatars.githubusercontent.com/u/6897831?v=4)](https://github.com/fafa973 "fafa973 (1 commits)")[![timstermatic](https://avatars.githubusercontent.com/u/3831380?v=4)](https://github.com/timstermatic "timstermatic (1 commits)")[![maxxer](https://avatars.githubusercontent.com/u/240201?v=4)](https://github.com/maxxer "maxxer (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/robmcvey-cakephp-paypal/health.svg)

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

###  Alternatives

[pagseguro/php

Biblioteca de integração com o PagSeguro

23260.3k6](/packages/pagseguro-php)[msilabs/bkash

bKash Payment Gateway API for Laravel Framework.

182.2k](/packages/msilabs-bkash)[xfoxawy/2checkout

2Checkout API Service Provider

101.1k](/packages/xfoxawy-2checkout)

PHPackages © 2026

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