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

ActiveLibrary[Payment Processing](/categories/payments)

zenithcoder/laravel-paypal
==========================

laravel paypal integration for payment processing

217PHP

Since May 2Pushed 5y ago2 watchersCompare

[ Source](https://github.com/Zenithcoder/laravel-paypal)[ Packagist](https://packagist.org/packages/zenithcoder/laravel-paypal)[ RSS](/packages/zenithcoder-laravel-paypal/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel PayPal
==============

[](#laravel-paypal)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Latest Version on Packagist](https://camo.githubusercontent.com/97a61653f66af50a0b14f30230652e4c263f089573a8f7452b5b4a67d4c58884/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a656e697468636f6465722f70617970616c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zenithcoder/laravel-paypal)[![Total Downloads](https://camo.githubusercontent.com/ae061d2a8a3fce406fb8743f970c420f4c68c621cd1bbaf43fe71ebc7872f7d8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a656e697468636f6465722f70617970616c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zenithcoder/laravel-paypal)[![StyleCI](https://camo.githubusercontent.com/8a5e62babb7ea5db53b430ac433264871cef8879231ee4120ca36f9fb8a3ec24/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f34333637313533332f736869656c643f6272616e63683d76322e30)](https://github.styleci.io/repos/43671533?branch=v2.0)[![Tests](https://github.com/zenithcoder/laravel-paypal/workflows/TestsV3/badge.svg)](https://github.com/zenithcoder/laravel-paypal/workflows/TestsV3/badge.svg)

- [Introduction](#introduction)
- [PayPal API Credentials](#paypal-api-credentials)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
- [Support](#support)

Introduction
------------

[](#introduction)

By using this library you can process payment from PayPal and listen to events in your Laravel application.

**This plugin supports the new paypal rest api.**

PayPal API Credentials
----------------------

[](#paypal-api-credentials)

This package uses the new paypal rest api. Refer to this link on how to create API credentials:

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

[](#installation)

- Use following command to install:

If you intend to use ExpressCheckout, please to the following [README](https://github.com/zenithcoder/laravel-paypal/tree/v1.0). *v2.0* &amp; *v3.0* uses the new rest api.

```
composer require zenithcoder/laravel-paypal
```

```
php artisan vendor:publish --provider "zenithcoder\PayPal\PayPalServiceProvider"
```

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

[](#configuration)

- After installation, you will need to add your paypal settings. Following is the code you will find in **config/paypal.php**, which you should update accordingly.

```
return [

    'client_id' => env('PAYPAL_CLIENT_ID'), //clientid from dashboard

    'client_secret' => env('PAYPAL_CLIENT_SECRET'),//client secret from dashboard

    'paymentUrl' => env('PAYPAL_PAYMENT_URL'),//payment url e.g. sandbox= https://api-m.sandbox.paypal.com
];
```

- Add this to `.env.example` and `.env`

```
#PayPal Setting & API Credentials
PAYPAL_CLIENT_ID=
PAYPAL_CLIENT_SECRET=
PAYPAL_PAYMENT_URL=

```

\##General payment flow

Though there are multiple ways to pay an order, most payment gateways expect you to follow the following flow in your checkout process:

\###1. The customer is redirected to the payment provider After the customer has gone through the checkout process and is ready to pay, the customer must be redirected to site of the payment provider.

The redirection is accomplished by submitting a form with some hidden fields. The form must post to the site of the payment provider. The hidden fields minimally specify the amount that must be paid,etc

\###2. The customer pays on the site of the payment provider The customer arrived on the site of the payment provider and gets to choose a payment method. All steps necessary to pay the order are taken care of by the payment provider.

\###3. Handle different Event We will post an event to the webhook URL set for your transaction's domain. If it was a live transaction, we will post to your live webhook url and vice-versa.

```
use Zenithcoder\Paypal\Paypal;

  public function redirectToPaypal(Request $request)
    {
        $this->processCheckout();
        return  $this->PaypalClient()->getAuthPaymentUrl()->redirectNow();
    }

    public function handlePaypalWebhook()
    {
        $paymentDetails =  $this->PaypalClient()->getPaymentData();

        dd($paymentDetails);
        $event_types = $paymentDetails['event_types'];

          switch ($event_types)
            {
                case "PAYMENT.SALE.COMPLETED":
                    $this->completedPayment();
                    break;
                case "BILLING.SUBSCRIPTION.PAYMENT.FAILED":
                    // Handle payment failed
                    break;
                    // Handle other webhooks
                case "BILLING.SUBSCRIPTION.CANCELLED":
                        // Handle subscription cancelled
                    break;
                case "BILLING.SUBSCRIPTION.SUSPENDED":
                        // Handle subscription suspended
                    break;
                        // Handle other webhooks
                default:
                    break;
            }
    }

    public function PaypalClient(){
        return new Paypal();
    }

    public function completedPayment()
    {
        //update payment status
    }

    public function processCheckout()
    {
        try{
            $user = Auth::user();
            $subscription = Subscription::create([
                'user_id' => Auth::user()->id,
                'total'=> request()->query('amount')
            ]);

            $cartItems = json_decode( request()->query('meta'),true);
            foreach($cartItems as $cartItem)
            {
                $subscription->transactions()->create([
                    'qty' => $cartItem->qty,
                    'total' => $cartItem->qty*$cartItem->price
                ]);
            }
        } catch(\Exception $e) {

            return $e->getMessage();
        }
    }
```

```
Route::post('/pay', [
    'uses' => 'PaymentController@redirectToPaypal',
    'as' => 'pay'
]);
```

```
Route::get('/paypal/webhook', 'PaymentController@handlePaypalWebhook');
```

A sample form will look like so:

```

                   Robotsea
                    $350

             {{-- For other necessary things you want to add to your payload. it is optional though --}}

            {{ csrf_field() }} {{-- works only when using laravel 5.1, 5.2 --}}

              {{-- employ this in place of csrf_field only in laravel 5.0 --}}

               Pay Now!

```

Support
-------

[](#support)

This version supports Laravel 6 or greater.

- In case of any issues, kindly create one on the [Issues](https://github.com/zenithcoder/laravel-paypal/issues) section.
- If you would like to contribute:
    - Fork this repository.
    - Implement your features.
    - Generate pull request.

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity30

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/22308024?v=4)[Awonusi Olajide](/maintainers/zenithcoder)[@Zenithcoder](https://github.com/Zenithcoder)

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[omnipay/paypal

PayPal gateway for Omnipay payment processing library

3156.8M53](/packages/omnipay-paypal)[eduardokum/laravel-boleto

Biblioteca com boletos para o laravel

626351.9k2](/packages/eduardokum-laravel-boleto)[tbbc/money-bundle

This is a Symfony bundle that integrates moneyphp/money library (Fowler pattern): https://github.com/moneyphp/money.

1961.9M](/packages/tbbc-money-bundle)[2checkout/2checkout-php

2Checkout PHP Library

83740.3k2](/packages/2checkout-2checkout-php)[smhg/sepa-qr-data

Generate QR code data for SEPA payments

61717.2k5](/packages/smhg-sepa-qr-data)[omnipay/dummy

Dummy driver for the Omnipay payment processing library

271.2M33](/packages/omnipay-dummy)

PHPackages © 2026

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