Skip to content
This repository has been archived by the owner on Nov 9, 2021. It is now read-only.

Commit

Permalink
Merge pull request #21 from renoki-co/upgrade/cashier-models
Browse files Browse the repository at this point in the history
[4.x] Removed BillableWithStripe and BillableWithPaddle
  • Loading branch information
rennokki authored Mar 16, 2021
2 parents df118eb + b3b6798 commit 36b4d8e
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 76 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- 7.*
- 8.*
prefer:
- 'prefer-lowest'
# - 'prefer-lowest'
- 'prefer-stable'
include:
- laravel: '7.*'
Expand Down Expand Up @@ -56,7 +56,7 @@ jobs:
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "orchestra/database:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.prefer }} --prefer-dist --no-interaction --no-suggest
composer require laravel/cashier:"^12.6" laravel/cashier-paddle:"^1.0"
composer require laravel/cashier:"^12.9.1" laravel/cashier-paddle:"^1.4.3"
- name: Run tests
run: |
Expand Down
39 changes: 8 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,14 @@ composer require renoki-co/cashier-register

The package does not come with Cashier as dependency, so you should install according to your needs:

Cashier for Stripe:

```
$ composer require laravel/cashier:"^12.7"
$ composer require laravel/cashier:"^12.9.1"
```

Cashier for Paddle:
For Paddle, use Cashier for Paddle:

```
$ composer require laravel/cashier-paddle:"^1.3"
$ composer require laravel/cashier-paddle:"^1.4.3"
```

Publish the config file:
Expand Down Expand Up @@ -92,35 +90,14 @@ $user->subscription('main')

## Preparing the model

Instead of using Cashier's Billing trait, you should use the trait that comes with this package.

The trait already uses the original cashier trait, with small modifications so that you can benefit of CashierRegister's features.
For billables, you should follow the installation instructions given with Cashier for Paddle or Cashier for Stripe.

For Stripe you can use `BillableWithStripe`:
This package already sets the custom `Subscription` model. In case you want to add more functionalities to the Subscription model, make sure you extend accordingly from these models:

```php
use RenokiCo\CashierRegister\BillableWithStripe;

class User extends Model
{
use BillableWithStripe;

//
}
```
- Paddle: `RenokiCo\CashierRegister\Models\Paddle\Subscription`
- Stripe: `RenokiCo\CashierRegister\Models\Stripe\Subscription`

For Paddle you can use `BillableWithPaddle`:

```php
use RenokiCo\CashierRegister\BillableWithPaddle;

class User extends Model
{
use BillableWithPaddle;

//
}
```
Further, make sure you check the `saas.php` file and replace the subscription model from there, or you can use the `::useSubscriptionModel` call in your code.

## Preparing the plans

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"require": {
"doctrine/dbal": "^2.9",
"laravel/framework": "^7.30|^8.24"
"laravel/framework": "^7.9|^8.0"
},
"autoload": {
"psr-4": {
Expand Down
19 changes: 0 additions & 19 deletions src/BillableWithPaddle.php

This file was deleted.

19 changes: 0 additions & 19 deletions src/BillableWithStripe.php

This file was deleted.

10 changes: 10 additions & 0 deletions src/CashierRegisterServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace RenokiCo\CashierRegister;

use Illuminate\Support\ServiceProvider;
use Laravel\Cashier\Cashier as StripeCashier;
use Laravel\Paddle\Cashier as PaddleCashier;

class CashierRegisterServiceProvider extends ServiceProvider
{
Expand All @@ -28,6 +30,14 @@ public function boot()
$this->mergeConfigFrom(
__DIR__.'/../config/saas.php', 'saas'
);

if (class_exists(StripeCashier::class)) {
StripeCashier::useSubscriptionModel(config('saas.cashier.models.subscription.stripe'));
}

if (class_exists(PaddleCashier::class)) {
PaddleCashier::useSubscriptionModel(config('saas.cashier.models.subscription.paddle'));
}
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Models/Paddle/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace RenokiCo\CashierRegister\Test\Models\Paddle;

use Illuminate\Foundation\Auth\User as Authenticatable;
use RenokiCo\CashierRegister\BillableWithPaddle;
use Laravel\Paddle\Billable;

class User extends Authenticatable
{
use BillableWithPaddle;
use Billable;

protected $table = 'users';

Expand Down
4 changes: 2 additions & 2 deletions tests/Models/Stripe/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace RenokiCo\CashierRegister\Test\Models\Stripe;

use Illuminate\Foundation\Auth\User as Authenticatable;
use RenokiCo\CashierRegister\BillableWithStripe;
use Laravel\Cashier\Billable;

class User extends Authenticatable
{
use BillableWithStripe;
use Billable;

protected $table = 'users';

Expand Down

0 comments on commit 36b4d8e

Please sign in to comment.