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

ActiveLibrary[Payment Processing](/categories/payments)

josephilipraja/laravel4-paypal
==============================

laravel4-paypal 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.

1.1(10y ago)217BSD-2-ClausePHPPHP &gt;=5.3.0

Since Apr 21Pushed 10y ago1 watchersCompare

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

READMEChangelog (2)Dependencies (3)Versions (3)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 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.

\##Donation : If you want to support us: [![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)Installation
====================================================================================================================================================================================================================================================================================================================================================================================================

[](#donation-if-you-want-to-support-us-installation)

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

```
"require": {
    "anouar/paypalpayment": "1.*"
}
```

Next, run `composer update` to download it.

Add the service provider to `app/config/app.php`, within the `providers` array.

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

    'Anouar\Paypalpayment\PaypalpaymentServiceProvider',
)
```

Finally, add the alias to `app/config/app.php`, within the `aliases` array.

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

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

\##Configuration Now go to `vendor\anouar\paypalpayment\src\Anouar\Paypalpayment\sdk_config.ini`

Set your SDK configuration `acct1.ClientId` and `acct1.ClientSecret` , set the `service.EndPoint` to the mode that you want , by default it set to testing mode which is`service.EndPoint="https://api.sandbox.paypal.com"`.If you were going live , make sure to comment the sandbox mode and uncomment the live mode .

```
;Account credentials from developer portal
[Account]
acct1.ClientId =AVJx0RArQzkCCsWC0evZi1SsoO4gxjDkkULQBdmPNBZ4fc14AROUq-etMEY
acct1.ClientSecret =EH5F0BAxqonVnP8M4a0c6ezUHq-UT-CWfGciPNQdUlTpWPkNyuS6eDN-tpA

;Connection Information
[Http]
http.ConnectionTimeOut = 30
http.Retry = 1
;http.Proxy=http://[username:password]@hostname[:port][/path]

;Service Configuration
[Service]
service.EndPoint="https://api.sandbox.paypal.com"
; Uncomment this line for integrating with the live endpoint
; service.EndPoint="https://api.paypal.com"

;Logging Information
[Log]

log.LogEnabled=true

# When using a relative path, the log file is created
# relative to the .php file that is the entry point
# for this request. You can also provide an absolute
# path here
log.FileName=../PayPal.log

# Logging level can be one of FINE, INFO, WARN or ERROR
# Logging is most verbose in the 'FINE' level and
# decreases as you proceed towards ERROR
log.LogLevel=FINE

```

If you do not want to use an ini file or want to pick your configuration dynamically, you can use the `$apiContext->setConfig()` method to pass in the configuration.

```
    /**
     * object to authenticate the call.
     * @param object $_apiContext
     */
    private $_apiContext;

    /**
     * Set the ClientId and the ClientSecret.
     * @param
     *string $_ClientId
     *string $_ClientSecret
     */
    private $_ClientId='AVJx0RArQzkCCsWC0evZi1SsoO4gxjDkkULQBdmPNBZT4fc14AROUq-etMEY';
    private $_ClientSecret='EH5F0BAxqonVnP8M4a0c6ezUHq-UT-CWfGciPNQOdUlTpWPkNyuS6eDN-tpA';

    /*
     *   These construct set the SDK configuration dynamiclly,
     *   If you want to pick your configuration from the sdk_config.ini file
     *   make sure to update you configuration there then grape the credentials using this code :
     *   $this->_cred= Paypalpayment::OAuthTokenCredential();
    */
    public function __construct()
    {

        // ### Api Context
        // Pass in a `ApiContext` object to authenticate
        // the call. You can also send a unique request id
        // (that ensures idempotency). The SDK generates
        // a request id if you do not pass one explicitly.

        $this->_apiContext = Paypalpayment::ApiContext($this->_ClientId, $this->_ClientSecret);

        // Uncomment this step if you want to use per request
        // dynamic configuration instead of using sdk_config.ini

        $this->_apiContext->setConfig(array(
            'mode' => 'sandbox',
            'http.ConnectionTimeOut' => 30,
            'log.LogEnabled' => true,
            'log.FileName' => __DIR__.'/../PayPal.log',
            'log.LogLevel' => 'FINE'
        ));

    }
```

That's it !!!!!
===============

[](#thats-it-)

Example Code
============

[](#example-code)

\##1-Initiate The Configuration Create new controller `PaypalPaymentController` and initiate the configuration :

```
class PaypalPaymentController extends BaseController {

