PHPackages                             protonemedia/laravel-paddle - 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. protonemedia/laravel-paddle

ActiveLibrary[Payment Processing](/categories/payments)

protonemedia/laravel-paddle
===========================

Paddle.com integration for Laravel

2.10.0(1y ago)20226.3k↓11.4%17[4 issues](https://github.com/protonemedia/laravel-paddle/issues)[3 PRs](https://github.com/protonemedia/laravel-paddle/pulls)MITPHPPHP ^8.2 || ^8.3 || ^8.4CI failing

Since Dec 2Pushed 2mo ago7 watchersCompare

[ Source](https://github.com/protonemedia/laravel-paddle)[ Packagist](https://packagist.org/packages/protonemedia/laravel-paddle)[ Docs](https://github.com/protonemedia/laravel-paddle)[ GitHub Sponsors](https://github.com/pascalbaljet)[ RSS](/packages/protonemedia-laravel-paddle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (37)Used By (0)

> ⚠️ I'm unsure about the future of this package. I might be abandoning it, so please consider using [Laravel Cashier (Paddle)](https://laravel.com/docs/10.x/cashier-paddle).

Laravel Paddle
==============

[](#laravel-paddle)

[![Latest Version on Packagist](https://camo.githubusercontent.com/fa9110c4bf2e2864a53ceb8837e3a7ef39a649182f130cdf0814821b14b829c5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70726f746f6e656d656469612f6c61726176656c2d706164646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/protonemedia/laravel-paddle)[![run-tests](https://github.com/protonemedia/laravel-paddle/workflows/run-tests/badge.svg)](https://github.com/protonemedia/laravel-paddle/workflows/run-tests/badge.svg)[![Quality Score](https://camo.githubusercontent.com/dcd5297592be4d45b807e55d623aa85ab3cb3eb31b6900167031e4aebd844e91/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f70726f746f6e656d656469612f6c61726176656c2d706164646c652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/protonemedia/laravel-paddle)[![Total Downloads](https://camo.githubusercontent.com/6a7106ced41a6d2661dfdbd9518941a4cb29bb433927fa90d53210e1e75a3700/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70726f746f6e656d656469612f6c61726176656c2d706164646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/protonemedia/laravel-paddle)

This package provides an integration with [Paddle.com](https://paddle.com) for Laravel. Read the [blogpost](https://protone.media/en/blog/a-new-laravel-package-to-handle-payments-and-subscriptions-with-paddle) about the introduction of the package!

Features
--------

[](#features)

- Super easy wrapper around the [Paddle.com API](https://developer.paddle.com/api-reference/intro)
- Built-in support for Webhooks and Event handling
- Blade directive to use [Paddle.js](https://paddle.com/docs/paddle-js-overlay-checkout/) in your front-end
- Support for [Paddle Sandbox](https://developer.paddle.com/getting-started/sandbox)

Sponsor Us
----------

[](#sponsor-us)

[![](https://camo.githubusercontent.com/b5348f68e9a1a6ff90432d75a6692be1d604b3320ce1fcabd4b1ef29668053c4/68747470733a2f2f696e657274696175692e636f6d2f76697369742d636172642e6a7067)](https://inertiaui.com/inertia-table?utm_source=github&utm_campaign=laravel-paddle)

❤️ We proudly support the community by developing Laravel packages and giving them away for free. If this package saves you time or if you're relying on it professionally, please consider [sponsoring the maintenance and development](https://github.com/sponsors/pascalbaljet) and check out our latest premium package: [Inertia Table](https://inertiaui.com/inertia-table?utm_source=github&utm_campaign=laravel-paddle). Keeping track of issues and pull requests takes time, but we're happy to help!

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

[](#installation)

Only the master branch and version 2.0 of this package are compatible with Laravel 8.0 and higher. If you're still using an older version of Laravel (or PHP &lt; 7.3), please use the chart below to find out which version you should use. Mind that older versions are no longer supported.

Laravel VersionPackage Version8.0-11.02.06.0-7.01.0You can install the package via composer:

```
composer require protonemedia/laravel-paddle
```

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

[](#configuration)

Publish the config file:

```
php artisan vendor:publish --provider="ProtoneMedia\LaravelPaddle\PaddleServiceProvider" --tag=config
```

Set your [Vendor ID and Code](https://vendors.paddle.com/authentication) and the [Public Key](https://vendors.paddle.com/public-key) settings in your `.env` file or in the `config/paddle.php` file. The Public Key is used to verify incoming webhooks from Paddle.

```
PADDLE_SANDBOX=false
PADDLE_VENDOR_ID=123
PADDLE_VENDOR_AUTH_CODE=456
PADDLE_PUBLIC_KEY="-----BEGIN PUBLIC KEY-----
...
-----END PUBLIC KEY-----"
```

### Paddle Sandbox

[](#paddle-sandbox)

As of version 2.2.0, this package supports the [Paddle Sandbox](https://developer.paddle.com/getting-started/sandbox) environment. To use this environment, set the `sandbox_environment` configuration key to `true`. This will configure the API URLs, as well as the Paddle JavaScript library. If you've published the Blade View while using a previous version of this package, make sure you republish the view:

```
php artisan vendor:publish --provider="ProtoneMedia\LaravelPaddle\PaddleServiceProvider" --tag=views
```

Usage
-----

[](#usage)

The API calls are available with the `Paddle` facade. Check out the [the documentation](https://developer.paddle.com/api-reference/intro) to learn all about the Paddle API. You can build your API calls fluently or you could simply pass an array which holds the data. This package has some basic validation rules for the given data and this might result in an `InvalidDataException` if your data is invalid. Whenever an API call fails it will throw a `PaddleApiException`.

```
// Fluent:
$paddleResponse = Paddle::product()
    ->generatePayLink()
    ->productId($paddlePlanId)
    ->customerEmail($team->owner->email)
    ->passthrough(['team_id' => $team->id])
    ->send();

// Array with payload:
$payload = [
    'product_id' => $paddlePlanId,
    'customer_email' => $team->owner->email,
    'passthrough' => ['team_id' => $team->id],
];

$paddleResponse = Paddle::product()
    ->generatePayLink($payload)
    ->send();

return Redirect::to($paddleResponse['url']);
```

Available API calls
-------------------

[](#available-api-calls)

```
// alerts
Paddle::alert()->getWebhookHistory();

// checkouts
Paddle::checkout()->getOrderDetails();
Paddle::checkout()->getUserHistory();
Paddle::checkout()->getPrices();

// products
Paddle::product()->listCoupons();
Paddle::product()->createCoupon();
Paddle::product()->updateCoupon();
Paddle::product()->deleteCoupon();

Paddle::product()->listProducts();
Paddle::product()->generateLicense();
Paddle::product()->generatePayLink();
Paddle::product()->listTransactions($entity, $id);

// subscriptions
Paddle::subscription()->listPlans();
Paddle::subscription()->createPlan();

Paddle::subscription()->listUsers();
Paddle::subscription()->updateUser();
Paddle::subscription()->previewUpdate();
Paddle::subscription()->cancelUser();

Paddle::subscription()->listModifiers();
Paddle::subscription()->createModifier();
Paddle::subscription()->deleteModifier();

Paddle::subscription()->listPayments();
Paddle::subscription()->reschedulePayment();
Paddle::subscription()->createOneOffCharge($subscriptionId);
```

Webhooks and Laravel Events
---------------------------

[](#webhooks-and-laravel-events)

You can configure your webhook URI in the `paddle.php` config file. Update your [webhook settings](https://vendors.paddle.com/alerts-webhooks) at Paddle accordingly. By default the URI is `paddle/webhook`. This means that the webhook calls will be posted to `https://your-domain.com/paddle/webhook`.

Every webhook will be mapped to an Event and contains the payload of the webhook. For example when the [Subscription Created](https://developer.paddle.com/webhook-reference/subscription-alerts/subscription-created) webhook is called, the request is verified and a `SubscriptionCreated` event will be fired.

Events:

- `ProtoneMedia\LaravelPaddle\Events\HighRiskTransactionCreated`
- `ProtoneMedia\LaravelPaddle\Events\HighRiskTransactionUpdated`
- `ProtoneMedia\LaravelPaddle\Events\LockerProcessed`
- `ProtoneMedia\LaravelPaddle\Events\NewAudienceMember`
- `ProtoneMedia\LaravelPaddle\Events\PaymentDisputeClosed`
- `ProtoneMedia\LaravelPaddle\Events\PaymentDisputeCreated`
- `ProtoneMedia\LaravelPaddle\Events\PaymentRefunded`
- `ProtoneMedia\LaravelPaddle\Events\PaymentSucceeded`
- `ProtoneMedia\LaravelPaddle\Events\SubscriptionCancelled`
- `ProtoneMedia\LaravelPaddle\Events\SubscriptionCreated`
- `ProtoneMedia\LaravelPaddle\Events\SubscriptionPaymentFailed`
- `ProtoneMedia\LaravelPaddle\Events\SubscriptionPaymentRefunded`
- `ProtoneMedia\LaravelPaddle\Events\SubscriptionPaymentSucceeded`
- `ProtoneMedia\LaravelPaddle\Events\SubscriptionUpdated`
- `ProtoneMedia\LaravelPaddle\Events\TransferCreated`
- `ProtoneMedia\LaravelPaddle\Events\TransferPaid`
- `ProtoneMedia\LaravelPaddle\Events\UpdateAudienceMember`

Some webhooks, like the [Fulfillment Webhook](https://developer.paddle.com/webhook-reference/product-fulfillment/fulfillment-webhook), don't have an `alert_name` key. Those webhooks will be mapped to a `ProtoneMedia\LaravelPaddle\Events\GenericWebhook` event.

When you register a listener to handle the event, the payload is easily accessible. You also have access to the original HTTP request.

```
