PHPackages                             ajithnow/laravel-subscription-webhooks - 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. ajithnow/laravel-subscription-webhooks

ActiveLibrary

ajithnow/laravel-subscription-webhooks
======================================

Laravel package for handling Apple and Google subscription webhooks

v1.1.0(1y ago)48MITPHPPHP ^8.1CI failing

Since Mar 6Pushed 1y ago2 watchersCompare

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

READMEChangelog (1)Dependencies (7)Versions (5)Used By (0)

Laravel Subscription Webhooks
=============================

[](#laravel-subscription-webhooks)

A Laravel package for handling webhooks from Apple App Store and Google Play Store subscription notifications.

Features
--------

[](#features)

- Automatic route registration for subscription webhooks
- Event-driven webhook processing
- Support for all Apple App Store Server Notification v2 event types
- Support for all Google Play Billing subscription events
- Configurable middleware and routes
- PSR-3 compliant logging
- Extensible webhook handler architecture

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

[](#installation)

Install the package via Composer:

```
composer require your-vendor/laravel-subscription-webhooks
```

Publish the configuration file:

```
php artisan vendor:publish --provider="SubscriptionWebhooks\Laravel\SubscriptionWebhookServiceProvider" --tag="config"
```

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

[](#configuration)

Edit `config/subscription-webhooks.php` to configure webhook handling:

```
return [
    'routes' => [
        // Enable automatic webhook routes
        'enabled' => true,

        // Customize middleware
        'middleware' => ['api'],

        // Customize route prefix
        'prefix' => 'webhooks/subscriptions',
    ],

    'platforms' => [
        'apple' => [
            // Configure Apple webhook settings
            'verify_signature' => true,
            'public_key_path' => storage_path('apple/public_key.pem'),
        ],
        'google' => [
            // Configure Google webhook settings
            'verify_signature' => true,
            'service_account_path' => storage_path('google/service_account.json'),
        ],
    ],

    'processing' => [
        // Queue webhook processing
        'queue' => false,

        // Default queue connection
        'queue_connection' => 'default',
    ],
];
```

Usage
-----

[](#usage)

### Automatic Route Registration

[](#automatic-route-registration)

When `routes.enabled` is set to `true` in the config, the package will automatically register the following routes:

- **POST** `/webhooks/subscriptions/apple` - For Apple App Store subscription webhooks
- **POST** `/webhooks/subscriptions/google` - For Google Play Store subscription webhooks

### Listening to Webhook Events

[](#listening-to-webhook-events)

In your `EventServiceProvider` or any service provider:

```
use SubscriptionWebhooks\Laravel\Events\SubscriptionWebhookReceived;

public function boot()
{
    Event::listen(SubscriptionWebhookReceived::class, function ($event) {
        // $event->platform will be 'apple' or 'google'
        // $event->webhookData contains the webhook data

        if ($event->platform === 'apple') {
            // Handle Apple subscription notification
            $notificationType = $event->webhookData['notificationType'];
            $subtype = $event->webhookData['subtype'] ?? null;

            // Process notification based on type
        } elseif ($event->platform === 'google') {
            // Handle Google subscription notification
            $notificationType = $event->webhookData['notificationType'];

            // Process notification based on type
        }
    });
}
```

### Specific Event Listeners

[](#specific-event-listeners)

For more targeted event handling, you can listen to platform-specific events:

```
use SubscriptionWebhooks\Laravel\Events\Apple\SubscriptionRenewed;
use SubscriptionWebhooks\Laravel\Events\Google\SubscriptionPurchased;

// Apple-specific event
Event::listen(SubscriptionRenewed::class, function ($event) {
    // Handle subscription renewal
    $subscriptionId = $event->getSubscriptionId();
    // Update your database
});

// Google-specific event
Event::listen(SubscriptionPurchased::class, function ($event) {
    // Handle new subscription purchase
    $subscriptionId = $event->getSubscriptionId();
    // Update your database
});
```

Advanced Usage
--------------

[](#advanced-usage)

### Custom Webhook Processing

[](#custom-webhook-processing)

You can implement your own webhook processor by extending the base handler:

```
use SubscriptionWebhooks\Laravel\Handlers\WebhookHandler;

class CustomAppleWebhookHandler extends WebhookHandler
{
    public function process(array $payload): void
    {
        // Custom processing logic here

        // You can still fire the built-in events if needed
        $this->fireEvents($payload);

        // Or implement completely custom logic
    }
}
```

Then register your custom handler in a service provider:

```
$this->app->bind(
    SubscriptionWebhooks\Laravel\Handlers\AppleWebhookHandler::class,
    CustomAppleWebhookHandler::class
);
```

### Manual Webhook Processing

[](#manual-webhook-processing)

If you prefer to handle the webhooks through your own controllers:

```
use SubscriptionWebhooks\Laravel\Processors\AppleWebhookProcessor;

class CustomWebhookController extends Controller
{
    public function handleAppleWebhook(Request $request, AppleWebhookProcessor $processor)
    {
        return $processor->handle($request);
    }
}
```

Logging
-------

[](#logging)

By default, all webhook processing is logged. You can configure the logging behavior in your Laravel logging configuration.

Testing
-------

[](#testing)

The package includes helpers for testing webhook handling in your application:

```
use SubscriptionWebhooks\Laravel\Testing\FakeAppleWebhook;

// In a test case
public function testSubscriptionRenewal()
{
    // Create a fake Apple webhook payload
    $fake = FakeAppleWebhook::renewalEvent()
        ->forSubscription('sub_123456')
        ->create();

    // Dispatch the fake webhook
    $fake->dispatch();

    // Assert the expected behavior
    Event::assertDispatched(SubscriptionRenewed::class);

    // Or assert against your database
    $this->assertDatabaseHas('subscriptions', [
        'subscription_id' => 'sub_123456',
        'status' => 'active',
    ]);
}
```

Security
--------

[](#security)

- Always ensure your webhook endpoints are properly secured.
- Use HTTPS for all webhook URLs in production.
- Keep your signature verification enabled in production environments.

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance46

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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 ~14 days

Total

2

Last Release

417d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1959908b173ba169ce10f1a3ed22cb436b612882d9f4f7cff7a416b96323b593?d=identicon)[ajithnow](/maintainers/ajithnow)

---

Top Contributors

[![ajithkumarpits](https://avatars.githubusercontent.com/u/202899361?v=4)](https://github.com/ajithkumarpits "ajithkumarpits (4 commits)")[![ajithnow](https://avatars.githubusercontent.com/u/61345326?v=4)](https://github.com/ajithnow "ajithnow (4 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ajithnow-laravel-subscription-webhooks/health.svg)

```
[![Health](https://phpackages.com/badges/ajithnow-laravel-subscription-webhooks/health.svg)](https://phpackages.com/packages/ajithnow-laravel-subscription-webhooks)
```

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k96.9M674](/packages/laravel-socialite)[google/auth

Google Auth Library for PHP

1.4k272.7M162](/packages/google-auth)[shopify/shopify-api

Shopify API Library for PHP

4634.8M16](/packages/shopify-shopify-api)[laravel-zero/framework

The Laravel Zero Framework.

3371.4M369](/packages/laravel-zero-framework)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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