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

ActiveLibrary[Payment Processing](/categories/payments)

puntodev/paypal
===============

PayPal API Client

v6.0.1(5d ago)07.1k1MITPHPPHP &gt;=8.4 &lt;9.0CI passing

Since Sep 15Pushed 5d ago1 watchersCompare

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

READMEChangelog (10)Dependencies (11)Versions (43)Used By (1)

PayPal API Client for Laravel
=============================

[](#paypal-api-client-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/2e1eeaf11f5b0b96a141ce4708447ea6f1a2a82ab671c6ff8632a3c7c959217a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70756e746f6465762f70617970616c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/puntodev/paypal)[![Total Downloads](https://camo.githubusercontent.com/e8d16686c010bb786de3a057d8dd312e7bc884872740b76e0b0421ef09d120e8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70756e746f6465762f70617970616c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/puntodev/paypal)

A lightweight Laravel package that wraps the [PayPal Orders v2 API](https://developer.paypal.com/docs/api/orders/v2/)(create, find and capture orders) and provides classic IPN verification. It uses Laravel's HTTP client under the hood and caches the OAuth2 access token automatically.

Requirements
------------

[](#requirements)

- PHP `>=8.4  sandbox, false -> production
```

These map to `config/paypal.php`:

```
return [
    'client_id' => env('PAYPAL_API_CLIENT_ID'),
    'client_secret' => env('PAYPAL_API_CLIENT_SECRET'),
    'use_sandbox' => env('SANDBOX_GATEWAYS', false),
];
```

When `use_sandbox` is `true` the client targets `api.sandbox.paypal.com` and the sandbox IPN endpoint; otherwise it targets production.

Usage
-----

[](#usage)

### Resolving the client

[](#resolving-the-client)

Inject the `PayPal` contract (or use the `Paypal` facade) and obtain a `PayPalApi`instance. Use `defaultClient()` to use the configured credentials, or `withCredentials()` to override them at runtime (e.g. for multi-tenant setups):

```
use Puntodev\Payments\PayPal;

public function __construct(private PayPal $paypal) {}

// With the credentials from config/paypal.php
$api = $this->paypal->defaultClient();

// Or with per-request credentials (sandbox flag still comes from config)
$api = $this->paypal->withCredentials($clientId, $clientSecret);
```

### Building an order

[](#building-an-order)

`OrderBuilder` produces the payload for the Orders v2 API. The order intent is `CAPTURE`, items are sent as `DIGITAL_GOODS` with `NO_SHIPPING`, and a discount is only included when greater than zero:

```
use Puntodev\Payments\OrderBuilder;

$order = (new OrderBuilder())
    ->externalId('your-internal-id')
    ->currency('USD')
    ->amount(23.20)
    ->discount(2.20)            // optional
    ->description('My custom product')
    ->brandName('My brand name')
    ->locale('es-AR')           // defaults to es-AR
    ->returnUrl('https://example.com/return')
    ->cancelUrl('https://example.com/cancel')
    ->make();
```

### Creating, finding and capturing orders

[](#creating-finding-and-capturing-orders)

```
$created = $api->createOrder($order);
$orderId = $created['id'];

// Send the buyer to the "payer-action" link to approve the payment
$approveUrl = collect($created['links'])
    ->firstWhere('rel', 'payer-action')['href'];

// Later, fetch or capture the order
$order = $api->findOrderById($orderId);
$capture = $api->captureOrder($orderId);
```

All order methods return the decoded JSON response as an `array` and throw `Illuminate\Http\Client\RequestException` on HTTP errors.

### Verifying IPN notifications

[](#verifying-ipn-notifications)

```
// In your IPN webhook controller
$status = $api->verifyIpn($request->getContent()); // "VERIFIED" or "INVALID"

if ($status === 'VERIFIED') {
    // process the notification
}
```

Testing
-------

[](#testing)

```
composer test            # runs PHPUnit
composer test-coverage   # generates HTML coverage report
```

> **Note:** the test suite (`tests/PayPalApiTest.php`) makes **real HTTP calls to the PayPal sandbox**. You must provide valid sandbox credentials via `PAYPAL_API_CLIENT_ID` and `PAYPAL_API_CLIENT_SECRET`. `phpunit.xml.dist` forces `SANDBOX_GATEWAYS=true`.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Releasing
---------

[](#releasing)

Releases are cut from GitHub and the changelog is kept in sync automatically:

1. Merge the pull requests you want to ship into `master`. Label them so the notes group nicely (`security`, `enhancement`, `bug`, `dependencies`, `documentation`); grouping is configured in [`.github/release.yml`](.github/release.yml).
2. On GitHub, go to **Releases → Draft a new release**, create a `vX.Y.Z` tag following [SemVer](https://semver.org/), and click **Generate release notes**.
3. **Publish** the release. Packagist picks up the new tag, and the [`update-changelog.yml`](.github/workflows/update-changelog.yml) workflow writes the release notes into `CHANGELOG.md` and commits them back to `master`.

The `Unreleased` section in the changelog is just an anchor — release notes flow from the published GitHub release, so there is no changelog to edit by hand.

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email instead of using the issue tracker.

Credits
-------

[](#credits)

- [Mariano Goldman](https://github.com/puntodev)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

59

—

FairBetter than 98% of packages

Maintenance99

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity85

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 93% 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 ~72 days

Recently: every ~23 days

Total

30

Last Release

5d ago

Major Versions

v1.3.2 → v2.0.02023-03-17

v2.0.1 → v3.0.02024-04-07

v3.1.3 → v4.0.02025-05-02

v4.1.3 → v5.x-dev2026-03-28

v5.x-dev → v6.0.02026-06-13

PHP version history (8 changes)v0.0.1PHP ^7.4

v1.1.0PHP ^7.4|^8.0

v1.2.2PHP ^8.0

v2.0.0PHP ^8.1

v3.0.0PHP ^8.2

v3.1.3PHP ^8.3

v4.1.0PHP &gt;=8.3 &lt;9.0

v4.1.2PHP &gt;=8.4 &lt;9.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/7201db0e06c12ae2e12e1cf4ee5806b5b465dc538bee3cab6bfb1c0ec52e4dce?d=identicon)[Mariano Goldman](/maintainers/Mariano%20Goldman)

---

Top Contributors

[![marianogoldman](https://avatars.githubusercontent.com/u/959563?v=4)](https://github.com/marianogoldman "marianogoldman (40 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")

---

Tags

paypalpuntodev

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[srmklive/paypal

PayPal REST API client for Laravel and standalone PHP.

1.2k4.2M29](/packages/srmklive-paypal)[illuminate/http

The Illuminate Http package.

11937.9M6.9k](/packages/illuminate-http)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[shetabit/multipay

PHP Payment Gateway Integration Package

293361.0k4](/packages/shetabit-multipay)[sebdesign/laravel-viva-payments

A Laravel package for integrating the Viva Payments gateway

4851.0k](/packages/sebdesign-laravel-viva-payments)

PHPackages © 2026

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