Skip to content

Commit

Permalink
Merge pull request #167 from Naoray/support-laravel-10
Browse files Browse the repository at this point in the history
Support laravel 10
  • Loading branch information
Naoray authored Mar 13, 2023
2 parents bd0611a + c7919c8 commit d7feef6
Show file tree
Hide file tree
Showing 53 changed files with 628 additions and 463 deletions.
21 changes: 14 additions & 7 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,24 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [7.4, 8.0, 8.1]
laravel: [^8.0, ^9.0]
os: [ ubuntu-latest ]
php: [ 8.2, 8.1, 8.0]
laravel: [ 10.*, 9.* ]
dependency-version: [ prefer-stable ]
include:
- laravel: 9.*
testbench: 7.*
- laravel: 10.*
testbench: 8.*
exclude:
- php: 7.4
laravel: 9
- laravel: 10.*
php: 8.0

name: P${{ matrix.php }} - L${{ matrix.laravel }}
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -35,7 +42,7 @@ jobs:

- name: Install dependencies
run: |
composer update --prefer-dist --no-interaction --no-progress
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-progress
- name: Execute tests
run: vendor/bin/phpunit --coverage-text
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ vendor
coverage
phpunit.xml
.phpunit.result.cache
.phpunit.cache
.idea
.phpstorm.meta.php
.php-cs-fixer.cache
151 changes: 74 additions & 77 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,81 +1,78 @@
{
"name": "mollie/laravel-cashier-mollie",
"description": "Laravel Cashier provides an expressive, fluent interface to Mollie's subscription billing services.",
"keywords": [
"mollie",
"laravel",
"subscriptions",
"recurring",
"billing",
"SEPA",
"Apple Pay",
"credit card",
"debit card",
"Europe"
],
"homepage": "https://github.com/mollie/laravel-cashier-mollie",
"license": "MIT",
"authors": [
{
"name": "Mollie.com",
"email": "support@mollie.com",
"homepage": "https://www.mollie.com",
"role": "Owner"
},
{
"name": "Sander van Hooft",
"email": "sander@sandorian.com",
"homepage": "https://www.sandorian.com",
"role": "Developer"
}
],
"require": {
"php": "^7.4|^8.0",
"ext-json": "*",
"ext-intl": "*",
"dompdf/dompdf": "^2.0",
"illuminate/database": "^8.0|^9.0",
"illuminate/support": "^8.0|^9.0",
"mollie/laravel-mollie": "^2.9",
"mollie/mollie-api-php": "^2.27",
"moneyphp/money": "^3.2|^4.0.3",
"nesbot/carbon": "^2.31"
},
"require-dev": {
"guzzle/http": "^3.9",
"guzzlehttp/guzzle": "^7.0",
"laravel/legacy-factories": "^1.0",
"mockery/mockery": "^1.4",
"orchestra/testbench": "^6.0|^7.0",
"phpunit/phpunit": "^8.5|^9.3",
"vlucas/phpdotenv": "^5.2"
},
"autoload": {
"files": [
"src/Helpers/helpers.php"
],
"psr-4": {
"Laravel\\Cashier\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Laravel\\Cashier\\Tests\\": "tests"
}
},
"extra": {
"laravel": {
"providers": [
"Laravel\\Cashier\\CashierServiceProvider"
]
}
"name": "mollie/laravel-cashier-mollie",
"description": "Laravel Cashier provides an expressive, fluent interface to Mollie's subscription billing services.",
"keywords": [
"mollie",
"laravel",
"subscriptions",
"recurring",
"billing",
"SEPA",
"Apple Pay",
"credit card",
"debit card",
"Europe"
],
"homepage": "https://github.com/mollie/laravel-cashier-mollie",
"license": "MIT",
"authors": [
{
"name": "Mollie.com",
"email": "support@mollie.com",
"homepage": "https://www.mollie.com",
"role": "Owner"
},
"config": {
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"test": "./vendor/bin/phpunit tests"
{
"name": "Sander van Hooft",
"email": "sander@sandorian.com",
"homepage": "https://www.sandorian.com",
"role": "Developer"
}
],
"require": {
"php": "^8.0",
"ext-json": "*",
"ext-intl": "*",
"dompdf/dompdf": "^2.0",
"illuminate/database": "^9.0|^10",
"illuminate/support": "^9.0|^10",
"mollie/laravel-mollie": "^2.22",
"mollie/mollie-api-php": "^2.27",
"moneyphp/money": "^4.1",
"nesbot/carbon": "^2.31"
},
"require-dev": {
"guzzlehttp/guzzle": "^7.0",
"mockery/mockery": "^1.4",
"orchestra/testbench": "^7.0|^8.0",
"phpunit/phpunit": "^9.5"
},
"autoload": {
"files": [
"src/Helpers/helpers.php"
],
"psr-4": {
"Laravel\\Cashier\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Laravel\\Cashier\\Tests\\": "tests"
}
},
"extra": {
"laravel": {
"providers": [
"Laravel\\Cashier\\CashierServiceProvider"
]
}
},
"config": {
"sort-packages": true
},
"minimum-stability": "stable",
"prefer-stable": true,
"scripts": {
"test": "./vendor/bin/phpunit tests"
}
}
10 changes: 7 additions & 3 deletions routes/webhooks.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
<?php

use Illuminate\Support\Facades\Route;
use Laravel\Cashier\Cashier;
use Laravel\Cashier\Http\Controllers\AftercareWebhookController;
use Laravel\Cashier\Http\Controllers\FirstPaymentWebhookController;
use Laravel\Cashier\Http\Controllers\WebhookController;

Route::namespace('\Laravel\Cashier\Http\Controllers')->group(function () {
Route::name('webhooks.mollie.default')->post(
Cashier::webhookUrl(),
'WebhookController@handleWebhook'
[WebhookController::class, 'handleWebhook']
);

Route::name('webhooks.mollie.aftercare')->post(
Cashier::aftercareWebhookUrl(),
'AftercareWebhookController@handleWebhook'
[AftercareWebhookController::class, 'handleWebhook']
);

Route::name('webhooks.mollie.first_payment')->post(
Cashier::firstPaymentWebhookUrl(),
'FirstPaymentWebhookController@handleWebhook'
[FirstPaymentWebhookController::class, 'handleWebhook']
);
});
14 changes: 3 additions & 11 deletions src/Order/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,9 @@ class Order extends Model
'balance_before' => 'int',
'credit_used' => 'int',
'total_due' => 'int',
];

/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $dates = [
'processed_at',
'created_at',
'updated_at',
'processed_at' => 'datetime',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];

protected $guarded = [];
Expand Down
14 changes: 3 additions & 11 deletions src/Order/OrderItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,7 @@ class OrderItem extends Model implements InvoicableItem
'unit_price' => 'int',
'tax_percentage' => 'float',
'orderable_id' => 'int',
];

