PHPackages                             drewdan/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. drewdan/paypal

ActiveLibrary[Payment Processing](/categories/payments)

drewdan/paypal
==============

A simple Paypal Client for the V2 API

v3.1.1(2y ago)410.6k↑1200%2[2 issues](https://github.com/Drewdan/paypal/issues)MITPHPPHP ^8.2

Since Mar 14Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Drewdan/paypal)[ Packagist](https://packagist.org/packages/drewdan/paypal)[ RSS](/packages/drewdan-paypal/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (15)Used By (0)

Laravel Paypal V2 Rest Client
=============================

[](#laravel-paypal-v2-rest-client)

This laravel package creates an interface with the PayPal API by generating API requests using the assorted classes available.

I built this package, because at the time, I could not find a suitable package to do what I wanted (though this might be due to poor Google skills.) - so I built this.

The documentation for the API which this package uses can be found here:

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

[](#installation)

This is best installed by composer:

```
composer require drewdan/paypal

```

Publish the config files using the following command

```
php artisan vendor:publish --tag=drewdan-paypal-config

```

Orders
------

[](#orders)

The orders class is the class you would use to create and capture payments from customers.

### Creating an Order

[](#creating-an-order)

```
use Drewdan\Paypal\Services\Orders\Order;

$order = new Order;

$purchaseUnits = [
	[
		'amount' => [
		    'currency_code' => 'GBP',
		    'value' => 12.50,
	    ],
    ],
];

$applicationContext = [
    'brand_name' => 'My Online Shop',
    'shipping_preference' => 'NO_SHIPPING',
    'user_action' => 'PAY_NOW',
    'return_url' => 'https://localhost/return',
    'cancel_url' => 'https://localhost/cancel',
];

$paypalOrder = $order->create($purchaseUnits, 'CAPTURE', $applicationContext);

return redirect($paypalOrder->getLinkByRel('approve')->href);

```

The above snippet will create a PayPal Order with a value of £12.50 and return an instance of PaypalOrder. This object contains a helper method to access the PayPal Links returned from the request. You can use this to redirect the user to PayPal to make payment.

The parameter for the application context can be found [https://developer.paypal.com/docs/api/orders/v2/#definition-order\_application\_context](https://developer.paypal.com/docs/api/orders/v2/#definition-order_application_context)

This will authorize the payment, but not capture it. To capture a payment, you will need the Order ID which will be passed in a get request when the user is redirected back. You can use whatever mechanism fits your application to track this Order ID.

### Capturing a Payment

[](#capturing-a-payment)

```
use Drewdan\Paypal\Services\Orders\Order;

$order = new Order;
//first retrieve the order from Paypal
$paypalOrder = $order->show(request()->PayerID);

//here you could do any validation you wish to verify the order is correct, checking the order amount etc before capturing the payment

$order->capture($paypalOrder);

```

Once this is complete, you will have captured the payment.

Captures
--------

[](#captures)

### Refunding a captured payment

[](#refunding-a-captured-payment)

After payment has been completed, you might sometimes need to refund the payment, if for example, you are unable to fulfil the order. The captures class has the ability to show an existing captured payment, or refund it.

The refund method accepts the following parameters:

ParameterTypeRequiredDescriptioncaptureIdstringTrueThis is the capture ID, used to identify the capture to provide the refund againstamountfloatTrueThis is amount you wish to refund.currencystringfalseThis is the currency in which the refund os given. Defaults to GBPreasonstringfalseYou can optionally provide a reason for the refund which will be displayed to the customerinvoiceIdstringfalseYou can optionally provide an invoice ID if applicable```
use Drewdan\Paypal\Services\Payments\Captures;

$client = new Captures;

$capture = $client->refund('captureId', 5.99, 'GBP', 'Some reason', 'Invoice 123');

```

### Showing a captured payment

[](#showing-a-captured-payment)

This call will show the details of a captured payment. They are retrieved via their capture ID. Ideally, when you take and capture a payment you would store the capture ID in a database against a given order, so you can reference it in future to make refunds or view details about the capture.

```
use Drewdan\Paypal\Services\Payments\Captures;

$client = new Captures;

$capture = $client->show('captureId');

```

Contributing
------------

[](#contributing)

Contributions are welcome, if you have anything you'd like to add, please open a Pull Request. If you find a bug or other issue with this package, please open an issue on the repo.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity73

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 ~95 days

Recently: every ~246 days

Total

13

Last Release

745d ago

Major Versions

v0.1.0 → v1.0.02021-07-11

v1.2.1 → v2.0.02022-12-07

v2.0.0 → v3.0.02023-07-01

PHP version history (4 changes)v1.0.0PHP ^7.3|^8.0

v1.0.1PHP ^7.4|^8.0

v2.0.0PHP ^8.0

v3.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/0659b8f3960866aa6b528f725add11aacdd58dc4d167c060c15c8d119b8cc22d?d=identicon)[drewdan](/maintainers/drewdan)

---

Top Contributors

[![Drewdan](https://avatars.githubusercontent.com/u/5255492?v=4)](https://github.com/Drewdan "Drewdan (38 commits)")

---

Tags

payment-integrationpaypalpaypal-rest-api

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[lemonsqueezy/laravel

A package to easily integrate your Laravel application with Lemon Squeezy.

58596.1k](/packages/lemonsqueezy-laravel)[bitpay/sdk

Complete version of the PHP library for the new cryptographically secure BitPay API

42337.5k4](/packages/bitpay-sdk)[buckaroo/sdk

Buckaroo payment SDK

12189.1k9](/packages/buckaroo-sdk)[tsaiyihua/laravel-linepay

linepay library for laravel

102.9k](/packages/tsaiyihua-laravel-linepay)[digikraaft/laravel-paystack-webhooks

Handle Paystack webhooks in a Laravel application

177.5k1](/packages/digikraaft-laravel-paystack-webhooks)[wandesnet/mercadopago-laravel

PHP SDK for integration with Mercado Pago

252.4k](/packages/wandesnet-mercadopago-laravel)

PHPackages © 2026

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