PHPackages                             coderscoop/laravelpaypal - 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. coderscoop/laravelpaypal

ActiveLibrary[Payment Processing](/categories/payments)

coderscoop/laravelpaypal
========================

Coder Scoop Laravel Paypal integration - A simplified way to interact with the Paypal REST API

1131PHP

Since May 24Pushed 9y ago1 watchersCompare

[ Source](https://github.com/Coder-Scoop-Inc/laravel-paypal-integration)[ Packagist](https://packagist.org/packages/coderscoop/laravelpaypal)[ RSS](/packages/coderscoop-laravelpaypal/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Paypal Payment API - Laravel integration
========================================

[](#paypal-payment-api---laravel-integration)

#### Developer: Guin Kellam

[](#developer-guin-kellam)

### DESCRIPTION

[](#description)

This package adds several url end points to your project that make using the Paypal API significantly easier. You will still need a Paypal vendor account, and make sure you are using https when you are submitting things (for your own safety)

When you initiate a payment with the Paypal Payment API, a Payment object is created on their servers. This package simplifies the process of accepting payments from your users by making calls that interact with the various REST end points that Paypal provides.

### INSTALLATION

[](#installation)

1. composer require "coderscoop/laravelpaypal:\*"
2. Add coderscoop\\laravelpaypal\\PaypalServiceProvider::class to your service provider in config/app

### USAGE

[](#usage)

This package will add the following routes to your project

#### paypal/demo - GET

[](#paypaldemo---get)

This route allows you to test your credentials and post a sample payment; It will return a payment\_id and approval\_url that you can use to test the endpoints and not have to worry about building up the JSON for a payment

#### paypal/payment - POST

[](#paypalpayment---post)

Post a fully formed paypal payment object such as the following (more examples and information on these objects can be found at ) to this route. It will return to you the paypal id for this transaction and the url you need to redirect your user to in order to approve the payment.

POST *{ "intent": "sale", "payer": { "payment\_method": "paypal" }, "transactions": \[ { "amount": { "total": "30.11", "currency": "USD", "details": { "subtotal": "30.00", "tax": "0.07", "shipping": "0.03", "handling\_fee": "1.00", "shipping\_discount": "-1.00", "insurance": "0.01" } }, "description": "The payment transaction description.", "custom": "EBAY\_EMS\_90048630024435", "invoice\_number": "48787589673", "payment\_options": { "allowed\_payment\_method": "INSTANT\_FUNDING\_SOURCE" }, "soft\_descriptor": "ECHI5786786", "item\_list": { "items": \[ { "name": "hat", "description": "Brown hat.", "quantity": "5", "price": "3", "tax": "0.01", "sku": "1", "currency": "USD" }, { "name": "handbag", "description": "Black handbag.", "quantity": "1", "price": "15", "tax": "0.02", "sku": "product34", "currency": "USD" } \], "shipping\_address": { "recipient\_name": "Brian Robinson", "line1": "4th Floor", "line2": "Unit #34", "city": "San Jose", "country\_code": "US", "postal\_code": "95131", "phone": "011862212345678", "state": "CA" } } } \], "note\_to\_payer": "Contact us for any questions on your order.", "redirect\_urls": { "return\_url": "", "cancel\_url": "" } }*

RETURN *{"payment\_id":"PAY-9JC48149SV546373BLENZEAY","approval\_url":"[https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=\_express-checkout&amp;token=EC-68K84205DL435322P](https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-68K84205DL435322P)"}*

##### IMPORTANT NOTE : you must redirect your user to the approval link that this route returns, that is how they will log into Paypal and approve the payment so you can get your money !!!

[](#important-note--you-must-redirect-your-user-to-the-approval-link-that-this-route-returns-that-is-how-they-will-log-into-paypal-and-approve-the-payment-so-you-can-get-your-money-)

##### IMPORTANT NOTE 2 : make sure you save the payment id somewhere, this is how you will identify and interact with this payment in the next steps !

[](#important-note-2--make-sure-you-save-the-payment-id-somewhere-this-is-how-you-will-identify-and-interact-with-this-payment-in-the-next-steps-)

##### LESS IMPORTANT BUT STILL KIND OF IMPORTANT NOTE : return\_url and cancel\_url are url's you provide, PayPal will redirect the user to these routes depending on the results of the approval process. See more information about this in the instructions for the confirm route.

[](#less-important-but-still-kind-of-important-note--return_url-and-cancel_url-are-urls-you-provide-paypal-will-redirect-the-user-to-these-routes-depending-on-the-results-of-the-approval-process--see-more-information-about-this-in-the-instructions-for-the-confirm-route)

An alternative to posting a JSON object to this route is to build your object programmatically using the Item and SalesData objects in the package. This is also a straightforward process and will be explained later in this document.

#### paypal/info/{id} -GET

[](#paypalinfoid--get)

Anytime after a payment has been created you can use this route to get it's current status and information. PayPal also tracks lineitems, notes, etc, all of this is available from this route.

Send a get requests to this route, {id} is the payment\_id that was returned when you created the payment with the paypal/payment route from this package.

RETURN A JSON object similar to the one below, it will look different depending on the status of the payment you queried *{"id":"PAY-5S991868XB086112JLEO2BJY","intent":"sale","state":"created","cart":"3T903907ND8538129","payer":{"payment\_method":"paypal"},"transactions":\[{"amount":{"total":"4.00","currency":"CAD"},"payee":{"merchant\_id":"DTW9Z49SZHQTG","email":""},"item\_list":{"items":\[{"name":"Thing1","sku":"1","description":"This is thing 1","price":"2.00","currency":"CAD","tax":"0.00","quantity":1},{"name":"Thing1","sku":"1","description":"This is thing 1","price":"2.00","currency":"CAD","tax":"0.00","quantity":1}\]},"related\_resources":\[\]}\],"redirect\_urls":{"return\_url":"example.com/?paymentId=PAY-5S991868XB086112JLEO2BJY","cancel\_url":"example.com"},"create\_time":"2017-05-18T13:24:54Z","update\_time":"2017-05-18T13:33:23Z","links":\[{"href":"[https://api.sandbox.paypal.com/v1/payments/payment/PAY-5S991868XB086112JLEO2BJY","rel":"self","method":"GET"},{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-5S991868XB086112JLEO2BJY/execute","rel":"execute","method":"POST"},{"href":"https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=\_express-checkout&amp;token=EC-3T903907ND8538129","rel":"approval\_url","method":"REDIRECT](https://api.sandbox.paypal.com/v1/payments/payment/PAY-5S991868XB086112JLEO2BJY","rel":"self","method":"GET"},{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-5S991868XB086112JLEO2BJY/execute","rel":"execute","method":"POST"},{"href":"https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-3T903907ND8538129","rel":"approval_url","method":"REDIRECT)"}\]}*

#### paypal/confirm/{id} - GET

[](#paypalconfirmid---get)

Once a payment has been approved by the payer (using the approval url returned when the payment was created... see the paypal/payment POST route if you have forgotten about this) You can use the payment\_id and this route to finalize the payment. If you do not do this the payment will not be finalized and you will not get paid !

RETURN This will return a JSON object with the payment info if the payment has been approved by the user, and if not, it will return a validation error. A possible site flow would be to send this route as your return url to the paypal/payment POST route, so that when your application successfully returns from a the paypal site you automatically process the payments. If you don't want to do this, you can check /paypal/info at anytime to see if the payment was approved, and then process it at your leisure.

#### Using the Item and Sales data models to build your payment

[](#using-the-item-and-sales-data-models-to-build-your-payment)

As an alternative to building your own payment JSON object and sending it with the paypal/payment POST route I have provided another method that you can use inside your own models.

The package provides an Item object, which is single line item from your sale and a SalesData object, which hold the items and generates the JSON that will be sent to the paypal REST API. Once you have built your SaleData you create a new Payment object with it, and then call the 'createPaypalPayment' method on it. This submits your SalesData object and returns the same information that the paypal/payment POST route would (payment\_id and approval\_url).

##### Useful Methods

[](#useful-methods)

Item Contstructor Item("name", "description", "quantity" , "price" , "tax" , "sku", "currency" ) NOTE:all of these values must be strings !!)

SalesData-&gt;addItem(Item);

Payment Constructor Payment('CLIENT\_ID', 'CLIENT\_SECRET', SalesData) NOTE: Client id and Client Secret are the ones provided by PayPal through your developer account, I hope you have these set in your .env file !! Do not expose theses to the world!!!)

Example namespace coderscoop/laravelpaypal;

/……/

```
$item1 = new Item("Thing1","Thi  s is thing 1","1","2","0.0","1","CAD");
$item2 = new Item("Thing2","This is thing 2","1","2","0.0","1","CAD");

$salesData = new SalesData();
$salesData->addItem($item1);
$salesData->addItem($item2);

$payment = new Payment(env('PAYPAL_CLIENT_ID'), env('PAYPAL_CLIENT_SECRET'),$salesData);

$payment_id = $payment->createPaypalPayment();

```

\####TO DO:

- More tests !
- More graceful error handling
- Add /paypal/cancel
- Implement other REST functions (Set up reoccurring payments, invoicing, etc)

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

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/17891571?v=4)[GuinivereJane](/maintainers/GuinivereJane)[@GuinivereJane](https://github.com/GuinivereJane)

### Embed Badge

![Health badge](/badges/coderscoop-laravelpaypal/health.svg)

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

###  Alternatives

[omnipay/coinbase

Coinbase driver for the Omnipay payment processing library

18570.2k1](/packages/omnipay-coinbase)

PHPackages © 2026

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