steadfastcollective/cashier-extended

4.0.3 2022-01-13 13:19 UTC

This package is auto-updated.

Last update: 2024-04-13 17:57:37 UTC


README

68747470733a2f2f647a776f6e73656d72697368372e636c6f756466726f6e742e6e65742f6974656d732f307431443078314d3338315930663258305130632f4c61726176656c5f436173686965724032782e706e673f763d3735303162313132

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 dev@steadfastcollective.com instead of using the issue tracker.

Credits

License

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