Skip to content

steadfast-collective/cashier-extended

Repository files navigation

Total Downloads Latest Stable Version License

Introduction

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services. It handles almost all of the boilerplate subscription billing code you are dreading writing. In addition to basic subscription management, Cashier can handle coupons, swapping subscription, subscription "quantities", cancellation grace periods, and even generate invoice PDFs.

Cashier Extended improves upon the core of Laravel Cashier by adding a store of Charges made, and additional methods to query them, as well as webhooks to keep this updated.

Official Documentation

Documentation for Laravel Cashier can be found on the Laravel website, there are several changes to make when using Laravel Cashier Extended, which are detailed below.

Installation

To get started install the package from composer:

composer require steadfastcollective/cashier-extended

The package will automatically register the service provider and facade.

Next publish the migrations with:

php artisan vendor:publish --provider="SteadfastCollective\CashierExtended\CashierExtendedServiceProvider" --tag="migrations"

and then run them:

php artisan migrate

As noted before, we have made a couple of changes to how you use the Cashier package these are detailed below.

The Billable trait has been updated and should use the new namespace:

<?php

// use Laravel\Cashier\Billable;
use SteadfastCollective\CashierExtended\Billable;

The following webhooks have been registered to keep your data up to date:

  • charge.expired
  • charge.failed
  • charge.refund.updated
  • charge.refunded
  • charge.succeeded
  • charge.updated
  • payment_intent.succeeded
  • payment_intent.created
  • payment_intent.payment_failed

to make use of the new webhooks you will need to update your routes\Web.php route file:

<?php

// Route::post(
//     'stripe/webhook',
//     '\App\Http\Controllers\WebhookController@handleWebhook'
// );

Route::post(
    'stripe/webhook',
    '\SteadfastCollective\CashierExtended\Http\Controllers\WebhookController@handleWebhook'
);

If you have extended or would like to extend the WebhookController and add addtional webhooks you can create the following file app\Http\Controllers\WebhookController.php:

<?php

namespace App\Http\Controllers;

use SteadfastCollective\CashierExtended\Http\Controllers\WebhookController as CashierController;

class WebhookController extends CashierController
{
    /**
     * Handle invoice payment succeeded.
     *
     * @param  array  $payload
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function handleInvoicePaymentSucceeded($payload)
    {
        // Handle The Event
    }
}

Then be sure to update your routes\Web.php file:

<?php

Route::post(
    'stripe/webhook',
    '\App\Http\Controllers\WebhookController@handleWebhook'
);

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.