    /**
     * object to authenticate the call.
     * @param object $_apiContext
     */
    private $_apiContext;

    /**
     * Set the ClientId and the ClientSecret.
     * @param
     *string $_ClientId
     *string $_ClientSecret
     */
    private $_ClientId = 'AVJx0RArQzkCCsWC0evZi1SsoO4gxjDkkULQBdmPNBZT4fc14AROUq-etMEU';
    private $_ClientSecret='EH5F0BAxqonVnP8M4a0c6ezUHq-UT-CWfGciPNQOdUlTpWPkNyuS6eDN-tpB';

    /*
     *   These construct set the SDK configuration dynamiclly,
     *   If you want to pick your configuration from the sdk_config.ini file
     *   make sure to update you configuration there then grape the credentials using this code :
     *   $this->_cred= Paypalpayment::OAuthTokenCredential();
    */
    public function __construct()
    {

        // ### Api Context
        // Pass in a `ApiContext` object to authenticate
        // the call. You can also send a unique request id
        // (that ensures idempotency). The SDK generates
        // a request id if you do not pass one explicitly.

        $this->_apiContext = Paypalpayment::ApiContext($this->_ClientId, $this->_ClientSecret);

        // Uncomment this step if you want to use per request
        // dynamic configuration instead of using sdk_config.ini

        $this->_apiContext->setConfig(array(
            'mode' => 'sandbox',
            'service.EndPoint' => 'https://api.sandbox.paypal.com',
            'http.ConnectionTimeOut' => 30,
            'log.LogEnabled' => true,
            'log.FileName' => __DIR__.'/../PayPal.log',
            'log.LogLevel' => 'FINE'
        ));
    }

}
```

\##2-Create Payment Add the `create()` function to the `PaypalPaymentController` Controller

```
    /*
    * Display form to process payment using credit card
    */
    public function create()
    {
        return View::mak('payment.order')
    }

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

        // ### 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->setCredit_card($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(array($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(array($item1,$item2));

        $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(array($transaction));

        try {
            // ### Create Payment
            // Create a payment by posting to the APIService
            // using a valid ApiContext
            // The return object contains the status;
            $payment->create($this->_apiContext);
        } catch (\PPConnectionException $ex) {
            return  "Exception: " . $ex->getMessage() . PHP_EOL;
            exit(1);
        }

        dd($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()
    {
        echo "";

        $payments = Paypalpayment::getAll(array('count' => 1, 'start_index' => 0), $this->_apiContext);

        dd($payments);
    }
```

\##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,$this->_apiContext);

       dd($payment);
    }
```

\##5-Execute Payment Only for Payment with `payment_method` as `"paypal"`

```
    // Get the payment Object by passing paymentId
    // payment id and payer ID was previously stored in database in
    // create() fuction , this function create payment using "paypal" method
    $paymentId = '';grape it from DB;
    $PayerID = '';grape it from DB;
    $payment = Paypalpayment::get($paymentId, $this->_apiContext);

    // PaymentExecution object includes information necessary
    // to execute a PayPal account payment.
    // The payer_id is added to the request query parameters
    // when the user is redirected from paypal back to your site
    $execution = Paypalpayment::PaymentExecution();
    $execution->setPayerId($PayerID);

    //Execute the payment
    $payment->execute($execution,$this->_apiContext);
```

Go to your `routes.php` file and register a resourceful route to the controller:` Route::resource('payment', 'PaypalPaymentController');`

These examples pick the SDK configuration dynamiccly.If you want to pick your configuration from the sdk\_config.ini file make sure to set thus configuration there. Conclusion
===============================================================================================================================================================================

[](#these-examples-pick-the-sdk-configuration-dynamicclyif-you-want-to-pick-your-configuration-from-the-sdk_configini-file-make-sure-to-set-thus-configuration-thereconclusion)

I hope this package help someone around -\_\*

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

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

Total

2

Last Release

3925d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/88f385afd07e5949c382a05c936d066346ce97c3ba5e8f6988f1320cd831f532?d=identicon)[josephilipraja](/maintainers/josephilipraja)

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[laraveldaily/laravel-invoices

Missing invoices for Laravel

1.5k1.3M4](/packages/laraveldaily-laravel-invoices)[anouar/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.

33980.2k3](/packages/anouar-paypalpayment)[musahmusah/laravel-multipayment-gateways

A Laravel Package that makes implementation of multiple payment Gateways endpoints and webhooks seamless

852.2k1](/packages/musahmusah-laravel-multipayment-gateways)

PHPackages © 2026

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