/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $dates = [
'process_at',
'process_at' => 'datetime',
];

protected $guarded = [];
Expand Down Expand Up @@ -124,7 +116,7 @@ public function getTotalAttribute()
*/
public function scopeProcessed($query, $processed = true)
{
if (! $processed) {
if (!$processed) {
return $query->whereNull('order_id');
}

Expand All @@ -140,7 +132,7 @@ public function scopeProcessed($query, $processed = true)
*/
public function scopeUnprocessed($query, $unprocessed = true)
{
return $query->processed(! $unprocessed);
return $query->processed(!$unprocessed);
}

/**
Expand Down
24 changes: 12 additions & 12 deletions src/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ class Subscription extends Model implements InteractsWithOrderItems, Preprocesse
*
* @var array
*/
protected $dates = [
'trial_ends_at',
'cycle_started_at',
'cycle_ends_at',
'ends_at',
protected $casts = [
'trial_ends_at' => 'datetime',
'cycle_started_at' => 'datetime',
'cycle_ends_at' => 'datetime',
'ends_at' => 'datetime',
];

/**
Expand Down Expand Up @@ -104,7 +104,7 @@ public function active()
*/
public function ended()
{
return $this->cancelled() && ! $this->onGracePeriod();
return $this->cancelled() && !$this->onGracePeriod();
}

/**
Expand Down Expand Up @@ -134,7 +134,7 @@ public function onGracePeriod()
*/
public function recurring()
{
return ! $this->onTrial() && ! $this->cancelled();
return !$this->onTrial() && !$this->cancelled();
}

/**
Expand All @@ -144,7 +144,7 @@ public function recurring()
*/
public function cancelled()
{
return ! is_null($this->ends_at);
return !is_null($this->ends_at);
}

/**
Expand Down Expand Up @@ -346,11 +346,11 @@ protected function removeScheduledOrderItem($save = false)
*/
public function resume()
{
if (! $this->cancelled()) {
if (!$this->cancelled()) {
throw new LogicException('Unable to resume a subscription that is not cancelled.');
}

if (! $this->onGracePeriod()) {
if (!$this->onGracePeriod()) {
throw new LogicException('Unable to resume a subscription that is not within grace period.');
}

Expand Down Expand Up @@ -468,7 +468,7 @@ public static function processOrderItem(OrderItem $item)
$plan_swapped = false;
$previousPlan = null;

if (! empty($subscription->next_plan)) {
if (!empty($subscription->next_plan)) {
$plan_swapped = true;
$previousPlan = $subscription->plan;
$subscription->plan = $subscription->next_plan;
Expand Down Expand Up @@ -704,7 +704,7 @@ protected function reimbursableAmount()

// Determine base amount eligible to reimburse
$latestProcessedOrderItem = $this->latestProcessedOrderItem();
if (! $latestProcessedOrderItem) {
if (!$latestProcessedOrderItem) {
return $zeroAmount;
}

Expand Down
Loading

0 comments on commit d7feef6

Please sign in to comment.