PHPackages                             jlkaufman/cakephp-paypal-rest-client - 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. jlkaufman/cakephp-paypal-rest-client

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

jlkaufman/cakephp-paypal-rest-client
====================================

This plugin is a full REST client for Paypal's API. It implements all of the functions available through the Paypal REST API.

v0.1-alpha(11y ago)02771[1 issues](https://github.com/jlkaufman/cakephp-paypal-rest-client/issues)FreeBSD LicensePHPPHP &gt;=5.3.0

Since Oct 5Pushed 11y ago1 watchersCompare

[ Source](https://github.com/jlkaufman/cakephp-paypal-rest-client)[ Packagist](https://packagist.org/packages/jlkaufman/cakephp-paypal-rest-client)[ Docs](http://jlkaufman.github.io/cakephp-paypal-rest-client)[ RSS](/packages/jlkaufman-cakephp-paypal-rest-client/feed)WikiDiscussions master Synced today

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

\#CakePHP Paypal REST Client (PaypalSource)

### Introduction

[](#introduction)

This plugin is a full REST client for Paypal's API. It implements all of the functions available through the Paypal REST API.

Instead of using CURL, CakePHP's HTTPSocket class is used.

#### Disclaimer

[](#disclaimer)

*Alpha Version... Probably a good idea not to use this in production yet...*

### Documentation: Table of Contents

[](#documentation-table-of-contents)

1. [Installation](#installation)
2. [Configuration](#configuration)
3. [Usage](#usage)
    - [Including the Paypal Model in your controller](#including-the-paypal-model-in-your-controller)
    - [Notes about response returned](#notes-about-response-returned)
    - [Credit Card Payment](#credit-card-payment)
    - [Capture an Authorization](#capture-an-authorization)
    - [Void an Authorization](#void-an-authorization)
    - [Refund a sale](#refund-a-sale)

#### Installation

[](#installation)

1. Clone the repository into the `app/Plugins/PaypalSource` directory

```
cd app/Plugins
git clone https://github.com/jlkaufman/cakephp-paypal-rest-client.git PaypalSource

```

2. Install with *composer*

```
require": {
    "jlkaufman/cakephp-paypal-rest-client": "0.1-alpha"
}

```

#### Configuration

[](#configuration)

In `database.php` add the following block and fill it out accordingly:

```
// Paypal
	public $Paypal = array(
		'datasource'     => 'PaypalSource.PaypalSource',
		'environment'    => 'sandbox', // Production: 'production'   SandBox: 'sandbox'
		'username'       => '',
		'password'       => '',
		'receiver_email' => ''
	);

```

### Usage

[](#usage)

#### Including the Paypal Model in your controller

[](#including-the-paypal-model-in-your-controller)

- Add `PaypalSource.Paypal` to your $uses array.
    *E.g.:* `public $uses = array('PaypalSource.Paypal');`

    You can now call the model with `$this->Paypal->method();` from your controller.

#### Notes about response returned

[](#notes-about-response-returned)

All the methods in the Paypal class will return an instance of StdClass. In the documentation we show the object in JSON form, simply for readability. You can access each member of the object using arrow notation.

#### Credit Card Payment

[](#credit-card-payment)

Credit card payments are easy to create. We can do one of two things; we can create a sale (a final payment), or we can authorize an amount that we will capture later.

- $data will contain all the information we're going to send to Paypal

Credit Card:

```
$data = array(
	'credit_card' => array(
		"number"       => "4417119669820331",
		"type"         => "visa",
		"expire_month" => 1,
		"expire_year"  => 2018,
		"cvv2"         => "874",
		"first_name"   => "Joe",
		"last_name"    => "Shopper"
	),
	'billing_address' => array(
		"line1"        => "52 N Main ST",
		"line2"        => "Apt. 211",
		"city"         => "Johnstown",
		"country_code" => "CA",
		"postal_code"  => "H0H 0H0",
		"state"        => "Quebec"
	),
	'transaction' => array(
		"amount" => array(
			"total"    => "7.47",
			"currency" => "USD",
			"details"  => array(
				"subtotal" => "7.41",
				"tax"      => "0.03",
				"shipping" => "0.03"
			)
		),
		"description" => "This is the payment transaction description."
	)
);

$response = $this->Paypal->creditCardPayment($data, $type);

```

Credit Card Token:

```
$data = array(
	'credit_card_token' => array(
		"credit_card_id" => "CARD-7VH15004HC811510SKEGDHDI"
	),
	'transaction' => array(
		"amount" => array(
			"total"    => "7.47",
			"currency" => "USD",
			"details"  => array(
				"subtotal" => "7.41",
				"tax"      => "0.03",
				"shipping" => "0.03"
			)
		),
		"description" => "This is the payment transaction description."
	)
);

$response = $this->Paypal->creditCardPayment($data, $type);

```

- $type can either be `authorization` or `sale`
    `sale`: A final sale, and will complete the transaction
    `authorization`: Authorize the card for the amount specified. We will have to capture the payment later.

##### Example response

[](#example-response)

```
{
   "id": "PAY-30J08441N2038343CKLJHKEA",
   "status": "approved",
   "created": "2014-01-12 10:57:20",
   "modified": "2014-01-12 10:57:29",
   "payment_method": "credit_card",
   "type": "authorize",
   "payer": {
      "billing_address": {
         "line1": "52 N Main ST",
         "line2": "Apt. 211",
         "city": "Johnstown",
         "state": "Quebec",
         "postal_code": "H0H 0H0",
         "country_code": "CA"
      },
      "credit_card": {
         "type": "visa",
         "number": "xxxxxxxxxxxx0331",
         "expire_month": "1",
         "expire_year": "2018",
         "first_name": "Joe",
         "last_name": "Shopper"
      },
      "id": "",
      "email": ""
   },
   "approval_url": "",
   "transaction": {
      "amount": {
         "total": "7.47",
         "currency": "USD",
         "details": {
            "subtotal": "7.41",
            "tax": "0.03",
            "shipping": "0.03"
         }
      },
      "description": "This is the payment transaction description.",
      "sale": {
         "id": "",
         "parent_id": ""
      },
      "authorization": {
         "id": "10V50318J8770814T",
         "created": "2014-01-12 10:57:20",
         "parent_id": "PAY-30J08441N2038343CKLJHKEA"
      }
   },
   "error": {
      "code": false
   }
}

```

#### Capture an Authorization

[](#capture-an-authorization)

To capture an authorization one must create the [Authorization](#credit-card-payment) (Credit Card Payment with $type set to `authorization`) and get the Authorization ID from the response.

Here's an example of capturing an authorization:

```
$capture_data = array(
	'authorization_id' => '10V50318J8770814T',
	'currency'         => 'USD',
	'total'            => '7.47',
	'is_final_capture' => true
);

$response = $this->Paypal->captureAuthorization($data);

```

- `authorization_id` is stored in the response object returned by `Paypal::creditCardPayment()` in `$response->transaction->authorization->id`

##### Example Capture Response

[](#example-capture-response)

```
{
   "id": "2E448764JU789501Y",
   "status": "completed",
   "created": "2014-01-12 10:57:30",
   "modified": "2014-01-12 10:57:42",
   "payment_method": null,
   "type": "capture",
   "payer": {
      "billing_address": {
         "line1": "",
         "line2": "",
         "city": "",
         "country_code": "",
         "postal_code": "",
         "state": ""
      },
      "credit_card": {
         "number": "",
         "type": "",
         "expire_month": "",
         "expire_year": "",
         "first_name": "",
         "last_name": ""
      },
      "id": "",
      "email": ""
   },
   "approval_url": "",
   "transaction": {
      "amount": {
         "total": "7.47",
         "currency": "USD"
      },
      "description": null,
      "sale": {
         "id": "",
         "parent_id": ""
      },
      "authorization": {
         "id": "",
         "created": ""
      }
   },
   "error": {
      "code": false
   }
}

```

#### Void an Authorization

[](#void-an-authorization)

There are all sorts of reasons one would void an authorization (client canceled the transaction, some other reason that would mean you shoudln't be charging them, whatever).

To void an authorization one must create the [Authorization](#credit-card-payment) (Credit Card Payment with $type set to `authorization`) and get the Authorization ID from the response.

Here's an example of voiding an authorization:

```
$data = array(
	'authorization_id' => '2073151243457584H'
);

$response = $this->Paypal->voidAuthorization($data);

```

- `authorization_id` is stored in the response object returned by `Paypal::creditCardPayment()` in `$response->transaction->authorization->id`

##### Example Response

[](#example-response-1)

```
{
   "id": "2073151243457584H",
   "status": "voided",
   "created": "2014-01-12 14:36:48",
   "modified": "2014-01-12 14:37:00",
   "payment_method": null,
   "type": null,
   "payer": {
      "billing_address": {
         "line1": "",
         "line2": "",
         "city": "",
         "country_code": "",
         "postal_code": "",
         "state": ""
      },
      "credit_card": {
         "number": "",
         "type": "",
         "expire_month": "",
         "expire_year": "",
         "first_name": "",
         "last_name": ""
      },
      "id": "",
      "email": ""
   },
   "approval_url": "",
   "transaction": {
      "amount": {
         "total": "7.47",
         "currency": "USD",
         "details": {
            "subtotal": "7.41",
            "tax": "0.03",
            "shipping": "0.03"
         }
      },
      "description": null,
      "sale": {
         "id": "",
         "parent_id": ""
      },
      "authorization": {
         "id": "",
         "created": ""
      }
   },
   "error": {
      "code": false
   }
}

```

#### Refund a sale

[](#refund-a-sale)

Sometimes it's necessary to refund a transaction. To refund a sale one must first create the [Sale](#credit-card-payment) (Credit Card Payment with $type set to `sale`) and get the Sale ID from the response.

```
$data = array(
	'payment_id' => '3XX41928KR179661L',
	'currency'   => 'USD',
	'total'      => '7.47'
);

$response = $this->Paypal->refundPayment($data);

```

- `payment_id` is stored in the response object returned by `Paypal::creditCardPayment()` in `$response->transaction->sale->id`

##### Example Response

[](#example-response-2)

```
{
   "id": "7FN74449PP796325P",
   "status": "completed",
   "created": "2014-01-13 16:31:24",
   "modified": "2014-01-13 16:31:24",
   "payment_method": null,
   "type": "refund",
   "payer": {
      "billing_address": {
         "line1": "",
         "line2": "",
         "city": "",
         "country_code": "",
         "postal_code": "",
         "state": ""
      },
      "credit_card": {
         "number": "",
         "type": "",
         "expire_month": "",
         "expire_year": "",
         "first_name": "",
         "last_name": ""
      },
      "id": "",
      "email": ""
   },
   "approval_url": "",
   "transaction": {
      "amount": {
         "total": "7.47",
         "currency": "USD"
      },
      "description": null,
      "sale": {
         "id": "",
         "parent_id": ""
      },
      "authorization": {
         "id": "",
         "created": ""
      }
   },
   "error": {
      "code": false
   }
}

```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

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

4234d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/119e3667ac35312e685ad81ecc298d4910e96e46c01a9c2e956a21238e0d53c7?d=identicon)[jlkaufman](/maintainers/jlkaufman)

---

Top Contributors

[![jlkaufman](https://avatars.githubusercontent.com/u/53496276?v=4)](https://github.com/jlkaufman "jlkaufman (1 commits)")[![jubaleth](https://avatars.githubusercontent.com/u/1205712?v=4)](https://github.com/jubaleth "jubaleth (1 commits)")

### Embed Badge

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

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

###  Alternatives

[wp-pay-extensions/gravityforms

Gravity Forms driver for the WordPress payment processing library.

1133.3k2](/packages/wp-pay-extensions-gravityforms)

PHPackages © 2026

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