Skip to content

Commit

Permalink
Merge pull request #238 from mollie/provide-laravel-11-compatibiity
Browse files Browse the repository at this point in the history
Provide laravel 11 compatibiity
  • Loading branch information
Naoray authored Mar 17, 2024
2 parents 69065e9 + 9a836ca commit f7118ed
Show file tree
Hide file tree
Showing 31 changed files with 211 additions and 1,594 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
name: tests

on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'
- cron: "0 0 * * *"

jobs:
tests:

runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
php: ['8.0', '8.1', '8.2', '8.3']
laravel: ['9.0', '10.0']
php: ["8.1", "8.2", "8.3"]
laravel: ["10.0", "11.0"]
exclude:
- laravel: '10.0'
php: '8.0'
- laravel: "11.0"
php: "8.0"
- laravel: "11.0"
php: "8.1"

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

Expand Down
8 changes: 0 additions & 8 deletions LICENSE

This file was deleted.

21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Mollie

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
50 changes: 15 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</p>
<h1 align="center">Mollie for Laravel</h1>

<img src="https://github.com/mollie/laravel-mollie/assets/7265703/d86d2ab5-d83c-4bc5-b49d-60ee01922b2a" />
![create new payment](https://github.com/mollie/laravel-mollie/assets/10154100/205b536f-51a3-4d1b-b2c9-69f02ba019fa)

Laravel-Mollie incorporates the [Mollie API](https://www.mollie.com/en/docs/overview) and [Mollie Connect](https://www.mollie.com/en/connect) into your [Laravel](https://laravel.com/) or [Lumen](https://lumen.laravel.com/) project.

Expand All @@ -16,20 +16,18 @@ Accepting [iDEAL](https://www.mollie.com/en/payments/ideal/), [Apple Pay](https:
[![Latest Stable Version](https://poser.pugx.org/mollie/laravel-mollie/v/stable)](https://packagist.org/packages/mollie/laravel-mollie)
[![Total Downloads](https://poser.pugx.org/mollie/laravel-mollie/downloads)](https://packagist.org/packages/mollie/laravel-mollie)

## Requirements
## **Requirements**

* Get yourself a free [Mollie account](https://www.mollie.com/signup). No sign up costs.
* Now you're ready to use the Mollie API client in test mode.
* Follow [a few steps](https://www.mollie.com/dashboard/?modal=onboarding) to enable payment methods in live mode, and let us handle the rest.
* Up-to-date OpenSSL (or other SSL/TLS toolkit)
* PHP >= 7.0
* [Laravel](https://www.laravel.com) (or [Lumen](https://lumen.laravel.com)) >= 5.5
* [Laravel Socialite](https://github.com/laravel/socialite) >= 3.0 (if you intend on using [Mollie Connect](https://docs.mollie.com/oauth/overview))
* PHP >= 8.1
* [Laravel](https://www.laravel.com) >= 10.0
* [Laravel Socialite](https://github.com/laravel/socialite) >= 5.0 (if you intend on using [Mollie Connect](https://docs.mollie.com/oauth/overview))

## Upgrading from v1.x?
To support the enhanced Mollie API, some breaking changes were introduced. Make sure to follow the instructions in the [package migration guide](docs/migration_instructions_v1_to_v2.md).

Not ready to upgrade? The Laravel-Mollie client v1 will remain supported for now.
## Upgrading from v2.x?
To support the enhanced Mollie API, some breaking changes were introduced. Make sure to follow the instructions in the [upgrade guide](UPGRADE.md).

Fresh install? Continue with the installation guide below.

Expand All @@ -45,19 +43,12 @@ Or add it to `composer.json` manually:

```json
"require": {
"mollie/laravel-mollie": "^2.0"
"mollie/laravel-mollie": "^3.0"
}
```

Laravel-Mollie's service providers will be automatically registered using Laravel's auto-discovery feature.

Note: For Lumen you have to add the Mollie facade and service provider manually to: `bootstrap/app.php` :
```php
$app->withFacades(true, ['Mollie\Laravel\Facades\Mollie' => 'Mollie']);

$app->register(Mollie\Laravel\MollieServiceProvider::class);
```

## Configuration

You'll only need to add the `MOLLIE_KEY` variable to your `.env` file.
Expand Down Expand Up @@ -112,17 +103,6 @@ public function handleWebhookNotification(Request $request) {
}
```

### Global helper method
For your convencience we've added the global `mollie()` helper function. It's an easy shortcut to the `Mollie::api()` facade accessor.

```php
// Using facade accessor
$payment = \Mollie\Laravel\Facades\Mollie::api()->payments->get($payment_id);

// Using global helper function
$payment = mollie()->payments->get($payment_id);
```

## Other examples

- [Process realtime status updates with a webhook](docs/webhook.md)
Expand All @@ -136,17 +116,17 @@ You can find the latest development roadmap for this package [here](docs/roadmap
## Want to help us make our Laravel module even better?

Want to help us make our Laravel module even better? We take [pull requests](https://github.com/mollie/laravel-mollie/pulls?utf8=%E2%9C%93&q=is%3Apr), sure.
But how would you like to contribute to a [technology oriented organization](https://www.mollie.com/nl/blog/post/werken-bij-mollie-als-developer/)? Mollie is hiring developers and system engineers.
[Check out our vacancies](https://www.mollie.com/nl/jobs) or [get in touch](mailto:[email protected]).
But how would you like to contribute to a technology oriented organization? Mollie is hiring developers and system engineers.
[Check out our vacancies](https://jobs.mollie.com/) or [get in touch](mailto:[email protected]).

## License

[BSD (Berkeley Software Distribution) License](http://www.opensource.org/licenses/bsd-license.php). Copyright (c) 2016, Mollie B.V.
[The MIT License](LICENSE.md). Copyright (c) 2024, Mollie B.V.

## Support

Contact: [www.mollie.com](https://www.mollie.com)[email protected] — +31 20-612 88 55
Contact: [www.mollie.com](https://www.mollie.com)[email protected]

* [More information about Mollie Connect](https://www.mollie.com/en/connect)
* [Documentation for the Mollie API](https://www.mollie.com/en/docs/overview)
* [Documentation for Mollie OAuth](https://www.mollie.com/en/docs/oauth/overview)
* [More information about Mollie Connect](https://www.mollie.com/products/connect)
* [Documentation for the Mollie API](https://docs.mollie.com/)
* [Documentation for Mollie OAuth](https://docs.mollie.com/connect/getting-started)
70 changes: 70 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
![Mollie](https://www.mollie.nl/files/Mollie-Logo-Style-Small.png)

# Migrating from Laravel-Mollie v2.x to v3

## Update composer dependencies

Update `composer.json` to match this:

```json
"require": {
"mollie/laravel-mollie": "^3.0"
}
```

Then run `composer update mollie/laravel-mollie`.

## Review Changes
### Updating Dependencies
Laravel-Mollie now requires PHP 8.1.0 or greater.

If you are using the mollie connect feature, make sure to checkout the upgrade instructions for [Laravel-Socialite](https://github.com/laravel/socialite/blob/5.x/UPGRADE.md)

#### Lumen support dropped
The Laravel team has added a note a while ago on the [Lumen Repository](https://github.com/laravel/lumen?tab=readme-ov-file) as well as the official [Lumen documentation](https://lumen.laravel.com/docs/master#installation) that they discourage starting a new project with Lumen. Therefore we dropped the Lumen support for this package.

### Removed Classes
In order to enhance maintainability the following classes were removed:

- `MollieApiWrapper`
- `MollieManager`

Instead the `MollieApiClient` is now directly resolved and provided through the container without any abstractions. This change means you can directly access the newest API features that are added to the underlying [mollie/mollie-api-php](https://github.com/mollie/mollie-api-php) client without having to wait on this repository being updated.

### Change in calling API endpoints
Earlier versions of Laravel-Mollie provided access to endpoints via both methods and properties. Moving forward, access to endpoints will be exclusively through properties, aligning with the practices of the mollie-api-php SDK.****

```php
// before
Mollie::api()->payments()->create();

// now
Mollie::api()->payments->create();
```

### No more global helper function
The `mollie()` helper function was deleted. If you rely on the helper function, either consider switching to
- injecting or resolving the `MollieApiClient` from the container, or
- use the `Mollie` facade

If none of these are an option for you, you can create your own `helpers.php` file and insert the code for the `mollie()` function yourself.

```php
// app/helpers.php
<?php

use \Mollie\Api\MollieApiClient;

if (! function_exists('mollie')) {
/**
* @return MollieApiClient
*/
function mollie()
{
return resolve(MollieApiClient::class);
}
}
```

## Stuck?
Feel free to open an [issue](https://github.com/mollie/laravel-mollie/issues).
13 changes: 5 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@
"socialite"
],
"require": {
"php": "^8.0",
"php": "^8.1|^8.2",
"mollie/mollie-api-php": "^2.60",
"illuminate/support": "^9.0|^10.0",
"illuminate/support": "^10.0|^11.0",
"ext-json": "*"
},
"require-dev": {
"mockery/mockery": "^1.4",
"orchestra/testbench": "^7.18|^8.0",
"phpunit/phpunit": "^9.0|^10.0",
"orchestra/testbench": "^8.0|^9.0",
"phpunit/phpunit": "^10.0",
"laravel/socialite": "^5.5",
"laravel/pint": "^1.1"
},
Expand All @@ -59,10 +59,7 @@
"autoload": {
"psr-4": {
"Mollie\\Laravel\\": "src/"
},
"files": [
"src/helpers.php"
]
}
},
"autoload-dev": {
"psr-4": {
Expand Down
52 changes: 0 additions & 52 deletions docs/migration_instructions_v1_to_v2.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/mollie_connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,3 @@ Route::get('login_callback', function () {
return Mollie::api()->profiles()->page(); // Retrieve payment profiles available on the obtained Mollie account
});
```

8 changes: 4 additions & 4 deletions docs/recurring_and_direct_charge.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Here you can see an example of how easy it is to use [Mollie recurring](https://
First of all you need to [create a new customer](https://docs.mollie.com/payments/recurring#payments-recurring-first-payment) (step 1), this is pretty straight forward

```php
$customer = Mollie::api()->customers()->create([
$customer = Mollie::api()->customers->create([
'name' => 'John Doe',
'email' => '[email protected]',
]);
Expand All @@ -20,7 +20,7 @@ $customer = Mollie::api()->customers()->create([
After creating the user, you can [start a payment](https://docs.mollie.com/payments/recurring#payments-recurring-first-payment) (step 3), it's important to set `sequenceType` to `first`, this will generate a mandate on Mollie's end that can be used to do direct charges. Without setting the `method` the payment screen of Mollie will display your methods that support recurring payments.

```php
$payment = Mollie::api()->payments()->create([
$payment = Mollie::api()->payments->create([
'amount' => [
'currency' => 'EUR',
'value' => '25.00', // You must send the correct number of decimals, thus we enforce the use of strings
Expand All @@ -41,14 +41,14 @@ return redirect($payment->getCheckoutUrl(), 303);
After doing the initial payment, you may [charge the users card/account directly](https://docs.mollie.com/payments/recurring#payments-recurring-charging-on-demand). Make sure there's a valid mandate connected to the customer. In case there are multiple mandates at least one should have `status` set to `valid`. Checking mandates is easy:

```php
$mandates = Mollie::api()->mandates()->listFor($customer);
$mandates = Mollie::api()->mandates->listFor($customer);
```

If any of the mandates is valid, charging the user is a piece of cake. Make sure `sequenceType` is set to `recurring`.


```php
$payment = Mollie::api()->payments()->create([
$payment = Mollie::api()->payments->create([
'amount' => [
'currency' => 'EUR',
'value' => '25.00', // You must send the correct number of decimals, thus we enforce the use of strings
Expand Down
22 changes: 1 addition & 21 deletions docs/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,9 @@ Please submit an [issue](https://github.com/mollie/laravel-mollie/issues) if you
## Planned for next major release

### Provide default webhook
The Laravel-Mollie package makes it easy to set up a new Mollie payment in your Laravel application. But right now, you'll need to implement the webhook yourself. We plan on providing a default webhook, which will trigger an Event when a payment status has been updated. This way, you'll only need to listen for the PaymentUpdatedEvent.
The Laravel-Mollie package makes it easy to set up a new Mollie payment in your Laravel application. But right now, you'll need to implement the webhook yourself. We plan on providing a default webhook, which will trigger an Event when a payment status has been updated. This way, you'll only need to listen for the PaymentUpdatedEvent.

Another solution may be to provide a default overridable controller, like Cashier has. Or to implement both events and the controller.

### Switch to MIT license
Currently, the Laravel Mollie client has a *BSD 2-Clause "Simplified" License*. We're discussing switching to a *MIT* license, which is most common in Laravel packages.

## Other Laravel packages by Mollie
Besides the Laravel-Mollie package, we're looking for other options to support you integrating Mollie in your Laravel applications.

### Explore Laravel Cashier support ("Laravel/Cashier-Mollie")
Laravel Cashier is a very popular package for easily adding recurring payments to your Laravel application. We are exploring whether it's possible for Laravel Cashier to support Mollie. You can join the discussion [here](https://github.com/mollie/laravel-mollie/issues/41).

### Explore Laravel Spark support
[Laravel Spark](https://spark.laravel.com/) is a commercial SAAS starter kit. By adding Cashier-Mollie support, new SAAS projects can be built rapidly on top of Mollie's subscription services.

Laravel Spark leverages Laravel Cashier for subscription billing.

When/If Cashier-Mollie is implemented, support for Laravel Spark would be a logical next topic for exploration.

### Explore Laravel Nova plugin options
[Laravel Nova](https://nova.laravel.com/) is a powerful Laravel and Vue based CMS (commercial license). Launch of this new CMS is scheduled August 2018.

Adoption rate is expected to be high; [Sander](https://github.com/sandervanhooft) expects Nova is going to blow a hole in other Laravel and PHP CMSes' market shares.

A Laravel Nova plugin for Mollie could for example list and manage payments, and include a few dashboard cards.
Loading

0 comments on commit f7118ed

Please sign in to comment.