PHPackages                             ahkmunna/paypalpayment - 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. ahkmunna/paypalpayment

ActiveLibrary[Payment Processing](/categories/payments)

ahkmunna/paypalpayment
======================

laravel-paypalpayment is simple package help you process direct credit card payments, stored credit card payments and PayPal account payments with your L4 projects using paypal REST API SDK.

011.9k↓50%PHP

Since Dec 4Pushed 6y ago1 watchersCompare

[ Source](https://github.com/ahkmunna/laravel-paypalpayment)[ Packagist](https://packagist.org/packages/ahkmunna/paypalpayment)[ RSS](/packages/ahkmunna-paypalpayment/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

laravel-paypalpayment
=====================

[](#laravel-paypalpayment)

[![Build Status](https://camo.githubusercontent.com/fa6ae2e69e15450d8bd0acf57e93d0cd8d4c91e68202072ec2f2d403a8bc921c/68747470733a2f2f7472617669732d63692e6f72672f78726f6f742f6c61726176656c2d70617970616c7061796d656e742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/xroot/laravel-paypalpayment)

laravel-paypalpayment is a simple package that helps you to process direct credit card payments, stored credit card payments and PayPal account payments with your Laravel 4/5 projects using PayPal REST API SDK.

Donation :
----------

[](#donation-)

donate a cup of ☕ 😊 : [![Click here to lend your support to: github and make a donation at pledgie.com !](https://camo.githubusercontent.com/38e0c9641a992ecb2b70b7d27b07c707fd3a0c18d9fb7aa3550b92471472ce01/68747470733a2f2f706c65646769652e636f6d2f63616d706169676e732f32343636362e706e673f736b696e5f6e616d653d6368726f6d65)](https://pledgie.com/campaigns/24666)

[Watch a Quick Demo](https://www.youtube.com/watch?v=F67YuGKm220)
-----------------------------------------------------------------

[](#watch-a-quick-demo)

Installation
============

[](#installation)

Install this package through Composer. To your `composer.json` file:

```
"require": {
    "ahkmunna/paypalpayment": ">=3.0"
}
```

Next, run `composer update`.

Add the service provider to `config/app.php` (`app/config/app.php` for Laravel 4), in the `providers` array.

```
'providers' => array(
    // ...

    Anouar\Paypalpayment\PaypalpaymentServiceProvider::class,
)
```

Then add an alias under `aliases` array.

```
'aliases' => array(
    // ...

    'Paypalpayment'   => Anouar\Paypalpayment\Facades\PaypalPayment::class,
)
```

Finaly Pulish the package configuration by running this CMD

```
php artisan vendor:publish --provider="Anouar\Paypalpayment\PaypalpaymentServiceProvider"

```

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

[](#configuration)

Under `config/paypal_payment.php` configuration file set your paypal `client_id` and `client_secert` keys

Samples
=======

[](#samples)

#### Note: If you are not fan of using facade calls, you can resove the paypal payment service like so `app('paypalpayment')` then assign it to a property.

[](#note-if-you-are-not-fan-of-using-facade-calls-you-can-resove-the-paypal-payment-service-like-so-apppaypalpayment-then-assign-it-to-a-property)

1-Using credit card as paypent method
-------------------------------------

[](#1-using-credit-card-as-paypent-method)

Create new controller `PaypalPaymentController`:

```
use Paypalpayment;
class PaypalPaymentController extends BaseController {

    /*
    * Process payment using credit card
    */
    public function paywithCreditCard()
    {
        // ### Address
        // Base Address object used as shipping or billing
        // address in a payment. [Optional]
        $shippingAddress = Paypalpayment::shippingAddress();
        $shippingAddress->setLine1("3909 Witmer Road")
            ->setLine2("Niagara Falls")
            ->setCity("Niagara Falls")
            ->setState("NY")
            ->setPostalCode("14305")
            ->setCountryCode("US")
            ->setPhone("716-298-1822")
            ->setRecipientName("Jhone");

        // ### CreditCard
        $card = Paypalpayment::creditCard();
        $card->setType("visa")
            ->setNumber("4758411877817150")
            ->setExpireMonth("05")
            ->setExpireYear("2019")
            ->setCvv2("456")
            ->setFirstName("Joe")
            ->setLastName("Shopper");

        // ### FundingInstrument
        // A resource representing a Payer's funding instrument.
        // Use a Payer ID (A unique identifier of the payer generated
        // and provided by the facilitator. This is required when
        // creating or using a tokenized funding instrument)
        // and the `CreditCardDetails`
        $fi = Paypalpayment::fundingInstrument();
        $fi->setCreditCard($card);

        // ### Payer
        // A resource representing a Payer that funds a payment
        // Use the List of `FundingInstrument` and the Payment Method
        // as 'credit_card'
        $payer = Paypalpayment::payer();
        $payer->setPaymentMethod("credit_card")
            ->setFundingInstruments([$fi]);

        $item1 = Paypalpayment::item();
        $item1->setName('Ground Coffee 40 oz')
                ->setDescription('Ground Coffee 40 oz')
                ->setCurrency('USD')
                ->setQuantity(1)
                ->setTax(0.3)
                ->setPrice(7.50);

        $item2 = Paypalpayment::item();
        $item2->setName('Granola bars')
                ->setDescription('Granola Bars with Peanuts')
                ->setCurrency('USD')
                ->setQuantity(5)
                ->setTax(0.2)
                ->setPrice(2);

        $itemList = Paypalpayment::itemList();
        $itemList->setItems([$item1,$item2])
            ->setShippingAddress($shippingAddress);

        $details = Paypalpayment::details();
        $details->setShipping("1.2")
                ->setTax("1.3")
                //total of items prices
                ->setSubtotal("17.5");

        //Payment Amount
        $amount = Paypalpayment::amount();
        $amount->setCurrency("USD")
                // the total is $17.8 = (16 + 0.6) * 1 ( of quantity) + 1.2 ( of Shipping).
                ->setTotal("20")
                ->setDetails($details);

        // ### Transaction
        // A transaction defines the contract of a
        // payment - what is the payment for and who
        // is fulfilling it. Transaction is created with
        // a `Payee` and `Amount` types

        $transaction = Paypalpayment::transaction();
        $transaction->setAmount($amount)
            ->setItemList($itemList)
            ->setDescription("Payment description")
            ->setInvoiceNumber(uniqid());

        // ### Payment
        // A Payment Resource; create one using
        // the above types and intent as 'sale'

        $payment = Paypalpayment::payment();

        $payment->setIntent("sale")
            ->setPayer($payer)
            ->setTransactions([$transaction]);

        try {
            // ### Create Payment
            // Create a payment by posting to the APIService
            // using a valid ApiContext
            // The return object contains the status;
            $payment->create(Paypalpayment::apiContext());
        } catch (\PPConnectionException $ex) {
            return response()->json(["error" => $ex->getMessage()], 400);
        }

        return response()->json([$payment->toArray()], 200);
    }

}
```

2-Using Express Checkout as payment method
------------------------------------------

[](#2-using-express-checkout-as-payment-method)

```
    /*
    * Process payment with express checkout
    */
    public function paywithPaypal()
    {
        // ### Address
        // Base Address object used as shipping or billing
        // address in a payment. [Optional]
        $shippingAddress= Paypalpayment::shippingAddress();
        $shippingAddress->setLine1("3909 Witmer Road")
            ->setLine2("Niagara Falls")
            ->setCity("Niagara Falls")
            ->setState("NY")
            ->setPostalCode("14305")
            ->setCountryCode("US")
            ->setPhone("716-298-1822")
            ->setRecipientName("Jhone");

        // ### Payer
        // A resource representing a Payer that funds a payment
        // Use the List of `FundingInstrument` and the Payment Method
        // as 'credit_card'
        $payer = Paypalpayment::payer();
        $payer->setPaymentMethod("paypal");

        $item1 = Paypalpayment::item();
        $item1->setName('Ground Coffee 40 oz')
                ->setDescription('Ground Coffee 40 oz')
                ->setCurrency('USD')
                ->setQuantity(1)
                ->setTax(0.3)
                ->setPrice(7.50);

        $item2 = Paypalpayment::item();
        $item2->setName('Granola bars')
                ->setDescription('Granola Bars with Peanuts')
                ->setCurrency('USD')
                ->setQuantity(5)
                ->setTax(0.2)
                ->setPrice(2);

        $itemList = Paypalpayment::itemList();
        $itemList->setItems([$item1,$item2])
            ->setShippingAddress($shippingAddress);

        $details = Paypalpayment::details();
        $details->setShipping("1.2")
                ->setTax("1.3")
                //total of items prices
                ->setSubtotal("17.5");

        //Payment Amount
        $amount = Paypalpayment::amount();
        $amount->setCurrency("USD")
                // the total is $17.8 = (16 + 0.6) * 1 ( of quantity) + 1.2 ( of Shipping).
                ->setTotal("20")
                ->setDetails($details);

        // ### Transaction
        // A transaction defines the contract of a
        // payment - what is the payment for and who
        // is fulfilling it. Transaction is created with
        // a `Payee` and `Amount` types

        $transaction = Paypalpayment::transaction();
        $transaction->setAmount($amount)
            ->setItemList($itemList)
            ->setDescription("Payment description")
            ->setInvoiceNumber(uniqid());

        // ### Payment
        // A Payment Resource; create one using
        // the above types and intent as 'sale'

        $redirectUrls = Paypalpayment::redirectUrls();
        $redirectUrls->setReturnUrl(url("/payments/success"))
            ->setCancelUrl(url("/payments/fails"));

        $payment = Paypalpayment::payment();

        $payment->setIntent("sale")
            ->setPayer($payer)
            ->setRedirectUrls($redirectUrls)
            ->setTransactions([$transaction]);

        try {
            // ### Create Payment
            // Create a payment by posting to the APIService
            // using a valid ApiContext
            // The return object contains the status;
            $payment->create(Paypalpayment::apiContext());
        } catch (\PPConnectionException $ex) {
            return response()->json(["error" => $ex->getMessage()], 400);
        }

        return response()->json([$payment->toArray(), 'approval_url' => $payment->getApprovalLink()], 200);
    }
```

3-List Payment
--------------

[](#3-list-payment)

Add the `index()` function to the `PaypalPaymentController` Controller

```
    /*
        Use this call to get a list of payments.
        url:payment/
    */
    public function index()
    {

        $payments = Paypalpayment::getAll(['count' => 1, 'start_index' => 0], Paypalpayment::apiContext());

        return response()->json([$payments->toArray()], 200);

    }
```

4-Get Payment details
---------------------

[](#4-get-payment-details)

Add the `show()` function to the `PaypalPaymentController` Controller

```
    /*
        Use this call to get details about payments that have not completed,
        such as payments that are created and approved, or if a payment has failed.
        url:payment/PAY-3B7201824D767003LKHZSVOA
    */

    public function show($payment_id)
    {
       $payment = Paypalpayment::getById($payment_id, Paypalpayment::apiContext());

        return response()->json([$payment->toArray()], 200);
    }
```

Under the (`routes.php` for previous versions) or `web.php` file and register your routing.

Conclusion
==========

[](#conclusion)

Please feel free to report issues and open any PRs that you thinks will help to improve the package.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 73.5% 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/9366303?v=4)[Munna Khan](/maintainers/ahkmunna)[@ahkmunna](https://github.com/ahkmunna)

---

Top Contributors

[![anouarabdsslm](https://avatars.githubusercontent.com/u/2453950?v=4)](https://github.com/anouarabdsslm "anouarabdsslm (108 commits)")[![al0mie](https://avatars.githubusercontent.com/u/5223895?v=4)](https://github.com/al0mie "al0mie (9 commits)")[![chriskonnertz](https://avatars.githubusercontent.com/u/4319323?v=4)](https://github.com/chriskonnertz "chriskonnertz (8 commits)")[![ahkmunna](https://avatars.githubusercontent.com/u/9366303?v=4)](https://github.com/ahkmunna "ahkmunna (5 commits)")[![webwizo](https://avatars.githubusercontent.com/u/1593953?v=4)](https://github.com/webwizo "webwizo (2 commits)")[![HapLifeMan](https://avatars.githubusercontent.com/u/1854141?v=4)](https://github.com/HapLifeMan "HapLifeMan (2 commits)")[![KasperFranz](https://avatars.githubusercontent.com/u/191405?v=4)](https://github.com/KasperFranz "KasperFranz (2 commits)")[![mferrara](https://avatars.githubusercontent.com/u/795065?v=4)](https://github.com/mferrara "mferrara (2 commits)")[![mix5003](https://avatars.githubusercontent.com/u/1129524?v=4)](https://github.com/mix5003 "mix5003 (2 commits)")[![justgage](https://avatars.githubusercontent.com/u/164033?v=4)](https://github.com/justgage "justgage (1 commits)")[![nemo3000](https://avatars.githubusercontent.com/u/5304942?v=4)](https://github.com/nemo3000 "nemo3000 (1 commits)")[![pelhage](https://avatars.githubusercontent.com/u/4411839?v=4)](https://github.com/pelhage "pelhage (1 commits)")[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (1 commits)")[![ghostprofile](https://avatars.githubusercontent.com/u/41087149?v=4)](https://github.com/ghostprofile "ghostprofile (1 commits)")[![jonathanfreites](https://avatars.githubusercontent.com/u/15368977?v=4)](https://github.com/jonathanfreites "jonathanfreites (1 commits)")[![josephting](https://avatars.githubusercontent.com/u/1507016?v=4)](https://github.com/josephting "josephting (1 commits)")

### Embed Badge

![Health badge](/badges/ahkmunna-paypalpayment/health.svg)

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

###  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)
